:root {
  --fond: #f3f5f8; --surface: #ffffff; --texte: #18202b; --discret: #5f6b7a; --bord: #dde2e9;
  --entete: #13233a; --entete-texte: #e8eef7; --accent: #1f5fbf; --accent-clair: #e6eefb;
  --ok: #15803d; --ok-fond: #e5f5ea; --ko: #c62828; --ko-fond: #fdecec; --attente: #b45309; --attente-fond: #fdf3e2;
  --voyant: #22c55e; --rayon: 10px; --ombre: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1620; --surface: #17212d; --texte: #e6ebf2; --discret: #95a3b5; --bord: #2a3747;
    --entete: #0a111a; --entete-texte: #e6ebf2; --accent: #6ea4ff; --accent-clair: #1c2c45;
    --ok: #4ade80; --ok-fond: #12301e; --ko: #f87171; --ko-fond: #3a1717; --attente: #fbbf24; --attente-fond: #3a2a0d;
    --ombre: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .3rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.discret { color: var(--discret); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* en-tête et cadre */
.entete { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px;
  background: var(--entete); color: var(--entete-texte); }
.marque { color: inherit; text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.entete-etat { margin-left: auto; display: flex; gap: 8px; }
.pastille { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: .85rem;
  color: var(--entete-texte); background: rgba(255, 255, 255, .1); text-decoration: none; white-space: nowrap; }
.pastille::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.pastille[data-etat=ok]::before { background: #22c55e; }
.pastille[data-etat=ko] { background: #b91c1c; }
.pastille[data-etat=ko]::before { background: #fff; }
.pastille[data-etat=attente]::before { background: #f59e0b; }
.pastille-alarme::before { display: none; }
.pastille-alarme.active { background: #b91c1c; }
.menu-bouton { display: none; background: none; border: 0; color: inherit; font-size: 1.4rem; cursor: pointer; padding: 4px 6px; }
.cadre { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 56px); }
.menu { background: var(--surface); border-right: 1px solid var(--bord); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.menu a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--texte); text-decoration: none; }
.menu a:hover { background: var(--fond); }
.menu a[aria-current] { background: var(--accent-clair); color: var(--accent); font-weight: 600; }
.menu-titre { margin: 14px 10px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--discret); }
.menu-pied { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--bord); }
.menu-pied form { padding: 0 10px; }
.contenu { padding: 24px; min-width: 0; max-width: 1400px; }

/* éléments communs */
.titre-ligne { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.panneau { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 18px; margin-bottom: 18px; box-shadow: var(--ombre); }
.bandeau { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.bandeau-alerte { background: var(--ko-fond); color: var(--ko); }
.bandeau-ok { background: var(--ok-fond); color: var(--ok); }
.bouton { display: inline-block; padding: 9px 16px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.bouton:hover { filter: brightness(1.08); }
.bouton-clair { background: var(--accent-clair); color: var(--accent); }
.bouton-petit { padding: 5px 10px; font-size: .85rem; }
.lien { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.lien.danger { color: var(--ko); }
input, select { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--bord); border-radius: 7px; padding: 8px 10px; max-width: 100%; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
label.case { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.formulaire input:not([type=checkbox]), .formulaire select { width: 100%; }
.formulaire .bouton { margin-top: 14px; }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 18px; }
.vide { color: var(--discret); margin: 0; }
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--discret); font-weight: 600; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.serre { white-space: nowrap; }
tr.inactif { opacity: .5; }
tr.ligne-active td:first-child { box-shadow: inset 3px 0 var(--ko); }
tr.ligne-haute td { background: var(--ko-fond); }
.statut { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .82rem; background: var(--fond); }
.statut-ok { background: var(--ok-fond); color: var(--ok); }
.statut-ko { background: var(--ko-fond); color: var(--ko); }
.en-ligne { display: inline-flex; gap: 6px; align-items: center; }
.actions { white-space: nowrap; }
.actions details { display: inline-block; margin-right: 10px; }
.actions summary { cursor: pointer; color: var(--accent); }

/* tuiles */
.bloc { margin-bottom: 26px; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tuile { position: relative; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); transition: border-color .2s; }
.tuile-lien { display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 12px; color: inherit; text-decoration: none; min-height: 118px; }
.tuile-lien:hover { background: var(--fond); border-radius: var(--rayon); }
.tuile-nom { font-weight: 600; font-size: .92rem; }
.tuile-tag { font-family: ui-monospace, Consolas, monospace; font-size: .75rem; color: var(--discret); }
.tuile-valeur { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 6px; letter-spacing: -.01em; }
.tuile-seuils, .tuile-etat { font-size: .78rem; color: var(--discret); }
.tuile-etat:empty { display: none; }
.jauge { display: block; height: 6px; background: var(--fond); border-radius: 99px; overflow: hidden; margin: 6px 0 2px; }
.jauge span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.voyant { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 1.15rem; font-weight: 700; color: var(--discret); }
.voyant::before { content: ""; width: 18px; height: 18px; border-radius: 50%; background: var(--bord); box-shadow: inset 0 0 0 2px rgba(0,0,0,.06); }
.voyant.allume { color: var(--ok); }
.voyant.allume::before { background: var(--voyant); box-shadow: 0 0 10px var(--voyant); }
.tuile.en-alarme { border-color: var(--ko); box-shadow: 0 0 0 1px var(--ko); }
.tuile.en-alarme .tuile-valeur, .tuile.en-alarme .tuile-etat { color: var(--ko); }
.tuile.qualite-liaison .tuile-valeur, .tuile.qualite-liaison .voyant, .tuile.qualite-inconnue .tuile-valeur { color: var(--discret); opacity: .55; }
.tuile.qualite-liaison { border-style: dashed; }
.tuile.qualite-liaison .tuile-etat { color: var(--attente); }
.commande { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 0 14px 12px; }
.commande input { width: 80px; padding: 5px 8px; }
.commande-retour { font-size: .8rem; color: var(--discret); width: 100%; }
.maj { margin: 0; font-size: .85rem; }

/* tendances */
.filtres fieldset { border: 0; padding: 0; margin: 0; }
.filtres legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.liste-points { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 12px; max-height: 210px; overflow-y: auto; border: 1px solid var(--bord); border-radius: 8px; padding: 6px 10px; }
.liste-points label { font-weight: 400; margin: 3px 0; display: flex; gap: 6px; align-items: baseline; }
.filtres-ligne { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 8px; }
.filtres-ligne label { margin-top: 0; }
.dates { display: flex; gap: 12px; flex-wrap: wrap; }
.graphique { position: relative; min-height: 120px; }
.graphique[data-etat=vide]::before { content: attr(data-vide); color: var(--discret); }
.graphique[data-etat=chargement]::before { content: "Chargement…"; color: var(--discret); }
.graphique[data-etat=erreur]::before { content: attr(data-message); color: var(--ko); }
.courbe { display: block; width: 100%; height: auto; margin-bottom: 10px; }
.courbe .grille { stroke: var(--bord); stroke-width: 1; }
.courbe .axe { fill: var(--discret); font-size: 11px; }
.courbe .unite { font-weight: 700; }
.courbe .trace { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.courbe .seuil { stroke-dasharray: 5 4; stroke-width: 1; opacity: .7; }
.courbe .curseur { stroke: var(--discret); stroke-width: 1; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; }
.legende i, .bulle i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.bulle { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--bord); border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: 0 4px 16px rgba(0,0,0,.15); white-space: nowrap; }

/* connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.carte-connexion { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 28px; box-shadow: var(--ombre); }
.carte-connexion input { width: 100%; }
.carte-connexion .bouton { width: 100%; margin-top: 18px; }

@media (max-width: 860px) {
  .menu-bouton { display: block; }
  .cadre { grid-template-columns: 1fr; }
  .menu { display: none; border-right: 0; border-bottom: 1px solid var(--bord); }
  body.menu-ouvert .menu { display: flex; }
  .contenu { padding: 16px; }
  .pastille { font-size: .78rem; padding: 3px 8px; }
  .tuiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .tuile-valeur { font-size: 1.5rem; }
}
