/* ALERTE — feuille de style unique. Police Manrope auto-hébergée (licence OFL). */

@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope-latin.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope-latin-ext.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --fond: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --bord: #e3e6ec;
  --texte: #161a24;
  --texte-2: #5b6475;
  --texte-3: #8a93a5;
  --accent: #f0592a;
  --accent-fort: #d8431a;
  --accent-doux: #fff0ea;
  --barre: #171a24;
  --barre-2: #222634;
  --barre-texte: #c9cfdc;
  --defaut: #d32f2f;
  --defaut-doux: #fdecec;
  --alerte: #e08a00;
  --alerte-doux: #fff5e0;
  --info: #2563eb;
  --info-doux: #e8f0fe;
  --ok: #2e7d32;
  --ok-doux: #e7f5e9;
  --neutre-doux: #eef0f4;
  --ombre: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --rayon: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0f1117; --surface: #181b24; --surface-2: #1e222d; --bord: #2a2f3c;
    --texte: #e8ebf1; --texte-2: #a3abbb; --texte-3: #737c8e;
    --accent-doux: #3a1f15; --barre: #0b0d12; --barre-2: #161a23;
    --defaut-doux: #3a1717; --alerte-doux: #3a2a0d; --info-doux: #172540; --ok-doux: #15301a; --neutre-doux: #232733;
    --ombre: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0f1117; --surface: #181b24; --surface-2: #1e222d; --bord: #2a2f3c;
  --texte: #e8ebf1; --texte-2: #a3abbb; --texte-3: #737c8e;
  --accent-doux: #3a1f15; --barre: #0b0d12; --barre-2: #161a23;
  --defaut-doux: #3a1717; --alerte-doux: #3a2a0d; --info-doux: #172540; --ok-doux: #15301a; --neutre-doux: #232733;
  --ombre: 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Manrope', system-ui, sans-serif; font-size: 14px; line-height: 1.5;
  background: var(--fond); color: var(--texte); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-fort); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.discret { color: var(--texte-2); }
.petit { font-size: 12px; }
.cache { display: none !important; }

/* --- Mise en page ----------------------------------------------------- */
#app { display: flex; min-height: 100%; }
.barre {
  width: 236px; flex-shrink: 0; background: linear-gradient(180deg, var(--barre), var(--barre-2));
  color: var(--barre-texte); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.marque { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; }
.marque img { width: 34px; height: 34px; }
.marque .nom { font-size: 19px; font-weight: 800; letter-spacing: .06em; line-height: 1; }
.marque .nom span { color: var(--accent); }
.marque .par { font-size: 10px; letter-spacing: .14em; color: #8d95a7; margin-top: 3px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav .titre { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #6f7789; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--barre-texte); font-weight: 600; text-decoration: none; margin-bottom: 1px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.actif { background: rgba(240, 89, 42, .16); color: #fff; }
.nav a.actif .ico { color: var(--accent); }
.nav .ico { width: 18px; height: 18px; flex-shrink: 0; color: #8d95a7; }
.nav .compteur { margin-left: auto; background: var(--defaut); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.pied-barre { padding: 12px 16px 16px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 12px; }
.pied-barre .qui { color: #fff; font-weight: 700; }
.pied-barre .role { color: #8d95a7; }
.pied-barre .liens { display: flex; gap: 12px; margin-top: 8px; }
.pied-barre button { background: none; border: 0; color: #aab2c3; cursor: pointer; padding: 0; font: inherit; }
.pied-barre button:hover { color: #fff; }
.etat-mqtt { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: #8d95a7; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entete {
  display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: var(--surface);
  border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 5; min-height: 70px;
}
.entete .fil { color: var(--texte-3); font-size: 12px; }
.entete .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bouton-menu { display: none; }
.contenu { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.bandeau-vue { background: var(--accent-doux); color: var(--accent-fort); padding: 8px 28px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--bord); }

/* --- Composants ------------------------------------------------------- */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px 20px; margin-bottom: 18px; }
.carte.sans-marge { padding: 0; overflow: hidden; }
.carte > .tete { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.carte > .tete h2 { margin: 0; }
.carte > .tete .droite { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.grille { display: grid; gap: 18px; }
.grille.deux { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.chiffre { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px 16px; box-shadow: var(--ombre); }
.chiffre .val { font-size: 28px; font-weight: 800; line-height: 1.1; }
.chiffre .lib { color: var(--texte-2); font-size: 12.5px; font-weight: 600; }
.chiffre.defaut .val { color: var(--defaut); }
.chiffre.alerte .val { color: var(--alerte); }
.chiffre.ok .val { color: var(--ok); }

button, .bouton {
  font: inherit; font-weight: 700; font-size: 13px; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte); display: inline-flex;
  align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
button:hover, .bouton:hover { background: var(--surface-2); text-decoration: none; }
button.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primaire:hover { background: var(--accent-fort); }
button.danger { color: var(--defaut); }
button.primaire.danger { background: var(--defaut); border-color: var(--defaut); color: #fff; }
button.danger:hover { background: var(--defaut-doux); }
button.petit { padding: 4px 10px; font-size: 12px; }
button.lien { border: 0; background: none; color: var(--accent-fort); padding: 0; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 600; font-size: 12.5px; color: var(--texte-2); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; font-size: 14px; width: 100%; padding: 8px 10px; border: 1px solid var(--bord); border-radius: 8px;
  background: var(--surface); color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(240, 89, 42, .35); border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
.champ { margin-bottom: 14px; }
.champ .aide { font-size: 12px; color: var(--texte-3); margin-top: 3px; }
.ligne-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.case { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--texte); font-size: 13.5px; margin-bottom: 8px; }
.jours { display: flex; gap: 4px; flex-wrap: wrap; }
.jours label { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; padding: 6px 8px; border: 1px solid var(--bord); border-radius: 8px; cursor: pointer; margin: 0; color: var(--texte); }
.jours input { display: none; }
.jours label.coche { background: var(--accent); border-color: var(--accent); color: #fff; }

table.tableau { width: 100%; border-collapse: collapse; }
.tableau th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--bord); background: var(--surface-2); white-space: nowrap; }
.tableau td { padding: 10px 14px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau tr.cliquable { cursor: pointer; }
.tableau tr.cliquable:hover td { background: var(--surface-2); }
.defile { overflow-x: auto; }
.vide { text-align: center; color: var(--texte-3); padding: 28px 12px; }

.pastille { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--neutre-doux); color: var(--texte-2); }
.pastille.defaut { background: var(--defaut-doux); color: var(--defaut); }
.pastille.alerte { background: var(--alerte-doux); color: var(--alerte); }
.pastille.info { background: var(--info-doux); color: var(--info); }
.pastille.ok { background: var(--ok-doux); color: var(--ok); }
.point { width: 9px; height: 9px; border-radius: 50%; background: var(--texte-3); display: inline-block; flex-shrink: 0; }
.point.ok { background: #2fbf55; box-shadow: 0 0 0 3px rgba(47, 191, 85, .18); }
.point.defaut { background: var(--defaut); box-shadow: 0 0 0 3px rgba(211, 47, 47, .18); }
.point.alerte { background: var(--alerte); }

/* Alertes */
.alerte-ligne { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--bord); border-left: 4px solid var(--texte-3); }
.alerte-ligne:last-child { border-bottom: 0; }
.alerte-ligne.defaut { border-left-color: var(--defaut); }
.alerte-ligne.alerte { border-left-color: var(--alerte); }
.alerte-ligne.info { border-left-color: var(--info); }
.alerte-ligne .corps { flex: 1; min-width: 0; }
.alerte-ligne .titre { font-weight: 700; }
.alerte-ligne .meta { color: var(--texte-2); font-size: 12.5px; }
.alerte-ligne .actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* Équipements */
.cartes-eq { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.carte-eq { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px 16px; box-shadow: var(--ombre); cursor: pointer; border-top: 4px solid var(--ok); }
.carte-eq:hover { border-color: var(--accent); border-top-color: inherit; }
.carte-eq.defaut { border-top-color: var(--defaut); }
.carte-eq.alerte { border-top-color: var(--alerte); }
.carte-eq.horsligne { border-top-color: var(--texte-3); }
.carte-eq .nom { font-weight: 800; font-size: 15px; }
.carte-eq .meta { color: var(--texte-2); font-size: 12.5px; margin: 2px 0 10px; }
.carte-eq .bas { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--bord); margin-bottom: 18px; overflow-x: auto; }
.onglets a { padding: 10px 14px; font-weight: 700; color: var(--texte-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.onglets a.actif { color: var(--accent-fort); border-bottom-color: var(--accent); }

.signaux { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.signal { border: 1px solid var(--bord); border-radius: 10px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; transition: background .3s; }
.signal .haut { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.signal .code { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--texte-3); }
.signal .lib { font-weight: 700; font-size: 13px; line-height: 1.3; }
.signal .val { font-size: 20px; font-weight: 800; }
.signal.actif { background: var(--info-doux); }
.signal.en-alerte.defaut { background: var(--defaut-doux); border-color: var(--defaut); }
.signal.en-alerte.alerte { background: var(--alerte-doux); border-color: var(--alerte); }
.signal.en-alerte.info { background: var(--info-doux); border-color: var(--info); }
.signal.flash { animation: flash 1s; }
@keyframes flash { from { box-shadow: 0 0 0 3px rgba(240, 89, 42, .5); } to { box-shadow: none; } }
.voyant { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bord); flex-shrink: 0; }
.voyant.on { background: #2fbf55; border-color: #2fbf55; }
.voyant.on.rouge { background: var(--defaut); border-color: var(--defaut); }
.groupe-signaux { margin-bottom: 18px; }
.groupe-signaux h3 { color: var(--texte-2); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

/* Couverture hebdomadaire */
.couverture { display: grid; grid-template-columns: 44px repeat(24, 1fr); gap: 2px; font-size: 11px; }
.couverture .h { color: var(--texte-3); text-align: center; }
.couverture .j { color: var(--texte-2); font-weight: 700; }
.couverture .c { height: 22px; border-radius: 3px; background: var(--defaut-doux); }
.couverture .c.n1 { background: #b9e4c3; }
.couverture .c.n2 { background: #7cc98f; }
.couverture .c.n3 { background: #3fa95b; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--texte-2); align-items: center; }
.legende i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* Courbe */
.courbe { width: 100%; height: 220px; display: block; }
.courbe .axe { stroke: var(--bord); }
.courbe .trace { fill: none; stroke: var(--accent); stroke-width: 2; }
.courbe .zone { fill: var(--accent-doux); }
.courbe .seuil { stroke: var(--defaut); stroke-dasharray: 4 4; }
.courbe text { fill: var(--texte-3); font-size: 11px; font-family: inherit; }

/* Journal */
.journal-ligne { display: flex; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--bord); font-size: 13px; }
.journal-ligne:last-child { border-bottom: 0; }
.journal-ligne .quand { color: var(--texte-3); width: 128px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.journal-ligne .type { width: 92px; flex-shrink: 0; }

/* Fenêtre modale */
.voile { position: fixed; inset: 0; background: rgba(10, 12, 18, .55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modale { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modale.large { max-width: 760px; }
.modale .tete { padding: 18px 22px 0; display: flex; align-items: center; }
.modale .tete h2 { margin: 0; }
.modale .tete button { margin-left: auto; border: 0; font-size: 20px; padding: 2px 8px; }
.modale .corps { padding: 18px 22px; }
.modale .pied { padding: 0 22px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: 380px; }
.toast { background: var(--barre); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-weight: 600; border-left: 4px solid var(--ok); }
.toast.erreur, .toast.defaut { border-left-color: var(--defaut); }
.toast.alerte { border-left-color: var(--alerte); }
.message { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; font-size: 13px; }
.message.erreur { background: var(--defaut-doux); color: var(--defaut); }
.message.avertissement { background: var(--alerte-doux); color: #8a5300; }
.message.info { background: var(--info-doux); color: var(--info); }
.message.succes { background: var(--ok-doux); color: var(--ok); }
:root[data-theme="dark"] .message.avertissement { color: #ffc46b; }

/* Connexion */
.ecran-connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, rgba(240, 89, 42, .25), transparent 40%), linear-gradient(160deg, #171a24, #232838); }
.boite-connexion { background: var(--surface); width: 100%; max-width: 400px; border-radius: 16px; padding: 30px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.boite-connexion .marque { color: var(--texte); padding: 0 0 20px; justify-content: center; }
.boite-connexion .marque .par { color: var(--texte-3); }
.boite-connexion button.primaire { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }
.boite-connexion .bas { text-align: center; margin-top: 14px; font-size: 13px; }

.chargement { padding: 40px; text-align: center; color: var(--texte-3); }

@media (max-width: 860px) {
  .barre { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  body.menu-ouvert .barre { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .bouton-menu { display: inline-flex; }
  .entete { padding: 10px 16px; min-height: 56px; flex-wrap: wrap; }
  .entete h1 { font-size: 18px; }
  .entete .fil { display: none; }
  .entete .actions { margin-left: 0; width: 100%; }
  .entete .actions:empty { display: none; }
  .contenu { padding: 16px 16px 40px; }
  .bandeau-vue { padding: 8px 16px; }
  .journal-ligne { flex-wrap: wrap; gap: 2px 10px; }
  .journal-ligne .quand, .journal-ligne .type { width: auto; }
  .couverture { grid-template-columns: 32px repeat(24, 1fr); font-size: 9px; }
  .masque-mobile { display: none; }
  .grille.deux { grid-template-columns: 1fr; }
}
