:root {
  --fond: #f4f6f9; --surface: #ffffff; --texte: #111827; --texte-doux: #4b5563; --bord: #cdd3dc;
  --primaire: #14355c; --primaire-2: #1d4d84; --primaire-clair: #e6eef8; --accent: #f2a900;
  --ok: #0b6b3a; --ok-fond: #e3f4ea; --info: #1d4d84; --info-fond: #e6eef8;
  --alerte: #8a4b00; --alerte-fond: #fff1d6; --danger: #a21b12; --danger-fond: #fde8e6;
  --rayon: 10px; --ombre: 0 1px 2px rgba(17, 24, 39, .08);
  --nav-largeur: 250px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--fond); color: var(--texte); line-height: 1.45; }
body { min-height: 100vh; overflow-x: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; color: var(--primaire); }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primaire-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .75rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid #0b57d0; outline-offset: 2px; }

/* Bandeau démo */
.bandeau-demo { background: #0f2640; color: #fff; font-size: .875rem; padding: .4rem 1rem; display: flex; gap: .75rem; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center; }
.bandeau-demo button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: 6px; padding: .35rem .7rem; font: inherit; font-size: .8rem; cursor: pointer; min-height: 32px; }

/* Structure */
.coque { display: grid; grid-template-columns: var(--nav-largeur) minmax(0, 1fr); min-height: calc(100vh - 36px); }
.nav { background: var(--primaire); color: #fff; padding: 1rem .75rem; position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; }
.marque { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; padding: .25rem .5rem 1rem; }
.marque img { width: 32px; height: 32px; }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a.nav-lien { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; padding: .7rem .75rem; border-radius: 8px; min-height: 44px; font-size: .95rem; }
.nav a.nav-lien:hover { background: rgba(255,255,255,.12); }
.nav a.nav-lien[aria-current="page"] { background: #fff; color: var(--primaire); font-weight: 700; }
.nav .num { display: inline-block; min-width: 1.6rem; text-align: center; font-size: .8rem; opacity: .85; }
.nav-bas { font-size: .75rem; opacity: .8; padding: 1rem .5rem 0; }
.contenu { min-width: 0; display: flex; flex-direction: column; }
.barre-haut { background: var(--surface); border-bottom: 1px solid var(--bord); padding: .6rem 1rem; display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.barre-haut .champ { margin: 0; min-width: 0; }
.barre-haut label { font-size: .75rem; color: var(--texte-doux); }
.barre-haut select { min-height: 40px; }
.statut-reseau { margin-left: auto; align-self: center; font-size: .85rem; font-weight: 600; padding: .35rem .7rem; border-radius: 999px; background: var(--ok-fond); color: var(--ok); }
.statut-reseau.hors { background: var(--alerte-fond); color: var(--alerte); }

main#vue { padding: 1.25rem; max-width: 1200px; width: 100%; }
.entete-page { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 1rem; }
.entete-page p { color: var(--texte-doux); margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Composants */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--ombre); min-width: 0; }
.carte-titre { margin-bottom: .75rem; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.grille-2 > .carte { margin-bottom: 0; }
.kpi { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .85rem 1rem; box-shadow: var(--ombre); }
.kpi-valeur { font-size: 1.6rem; font-weight: 700; color: var(--primaire); overflow-wrap: anywhere; }
.kpi-libelle { font-size: .875rem; color: var(--texte-doux); }
.kpi-note { font-size: .8rem; color: var(--texte-doux); margin-top: .2rem; }
.kpi-danger .kpi-valeur { color: var(--danger); } .kpi-alerte .kpi-valeur { color: var(--alerte); } .kpi-ok .kpi-valeur { color: var(--ok); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--primaire); background: var(--surface); color: var(--primaire); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--primaire-clair); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primaire { background: var(--primaire); color: #fff; } .btn-primaire:hover { background: var(--primaire-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; } .btn-danger:hover { background: #8a1810; }
.btn-petit { min-height: 36px; padding: .3rem .7rem; font-size: .875rem; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #e5e7eb; color: #1f2937; white-space: nowrap; }
.badge-ok { background: var(--ok-fond); color: var(--ok); } .badge-info { background: var(--info-fond); color: var(--info); }
.badge-alerte { background: var(--alerte-fond); color: var(--alerte); } .badge-danger { background: var(--danger-fond); color: var(--danger); }
.avis { padding: .7rem .9rem; border-radius: 8px; border-left: 4px solid var(--info); background: var(--info-fond); margin: 0 0 .75rem; }
.avis-ok { border-color: var(--ok); background: var(--ok-fond); } .avis-alerte { border-color: var(--alerte); background: var(--alerte-fond); }
.avis-danger { border-color: var(--danger); background: var(--danger-fond); }
.vide { color: var(--texte-doux); font-style: italic; }
.aide { font-size: .8rem; color: var(--texte-doux); margin: .25rem 0 0; }
.mention { font-size: .85rem; color: var(--texte-doux); }

/* Formulaires */
.champ { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; min-width: 0; }
.champ label { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], input[type=email], input[type=file], select, textarea {
  font: inherit; color: var(--texte); background: #fff; border: 1.5px solid #8b95a5; border-radius: 8px; padding: .55rem .65rem; min-height: 44px; width: 100%; max-width: 100%; }
textarea { min-height: 90px; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--primaire); }
.ligne-case { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-weight: 500; }
.ligne-case label { font-weight: 500; }
.formulaire { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 1rem; }
.formulaire .large { grid-column: 1 / -1; }
.filtres { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .75rem; }
.filtres .champ { margin: 0; min-width: 150px; flex: 1 1 150px; }
fieldset { border: 1px solid var(--bord); border-radius: 8px; margin: 0 0 .75rem; padding: .6rem .8rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.puces { display: flex; flex-wrap: wrap; gap: .5rem; }
.puce { min-height: 44px; min-width: 56px; padding: .4rem .9rem; border-radius: 999px; border: 1.5px solid var(--primaire); background: #fff; color: var(--primaire); font: inherit; font-weight: 700; cursor: pointer; }
.puce:hover { background: var(--primaire-clair); }

/* Tableaux */
.tableau-wrap { width: 100%; }
.tableau { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tableau th { text-align: left; background: #eef1f6; color: #1f2937; padding: .55rem .6rem; border-bottom: 2px solid var(--bord); white-space: nowrap; }
.tableau td { padding: .55rem .6rem; border-bottom: 1px solid #e3e7ee; vertical-align: top; overflow-wrap: anywhere; }
.tableau .num, .tableau th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tableau tr.surligne td { background: var(--alerte-fond); }
.tableau tr.faible td { background: var(--danger-fond); }

/* Jauges et graphiques */
.jauge { display: flex; align-items: center; gap: .6rem; min-width: 150px; }
.jauge-piste { flex: 1; height: 12px; background: #e3e7ee; border-radius: 999px; overflow: hidden; min-width: 80px; }
.jauge-barre { display: block; height: 100%; border-radius: 999px; background: var(--info); }
.jauge-ok { background: var(--ok); } .jauge-alerte { background: #c77700; } .jauge-danger { background: var(--danger); } .jauge-neutre { background: #9aa3b2; }
.jauge-texte { font-size: .85rem; font-weight: 600; white-space: nowrap; }
.barres { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.barres li { display: grid; grid-template-columns: minmax(80px, 28%) 1fr minmax(60px, auto); gap: .6rem; align-items: center; font-size: .9rem; }
.barres-piste { height: 14px; background: #e3e7ee; border-radius: 4px; overflow: hidden; display: block; }
.barres-barre { display: block; height: 100%; background: var(--primaire-2); }
.barres-danger { background: var(--danger) !important; } .barres-ok { background: var(--ok) !important; } .barres-alerte { background: #c77700 !important; } .barres-doux { background: #8fa8c8 !important; }
.barres-valeur { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.colonnes { display: flex; gap: .4rem; align-items: flex-end; height: 190px; }
.colonne { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .2rem; font-size: .75rem; }
.colonne-piste { display: flex; align-items: flex-end; width: 100%; flex: 1; }
.colonne-barre { display: block; width: 100%; background: var(--primaire-2); border-radius: 4px 4px 0 0; }
.colonne-valeur { font-weight: 700; font-variant-numeric: tabular-nums; }
.colonne-libelle { color: var(--texte-doux); }

/* Carte schématique */
.carte-svg { width: 100%; height: auto; max-height: 460px; background: #eaf1f8; border-radius: 10px; border: 1px solid var(--bord); }
.carte-svg .zone { cursor: pointer; stroke: #fff; stroke-width: 3; }
.carte-svg .zone:focus-visible { stroke: #0b57d0; stroke-width: 5; outline: none; }
.carte-svg .zone-sel { stroke: #111827; stroke-width: 4; }
.carte-svg text { font-family: inherit; font-size: 15px; font-weight: 700; fill: #111827; pointer-events: none; }
.legende { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; margin-top: .5rem; }
.legende i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: .3rem; vertical-align: -2px; }

/* Modale et toasts */
dialog.modale { border: 0; border-radius: 12px; padding: 1.25rem; max-width: min(520px, 92vw); width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog.modale::backdrop { background: rgba(15, 38, 64, .55); }
.modale-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: .5rem; width: min(92vw, 460px); }
.toast { background: #0f2640; color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.toast-danger { background: var(--danger); } .toast-alerte { background: #7a4300; }
.bloc-code { background: #0f172a; color: #e2e8f0; padding: .75rem; border-radius: 8px; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
.avant-apres { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.avant-apres pre { margin: 0; background: #f1f4f9; padding: .4rem; border-radius: 6px; font-size: .78rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Saisie terrain */
.saisie-sig { border: 1px solid var(--bord); border-radius: 8px; padding: .6rem; margin-bottom: .6rem; background: #fafbfd; }
.saisie-sig .formulaire { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.presents { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .25rem 1rem; }

/* Rapport imprimable */
.rapport { background: #fff; color: #000; padding: 1.5rem; border: 1px solid var(--bord); border-radius: 10px; }
.rapport h1, .rapport h2 { color: #000; }
.rapport .mention-simulation { font-style: italic; }

/* Téléphone */
@media (max-width: 860px) {
  .coque { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(82vw, 300px); transform: translateX(-105%); transition: transform .2s ease; visibility: hidden; height: 100%; }
  .nav.ouvert { transform: translateX(0); visibility: visible; box-shadow: 0 0 0 100vmax rgba(15, 38, 64, .5); }
  .barre-haut .btn.btn-menu { display: inline-flex; }
  main#vue { padding: .9rem; }
  .barre-haut { padding: .5rem .75rem; }
  .barre-haut .champ { flex: 1 1 140px; }
  .statut-reseau { margin-left: 0; }
  .tableau thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tableau, .tableau tbody, .tableau tr, .tableau td { display: block; width: 100%; }
  .tableau tr { border: 1px solid var(--bord); border-radius: 8px; margin-bottom: .6rem; padding: .3rem .5rem; background: #fff; }
  .tableau td { border: 0; padding: .25rem 0; display: flex; justify-content: space-between; gap: .75rem; text-align: right; }
  .tableau td::before { content: attr(data-label); font-weight: 700; color: var(--texte-doux); text-align: left; flex: 0 0 38%; }
  .tableau td:empty { display: none; }
  .tableau .num, .tableau th.num { text-align: right; }
  .jauge { min-width: 0; flex: 1; }
  .barres li { grid-template-columns: minmax(70px, 30%) 1fr auto; }
  .avant-apres { grid-template-columns: 1fr; }
  .kpi-valeur { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Impression : seul le rapport est imprimé */
@media print {
  .bandeau-demo, .nav, .barre-haut, .no-print, .toasts, .skip { display: none !important; }
  .coque { display: block; }
  body, html { background: #fff; }
  main#vue { padding: 0; max-width: none; }
  .rapport { border: 0; padding: 0; }
  .carte { box-shadow: none; break-inside: avoid; }
}
.chargement { padding: 1rem; }
.liste-simple { list-style: none; margin: 0 0 .75rem; padding: 0; }
.ligne-membre { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .35rem 0; border-bottom: 1px solid #e3e7ee; }
.ligne-membre select { max-width: 55%; }
.carte .filtres { margin-top: .75rem; }

.btn.btn-menu { display: none; }
.tableau .nw { white-space: nowrap; }
.tableau .btn { min-height: 36px; padding: .25rem .7rem; font-size: .875rem; white-space: nowrap; }

.carte-svg text.z-sous { font-weight: 400; font-size: 13px; }
.pastille.p-fort { background: #9ad3a8; } .pastille.p-moyen { background: #f3dc92; } .pastille.p-faible { background: #efa9a4; } .pastille.p-aucun { background: #d5dbe4; }
.legende .pastille { border: 1px solid #6b7280; }
.rapport h2.rapport-titre { font-size: 1.5rem; margin-bottom: .75rem; }
.rapport h3 { margin-top: 1rem; color: #000; }
