/* Tableau de bord de l'équipe. Couleurs des séries : palette de référence validée (8 teintes dans un ordre fixe, pas
   d'éclairage automatique en sombre : chaque teinte a son pas sombre). Les états (bon, à surveiller, problème) ont leurs
   propres couleurs, toujours accompagnées d'un mot. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --encre: #0b0b0b;
  --encre-2: #52514e;
  --encre-3: #6b6a65;
  --grille: #e1e0d9;
  --base: #c3c2b7;
  --bord: rgba(11, 11, 11, 0.10);
  --serie-1: #2a78d6; --serie-2: #eb6834; --serie-3: #1baf7a; --serie-4: #eda100;
  --serie-5: #e87ba4; --serie-6: #008300; --serie-7: #6250d6; --serie-autres: #898781;
  --bon: #0ca30c; --attention: #fab219; --serieux: #ec835a; --critique: #d03b3b;
  --accent: #2a78d6;
  --note: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --encre: #f0efec; --encre-2: #c3c2b7; --encre-3: #a3a29b;
    --grille: #2c2c2a; --base: #383835; --bord: rgba(255, 255, 255, 0.10);
    --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
    --serie-5: #d55181; --serie-6: #008300; --serie-7: #9085e9; --serie-autres: #898781;
    --accent: #3987e5; --note: #262624;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --encre: #f0efec; --encre-2: #c3c2b7; --encre-3: #a3a29b;
  --grille: #2c2c2a; --base: #383835; --bord: rgba(255, 255, 255, 0.10);
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
  --serie-5: #d55181; --serie-6: #008300; --serie-7: #9085e9; --serie-autres: #898781;
  --accent: #3987e5; --note: #262624;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 140px; }
body {
  margin: 0; background: var(--page); color: var(--encre);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--note); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--encre-2); font-weight: 600; }
h4 { font-size: 14px; margin: 0 0 6px; }
.discret { color: var(--encre-3); font-weight: 400; }
.chiffres { font-variant-numeric: tabular-nums; }
button, select, input { font: inherit; color: inherit; }
button, select {
  background: var(--surface); border: 1px solid var(--base); border-radius: 8px; padding: 6px 12px; min-height: 36px; cursor: pointer;
}
button:hover, select:hover { border-color: var(--encre-3); }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* En-tête */
.entete {
  position: sticky; top: 0; z-index: 5; background: var(--page); border-bottom: 1px solid var(--bord);
  padding: 10px 16px 0;
}
.entete-ligne { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; max-width: 1200px; margin: 0 auto; }
.commandes { justify-content: flex-start; margin-top: 8px; }
.entete-etat { color: var(--encre-2); font-size: 13px; }
.entete-etat.etat-bon::before, .entete-etat.etat-critique::before, .entete-etat.etat-attention::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px;
}
.entete-etat.etat-bon::before { background: var(--bon); }
.entete-etat.etat-attention::before { background: var(--attention); }
.entete-etat.etat-critique::before { background: var(--critique); }
.badge { border: 1px solid var(--base); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--encre-2); }
.badge.source-local { border-color: var(--serie-4); }
.periode { display: inline-flex; align-items: center; gap: 6px; color: var(--encre-2); }
.sommaire { display: flex; gap: 4px; overflow-x: auto; max-width: 1200px; margin: 6px auto 0; padding-bottom: 6px; scrollbar-width: none; }
.sommaire a { color: var(--encre-2); text-decoration: none; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.sommaire a:hover { background: var(--note); color: var(--encre); }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.accueil { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 16px; max-width: 680px; }

/* Sections */
.section, .projection-hote {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 16px; margin-bottom: 16px; min-width: 0;
}
.projection-hote { margin-top: -8px; }
.sous-titre { color: var(--encre-3); margin: 0 0 12px; }
.bloc { margin-top: 16px; min-width: 0; }
.duo { display: grid; grid-template-columns: 1fr; gap: 0 32px; }
@media (min-width: 900px) { .duo { grid-template-columns: 1fr 1fr; } }
.note { background: var(--note); border-radius: 8px; padding: 8px 12px; color: var(--encre-2); margin: 8px 0; }
.note-erreur { border-left: 4px solid var(--critique); }
.note:empty { display: none; }
.vide { color: var(--encre-3); margin: 8px 0; }
.vide.grand { font-size: 18px; color: var(--encre-2); margin: 8px 0 4px; }

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.tuile { display: flex; flex-direction: column; border: 1px solid var(--bord); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.tuile-valeur { font-size: 24px; font-weight: 650; }
.tuile-libelle { color: var(--encre-2); }
.tuile-detail { color: var(--encre-3); font-size: 12px; }

.cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.carte { border: 1px solid var(--bord); border-radius: 10px; padding: 12px; min-width: 0; }
.carte-titre { color: var(--encre-2); font-weight: 600; }
.carte-etat { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--encre-2); margin: 2px 0 6px; }
.carte-valeur { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.carte-detail { color: var(--encre-3); font-size: 12px; overflow-wrap: anywhere; }
.pastille { width: 10px; height: 10px; border-radius: 50%; background: var(--base); flex: none; display: inline-block; }
.etat-bon .pastille { background: var(--bon); }
.etat-attention .pastille { background: var(--attention); }
.etat-critique .pastille { background: var(--critique); }

/* Tableaux */
.defile { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grille); vertical-align: top; }
th { color: var(--encre-3); font-weight: 600; font-size: 12px; }
td:first-child { overflow-wrap: anywhere; }
.nombre { text-align: right; white-space: nowrap; }

/* Graphiques */
.graphique { display: block; max-width: 100%; height: auto; overflow: visible; }
.graphique text { font-size: 11px; fill: var(--encre-3); }
.graphique .encre-secondaire { fill: var(--encre-2); }
.graphique .grille { stroke: var(--grille); stroke-width: 1; }
.graphique .base { stroke: var(--base); stroke-width: 1; }
.graphique .limite { stroke: var(--critique); stroke-width: 1.5; stroke-dasharray: 4 3; }
.graphique .trait { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .point { stroke: var(--surface); stroke-width: 2; }
.graphique .survol { fill: transparent; }
.graphique .survol:hover { fill: var(--grille); fill-opacity: 0.5; }
.graphique path:hover, .graphique rect:not(.survol):hover { opacity: 0.8; }
.serie-1 { fill: var(--serie-1); } .trait.serie-1 { stroke: var(--serie-1); fill: none; }
.serie-2 { fill: var(--serie-2); } .serie-3 { fill: var(--serie-3); } .serie-4 { fill: var(--serie-4); }
.serie-5 { fill: var(--serie-5); } .serie-6 { fill: var(--serie-6); } .serie-7 { fill: var(--serie-7); }
.serie-autres { fill: var(--serie-autres); }
.legende { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; margin: 8px 0 0; color: var(--encre-2); }
.legende li { display: inline-flex; align-items: center; gap: 6px; }
.carre { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.carre.serie-1 { background: var(--serie-1); } .carre.serie-2 { background: var(--serie-2); } .carre.serie-3 { background: var(--serie-3); }
.carre.serie-4 { background: var(--serie-4); } .carre.serie-5 { background: var(--serie-5); } .carre.serie-6 { background: var(--serie-6); }
.carre.serie-7 { background: var(--serie-7); } .carre.serie-autres { background: var(--serie-autres); }

/* Jauges */
.jauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 32px; margin-top: 8px; }
.jauge { min-width: 0; }
.jauge-tete { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.jauge-titre { color: var(--encre-2); }
.jauge-valeur { font-weight: 600; }
.jauge-barre { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.jauge-fond { fill: var(--grille); }
.jauge-plein { fill: var(--serie-1); }
.etat-attention .jauge-plein { fill: var(--attention); }
.etat-critique .jauge-plein { fill: var(--critique); }
.jauge-etat { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--encre-3); }

.alertes { margin: 8px 0; padding-left: 20px; }
.alertes li { margin: 4px 0; overflow-wrap: anywhere; }

/* Projection et réglages */
.champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.champ span { color: var(--encre-2); }
.champ small { color: var(--encre-3); }
input[type="number"], input[type="url"], input[type="password"] {
  background: var(--surface); border: 1px solid var(--base); border-radius: 8px; padding: 6px 10px; min-height: 36px; width: 100%;
}
.champ-principal { max-width: 260px; }
.champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; margin: 12px 0; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--encre-2); }
.offre { border: 1px solid var(--bord); border-radius: 10px; padding: 12px; margin-top: 12px; }
.offre ul { margin: 0; padding-left: 18px; color: var(--encre-2); }
dialog { border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); color: var(--encre); padding: 20px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
.boutons { display: flex; flex-wrap: wrap; gap: 8px; }
#enregistrer { background: var(--accent); color: #ffffff; border-color: var(--accent); }

@media (max-width: 600px) {
  /* Sur un téléphone, l'en-tête collant mangerait un quart de l'écran. */
  .entete { position: static; }
  html { scroll-padding-top: 8px; }
  .tuile-valeur { font-size: 20px; }
  .section, .projection-hote { padding: 12px; }
  main { padding: 12px 16px; }
}
@media (forced-colors: active) {
  .pastille, .carre { forced-color-adjust: none; border: 1px solid CanvasText; }
}
