/* ============================================================
 * StarGate — jetons de design (charte contributeurs v1.0, nov. 2026)
 * À importer en PREMIER dans toutes les pages :
 *   <link rel="stylesheet" href="/static/sg-tokens.css">
 * Règle : aucune couleur, police ou ombre en dur dans une page.
 * ============================================================ */
/* Police de la charte : Barlow (décision du 04/11/2026), hébergée sur le site (licence OFL,
   /static/fonts/OFL-Barlow.txt) — aucun appel à un CDN, fonctionne derrière le pare-feu ECS. */
@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-400-latin.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-500-latin.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-600-latin.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-style: normal; font-display: swap; src: url("/static/fonts/barlow-700-latin.woff2") format("woff2"); }

:root {
  /* Marque */
  --sg-brand: #00A65D;        /* aplats, graphiques, pictos, focus — JAMAIS en texte */
  --sg-brand-ink: #007A44;    /* texte vert, liens, bouton principal (5,4:1) */
  --sg-brand-deep: #005A32;   /* survol bouton, texte sur fond pâle */
  --sg-brand-tint: #E6F7EF;   /* pastilles d'icônes, sélection */

  /* Neutres */
  --sg-night: #0B100E;        /* en-tête, titres */
  --sg-ink: #1A1F1C;          /* texte courant */
  --sg-muted: #5B6660;        /* texte secondaire — rien de plus clair */
  --sg-line: #E3E8E5;         /* bordures, grilles d'axes */
  --sg-bg: #F6F8F7;           /* fond de page */
  --sg-surface: #FFFFFF;      /* cartes, tuiles, tableaux */

  /* Statuts (texte / fond) */
  --sg-warn: #B45309;   --sg-warn-bg: #FEF3E2;
  --sg-danger: #B42318; --sg-danger-bg: #FDECEA;
  --sg-info: #1D4ED8;   --sg-info-bg: #E8EEFA;
  --sg-ok: #007A44;     --sg-ok-bg: #E6F7EF;

  /* Agences — identiques dans tous les modules (décision du 04/11/2026) */
  --sg-ag-var: #00A65D;        /* vert ECS */
  --sg-ag-bdr: #2FAEE0;        /* bleu ciel */
  --sg-ag-est: #C8102E;        /* rouge — proche du rouge d'alerte : toujours signer les écarts */
  --sg-ag-alpes: #8A949A;      /* gris montagne */
  --sg-ag-occitanie: #C9861A;  /* ocre */
  --sg-ag-solaire: #1F3A6E;    /* bleu nuit */

  /* Services (Plan des bureaux, bordure des pastilles) — famille validée par David le 12/11/2026.
     Ne pas l'utiliser pour les agences (--sg-ag-*), même quand la teinte coïncide. */
  --sg-service-direction: #1F3A6E;       /* Direction / CODIR (bleu nuit) */
  --sg-service-be-conception: #00A65D;   /* BE Conception (vert ECS) */
  --sg-service-be-execution: #7CB342;    /* BE Exécution (vert clair) */
  --sg-service-rh: #C9861A;              /* Pôle RH (ocre) */
  --sg-service-administration: #7C3AED;  /* Administration (violet) */
  --sg-service-affaires: #2FAEE0;        /* Chargés d'affaires (bleu ciel) */
  --sg-service-techniciens: #8A949A;     /* Techniciens (gris) */
  --sg-service-aucun: #5B6660;           /* service non renseigné */
  --sg-plan-service-bg: #E5E7EB;         /* fond des circulations et sanitaires sur un plan */

  /* Séries de graphiques porteuses de sens (hors agences) — décision du 04/11/2026 :
     on garde la logique de couleurs historique des tableaux de bord, déclarée ici
     plutôt qu'en dur dans les pages. Lues par /static/sg-charts.js. */
  --sg-serie-marge: var(--sg-brand);       /* marge, traité, réel */
  --sg-serie-clair: #A7F3D0;               /* hors cohorte (vert clair) */
  --sg-serie-chiffre: #2D7DD2;             /* chiffré, études, en cours */
  --sg-serie-etudie: #1E40AF;              /* étudiées (bleu foncé) */
  --sg-serie-achats: #FFC000;              /* achats (convention « Résultats Globaux ECS ») */
  --sg-serie-mod: #2E75B6;                 /* coût MOD */
  --sg-serie-reference: #9CA3AF;           /* objectif, N-1, total, abandon, ACD & matériel */
  --sg-serie-neutre: #808080;              /* marge brute (graphique Résultats Globaux), heures */
  --sg-serie-negatif: #C00000;             /* marge négative, dérive défavorable */
  --sg-serie-alerte: #DC2626;              /* perdu, taux de retour */
  --sg-serie-total: #374151;               /* total de cascade */
  --sg-serie-trait: #1F2937;               /* courbes de taux en surimpression */
  /* Seuils (marge %, taux de retour) : du meilleur au pire */
  --sg-seuil-bon: #059669;
  --sg-seuil-moyen: #B45309;
  --sg-seuil-faible: #B91C1C;
  --sg-echelle-1: #15803D; --sg-echelle-2: #84CC16; --sg-echelle-3: #F59E0B;
  --sg-echelle-4: #DC2626; --sg-echelle-5: #1F2937;

  /* Typographie */
  --sg-font-brand: "Barlow", "Segoe UI", system-ui, sans-serif;   /* titres, grands chiffres (gras) */
  --sg-font: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --sg-font-mono: Consolas, "SF Mono", monospace;
  --sg-fs-display: 32px;
  --sg-fs-h2: 20px;
  --sg-fs-h3: 15px;
  --sg-fs-body: 13.5px;
  --sg-fs-small: 12px;
  --sg-fs-label: 11px;        /* plancher absolu */

  /* Espaces, rayons, ombre */
  --sg-s1: 4px; --sg-s2: 8px; --sg-s3: 12px; --sg-s4: 16px;
  --sg-s5: 24px; --sg-s6: 32px; --sg-s7: 48px;
  --sg-radius-s: 6px;
  --sg-radius-m: 10px;
  --sg-shadow: 0 1px 2px rgba(11,16,14,.06), 0 4px 12px rgba(11,16,14,.06);

  /* Compatibilité : anciens noms redirigés le temps de la migration */
  --sg-ecs: var(--sg-brand);
  --ecs-green: var(--sg-brand);
  --ecs-green-dark: var(--sg-brand-ink);
  --ecs-text: var(--sg-ink);
  --ecs-muted: var(--sg-muted);
  --ecs-border: var(--sg-line);
  --ecs-bg: var(--sg-bg);
}

/* Base commune — spécificité nulle (:where) : ne l'emporte jamais sur une règle de la page,
   même quand sg-tokens.css arrive après les styles de la page (via @import dans stargate-header.css). */
:where(body) { font-family: var(--sg-font); color: var(--sg-ink); }
:where(a) { color: var(--sg-brand-ink); }
:where(a:hover) { color: var(--sg-brand-deep); }
:where(:focus-visible) { outline: 2px solid var(--sg-brand); outline-offset: 2px; }
.sg-num { font-variant-numeric: tabular-nums; text-align: right; }

/* Icônes : <span class="sg-ico-tile"><svg class="sg-ico"><use href="/static/sg-icons.svg#budget"/></svg></span> */
.sg-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75;
          stroke-linecap: round; stroke-linejoin: round; color: var(--sg-brand-ink); flex: none; }
.sg-ico.s18 { width: 18px; height: 18px; }
.sg-ico-tile { width: 40px; height: 40px; border-radius: var(--sg-radius-m); background: var(--sg-brand-tint);
               display: inline-flex; align-items: center; justify-content: center; }
.sg-ico-tile.is-fav { background: var(--sg-brand-ink); border-radius: 12px; }   /* favoris épinglés (style 02) */
.sg-ico-tile.is-fav .sg-ico { color: #fff; }
.sg-ico-tile.is-alert { background: var(--sg-danger-bg); }
.sg-ico-tile.is-alert .sg-ico { color: var(--sg-danger); }

/* Boutons */
.sg-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 10px 16px;
          border-radius: var(--sg-radius-s); font: 600 var(--sg-fs-body) var(--sg-font); cursor: pointer; border: 0; }
.sg-btn-primary { background: var(--sg-brand-ink); color: #fff; }
.sg-btn-primary:hover { background: var(--sg-brand-deep); }
.sg-btn-secondary { background: var(--sg-surface); color: var(--sg-ink); border: 1px solid #D5DDD8; }
.sg-btn-ghost { background: transparent; color: var(--sg-brand-ink); }
.sg-btn-danger { background: var(--sg-danger); color: #fff; }

/* Statuts */
.sg-badge { display: inline-block; font: 600 12px var(--sg-font); padding: 3px 10px; border-radius: 999px; }
.sg-badge.ok { background: var(--sg-ok-bg); color: var(--sg-brand-deep); }
.sg-badge.warn { background: var(--sg-warn-bg); color: #8A3D05; }
.sg-badge.danger { background: var(--sg-danger-bg); color: #912018; }
.sg-badge.info { background: var(--sg-info-bg); color: #1D3F8F; }
.sg-badge.neutral { background: #EEF2F0; color: #3B4540; }
