:root {
  --fond: #0f141c; --carte: #171f2b; --carte2: #1e2836; --ligne: #2a3647;
  --texte: #e6ebf2; --discret: #8b98aa;
  --vert: #3fb6a8; --orange: #e8a33d; --rouge: #e25c5c; --gris: #6b778a; --bleu: #5b9cf0;
  --rayon: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --fond: #f2f4f7; --carte: #ffffff; --carte2: #f6f8fa; --ligne: #dde3ea; --texte: #18202b; --discret: #5f6b7b;
    --vert: #19897c; --orange: #b97510; --rouge: #c73d3d; --gris: #7b8696; --bleu: #2f6fc4; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--ligne); background: var(--carte2); border-radius: 99px; padding: 8px 16px; }
button:hover { border-color: var(--discret); }
button:disabled { opacity: .5; cursor: default; }
button.principal { background: var(--vert); border-color: var(--vert); color: #06201c; font-weight: 600; }
button.icone { border-radius: 50%; width: 36px; height: 36px; padding: 0; font-size: 18px; }
input { font: inherit; color: inherit; background: var(--carte2); border: 1px solid var(--ligne); border-radius: 10px; padding: 10px 12px; width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 17px; margin: 22px 4px 10px; }
.discret { color: var(--discret); font-size: 13px; }
.erreur { color: var(--rouge); min-height: 1em; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

.ecran-connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.connexion { width: min(360px, 100%); display: grid; gap: 12px; text-align: center; padding: 28px; }
.connexion img { justify-self: center; }
.connexion label { display: grid; gap: 4px; text-align: left; font-size: 13px; color: var(--discret); }

.entete { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: color-mix(in srgb, var(--fond) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--ligne); }
.titre { display: flex; gap: 10px; align-items: center; font-weight: 650; font-size: 17px; }
.entete-droite { display: flex; gap: 10px; align-items: center; }
.onglets { display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--ligne); }
.onglets a { display: flex; gap: 6px; align-items: center; padding: 7px 14px; border-radius: 99px; color: var(--discret); text-decoration: none; white-space: nowrap; }
.onglets a span { font-size: 15px; }
.onglets a.actif { background: var(--carte2); color: var(--texte); font-weight: 600; }
main { max-width: 980px; margin: 0 auto; padding: 8px 14px 90px; }

@media (max-width: 640px) {
  .onglets { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; justify-content: space-around; background: var(--carte); border-top: 1px solid var(--ligne); border-bottom: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .onglets a { flex-direction: column; gap: 0; font-size: 11px; padding: 4px 6px; border-radius: 10px; }
  .onglets a span { font-size: 20px; }
  #maj { display: none; }
}

.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 16px; }
.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.bandeau { display: flex; gap: 14px; align-items: center; padding: 16px 18px; margin-top: 12px; }
.bandeau .gros { font-size: 30px; }
.bandeau h1 { font-size: 19px; }
.bandeau.ok { border-color: color-mix(in srgb, var(--vert) 45%, var(--ligne)); }
.bandeau.alerte { border-color: var(--orange); }
.bandeau.panne { border-color: var(--rouge); }

.machine { display: grid; gap: 6px; }
.machine .haut { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.machine h3 { font-size: 15px; }
.pastille { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--carte2); white-space: nowrap; }
.pastille::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.vert { color: var(--vert); } .orange { color: var(--orange); } .rouge { color: var(--rouge); } .gris { color: var(--gris); } .bleu { color: var(--bleu); }

.jauge { height: 8px; border-radius: 99px; background: var(--carte2); overflow: hidden; margin-top: 6px; }
.jauge > div { height: 100%; border-radius: 99px; background: var(--vert); }
.jauge.orange > div { background: var(--orange); } .jauge.rouge > div { background: var(--rouge); }

.liste { display: grid; gap: 0; padding: 4px 0; }
.ligne { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--ligne); }
.ligne:first-child { border-top: 0; }
.ligne .nom { flex: 1; min-width: 0; }
.ligne .nom div:first-child { font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.groupe { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--discret); padding: 12px 16px 4px; border-top: 1px solid var(--ligne); }
.groupe:first-child { border-top: 0; }
.filtres { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.filtres button.actif { background: var(--texte); color: var(--fond); border-color: var(--texte); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.etapes { margin: 8px 0 0; padding-left: 20px; }
.etapes li { margin: 4px 0; }
pre.sortie { background: var(--carte2); border-radius: 10px; padding: 12px; overflow: auto; max-height: 320px; white-space: pre-wrap; margin: 10px 0 0; }
details summary { cursor: pointer; color: var(--discret); margin-top: 10px; }
.journal .ligne { align-items: flex-start; }
.journal .heure { width: 92px; flex: none; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--texte); color: var(--fond); padding: 10px 18px; border-radius: 99px; font-weight: 550; z-index: 20; max-width: 90vw; }
.vide { text-align: center; padding: 30px 10px; color: var(--discret); }

/* V2 : fenêtres, boutons de ligne, formulaires */
.fenetre { border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--carte); color: var(--texte); padding: 20px; width: min(640px, 94vw); max-height: 86vh; }
.fenetre::backdrop { background: rgb(0 0 0 / .55); }
.fenetre h3 { margin-bottom: 10px; }
.fenetre label { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--discret); }
.fenetre .actions { justify-content: flex-end; }
.fenetre pre.sortie { max-height: 58vh; }
button.danger { background: var(--rouge); border-color: var(--rouge); color: #fff; font-weight: 600; }
button.attention { background: var(--orange); border-color: var(--orange); color: #1c1405; font-weight: 600; }
button.petit { padding: 5px 12px; font-size: 13px; }
.ligne .boutons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ligne .nom { cursor: pointer; }
.formulaire { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 12px; }
.formulaire label { display: grid; gap: 4px; font-size: 13px; color: var(--discret); }
.bilan { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--carte2); }
.sous-titre { font-weight: 600; margin-top: 14px; }
@media (max-width: 640px) { .ligne { flex-wrap: wrap; } .ligne .boutons { width: 100%; justify-content: flex-start; } }

/* V3 : frises, tableaux, disques */
@media (max-width: 640px) { .onglets a.large { display: none; } .onglets a { padding: 4px 3px; font-size: 10.5px; } }
.frise { display: flex; gap: 2px; margin-top: 6px; height: 10px; }
.frise i { flex: 1; border-radius: 2px; background: var(--vert); opacity: .85; }
.frise i.o { background: var(--orange); } .frise i.r { background: var(--rouge); } .frise i.v { background: var(--ligne); }
.orange { color: var(--orange); } .rouge { color: var(--rouge); }
.chiffres { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin-top: 10px; }
.chiffres div { background: var(--carte2); border-radius: 10px; padding: 8px 10px; }
.chiffres b { display: block; font-size: 17px; }
.badge { font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--bleu) 22%, transparent); color: var(--bleu); margin-left: 6px; white-space: nowrap; }
.rapport li { margin: 4px 0; }
.etiquette { font-size: 12px; color: var(--discret); }
textarea { font: inherit; color: inherit; background: var(--carte2); border: 1px solid var(--ligne); border-radius: 10px; padding: 10px 12px; width: 100%; }
