:root {
  color-scheme: light;
  --fond: #f6f5f2;
  --surface: #fcfcfb;
  --bordure: #e3e1dc;
  --grille: #ebe9e4;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --texte-3: #75736e;
  --accent: #1c5cab;
  --alerte-fond: #fff4e0;
  --alerte-texte: #7a4a00;
  --neutre-barre: #c9c7c0;
  /* Palette categorielle validee (dataviz), ordre fixe : une couleur par entite, jamais par rang. */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #121211;
    --surface: #1a1a19;
    --bordure: #2e2e2c;
    --grille: #262624;
    --texte: #f0efec;
    --texte-2: #c3c2b7;
    --texte-3: #9a988f;
    --accent: #86b6ef;
    --alerte-fond: #3a2a0c;
    --alerte-texte: #f3c77a;
    --neutre-barre: #4a4946;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #121211; --surface: #1a1a19; --bordure: #2e2e2c; --grille: #262624;
  --texte: #f0efec; --texte-2: #c3c2b7; --texte-3: #9a988f; --accent: #86b6ef;
  --alerte-fond: #3a2a0c; --alerte-texte: #f3c77a; --neutre-barre: #4a4946;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte); line-height: 1.5; font-size: 15px; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 1.6em; }
h3 { font-size: 1rem; }
.discret { color: var(--texte-2); }
.petit { font-size: .85rem; }
.lien { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; word-break: break-all; }

.entete {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--bordure);
  position: sticky; top: 0; z-index: 5;
}
.marque { font-weight: 700; color: var(--texte); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.drapeau { display: inline-flex; width: 18px; height: 14px; border-radius: 2px; overflow: hidden; }
.drapeau i { flex: 1; }
.drapeau i:nth-child(1) { background: #111; }
.drapeau i:nth-child(2) { background: #f6c400; }
.drapeau i:nth-child(3) { background: #e2231a; }
nav { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; font-size: .92rem; }
nav a { color: var(--texte-2); text-decoration: none; }
nav a[aria-current="page"] { color: var(--texte); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }

.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: 16px; }
.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.tuile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; transition: border-color .15s; }
.tuile:hover, .tuile:focus-visible { border-color: var(--accent); }
.tuile .titre { font-size: .9rem; color: var(--texte-2); }
.tuile .valeur { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tuile .unite { font-size: .8rem; color: var(--texte-3); }
.tuile .comparaison { font-size: .85rem; color: var(--texte-2); }
.tuile svg { margin-top: 6px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: .72rem; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--bordure); color: var(--texte-2); white-space: nowrap; }
.badge.alerte { background: var(--alerte-fond); color: var(--alerte-texte); border-color: transparent; }

.bandeau { background: var(--alerte-fond); color: var(--alerte-texte); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }

.filtres { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 12px 0; }
.segment { display: inline-flex; border: 1px solid var(--bordure); border-radius: 8px; overflow: hidden; }
.segment button { background: var(--surface); border: 0; padding: 5px 11px; font: inherit; font-size: .85rem; color: var(--texte-2); cursor: pointer; }
.segment button + button { border-left: 1px solid var(--bordure); }
.segment button[aria-pressed="true"] { background: var(--texte); color: var(--surface); }
.puce { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--bordure); background: var(--surface); border-radius: 99px; padding: 3px 10px; font: inherit; font-size: .85rem; color: var(--texte-2); cursor: pointer; }
.puce[aria-pressed="true"] { color: var(--texte); border-color: var(--texte-3); }
.puce[aria-pressed="false"] .pastille { opacity: .25; }
.pastille { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
label.case { display: inline-flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--texte-2); }

.graphique { width: 100%; height: auto; display: block; touch-action: pan-y; }
.graphique text { fill: var(--texte-2); font-size: 11px; font-family: inherit; }
.graphique .axe { stroke: var(--bordure); }
.graphique .grille-ligne { stroke: var(--grille); }
.graphique .zero { stroke: var(--texte-3); }
.graphique .curseur { stroke: var(--texte-3); stroke-dasharray: 3 3; }
.graphique .etiquette { font-weight: 600; fill: var(--texte); }

.infobulle {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--texte);
  border: 1px solid var(--bordure); border-radius: 8px; padding: 8px 10px; font-size: .82rem;
  box-shadow: 0 4px 16px rgb(0 0 0 / .12); max-width: 280px;
}
.infobulle .ligne { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.infobulle .ligne span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grille); vertical-align: top; }
th { color: var(--texte-2); font-weight: 600; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.cible td { font-weight: 700; }
.defile { overflow-x: auto; max-height: 460px; overflow-y: auto; }

.deux { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 860px) { .deux { grid-template-columns: 1fr; } }

dl.provenance { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .88rem; }
dl.provenance dt { color: var(--texte-2); }
dl.provenance dd { margin: 0; min-width: 0; }
@media (max-width: 560px) { dl.provenance { grid-template-columns: 1fr; } dl.provenance dd { margin-bottom: 6px; } }

.connexion { max-width: 380px; margin: 8vh auto; }
.connexion form { display: grid; gap: 12px; }
input[type="email"], input[type="password"] { width: 100%; padding: 9px 11px; border: 1px solid var(--bordure); border-radius: 8px; background: var(--surface); color: var(--texte); font: inherit; }
.bouton { background: var(--texte); color: var(--surface); border: 0; border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.bouton.second { background: var(--surface); color: var(--texte); border: 1px solid var(--bordure); }
.bouton:disabled { opacity: .5; cursor: progress; }
.erreur { color: #c0392b; }

.methode { max-width: 760px; }
.methode table { margin: 8px 0 16px; }
.ok { color: var(--s6); }
.ko { color: #c0392b; }
