/* ============================================================
   CALTHIA OS — habillage du bureau
   Référence visuelle contractuelle : maquette 12b.
   En-tête « Calthia OS », carré « C », aucun domaine affiché.
   ============================================================ */

:root {
  --bg: #f4f4f6;
  --panel: #ffffff;
  --panel2: #fafafb;
  --ink: #1c1c1e;
  --ink2: #55555a;
  --muted: #8e8e93;
  --line: #e7e7ea;
  --accent: #2a78d6;
  --accent-soft: #eaf2fc;
  --good: #0ca30c;
  --good-soft: #e8f6e8;
  --warn: #c98500;
  --warn-soft: #fdf4e0;
  --orange: #d95926;
  --orange-soft: #fdeee7;
  --violet: #6b5bd2;
  --violet-soft: #efecfb;
  --rouge: #c0392b;
  --rouge-soft: #fdecea;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* L'attribut `hidden` doit toujours l'emporter. Sans cette règle, n'importe
   quel `display:` posé plus bas le neutralise en silence — et l'écran de
   connexion reste affiché au-dessus du bureau après la connexion. */
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
a { color: var(--accent); }

/* ================= ÉCRAN DE CONNEXION ================= */
.connexion {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #eef3fa 0%, var(--bg) 55%);
}
.connexion-carte {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 30px 26px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(28, 28, 30, 0.07);
}
.connexion-marque {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.connexion-marque .sq {
  width: 44px; height: 44px; border-radius: 12px; font-size: 20px;
  background: var(--accent); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.connexion-marque b { font-size: 18px; display: block; }
.connexion-marque small { color: var(--muted); font-size: 12px; }
.connexion h1 { font-size: 17px; margin-bottom: 4px; }
.connexion .sous { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.champ { margin-bottom: 14px; }
.champ label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin-bottom: 5px; }
.champ input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14.5px;
  outline: none;
  background: var(--panel2);
}
.champ input:focus { border-color: var(--accent); background: var(--panel); }
.champ .aide-champ { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.btn:hover { background: #2468bb; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-lien { display: block; text-align: center; text-decoration: none; color: #fff; }
.btn.secondaire { background: var(--panel2); color: var(--ink2); border: 1px solid var(--line); width: auto; }
.btn.secondaire:hover { background: var(--line); }

/* Message d'erreur : toujours en français, toujours avec la marche à suivre. */
.message-erreur {
  background: var(--rouge-soft);
  border: 1px solid #f3c4bf;
  border-left: 3px solid var(--rouge);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13px;
  margin-bottom: 14px;
}
.message-erreur b { display: block; color: var(--rouge); margin-bottom: 3px; }
.message-erreur .marche-a-suivre { color: var(--ink2); }

.rappel-securite {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

/* ================= STRUCTURE DU BUREAU ================= */
.app { display: flex; height: 100vh; overflow: hidden; }

.side {
  width: 236px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand .sq {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex-shrink: 0;
}
.brand b { font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 11px; font-weight: normal; }

.sect { font-size: 10.5px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin: 13px 8px 5px; }
.nav { list-style: none; }
.nav li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  color: var(--ink2); font-size: 13.5px;
}
.nav li:hover { background: var(--panel2); }
.nav li.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .em { width: 20px; text-align: center; }

.mini {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 9px 4px 20px; border-radius: 8px; cursor: pointer;
  color: var(--ink2); font-size: 12.5px;
}
.mini:hover { background: var(--panel2); }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex-shrink: 0; }
.pip.work { background: var(--orange); animation: pulse 1.4s infinite; }
.pip.zz { background: #c9c9ce; }
.pip.panne { background: var(--rouge); }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .3 } }

.pied-side { margin-top: auto; padding: 12px 8px 0; font-size: 11px; color: var(--muted); }
.pied-side .qui { color: var(--ink2); font-weight: 600; font-size: 12px; }
.pied-side button {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 11.5px; padding: 4px 0;
}

.main { flex: 1; overflow-y: auto; padding: 0 0 26px; }
.contenu { padding: 20px 26px; }
.crumb { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.crumb b { color: var(--ink); }
.crumb span { cursor: pointer; }
.view { display: none; }
.view.on { display: block; }
h1 { font-size: 21px; margin-bottom: 2px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--ink2); margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.card h2 .a-droite { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: normal; }
.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }

/* ============ BANDEAU D'ALERTES (Avenant 2) ============
   Permanent, en haut, visible par TOUT utilisateur connecté,
   non masquable tant que l'alerte n'est pas résolue. */
#bandeau-alertes { position: sticky; top: 0; z-index: 30; }
.alerte {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
  font-size: 13px;
}
.alerte .ic { font-size: 18px; line-height: 1.2; flex-shrink: 0; }
.alerte .txt { flex: 1; }
.alerte .txt b { display: block; margin-bottom: 2px; }
.alerte .echeance { font-weight: 600; }
.alerte a.doc {
  flex-shrink: 0; background: rgba(255, 255, 255, .75);
  border: 1px solid rgba(0, 0, 0, .12); border-radius: 8px;
  padding: 6px 12px; font-size: 12.5px; font-weight: 600;
  text-decoration: none; color: inherit; white-space: nowrap;
}
.alerte.critique { background: #fbe3e0; color: #7d211a; }
.alerte.grave { background: var(--warn-soft); color: #7a5200; }
.alerte.attention { background: var(--accent-soft); color: #1c4f8f; }

/* ============ OPEN SPACE ============ */
.space { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.desk {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; cursor: pointer; position: relative;
  transition: box-shadow .15s; text-align: left; width: 100%; font: inherit; color: inherit;
}
.desk:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, .08); }
.desk .top { display: flex; align-items: center; gap: 9px; }
.desk .av {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0; background: var(--panel);
}
.desk .nm { font-weight: 700; font-size: 13px; }
.desk .rl { font-size: 10.5px; color: var(--muted); }
.desk .doing { margin-top: 8px; font-size: 11.5px; color: var(--ink2); min-height: 17px; }
.desk.working { border-color: #f2c39a; background: #fffaf5; }
.desk.working .av { animation: bob 2.2s ease-in-out infinite; }
.desk.panne { border-color: #eab5ae; background: var(--rouge-soft); }
@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-3px) } }
.dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: 1px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--orange); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s }
.dots i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }
.zzz { position: absolute; top: 8px; right: 10px; font-size: 10px; color: #c9c9ce; }

/* ============ WIDGETS ============ */
.gauge { margin-bottom: 10px; }
.gauge .gl { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
.gauge .gl b { font-variant-numeric: tabular-nums; }
.gbar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.gbar i { display: block; height: 100%; border-radius: 4px; background: var(--good); transition: width .4s; }
.gbar i.mid { background: var(--warn); }
.gbar i.haut { background: var(--rouge); }

.feed { list-style: none; font-size: 12.5px; }
.feed li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.feed li:last-child { border: none; }
.feed .wh {
  color: var(--muted); font-size: 10.5px; white-space: nowrap;
  padding-top: 2px; font-variant-numeric: tabular-nums;
}
.feed .grave { color: var(--rouge); }
.feed .attention { color: var(--warn); }

.vide { color: var(--muted); font-size: 12.5px; font-style: italic; padding: 8px 0; }

/* Le voyant de latence : le contrat du CDC (≤ 5 s) est affiché, pas promis. */
.latence { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.latence .voyant { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.latence.lent .voyant { background: var(--warn); }
.latence.coupe .voyant { background: var(--rouge); }

/* ============ USINES ============ */
.usine-card { display: flex; gap: 16px; align-items: center; cursor: pointer; }
.usine-card .ic { font-size: 32px; }
.usine-card .nm { font-weight: 700; font-size: 15px; }
.usine-card .st { font-size: 12.5px; color: var(--muted); }
.pbar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 7px; }
.pbar i { display: block; height: 100%; background: var(--orange); border-radius: 4px; }
.locked { opacity: .55; border-style: dashed; cursor: default; }
.tag { font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .5px; }
.t-usine { background: var(--orange-soft); color: var(--orange); }
.t-attente { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }

/* ============ COFFRE ============ */
.vault { max-width: 460px; margin: 40px auto; text-align: center; }
.vault .big { font-size: 52px; margin-bottom: 10px; }
.vnote { font-size: 11.5px; color: var(--muted); margin-top: 12px; }

/* ============ PAGES D'AIDE ============ */
.aide { max-width: 720px; }
.aide h2 { font-size: 15px; margin: 22px 0 8px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.aide p { margin-bottom: 10px; }
.aide ol, .aide ul { margin: 0 0 12px 22px; }
.aide li { margin-bottom: 6px; }
.aide .encadre {
  background: var(--warn-soft); border: 1px solid #f0dcb0;
  border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 13px;
}
.aide .encadre b { display: block; margin-bottom: 3px; }

/* ============ CLASSES UTILITAIRES ============
   La politique de sécurité du contenu interdit les styles écrits directement
   dans le HTML (`style="..."`). C'est volontaire : on ne l'affaiblit pas pour
   trois marges. Ces quelques classes remplacent tous les styles en ligne. */
.serre { margin-top: 6px; }
.espace-haut { margin-top: 10px; }
.remplir { flex: 1; }
.etiquette-usine { margin-left: 8px; }
.note { font-size: 11px; color: var(--muted); margin-top: 8px; }
.note-pied { margin-top: 8px; }
.texte-doux { font-size: 13px; color: var(--ink2); }
.carte-etroite { max-width: 520px; }
.aide-serree { font-size: 13.5px; }
.encadre.danger { background: var(--rouge-soft); border-color: #f3c4bf; }

/* ============ DIVERS ============ */
#toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 10px; font-size: 13px; transition: transform .25s; z-index: 90;
  max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }

.bandeau-hors-ligne {
  background: var(--rouge); color: #fff; padding: 9px 20px;
  font-size: 13px; text-align: center;
}

@media (max-width: 920px) {
  .cols { grid-template-columns: 1fr; }
  .space { grid-template-columns: repeat(2, 1fr); }
  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 40px rgba(0, 0, 0, .2);
  }
  .side.ouvert { transform: none; }
  .contenu { padding: 16px 14px; }
  .bouton-menu { display: inline-flex !important; }
}

.bouton-menu {
  display: none; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px; margin: 14px 14px 0;
  font-size: 13px; cursor: pointer;
}
