/* Écran mural : grand format, toujours sombre, lisible à plusieurs mètres */
:root {
    --fond: #0b1020;
    --panneau: #141b2f;
    --bord: #24304f;
    --texte: #e8ecf6;
    --discret: #8b97b5;
    --ok: #2fbf71;
    --info: #4a8cff;
    --alerte: #f2b233;
    --majeure: #ff7a33;
    --critique: #ff4d5e;
    --hors-ligne: #a46bff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--fond);
    color: var(--texte);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    font-size: clamp(14px, 1.05vw, 26px);
    overflow: hidden;
}

body { display: flex; flex-direction: column; }

.entete {
    display: flex;
    align-items: center;
    gap: 2em;
    padding: .6em 1.2em;
    border-bottom: 1px solid var(--bord);
}
.marque { display: flex; align-items: center; gap: .6em; font-size: 1.4em; font-weight: 600; }
.logo { height: 1.8em; }
.etat-global {
    flex: 1;
    text-align: center;
    font-size: 1.5em;
    font-weight: 700;
    padding: .25em 1em;
    border-radius: .4em;
    background: var(--panneau);
}
.etat-global.ok { background: color-mix(in srgb, var(--ok) 25%, var(--panneau)); color: var(--ok); }
.etat-global.alerte { background: color-mix(in srgb, var(--alerte) 25%, var(--panneau)); color: var(--alerte); }
.etat-global.critique { background: color-mix(in srgb, var(--critique) 30%, var(--panneau)); color: #fff; animation: pulse 2s infinite; }
@keyframes pulse { 50% { background: color-mix(in srgb, var(--critique) 55%, var(--panneau)); } }
@media (prefers-reduced-motion: reduce) { .etat-global.critique { animation: none; } }

.horloge { text-align: right; }
#heure { font-size: 2.2em; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
#date { color: var(--discret); }

.ecran {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.3fr 1fr 0.8fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tuiles tuiles tuiles" "alertes machines cote";
    gap: 1em;
    padding: 1em 1.2em;
}
.tuiles { grid-area: tuiles; display: grid; grid-template-columns: repeat(6, 1fr); gap: 1em; }
.alertes { grid-area: alertes; }
.machines { grid-area: machines; }
.cote { grid-area: cote; }

.tuile {
    background: var(--panneau);
    border: 1px solid var(--bord);
    border-left: .4em solid var(--bord);
    border-radius: .5em;
    padding: .6em 1em;
}
.tuile .valeur { font-size: 3em; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tuile .libelle { color: var(--discret); }
.tuile.ok { border-left-color: var(--ok); }
.tuile.alerte { border-left-color: var(--alerte); }
.tuile.alerte .valeur { color: var(--alerte); }
.tuile.majeure { border-left-color: var(--majeure); }
.tuile.majeure .valeur { color: var(--majeure); }
.tuile.critique { border-left-color: var(--critique); }
.tuile.critique .valeur { color: var(--critique); }
.tuile.hors_ligne { border-left-color: var(--hors-ligne); }
.tuile.hors_ligne .valeur { color: var(--hors-ligne); }

.panneau {
    background: var(--panneau);
    border: 1px solid var(--bord);
    border-radius: .5em;
    padding: .8em 1em;
    overflow: hidden;
    min-height: 0;
}
.panneau h2 { margin: 0 0 .5em; font-size: 1.1em; color: var(--discret); text-transform: uppercase; letter-spacing: .05em; }
.panneau h2:not(:first-child) { margin-top: 1em; }

.ligne {
    display: flex;
    align-items: baseline;
    gap: .6em;
    padding: .4em 0;
    border-bottom: 1px solid var(--bord);
}
.ligne:last-child { border-bottom: 0; }
.ligne .titre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .quand { color: var(--discret); white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-block;
    min-width: 5.5em;
    text-align: center;
    padding: .1em .5em;
    border-radius: .3em;
    font-size: .85em;
    font-weight: 700;
    background: var(--bord);
}
.badge.critique { background: var(--critique); color: #fff; }
.badge.majeure { background: var(--majeure); color: #111; }
.badge.alerte { background: var(--alerte); color: #111; }
.badge.info { background: var(--info); color: #fff; }
.badge.ok { background: var(--ok); color: #111; }
.badge.en_retard { background: var(--critique); color: #fff; }

.grille-machines { display: grid; grid-template-columns: repeat(auto-fill, minmax(11em, 1fr)); gap: .6em; }
.machine {
    border: 1px solid var(--bord);
    border-top: .3em solid var(--ok);
    border-radius: .4em;
    padding: .4em .6em;
}
.machine.alerte { border-top-color: var(--alerte); }
.machine.critique { border-top-color: var(--critique); background: color-mix(in srgb, var(--critique) 12%, transparent); }
.machine.hors_ligne { border-top-color: var(--hors-ligne); background: color-mix(in srgb, var(--hors-ligne) 12%, transparent); }
.machine.inactif { opacity: .5; }
.machine .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine .details { color: var(--discret); font-size: .85em; font-variant-numeric: tabular-nums; }
.machine .details .mauvais { color: var(--critique); font-weight: 600; }

.vide { color: var(--discret); padding: .5em 0; }
.vide.ok { color: var(--ok); font-size: 1.3em; }
.discret { color: var(--discret); }
.mauvais { color: var(--critique); }

.pied {
    display: flex;
    justify-content: space-between;
    padding: .3em 1.2em;
    color: var(--discret);
    font-size: .8em;
    border-top: 1px solid var(--bord);
}
.pied .perime { color: var(--critique); font-weight: 600; }

.message {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2em;
    text-align: center;
    font-size: 1.6em;
    background: rgba(11, 16, 32, .94);
}
.message[hidden] { display: none; }

/* Check-up sur téléphone ou ordinateur : page qui défile */
.retour { color: var(--info); text-decoration: none; font-weight: 600; white-space: nowrap; }
body.checkup { overflow: auto; height: auto; }
html:has(body.checkup) { overflow: auto; height: auto; }

/* Écran plus petit (test sur un portable, tablette) : défilement permis */
@media (max-width: 1100px) {
    html, body { overflow: auto; height: auto; }
    .ecran { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tuiles" "alertes" "machines" "cote"; }
    .tuiles { grid-template-columns: repeat(3, 1fr); }
    .entete { flex-wrap: wrap; gap: .8em; }
    .etat-global { order: 3; flex-basis: 100%; }
}

/* Téléphone */
@media (max-width: 600px) {
    html, body { font-size: 15px; }
    .entete { padding: .6em 16px; }
    .marque { font-size: 1.1em; }
    #heure { font-size: 1.6em; }
    .etat-global { font-size: 1.15em; }
    .ecran { padding: .8em 16px; gap: .8em; }
    .tuiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6em; }
    .tuile .valeur { font-size: 2em; }
    .grille-machines { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panneau { overflow: visible; }
    .pied { padding: .3em 16px; flex-direction: column; gap: .2em; }
}
