:root {
  color-scheme: light;
  --fond: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --bord: #e3e2de;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --texte-3: #7a7974;
  --grille: #e8e7e3;
  --accent: #2a78d6;
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --bon: #0ca30c;
  --vigilance: #fab219;
  --serieux: #ec835a;
  --critique: #d03b3b;
  --bon-fond: #e6f5e6;
  --vigilance-fond: #fdf3dc;
  --critique-fond: #fbe7e7;
  --ombre: 0 1px 2px rgb(0 0 0 / 5%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #121211;
    --surface: #1a1a19;
    --surface-2: #232322;
    --bord: #2e2e2c;
    --texte: #f0efec;
    --texte-2: #c3c2b7;
    --texte-3: #8f8e86;
    --grille: #2a2a28;
    --accent: #3987e5;
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --bon-fond: #142614;
    --vigilance-fond: #2b2410;
    --critique-fond: #2e1616;
    --ombre: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #121211; --surface: #1a1a19; --surface-2: #232322; --bord: #2e2e2c;
  --texte: #f0efec; --texte-2: #c3c2b7; --texte-3: #8f8e86; --grille: #2a2a28;
  --accent: #3987e5; --serie-1: #3987e5; --serie-2: #d95926;
  --bon-fond: #142614; --vigilance-fond: #2b2410; --critique-fond: #2e1616; --ombre: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--texte-2); }
.espace-haut { margin-top: 18px; }
button { font: inherit; cursor: pointer; }
.lien { background: none; border: 0; color: var(--texte-2); padding: 4px 6px; border-radius: 6px; }
.lien:hover { color: var(--texte); background: var(--surface-2); }
.muet { color: var(--texte-3); }
.note { color: var(--texte-3); font-size: 12px; margin: 8px 2px 0; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 16px; box-shadow: var(--ombre); min-width: 0; }

/* ---------- connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion-carte { width: 100%; max-width: 360px; display: grid; gap: 14px; padding: 24px; }
.connexion-carte label { display: grid; gap: 6px; font-size: 13px; color: var(--texte-2); }
.connexion-carte input { font: inherit; font-size: 15px; padding: 9px 11px; border: 1px solid var(--bord); border-radius: 8px; background: var(--fond); color: var(--texte); }
.connexion-carte input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.connexion-carte button { padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
.erreur { color: var(--critique); margin: 0; font-size: 13px; }

/* ---------- entête */
.marque { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: url(favicon.svg) center / cover; }
.entete {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 24px; background: color-mix(in srgb, var(--fond) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bord);
}
.modules { display: flex; gap: 2px; flex-wrap: wrap; }
.modules a, .modules span { padding: 5px 10px; border-radius: 7px; color: var(--texte-2); text-decoration: none; font-size: 13px; }
.modules .actif { background: var(--surface); color: var(--texte); font-weight: 600; box-shadow: inset 0 0 0 1px var(--bord); }
.modules .bientot { color: var(--texte-3); cursor: default; }
.entete-droite { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }

.contenu { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.contenu > section { min-width: 0; }
.titre-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.titre-ligne h2 { margin: 0; }
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grille-2 { grid-template-columns: minmax(0, 1fr); } }

.segment { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.segment button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; color: var(--texte-2); font-size: 12px; }
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--texte); font-weight: 600; box-shadow: var(--ombre), inset 0 0 0 1px var(--bord); }

/* ---------- synthèse */
.synthese { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .synthese { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .synthese { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tuile { padding: 14px 16px; }
.tuile .libelle { font-size: 12px; color: var(--texte-2); }
.tuile .valeur { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; }
.tuile .sous { font-size: 12px; color: var(--texte-3); margin-top: 2px; }

/* ---------- statuts (toujours icône + libellé) */
.statut { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.statut::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.statut.bon { color: var(--texte-2); } .statut.bon::before { background: var(--bon); }
.statut.attention { color: var(--texte); } .statut.attention::before { background: var(--vigilance); border-radius: 1px; transform: rotate(45deg) scale(0.9); }
.statut.critique { color: var(--critique); } .statut.critique::before { background: var(--critique); border-radius: 1px; }
.statut.neutre { color: var(--texte-3); } .statut.neutre::before { background: var(--texte-3); }

/* ---------- incidents */
.incidents { display: grid; gap: 8px; }
.incident { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--bord); background: var(--surface); }
.incident.critique { background: var(--critique-fond); border-color: color-mix(in srgb, var(--critique) 35%, var(--bord)); }
.incident.attention { background: var(--vigilance-fond); border-color: color-mix(in srgb, var(--vigilance) 40%, var(--bord)); }
.incident .titre { font-weight: 600; }
.incident .detail { grid-column: 2 / 4; color: var(--texte-2); font-size: 13px; }
.incident .quand { color: var(--texte-3); font-size: 12px; white-space: nowrap; }
.vide { padding: 14px; border-radius: 10px; border: 1px dashed var(--bord); color: var(--texte-2); display: flex; gap: 8px; align-items: center; }

/* ---------- serveurs */
.serveur-entete { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.serveur-entete .nom { font-size: 16px; font-weight: 650; }
.serveur-entete .os { color: var(--texte-2); font-size: 12px; }
.jauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.jauge .haut { display: flex; justify-content: space-between; font-size: 12px; color: var(--texte-2); }
.jauge .haut b { color: var(--texte); font-size: 15px; font-weight: 650; }
.jauge .piste { height: 6px; background: var(--surface-2); border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
.jauge .barre { height: 100%; border-radius: 3px; background: var(--accent); width: 0; }
.jauge .barre.attention { background: var(--vigilance); }
.jauge .barre.critique { background: var(--critique); }
.jauge .bas { font-size: 11px; color: var(--texte-3); }
.puces { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 4px; font-size: 12px; color: var(--texte-2); }
.graphe { position: relative; margin-top: 8px; }
.graphe svg { display: block; width: 100%; height: auto; overflow: visible; }
.graphe .axe { fill: var(--texte-3); font-size: 10px; }
.graphe .ligne-grille { stroke: var(--grille); stroke-width: 1; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--texte-2); margin-top: 4px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.legende i.s1 { background: var(--serie-1); } .legende i.s2 { background: var(--serie-2); }
.process { display: grid; gap: 2px; margin-top: 12px; }
.process-ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; font-size: 12px; padding: 5px 0; border-top: 1px solid var(--bord); }
.process-ligne .n { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.process-ligne .m { color: var(--texte-3); text-align: right; }

/* ---------- tableaux */
.table-defile { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--texte-2); padding: 10px 12px; border-bottom: 1px solid var(--bord); white-space: nowrap; background: var(--surface); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--bord); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .groupe td { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--texte-2); padding: 6px 12px; }
.table .hote { font-weight: 550; }
.table .sous { color: var(--texte-3); font-size: 11px; }
.etincelle { display: block; }
.etincelle rect { fill: var(--serie-1); }
.etincelle rect.zero { fill: var(--grille); }

.liste { display: grid; gap: 0; }
.liste-ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 7px 0; border-top: 1px solid var(--bord); font-size: 13px; align-items: center; }
.liste-ligne:first-child { border-top: 0; }
.liste-ligne .d { color: var(--texte-3); font-size: 12px; }
.liste-ligne .t { overflow: hidden; text-overflow: ellipsis; }
.cles { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.cles dt { color: var(--texte-2); }
.cles dd { margin: 0; text-align: right; }

.infobulle {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--texte);
  border: 1px solid var(--bord); border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: 0 4px 14px rgb(0 0 0 / 14%);
  min-width: 120px;
}
.infobulle .q { color: var(--texte-2); margin-bottom: 4px; }
.infobulle .r { display: flex; justify-content: space-between; gap: 12px; }
.infobulle .r i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

@media (max-width: 640px) {
  .entete { padding: 10px 16px; gap: 10px; }
  .modules { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .contenu { padding: 16px 16px 40px; }
  .jauges { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}
