/* ╔══════════════════════════════════════════════════════════════════════════╗
   ║  FSOS — LE SYSTÈME VISUEL (plateforme des agents ET console)             ║
   ║                                                                          ║
   ║  Les jetons d'EnigmaOS, lus dans sa source (pas mesurés sur une image) : ║
   ║  fond #F4F5F7, surfaces blanches séparées par une BORDURE, jamais par    ║
   ║  une ombre ; vert #36C26E pour les états actifs et les réussites ; le    ║
   ║  NOIR réservé à ce qui engage la facturation (« Voir l'abonnement »).    ║
   ║  Aucun style en ligne : la politique de contenu les refuse.              ║
   ╚══════════════════════════════════════════════════════════════════════════╝ */

/* L'attribut `hidden` cache, quelle que soit la classe (un `display: flex` l'écrasait). */
[hidden] { display: none !important; }

@font-face {
  font-family: "Inter";
  src: url("../polices/inter-latin.woff?v=fc87c9046c65") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --vert: #36c26e;
  /*  Les TEXTES teintés sont des nuances plus foncées des couleurs EnigmaOS (E30, décidé le 13 oct. : AA
      partout, 4,5:1 au moins sur leur fond) ; les fonds, points, bordures et boutons pleins gardent les couleurs
      d'origine. En mode sombre, ces jetons prennent des nuances CLAIRES. */
  --vert-fonce: #19743e;
  /* L'aplat vert appuyé (survol, dégradé) : le même en clair et en sombre — --vert-fonce, lui, est un TEXTE (E30). */
  --vert-appuye: #2a9d58;
  --vert-pale: #eaf8f0;
  --vert-bord: #cdefdc;
  --encre: #111111;
  --texte: #1a1d1f;
  --texte-doux: #5f666d;
  --texte-pale: #646b74;
  --fond: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #f7f8fa;
  --bord: #eaecef;
  --bord-fort: #e0e3e7;
  /*  Le bord d'un CHAMP ou d'une case : 3:1 au moins sur la surface et le fond (WCAG 1.4.11, D2-9) — un
      bord à 1,3:1 laissait un champ vide ou une case non cochée invisibles. Les cartes gardent --bord. */
  --bord-saisie: #858c95;
  --rouge: #ef4444;
  --rouge-pale: #fdecec;
  --orange: #f59e0b;
  --orange-pale: #fef4e2;
  --bleu: #6366f1;
  --bleu-pale: #eef0fe;
  --violet: #8b5cf6;
  --turquoise: #14b8a6;
  --rouge-texte: #b91c1c;
  --bleu-texte: #4338ca;
  --violet-texte: #6d28d9;
  --turquoise-texte: #0f766e;
  --orange-texte: #9a3412;
  --ambre-texte: #92400e;
  --volet: #14181f;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --ombre-pop: 0 12px 32px rgba(17, 17, 17, 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --texte: #e8eaed;
    --texte-doux: #a2a8b0;
    --texte-pale: #7b828b;
    --fond: #0f1216;
    --surface: #171b21;
    --surface-alt: #1d222a;
    --bord: #262c35;
    --bord-fort: #303741;
    --bord-saisie: #6b737d;
    --vert-pale: #13281d;
    --vert-bord: #1f4a33;
    --rouge-pale: #3a1717;
    --orange-pale: #3a2a10;
    --bleu-pale: #1d1f3d;
    --encre: #f1f3f5;
    --vert-fonce: #36c26e; --texte-pale: #8f969f; --rouge-texte: #f87171; --bleu-texte: #a5b4fc; --violet-texte: #c4b5fd;
    --turquoise-texte: #5eead4; --orange-texte: #fdba74; --ambre-texte: #fcd34d;
    --ombre-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --texte: #e8eaed; --texte-doux: #a2a8b0; --texte-pale: #7b828b; --fond: #0f1216; --surface: #171b21;
  --surface-alt: #1d222a; --bord: #262c35; --bord-fort: #303741; --bord-saisie: #6b737d; --vert-pale: #13281d; --vert-bord: #1f4a33;
  --rouge-pale: #3a1717; --orange-pale: #3a2a10; --bleu-pale: #1d1f3d; --encre: #f1f3f5;
  --vert-fonce: #36c26e; --texte-pale: #8f969f; --rouge-texte: #f87171; --bleu-texte: #a5b4fc; --violet-texte: #c4b5fd;
  --turquoise-texte: #5eead4; --orange-texte: #fdba74; --ambre-texte: #fcd34d;
  --ombre-pop: 0 12px 32px rgba(0, 0, 0, 0.5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  /*  La hauteur de ligne de Material 3 (bodyMedium : 20 / 14). Flutter la garde sous TOUT texte qui ne
      la redéfinit pas — titres compris : c'est elle qui donne aux bandeaux et aux onglets leur hauteur. */
  line-height: 1.43;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
  /*  Sur un écran à zoom fractionnaire (125 %, 115 %…), l'arrondi des chasses
      donnait « Perso nnel », « Fo ndateur ». Flutter place ses glyphes au
      sous-pixel : on fait de même. */
  text-rendering: geometricPrecision;
  /*  Le texte par défaut de Flutter (Material 3, bodyMedium) est espacé de 0,25 ; celui d'un
      champ (bodyLarge) de 0,5 ; celui d'un bouton (labelLarge) de 0,1. Mesuré sur les captures. */
  letter-spacing: .25px;
  /*  Inter est ici une police VARIABLE, avec un axe de taille optique : aux
      grandes tailles elle se resserre (« Display »). Celle d'EnigmaOS est une
      Inter statique, sans cet axe — d'où ses titres plus aérés. On fige l'axe
      pour retrouver le même dessin à toutes les tailles. */
  font-optical-sizing: none;
  font-variation-settings: "opsz" 14;
}
b, strong { font-weight: 550; }
h1, h2, h3, h4 { margin: 0; line-height: 1.43; }
p { margin: 0; }
/*  Une liste de définitions n'a pas de marge propre : c'est son conteneur (`.espace`) qui l'espace.
    (Une marge posée sur `.kv` écrasait celle d'`.espace` : le paragraphe et la liste se touchaient.) */
dl, dd { margin: 0; }
a { color: var(--vert-fonce); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; text-rendering: geometricPrecision; }
/*  L'anneau de focus se voit : --vert-fonce (≈ 5:1 sur blanc, clair en sombre) — le vert d'aplat n'en
    faisait que 2,3:1 (WCAG 1.4.11 / 2.4.13, D2-9). */
:focus-visible { outline: 2px solid var(--vert-fonce); outline-offset: 2px; }
.cache { display: none !important; }
svg.ic { width: 18px; height: 18px; flex: none; fill: currentColor; stroke: none;
         stroke-linecap: round; stroke-linejoin: round; }
svg.ic.petit { width: 15px; height: 15px; }
svg.ic.grand { width: 22px; height: 22px; }

/* ── LES BOUTONS ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 32px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; letter-spacing: .1px;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: default; pointer-events: none; }
.btn.vert { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn.vert:hover { background: var(--vert-appuye); border-color: var(--vert-appuye); }
.btn.encre { background: var(--encre); border-color: var(--encre); color: var(--surface); }
.btn.encre:hover { opacity: .9; }
.btn.danger { color: var(--rouge-texte); border-color: color-mix(in srgb, var(--rouge) 35%, var(--bord-fort)); }
.btn.danger:hover { background: var(--rouge-pale); }
.btn.danger.plein { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.btn svg.ic { width: 17px; height: 17px; }
.btn.discret { border-color: transparent; background: transparent; color: var(--texte-doux); }
/* Le bouton TEXTE d'EnigmaOS : « Annuler » d'une fenêtre — gris, sans bordure. */
.btn.texte { border-color: transparent; background: transparent; color: var(--texte-doux); padding: 0 14px; }
.btn.texte:hover { background: var(--surface-alt); color: var(--texte); }
.btn.discret:hover { background: var(--surface-alt); color: var(--texte); }
.btn.petit { min-height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.petit svg.ic { width: 15px; height: 15px; }
.btn.large { width: 100%; min-height: 32px; font-size: 14px; }
.btn.icone { width: 32px; padding: 0; }
.lien { background: none; border: 0; padding: 0; color: var(--vert-fonce); font-weight: 500; cursor: pointer; }
.lien:hover { text-decoration: underline; }

/* ── LES CHAMPS ──────────────────────────────────────────────────────────── */
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > .etiquette { font-size: 12px; font-weight: 600; color: var(--texte-doux); }
.champ > .aide { font-size: 12px; color: var(--texte-doux); }
.saisie, select.saisie, textarea.saisie {
  width: 100%; min-height: 35px; padding: 7px 12px;
  border: 1px solid var(--bord-saisie); border-radius: var(--r-sm);
  background: var(--surface); color: var(--texte); font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.saisie { min-height: 110px; resize: vertical; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }
.saisie::placeholder { color: var(--texte-pale); }
.saisie:focus { outline: none; border-color: var(--vert-fonce); box-shadow: 0 0 0 1px var(--vert-fonce); }
/*  Les hauteurs relevées sur EnigmaOS : un champ 35, une liste déroulante 42,
    44 dans une fenêtre ; le chevron 17 px gris, dessiné sans image. */
/*  Le texte d'un champ commence à 16 du bord (mesuré sur la fiche d'école d'EnigmaOS). */
input.saisie { height: 35px; padding-left: 15px; padding-right: 15px; }
.saisie, .recherche-haut input { letter-spacing: .5px; }
select.saisie { letter-spacing: .15px; }
select.saisie { cursor: pointer; height: 42px; padding-right: 34px; appearance: none; -webkit-appearance: none;
  /*  Le chevron « keyboard_arrow_down » : deux traits de 1,5 px, dessinés en dégradés. */
  background-image: linear-gradient(45deg, transparent 40%, var(--texte-doux) 40%, var(--texte-doux) 60%, transparent 60%),
                    linear-gradient(-45deg, transparent 40%, var(--texte-doux) 40%, var(--texte-doux) 60%, transparent 60%);
  background-position: calc(100% - 19px) 55%, calc(100% - 14px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.fenetre select.saisie { height: 44px; }
.saisie[readonly], .saisie:disabled { background: var(--surface-alt); color: var(--texte); }
.saisie[aria-invalid="true"] { border-color: var(--rouge); }
.grille-champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.avec-icone { position: relative; }
.avec-icone > svg.ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--texte-doux); pointer-events: none; }
.avec-icone > .saisie { padding-left: 38px; }
.grille-champs .large { grid-column: 1 / -1; }
.case { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; cursor: pointer; }
.case input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--vert); }
.mot-de-passe { position: relative; }
.mot-de-passe .saisie { padding-right: 44px; }
.mot-de-passe .voir { position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--texte-pale); cursor: pointer; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: var(--r-sm); }
.mot-de-passe .voir:hover { color: var(--texte); background: var(--surface-alt); }
.jauge-mdp { height: 4px; border-radius: 99px; background: var(--bord); overflow: hidden; }
.jauge-mdp > i { display: block; height: 100%; width: 0; background: var(--rouge); transition: width .2s, background .2s; }
.jauge-mdp > i.moyen { background: var(--orange); }
.jauge-mdp > i.fort { background: var(--vert); }

/* ── LES MESSAGES ────────────────────────────────────────────────────────── */
.message { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--r-sm);
  font-size: 12.5px; line-height: 1.5; border: 1px solid var(--bord); background: var(--surface-alt); }
.message.ok { background: var(--vert-pale); border-color: var(--vert-bord); color: var(--vert-fonce); }
.message.refus { background: color-mix(in srgb, var(--rouge) 7%, var(--surface)); border-color: color-mix(in srgb, var(--rouge) 25%, transparent); color: var(--rouge-texte); }
.message.alerte { background: color-mix(in srgb, #fb923c 7%, var(--surface)); border-color: color-mix(in srgb, #fb923c 25%, transparent); color: var(--orange-texte); }
.message.info { background: color-mix(in srgb, var(--bleu) 7%, var(--surface)); border-color: color-mix(in srgb, var(--bleu) 25%, transparent); color: var(--bleu-texte); }
.message .ic { margin-top: 1px; width: 16px; height: 16px; }

/* ── LES CARTES, PASTILLES, TABLEAUX ─────────────────────────────────────── */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r-md); }
.carte.pad { padding: 20px; }
.carte-tete { display: flex; align-items: center; gap: 10px; min-height: 46px;
  padding: 13px 12px 13px 18px; border-bottom: 1px solid var(--bord); background: var(--surface-alt);
  border-radius: var(--r-md) var(--r-md) 0 0; }
.carte-tete > svg.ic { width: 17px; height: 17px; color: var(--vert-fonce); }
.carte-tete h3 { font-size: 13.5px; font-weight: 550; }
.carte-tete > :last-child:not(h3):not(svg) { margin-left: auto; }
.carte-corps { padding: 18px; }
.pastille { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-alt); color: var(--texte-doux); white-space: nowrap; }
.pastille.vert { background: color-mix(in srgb, var(--vert) 10%, transparent); color: var(--vert-fonce); }
.pastille.orange { background: color-mix(in srgb, #fb923c 10%, transparent); color: var(--orange-texte); }
.pastille.rouge { background: color-mix(in srgb, var(--rouge) 10%, transparent); color: var(--rouge-texte); }
.pastille.bleu { background: color-mix(in srgb, var(--bleu) 10%, transparent); color: var(--bleu-texte); }
.pastille.violet { background: color-mix(in srgb, var(--violet) 10%, transparent); color: var(--violet-texte); }
.pastille svg.ic { width: 12px; height: 12px; }
.pastille.encre { background: var(--encre); color: var(--surface); }
.pastille .point { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tableau-boite { overflow-x: auto; }
table.tableau { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tableau th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .3px; color: var(--texte-doux);
  padding: 11px 16px; border-bottom: 1px solid var(--bord); white-space: nowrap; background: var(--surface-alt); }
table.tableau td { padding: 12px 16px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
table.tableau td.date, table.tableau td.nowrap { white-space: nowrap; }
table.tableau td.date { color: var(--texte-doux); font-variant-numeric: tabular-nums; }
table.tableau tr:last-child td { border-bottom: 0; }
table.tableau tbody tr.cliquable { cursor: pointer; }
table.tableau tbody tr.cliquable:hover { background: var(--vert-pale); }
.vide { text-align: center; padding: 42px 20px; color: var(--texte-doux); }
.vide .ico-vide { width: 52px; height: 52px; border-radius: var(--r-md); background: var(--surface-alt);
  display: inline-grid; place-items: center; color: var(--texte-pale); margin-bottom: 14px; }
.vide h4 { font-size: 15px; font-weight: 500; color: var(--texte); margin-bottom: 6px; }
.vide p { font-size: 13px; line-height: 1.5; max-width: 380px; margin: 0 auto; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--vert) 15%, transparent); border: 1px solid color-mix(in srgb, var(--vert) 40%, transparent);
  color: var(--vert-fonce); font-weight: 600; font-size: 12.5px; }
.avatar.grand { width: 56px; height: 56px; font-size: 18px; }
.personne { display: flex; align-items: center; gap: 12px; min-width: 0; }
.personne b { display: block; font-weight: 500; }
.personne small { display: block; color: var(--texte-doux); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.muet { color: var(--texte-doux); }
.pale { color: var(--texte-pale); }
.ligne { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pousse { margin-left: auto; }
.espace > * + * { margin-top: 16px; }

/* ── LA FENÊTRE (AppDialog d'EnigmaOS) ───────────────────────────────────── */
.voile { position: fixed; inset: 0; background: rgba(15, 18, 22, .45); display: grid; place-items: center;
  padding: 24px; z-index: 50; animation: apparait .15s ease-out; }
.fenetre { width: min(620px, 100%); max-height: 88vh; display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--ombre-pop); animation: monte .2s ease-out; overflow: hidden; }
.fenetre.large { width: min(680px, 100%); }
.fenetre:not(.large) .fenetre-corps { padding-left: max(20px, calc((100% - 480px) / 2)); padding-right: max(20px, calc((100% - 480px) / 2)); }
/* Le formulaire d'une fenêtre étroite tient en UNE colonne centrée, comme le FormKit d'EnigmaOS. */
.fenetre:not(.large) .fenetre-corps .grille-champs { grid-template-columns: minmax(0, 1fr); }
.fenetre-pied .btn.texte { color: var(--texte-doux); font-weight: 500; }
.fenetre-tete .btn.fermer { width: 40px; min-height: 40px; color: var(--texte); }
.fenetre-tete .btn.fermer svg { width: 19px; height: 19px; }
.fenetre .grille-champs { gap: 12px; }
.fenetre-tete { display: flex; align-items: center; gap: 12px; padding: 16px 10px 16px 20px; border-bottom: 1px solid var(--bord); flex: none; }
.fenetre-tete .carre { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--vert-pale); color: var(--vert-fonce); flex: none; }
.fenetre-tete .carre svg { width: 19px; height: 19px; }
.fenetre-tete .carre.rouge { background: color-mix(in srgb, var(--rouge) 10%, transparent); color: var(--rouge-texte); }
.fenetre-tete h3 { font-size: 16px; font-weight: 550; flex: 1; min-width: 0; }
.fenetre-corps { padding: 18px 20px; overflow-y: auto; flex: 1; }
.fenetre-corps > p.sous { font-size: 13px; color: var(--texte-doux); line-height: 1.5; }
.fenetre-pied { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--bord); flex: none; flex-wrap: wrap; }
@keyframes apparait { from { opacity: 0; } }
@keyframes monte { from { opacity: 0; transform: translateY(10px) scale(.99); } }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: var(--r-md); background: var(--encre);
  color: var(--surface); font-size: 13.5px; box-shadow: var(--ombre-pop); display: flex; gap: 10px; align-items: flex-start;
  animation: monte .2s ease-out; }
.toast.refus { background: var(--rouge); color: #fff; }
.toast > span { flex: 1; }
.toast .fermer-toast { flex: none; margin: -4px -6px -4px 4px; width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; opacity: .85; cursor: pointer; }
.toast .fermer-toast:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }
.toast .fermer-toast:focus-visible { outline-color: currentColor; }

@media (prefers-reduced-motion: reduce) {
  /*  UNE seule image : une animation infinie ramenée à 0,001 ms changeait de phase à chaque image — un
      tremblement pire que le mouvement (D2-12). */
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 640px) {
  .grille-champs { grid-template-columns: 1fr; }
}

/* ── PETITS UTILITAIRES ──────────────────────────────────────────────────── */
.bloc { display: block; }
.ligne.fin { justify-content: flex-end; }
.espace-haut { margin-top: 16px; }
.espace-bas { margin-bottom: 16px; }
label.coche { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
label.coche input { width: 16px; height: 16px; accent-color: var(--vert); }
.carre-ok { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--vert-pale); color: var(--vert-fonce); flex: none; }

/* ── CLÉ / VALEUR (KeyValue d'EnigmaOS) ──────────────────────────────────── */
.kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 10px 18px; }
.kv dt { font-size: 12.5px; font-weight: 500; color: var(--texte-doux); }
.kv dd { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }

/* ── LES PASTILLES DE CHOIX (EnigmaOS : Cycle, Secteur) ─────────────────── */
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puces button { padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--bord); background: var(--surface-alt);
  font-size: 12.5px; font-weight: 400; color: var(--texte-doux); cursor: pointer; }
.puces button.actif { background: var(--vert-pale); border-color: var(--vert); color: var(--vert-fonce); font-weight: 600; }
.puces button:hover:not(.actif) { color: var(--texte); }

/* Le code à 6 chiffres (DECISIONS § H25) : lisible d'un coup d'œil, recopié chiffre par chiffre. */
.saisie.code-six { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 22px; letter-spacing: 6px; text-align: center; max-width: 220px; }
