/* Hypervision Osiris360 — jetons de couleur, clair et sombre. */
:root {
  color-scheme: light;
  --plan: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --muet: #898781;
  --grille: #e1e0d9;
  --axe: #c3c2b7;
  --bord: rgba(11, 11, 11, 0.10);
  --marque: #b8941f;
  --lien: #1c5cab;
  --serie-1: #2a78d6; --serie-2: #eb6834; --serie-3: #1baf7a; --serie-4: #eda100;
  --serie-5: #e87ba4; --serie-6: #008300; --serie-7: #6250d6; --serie-8: #e34948;
  --ok: #0ca30c; --attention: #fab219; --serieux: #ec835a; --critique: #d03b3b;
  --ok-texte: #006300; --critique-texte: #b02a2a; --attention-texte: #8a5a00;
  --ombre: 0 1px 2px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plan: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --texte: #f0efec; --texte-2: #c3c2b7; --muet: #898781;
    --grille: #2c2c2a; --axe: #383835; --bord: rgba(255, 255, 255, 0.10);
    --marque: #d4af37; --lien: #86b6ef;
    --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
    --serie-5: #d55181; --serie-6: #008300; --serie-7: #9085e9; --serie-8: #e66767;
    --ok-texte: #0ca30c; --critique-texte: #e66767; --attention-texte: #fab219;
    --ombre: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plan: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --texte: #f0efec; --texte-2: #c3c2b7; --muet: #898781;
  --grille: #2c2c2a; --axe: #383835; --bord: rgba(255, 255, 255, 0.10);
  --marque: #d4af37; --lien: #86b6ef;
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
  --serie-5: #d55181; --serie-6: #008300; --serie-7: #9085e9; --serie-8: #e66767;
  --ok-texte: #0ca30c; --critique-texte: #e66767; --attention-texte: #fab219;
  --ombre: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--plan); color: var(--texte);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--lien); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--texte-2); text-transform: uppercase; letter-spacing: .04em; }
.muet { color: var(--muet); }
.secondaire { color: var(--texte-2); }
.petit { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* En-tête */
.entete {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--bord);
}
.marque { font-weight: 700; letter-spacing: .02em; color: var(--texte); white-space: nowrap; }
.marque span { color: var(--marque); }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--texte-2); white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.actif { color: var(--texte); background: var(--surface-2); font-weight: 600; }
.pastille-nav { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--critique); color: #fff; font-size: 11px; text-align: center; font-weight: 600; }
.outils { display: flex; gap: 8px; align-items: center; }
.bouton {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
}
.bouton:hover { background: var(--surface-2); }
.bouton.principal { background: var(--texte); color: var(--surface); border-color: var(--texte); }
.bouton.discret { border-color: transparent; background: transparent; color: var(--texte-2); }

main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.titre-page { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }

/* Cartes et grilles */
.grille { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 10px;
  padding: 16px 18px; box-shadow: var(--ombre); min-width: 0;
}
.carte + .carte, .grille + .carte, .carte + .grille, .grille + .grille { margin-top: 16px; }
.grille > .carte, .grille > .grille { margin-top: 0; }
.carte-client { display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--couleur-client, var(--axe)); }
.carte-client header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.carte-client h2 { margin: 0; font-size: 17px; }
.carte-client h2 a { color: var(--texte); }
.c1 { --couleur-client: var(--serie-1); } .c2 { --couleur-client: var(--serie-2); } .c3 { --couleur-client: var(--serie-3); }
.c4 { --couleur-client: var(--serie-4); } .c5 { --couleur-client: var(--serie-5); } .c6 { --couleur-client: var(--serie-6); }
.puce-client { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--couleur-client); margin-right: 6px; }

/* Tuiles */
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 16px; }
.tuile .valeur { font-size: 22px; font-weight: 600; line-height: 1.2; }
.tuile .libelle { font-size: 12px; color: var(--texte-2); }
.tuile .sous { font-size: 12px; color: var(--muet); }
.carte .tuiles.grandes .valeur { font-size: 28px; }

/* Statuts : couleur + icône + libellé, jamais la couleur seule */
.statut { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 99px; border: 1px solid var(--bord); white-space: nowrap; }
.statut::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.statut.ok { color: var(--ok-texte); }
.statut.attention { color: var(--attention-texte); }
.statut.critique { color: var(--critique-texte); }
.statut.ok::after { content: "Opérationnel"; color: var(--texte); font-weight: 500; }
.statut.attention::after { content: "Attention"; color: var(--texte); font-weight: 500; }
.statut.critique::after { content: "Critique"; color: var(--texte); font-weight: 500; }
.icone-niveau { font-weight: 700; }

/* Alertes */
.alerte { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--grille); }
.alerte:first-child { border-top: 0; }
.alerte .titre { font-weight: 600; }
.alerte .detail { grid-column: 2 / 4; color: var(--texte-2); font-size: 13px; }
.bandeau-alertes { border-left: 3px solid var(--critique); }

/* Tableaux */
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--texte-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--axe); white-space: nowrap; }
td { padding: 6px 8px; border-bottom: 1px solid var(--grille); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
table.triable th { cursor: pointer; user-select: none; }
table.triable th:hover { color: var(--texte); }
td.code, .code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }
tr.ferme td { color: var(--muet); }
.barre-fond { position: relative; height: 6px; border-radius: 3px; background: var(--grille); min-width: 60px; }
.barre-fond span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--serie-1); }

/* Onglets et filtres */
.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--bord); margin-bottom: 20px; overflow-x: auto; }
.onglets a { padding: 8px 14px; color: var(--texte-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.onglets a.actif { color: var(--texte); border-bottom-color: var(--texte); font-weight: 600; }
.onglets a:hover { text-decoration: none; color: var(--texte); }
.filtres { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filtres a, .filtres select { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--bord); color: var(--texte-2); background: var(--surface); }
.filtres a.actif { background: var(--texte); color: var(--surface); border-color: var(--texte); }
.filtres a:hover { text-decoration: none; }

/* Graphiques */
.graphique { width: 100%; height: 260px; }
.graphique.haut { height: 340px; }
.entete-graphique { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.vue-tableau { margin-top: 8px; max-height: 280px; overflow: auto; }
.vide { color: var(--muet); padding: 24px 0; text-align: center; }

/* Formulaires de connexion */
.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.boite { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 28px; }
.boite h1 { margin-bottom: 4px; }
.boite p { color: var(--texte-2); margin: 0 0 18px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; font: inherit; font-size: 15px; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--axe); background: var(--surface); color: var(--texte);
}
input:focus-visible, .bouton:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--lien); outline-offset: 2px; }
.boite .bouton { width: 100%; margin-top: 18px; padding: 10px; font-size: 15px; }
.erreurs, .errorlist { color: var(--critique-texte); font-size: 13px; padding-left: 18px; margin: 8px 0 0; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--bord); }
.qr { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 8px; margin: 12px 0; }
.qr svg { width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 16px; }
.codes span { padding: 6px; background: var(--surface-2); border-radius: 6px; text-align: center; }

/* Aide à la lecture */
details.aide { margin-top: 8px; font-size: 12px; color: var(--texte-2); }
details.aide summary { cursor: pointer; color: var(--muet); }
details.aide p { margin: 6px 0 0; line-height: 1.55; }

/* Score de santé */
.score { display: flex; align-items: baseline; gap: 6px; }
.score .valeur { font-size: 34px; font-weight: 650; line-height: 1; }
.score.ok .valeur { color: var(--ok-texte); }
.score.attention .valeur { color: var(--attention-texte); }
.score.critique .valeur { color: var(--critique-texte); }
.composante { display: grid; grid-template-columns: 90px 1fr 54px; gap: 8px; align-items: center; font-size: 12px; margin-top: 6px; }
.composante .barre-fond { height: 6px; }
.composante .detail { grid-column: 1 / 4; color: var(--muet); margin-top: -4px; }

/* Cohortes : intensité d'une seule teinte, texte toujours lisible */
table.cohortes td.cellule { text-align: center; font-variant-numeric: tabular-nums; border: 2px solid var(--surface); border-radius: 4px; }
table.cohortes td.cellule.fonce { color: #fff; }

@media (max-width: 720px) {
  .entete { padding: 0 16px; gap: 10px; }
  main { padding: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .marque small { display: none; }
}
@media print { .entete, .filtres, .onglets { display: none; } }
