:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --border: #e2e0da;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --flame: #eb6834;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #2e2e2b;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --flame: #d95926;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --border: #2e2e2b;
  --grid: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --flame: #d95926;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }

header.barre {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px;
}
header.barre h1 { font-size: 1.35rem; margin: 0; }
header.barre .meta { color: var(--text-secondary); font-size: .875rem; }
header.barre a, header.barre button.lien {
  color: var(--text-secondary); background: none; border: 0; font: inherit; cursor: pointer;
  text-decoration: underline; padding: 0;
}

.carte {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.carte h2 { font-size: 1rem; margin: 0 0 12px; }

.alerte {
  border-left: 4px solid var(--critical); background: var(--surface-1);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; color: var(--text-primary);
}
.alerte.attention { border-left-color: var(--warning); }

.tuiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
  margin-bottom: 16px;
}
.tuile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.tuile .libelle { color: var(--text-secondary); font-size: .8rem; }
.tuile .valeur { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tuile .valeur small { font-size: .9rem; font-weight: 400; color: var(--text-secondary); }
.tuile .note { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.pastille { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-muted); }
.pastille.ok { background: var(--good); }
.pastille.attention { background: var(--warning); }
.pastille.critique { background: var(--critical); }
.pastille.flamme { background: var(--flame); }

.reglages { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.reglage { display: flex; flex-direction: column; gap: 6px; }
.reglage label { color: var(--text-secondary); font-size: .85rem; }
.reglage select, .pas input {
  font: inherit; color: var(--text-primary); background: var(--surface-0);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 40px;
}
.pas { display: flex; gap: 6px; align-items: stretch; }
.pas input { width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.pas button, .btn {
  font: inherit; min-width: 40px; min-height: 40px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-0); color: var(--text-primary);
}
.btn.principal { background: var(--accent); border-color: var(--accent); color: #fff; padding: 0 14px; }
.btn:disabled, .pas button:disabled { opacity: .5; cursor: wait; }
.zone-titre { font-weight: 600; margin: 4px 0 0; grid-column: 1 / -1; }

.periode { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.periode button {
  font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
}
.periode button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }

.graphe { position: relative; height: 300px; }
.graphe.court { height: 180px; }
.graphe.bande { height: 70px; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--text-secondary); margin-bottom: 8px; }
.legende button {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 4px 0;
  color: inherit; font: inherit; cursor: pointer;
}
.legende button[aria-pressed="false"] { opacity: .4; text-decoration: line-through; }
.legende i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legende i.tirets { background-image: linear-gradient(90deg, currentColor 60%, transparent 0) !important; background-size: 5px 3px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--text-primary); color: var(--surface-1); padding: 10px 16px; border-radius: 8px;
  font-size: .9rem; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.visible { opacity: 1; }
.toast.erreur { background: var(--critical); color: #fff; }

.connexion { max-width: 360px; margin: 10vh auto; }
.connexion form { display: flex; flex-direction: column; gap: 10px; }
.connexion input {
  font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-0); color: var(--text-primary);
}
.connexion .btn { min-height: 44px; }
.vide { color: var(--text-muted); font-size: .9rem; }
.carte h3 { font-size: .85rem; font-weight: 600; color: var(--text-secondary); margin: 18px 0 6px; }
