:root {
  color-scheme: light;
  --surface-0: #f5f4f1;
  --surface-1: #fcfcfb;
  --bordure: #e2e1dc;
  --grille: #ebeae6;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --texte-3: #7a7974;
  --accent: #256abf;
  --accent-texte: #ffffff;
  --serie-1: #2a78d6;  /* OCPV */
  --serie-2: #eb6834;  /* PAM */
  --serie-3: #1baf7a;  /* ANSTAT */
  --serie-4: #eda100;  /* CNLVC */
  --hausse: #d03b3b;   /* toujours avec flèche + libellé */
  --baisse: #0a7d0a;
  --stable: #52514e;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --bordure: #33332f;
    --grille: #2a2a27;
    --texte: #f0efec;
    --texte-2: #c3c2b7;
    --texte-3: #9a998f;
    --accent: #5598e7;
    --accent-texte: #0b0b0b;
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --serie-3: #199e70;
    --serie-4: #c98500;
    --hausse: #e66767;
    --baisse: #0ca30c;
    --stable: #c3c2b7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --bordure: #33332f; --grille: #2a2a27;
  --texte: #f0efec; --texte-2: #c3c2b7; --texte-3: #9a998f; --accent: #5598e7; --accent-texte: #0b0b0b;
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
  --hausse: #e66767; --baisse: #0ca30c; --stable: #c3c2b7;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface-0); color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.conteneur { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
.entete { background: var(--surface-1); border-bottom: 1px solid var(--bordure); padding: 22px 0 16px; }
.sous-titre { margin: 0; color: var(--texte-2); }
#maj { color: var(--texte-3); }

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 18px 0; }
.tuile { background: var(--surface-1); border: 1px solid var(--bordure); border-radius: 10px; padding: 12px 14px; }
.tuile .valeur { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tuile .libelle { color: var(--texte-2); font-size: .85rem; }

.filtres { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin-bottom: 10px; }
.filtres label { display: flex; flex-direction: column; font-size: .8rem; color: var(--texte-2); gap: 3px; }
.filtres label.case, label.case { flex-direction: row; align-items: center; gap: 6px; }
select, input[type="search"], input[type="email"], input:not([type]) {
  font: inherit; color: var(--texte); background: var(--surface-1); border: 1px solid var(--bordure);
  border-radius: 8px; padding: 7px 9px; min-height: 38px; max-width: 100%;
}
.recherche input { width: 210px; }

.tableau-zone { background: var(--surface-1); border: 1px solid var(--bordure); border-radius: 10px; padding: 8px 0; }
.compte { margin: 4px 14px 6px; color: var(--texte-3); font-size: .85rem; }
.defile { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--grille); white-space: nowrap; }
th { font-size: .78rem; color: var(--texte-2); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }
th[data-tri] { cursor: pointer; user-select: none; }
th[data-tri]:hover { color: var(--texte); }
th.trie::after { content: " ▾"; } th.trie.asc::after { content: " ▴"; }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr:focus-visible { background: var(--surface-0); outline: none; }
.unite, .date { color: var(--texte-3); font-size: .8rem; }
.marche { color: var(--texte-3); font-size: .8rem; display: block; }
.var { font-weight: 600; }
.var.hausse { color: var(--hausse); } .var.baisse { color: var(--baisse); } .var.stable { color: var(--stable); }
.pastille { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.etat { margin: 12px 14px; color: var(--texte-2); }
.etat:empty { display: none; }
.spark { display: block; }

.detail { background: var(--surface-1); border: 1px solid var(--bordure); border-radius: 10px; padding: 14px; margin-top: 16px; }
.detail-tete { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.bouton-lien { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px; }
.legende { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; color: var(--texte-2); margin: 4px 0 8px; }
.graphe { position: relative; }
.graphe svg { display: block; width: 100%; height: auto; }
.infobulle {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--bordure);
  border-radius: 8px; padding: 6px 9px; font-size: .8rem; box-shadow: 0 2px 8px rgb(0 0 0 / .12); white-space: nowrap;
}
.table-vue { margin-top: 8px; font-size: .85rem; }
.table-vue table { max-width: 640px; }

.abonnement { background: var(--surface-1); border: 1px solid var(--bordure); border-radius: 10px; padding: 16px; margin: 16px 0 28px; }
.abonnement p { color: var(--texte-2); margin-top: 0; }
#form-abonnement { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 16px; }
#form-abonnement label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--texte-2); }
#form-abonnement small { color: var(--texte-3); }
#form-abonnement .consentement { grid-column: 1 / -1; flex-direction: row; align-items: start; }
#form-abonnement .consentement input { margin-top: 3px; }
#form-abonnement button {
  justify-self: start; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-texte);
  border: 0; border-radius: 8px; padding: 9px 18px; cursor: pointer; min-height: 40px;
}
#form-abonnement button:disabled { opacity: .6; cursor: default; }
.message { grid-column: 1 / -1; margin: 0; color: var(--texte); }
.piege { position: absolute !important; left: -9999px; }

.pied { border-top: 1px solid var(--bordure); padding: 16px 0 28px; color: var(--texte-2); font-size: .85rem; }

@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  th, td { padding: 7px 10px; }
  .recherche input { width: 100%; }
  .filtres label { flex: 1 1 140px; }
}
