/* ==========================================================================
   SYDIAG — Plateforme web (mode clair / sombre)
   ========================================================================== */
:root {
  --primaire: #0f766e; --primaire-clair: #14b8a6; --primaire-pale: #ecfdf5;
  --bleu: #1d4ed8; --violet: #7c3aed; --vert: #16a34a; --orange: #ea580c; --ambre: #f59e0b; --rouge: #dc2626; --cyan: #0891b2;
  --fond: #f1f5f9; --surface: #ffffff; --surface-2: #f8fafc; --bordure: #e2e8f0; --bordure-2: #cbd5e1;
  --texte: #0f172a; --texte-2: #475569; --texte-3: #94a3b8;
  --ombre-s: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --ombre-m: 0 4px 6px -1px rgba(15,23,42,.08), 0 2px 4px -2px rgba(15,23,42,.06);
  --rayon: 12px; --rayon-s: 8px; --barre: 262px;
  --police: "Segoe UI", Roboto, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
html[data-theme="sombre"] {
  --fond: #0b1220; --surface: #131c2e; --surface-2: #1a2438; --bordure: #253248; --bordure-2: #33415c;
  --texte: #e2e8f0; --texte-2: #94a3b8; --texte-3: #64748b; --primaire-pale: #042f2e;
  --ombre-s: 0 1px 3px rgba(0,0,0,.4); --ombre-m: 0 4px 10px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--police); font-size: 14px; line-height: 1.55; color: var(--texte); background: var(--fond); -webkit-font-smoothing: antialiased; }
a { color: var(--primaire); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* ---- Structure ---- */
.appli { display: flex; min-height: 100vh; }
.barre-laterale { width: var(--barre); flex: 0 0 var(--barre); background: linear-gradient(178deg, #0f172a, #134e4a 60%, #0f766e); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.marque { padding: 1.1rem 1.15rem .9rem; border-bottom: 1px solid rgba(255,255,255,.09); }
.marque-titre { display: flex; align-items: center; gap: .6rem; }
.marque-logo { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(135deg, #14b8a6, #0ea5e9); font-size: 1.15rem; box-shadow: 0 4px 12px rgba(20,184,166,.35); }
.marque-nom { font-size: 1.15rem; font-weight: 750; color: #fff; letter-spacing: .3px; }
.marque-sous { font-size: .68rem; color: #94a3b8; margin-top: .1rem; }
.marque-mission { margin-top: .7rem; font-size: .68rem; color: #94a3b8; border-left: 2px solid rgba(20,184,166,.6); padding-left: .5rem; }
.nav { padding: .7rem .6rem 1.5rem; flex: 1; }
.nav-groupe { font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; color: #64748b; padding: .9rem .6rem .35rem; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: var(--rayon-s); color: #cbd5e1; font-weight: 500; text-decoration: none; transition: background .15s; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.actif { background: rgba(20,184,166,.22); color: #fff; box-shadow: inset 2px 0 0 #14b8a6; }
.nav-emoji { width: 1.4rem; text-align: center; font-size: 1.05rem; }
.nav-pastille { margin-left: auto; background: #f59e0b; color: #0f172a; border-radius: 999px; font-size: .68rem; font-weight: 700; padding: .05rem .5rem; }
.pied-barre { padding: .9rem 1.15rem; font-size: .68rem; color: #64748b; border-top: 1px solid rgba(255,255,255,.09); }
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entete { display: flex; align-items: center; gap: 1rem; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--bordure); position: sticky; top: 0; z-index: 20; }
.entete-titre { flex: 1; min-width: 0; }
.entete h1 { font-size: 1.25rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.fil-ariane { font-size: .78rem; color: var(--texte-3); }
.fil-ariane a { color: var(--texte-2); }
.recherche-globale input { width: 240px; }
.utilisateur-puce { display: flex; align-items: center; gap: .55rem; padding: .3rem .6rem .3rem .3rem; border-radius: 999px; border: 1px solid var(--bordure); background: var(--surface-2); color: var(--texte); text-decoration: none; font-size: .8rem; line-height: 1.2; }
.utilisateur-puce:hover { text-decoration: none; border-color: var(--primaire-clair); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--primaire-pale); font-size: 1rem; }
.utilisateur-nom { font-weight: 650; } .utilisateur-role { color: var(--texte-3); font-size: .72rem; }
.basculer-menu { display: none; }
.contenu { padding: 1.4rem 1.5rem 3rem; max-width: 1500px; width: 100%; }

/* ---- Cartes et grilles ---- */
.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); box-shadow: var(--ombre-s); margin-bottom: 1.1rem; }
.carte-entete { display: flex; align-items: center; gap: .7rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--bordure); }
.carte-entete h2, .carte-entete h3 { margin: 0; }
.carte-corps { padding: 1.1rem; }
.carte-corps.sans-marge { padding: 0; }
.grille { display: grid; gap: 1.1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g21 { grid-template-columns: 2fr 1fr; } .g12 { grid-template-columns: 1fr 2fr; }
.rangee { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.entre { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.droite { margin-left: auto; } .aligne-droite { margin-left: auto; }
.petit { font-size: .8rem; } .tres-petit { font-size: .72rem; } .gras { font-weight: 650; } .discret { color: var(--texte-3); } .secondaire { color: var(--texte-2); }
.nowrap { white-space: nowrap; } .centre { text-align: center; } .mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }

/* ---- Statistiques ---- */
.stat { display: block; background: var(--surface); border: 1px solid var(--bordure); border-left: 4px solid var(--accent, var(--primaire)); border-radius: var(--rayon); padding: .9rem 1rem; box-shadow: var(--ombre-s); color: var(--texte); text-decoration: none; }
a.stat:hover { text-decoration: none; box-shadow: var(--ombre-m); }
.stat-tete { display: flex; align-items: center; gap: .5rem; color: var(--texte-2); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-emoji { font-size: 1.1rem; } .stat-valeur { font-size: 1.9rem; font-weight: 750; line-height: 1.15; margin: .3rem 0 .1rem; }
.stat-detail { font-size: .78rem; color: var(--texte-2); }
.jauge { height: 6px; background: var(--bordure); border-radius: 999px; overflow: hidden; margin-top: .55rem; }
.jauge span { display: block; height: 100%; background: var(--accent, var(--primaire)); border-radius: 999px; }
.barre-progression { height: 8px; background: var(--bordure); border-radius: 999px; overflow: hidden; min-width: 60px; }
.barre-progression span { display: block; height: 100%; border-radius: 999px; }
.histo-barres { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: .3rem 0; }
.histo-barre { flex: 1; background: linear-gradient(180deg, var(--primaire-clair), var(--primaire)); border-radius: 4px 4px 0 0; min-height: 3px; }
.histo-legende { display: flex; gap: 4px; font-size: .62rem; color: var(--texte-3); }
.histo-legende span { flex: 1; text-align: center; overflow: hidden; }

/* ---- Pastilles ---- */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; border: 1px solid var(--bordure-2); color: var(--texte-2); background: var(--surface-2); white-space: nowrap; line-height: 1.5; }
.badge.plein { color: #fff; }
.precision { font-size: .8rem; color: var(--texte-2); margin-top: .25rem; font-style: italic; }
.frise { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.frise-etape { padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--bordure-2); font-size: .76rem; color: var(--texte-3); background: var(--surface-2); }
.frise-etape.faite { color: var(--vert); border-color: #86efac; background: #f0fdf4; }
.frise-etape.courant { color: #fff; background: var(--primaire); border-color: var(--primaire); font-weight: 650; }
.frise-fleche { color: var(--texte-3); }
.alerte-ruban { display: flex; align-items: center; gap: .7rem; padding: .75rem 1rem; border-radius: var(--rayon-s); margin-bottom: 1.1rem; border: 1px solid; font-size: .9rem; }
.alerte-ruban.vert { background: #f0fdf4; border-color: #86efac; color: #14532d; }
.alerte-ruban.rouge { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }
.alerte-ruban.orange { background: #fff7ed; border-color: #fdba74; color: #7c2d12; }
.alerte-ruban.bleu { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }
html[data-theme="sombre"] .alerte-ruban.vert { background: #052e16; color: #bbf7d0; } html[data-theme="sombre"] .alerte-ruban.rouge { background: #450a0a; color: #fecaca; }
html[data-theme="sombre"] .alerte-ruban.orange { background: #431407; color: #fed7aa; } html[data-theme="sombre"] .alerte-ruban.bleu { background: #172554; color: #bfdbfe; }

/* ---- Tableaux ---- */
table.tableau { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tableau th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); padding: .6rem .8rem; border-bottom: 1px solid var(--bordure); background: var(--surface-2); white-space: nowrap; }
.tableau td { padding: .55rem .8rem; border-bottom: 1px solid var(--bordure); vertical-align: top; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau tbody tr:hover td { background: var(--surface-2); }
.tableau .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Tri par l'en-tête : th.triable (tri dans le navigateur, sydiag.js) ou lien a.tri (liste paginée, tri par le serveur) */
.tableau th.triable, .tableau th a.tri { cursor: pointer; user-select: none; }
.tableau th a.tri { display: block; margin: -.6rem -.8rem; padding: .6rem .8rem; color: inherit; text-decoration: none; }
.tableau th.triable:hover, .tableau th a.tri:hover, .tableau th.triable:focus-visible { color: var(--texte); background: var(--bordure); outline: none; }
.tableau th.triable::after, .tableau th a.tri::after { content: " ↕"; opacity: .4; }
.tableau th[aria-sort="ascending"].triable::after, .tableau th[aria-sort="ascending"] a.tri::after { content: " ▲"; opacity: 1; color: var(--primaire); }
.tableau th[aria-sort="descending"].triable::after, .tableau th[aria-sort="descending"] a.tri::after { content: " ▼"; opacity: 1; color: var(--primaire); }
.tableau th[aria-sort] { color: var(--texte); }
.defilant { overflow-x: auto; }
.pagination { display: flex; gap: .3rem; align-items: center; padding: .8rem 1.1rem; flex-wrap: wrap; }
.pagination a { padding: .2rem .6rem; border: 1px solid var(--bordure); border-radius: 6px; font-size: .8rem; }
.pagination a.courant { background: var(--primaire); color: #fff; border-color: var(--primaire); }

/* ---- Formulaires ---- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--bordure-2); border-radius: var(--rayon-s); background: var(--surface); color: var(--texte); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primaire-clair); box-shadow: 0 0 0 3px rgba(20,184,166,.18); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--texte-2); margin-bottom: .3rem; }
.champ { margin-bottom: .9rem; }
.filtres { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; padding: .9rem 1.1rem; border-bottom: 1px solid var(--bordure); }
.filtres > div { min-width: 160px; }
.filtres select, .filtres input { width: auto; min-width: 160px; }
.bouton { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; border-radius: var(--rayon-s); border: 1px solid var(--bordure-2); background: var(--surface); color: var(--texte); font-weight: 600; cursor: pointer; text-decoration: none; transition: all .15s; font-size: .88rem; line-height: 1.3; }
.bouton:hover { border-color: var(--primaire-clair); text-decoration: none; box-shadow: var(--ombre-s); }
.bouton.primaire { background: var(--primaire); color: #fff; border-color: var(--primaire); }
.bouton.primaire:hover { background: #115e59; }
.bouton.danger { background: var(--rouge); color: #fff; border-color: var(--rouge); }
.bouton.orange { background: var(--orange); color: #fff; border-color: var(--orange); }
.bouton.vert { background: var(--vert); color: #fff; border-color: var(--vert); }
.bouton.petit { padding: .3rem .65rem; font-size: .8rem; }
.bouton:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Fiche restituée ---- */
.section-fiche { margin-bottom: 1.1rem; }
.section-fiche summary { cursor: pointer; list-style: none; }
.section-fiche summary::-webkit-details-marker { display: none; }
.section-titre { display: flex; align-items: center; gap: .6rem; padding: .8rem 1.1rem; }
.section-titre .num { font-family: var(--mono); font-size: .75rem; color: var(--texte-3); background: var(--surface-2); padding: .1rem .45rem; border-radius: 6px; }
.sous-section { padding: .45rem 1.1rem; background: var(--surface-2); font-size: .78rem; font-weight: 700; color: var(--texte-2); text-transform: uppercase; letter-spacing: .05em; border-top: 1px solid var(--bordure); border-bottom: 1px solid var(--bordure); }
.tableau-fiche td:first-child { width: 52px; color: var(--texte-3); font-family: var(--mono); font-size: .74rem; }
.tableau-fiche td:nth-child(2) { width: 42%; color: var(--texte-2); }
.tableau-fiche tr.manquant td { background: #fff7ed; }
html[data-theme="sombre"] .tableau-fiche tr.manquant td { background: #431407; }
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.galerie a { display: block; border-radius: var(--rayon-s); overflow: hidden; border: 1px solid var(--bordure); background: var(--surface-2); }
.galerie img { width: 100%; height: 120px; object-fit: cover; display: block; }
.galerie .legende { font-size: .7rem; padding: .3rem .45rem; color: var(--texte-2); }
.vide { text-align: center; padding: 2rem 1rem; color: var(--texte-2); }
.vide-emoji { font-size: 2rem; display: block; margin-bottom: .4rem; }
.arbre ul { list-style: none; margin: 0; padding-left: 1.2rem; border-left: 1px dashed var(--bordure-2); }
.arbre li { padding: .25rem 0; }
.liste-manques li { padding: .3rem 0; border-bottom: 1px dashed var(--bordure); font-size: .85rem; }
.repartition { display: flex; flex-direction: column; gap: .5rem; }
.repartition .ligne { display: grid; grid-template-columns: 1fr 60px; gap: .5rem; align-items: center; font-size: .82rem; }
#carte { height: calc(100vh - 190px); min-height: 460px; border-radius: var(--rayon); }
.legende-carte { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .78rem; }
.legende-carte span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: .3rem; }
.chip-controle { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .6rem; border-radius: 8px; border: 1px solid var(--bordure); font-size: .8rem; margin: .15rem; }
.chip-controle.ok { background: #f0fdf4; border-color: #86efac; } .chip-controle.ko { background: #fef2f2; border-color: #fca5a5; }

/* ---- Connexion ---- */
.page-connexion { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f172a, #134e4a 55%, #0f766e); padding: 1rem; }
.boite-connexion { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.comptes-demo { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; }
.comptes-demo button { font-size: .72rem; padding: .2rem .5rem; border-radius: 999px; border: 1px solid var(--bordure-2); background: var(--surface-2); cursor: pointer; }

/* ---- Impression ---- */
/* ---- Pages de rapport ---- */
.rapport-tete { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; border-bottom: 2px solid var(--primaire, #0f766e); padding-bottom: .6rem; margin-bottom: 1rem; }
.rapport-tete h2 { margin: 0 0 .15rem; font-size: 1.15rem; }
.rapport-outils { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.rapport-outils select { width: auto; min-width: 260px; }
.rapport-section { margin: 1.4rem 0 .6rem; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.rapport-section .compte { font-size: .75rem; font-weight: 600; color: var(--texte-3); }
.rapport-texte { white-space: pre-line; font-size: .88rem; line-height: 1.55; }
.matrice td.cellule { text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.matrice th.centre { text-align: center; }
.impression-seule { display: none; }
@media print {
  .impression-seule { display: block; }
  .rapport-outils, .alerte-ruban .bouton { display: none !important; }
  .rapport-tete { border-color: #0f766e; }
  .appli { display: block; } .principal { margin: 0; }
  .grille.g4 { grid-template-columns: repeat(4, 1fr); } .grille.g2, .grille.g21 { grid-template-columns: repeat(2, 1fr); } .grille.g3 { grid-template-columns: repeat(3, 1fr); }
  .tableau { font-size: 10px; } .tableau th, .tableau td { padding: 3px 5px; }
  .tableau thead { display: table-header-group; } .tableau tr { break-inside: avoid; }
  .tableau th.triable::after, .tableau th a.tri::after { content: none; }
  .tableau th { white-space: normal; letter-spacing: 0; } .tableau .nowrap { white-space: normal; } .tableau .badge { font-size: 9px; padding: 1px 5px; white-space: normal; }
  .carte { overflow: visible; } .stat { padding: .6rem .7rem; } .stat-valeur { font-size: 1.3rem; }
  a { color: inherit; text-decoration: none; }
  .badge, .jauge span, .barre-progression span, .histo-barre { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 14mm 12mm; }
}
@media print {
  .barre-laterale, .entete, .bouton, .filtres, .pagination { display: none !important; }
  .contenu { padding: 0; max-width: none; } .carte { break-inside: avoid; box-shadow: none; }
  body { background: #fff; font-size: 11px; }
}
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } .g21, .g12 { grid-template-columns: 1fr; } .recherche-globale { display: none; } }
@media (max-width: 760px) {
  .barre-laterale { position: fixed; left: calc(-1 * var(--barre)); transition: left .2s; height: 100vh; }
  .barre-laterale.ouverte { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .basculer-menu { display: inline-flex; } .contenu { padding: 1rem; } .g2, .g4, .g3 { grid-template-columns: 1fr; }
  .utilisateur-puce span:last-child { display: none; }
}
