/* CONSOLE — salle de contrôle MYRACL.
 * Système d'instrument : nuit profonde, couleurs de STATUT porteuses de sens,
 * Bricolage pour les noms, monospace pour les données. Servi en local, CSP-safe. */
@font-face {
  font-family: 'Bricolage';
  src: url('/bricolage-grotesque-latin.woff2') format('woff2');
  font-weight: 200 800; font-display: swap;
}

:root {
  color-scheme: dark;
  --nuit: #0d0f14;
  --panneau: #141821;
  --panneau-haut: #1a1f2b;
  --trait: #232a37;
  --trait-clair: #2f3746;
  --texte: #e8ebf2;
  --doux: #8b95a7;
  --faible: #5c6472;
  --iris: #7c86ff;
  --iris-fonce: #5b63d6;
  /* statuts — la couleur est une information, pas une décoration */
  --st-brouillon: #64748b;
  --st-a-valider: #f0a835;
  --st-valide: #34d399;
  --st-publie: #5b9dff;
  --st-rejete: #f2585b;
  --rayon: 12px;
  --rayon-s: 8px;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
  --ombre: 0 12px 32px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* sinon .btn/.app (display:…) écrasent l'attribut hidden */
html, body { height: 100%; }
body {
  margin: 0; background: var(--nuit); color: var(--texte);
  font-family: 'Bricolage', system-ui, sans-serif;
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { color: var(--iris); }
::selection { background: color-mix(in srgb, var(--iris) 40%, transparent); }

/* étiquette / donnée en mono — la signature */
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--doux); }

/* ===================== CONNEXION / ACCUEIL ===================== */
.centre { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.carte-auth {
  background: linear-gradient(180deg, var(--panneau-haut), var(--panneau));
  border: 1px solid var(--trait); border-radius: 16px; padding: 2rem 1.75rem;
  width: min(30rem, 100%); box-shadow: var(--ombre);
}
.marque { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.4rem; }
.marque .anneau { width: 34px; height: 34px; color: #eef0f6; }
.marque .anneau svg { width: 100%; height: 100%; }
.btn.mini { padding: .2rem .5rem; font-size: 12px; }
.mt-s { margin-top: .4rem; }
.m0 { margin-top: 0; }
.marque h1 { margin: 0; font-size: 1.15rem; letter-spacing: .18em; font-weight: 700; }
.carte-auth h2 { margin: 0 0 .3rem; font-size: 1.3rem; font-weight: 600; }
.carte-auth .aide { color: var(--doux); font-size: .9rem; margin: 0 0 1rem; }
label { display: block; margin: .85rem 0 .35rem; }
label .mono { color: var(--doux); }
input, textarea, select {
  width: 100%; padding: .62rem .7rem; background: #0b0e14; color: var(--texte);
  border: 1px solid var(--trait); border-radius: var(--rayon-s); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 5rem; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--iris);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--iris) 28%, transparent);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1rem; border: 0; border-radius: var(--rayon-s);
  background: var(--iris); color: #0b1020; font-weight: 600;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.large { width: 100%; margin-top: 1.1rem; padding: .7rem; }
.btn.fantome { background: transparent; color: var(--doux); border: 1px solid var(--trait); }
.btn.fantome:hover { color: var(--texte); border-color: var(--trait-clair); filter: none; }
.btn.danger { background: transparent; color: var(--st-rejete); border: 1px solid color-mix(in srgb, var(--st-rejete) 45%, var(--trait)); }
.btn:focus-visible, a:focus-visible, .rail-btn:focus-visible, .icone-btn:focus-visible { outline: 2px solid var(--iris); outline-offset: 2px; }
.erreur { color: var(--st-rejete); margin-top: .6rem; min-height: 1.2em; font-size: .9rem; }
.secret {
  font-family: var(--mono); font-size: 1rem; letter-spacing: .12em; text-align: center;
  background: #0b0e14; border: 1px dashed var(--trait-clair); border-radius: var(--rayon-s);
  padding: .7rem; word-break: break-all; color: var(--st-valide);
}

/* ===================== COQUILLE APPLICATIVE ===================== */
.app { display: grid; grid-template-columns: 64px 1fr; min-height: 100dvh; }

/* rail d'instruments */
.rail {
  background: #0a0c11; border-right: 1px solid var(--trait);
  display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .9rem 0;
  position: sticky; top: 0; height: 100dvh;
}
.rail .logo { width: 36px; height: 36px; margin-bottom: .8rem; color: #eef0f6; }
.rail .logo svg { width: 100%; height: 100%; }
/* Mascotte Myra : corps (currentColor) + regard qui suit le curseur + clignement. */
.mascotte { width: 100%; height: 100%; display: block; overflow: visible; }
.mascotte .regard { transition: transform 220ms cubic-bezier(.22,.61,.36,1); }
.mascotte .paupieres { transform-box: fill-box; transform-origin: center; transition: transform .12s ease; }
.mascotte .paupieres.cligne { transform: scaleY(.12); }
@media (prefers-reduced-motion: reduce) { .mascotte .regard, .mascotte .paupieres { transition: none; } }
.rail-btn {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 10px; color: var(--faible);
  position: relative; transition: color .15s, background .15s;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn:hover { color: var(--doux); background: rgba(255,255,255,.04); }
.rail-btn.actif { color: var(--texte); background: rgba(124,134,255,.14); }
.rail-btn.actif::before {
  content: ''; position: absolute; left: -0px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 3px; background: var(--iris);
  box-shadow: 0 0 10px var(--iris);
}
.rail-espace { flex: 1; }
.rail-btn.plus { background: var(--iris); color: #0b1020; }
.rail-btn.plus:hover { filter: brightness(1.08); background: var(--iris); color: #0b1020; }
.rail .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panneau-haut); border: 1px solid var(--trait); color: var(--doux);
  font-size: 13px; font-weight: 700; text-transform: uppercase;
}
.infobulle { /* petit label au survol du rail */ position: absolute; left: 52px; white-space: nowrap;
  background: #0b0e14; border: 1px solid var(--trait); color: var(--texte); padding: .25rem .5rem;
  border-radius: 6px; font-size: 12px; opacity: 0; pointer-events: none; transform: translateX(-4px);
  transition: opacity .12s, transform .12s; z-index: 5; }
.rail-btn:hover .infobulle { opacity: 1; transform: translateX(0); }

/* zone principale */
.vue { padding: 1.6rem 2rem 3rem; width: 100%; }
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.entete h1 { margin: 0; font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
.entete .compteur { margin-top: .25rem; }
.entete .compteur b { color: var(--texte); font-family: var(--mono); font-weight: 700; }
.outils { display: flex; align-items: center; gap: .5rem; }
.recherche { position: relative; }
.recherche input { width: 190px; padding-left: 2rem; }
.recherche svg { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faible); }
.icone-btn { width: 38px; height: 38px; display: grid; place-items: center; background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--rayon-s); color: var(--doux); }
.icone-btn:hover { color: var(--texte); border-color: var(--trait-clair); }

/* filtres segmentés */
.segments { display: flex; gap: .35rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.segment { padding: .32rem .7rem; border-radius: 999px; border: 1px solid var(--trait); background: transparent; color: var(--doux); font-size: 12px; letter-spacing: .03em; }
.segment.actif { background: var(--panneau-haut); color: var(--texte); border-color: var(--trait-clair); }
.segment .pastille { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }

/* grille de cartes */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.fiche {
  position: relative; background: var(--panneau); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 1.05rem 1rem .95rem; min-height: 130px;
  display: flex; flex-direction: column; overflow: hidden; text-align: left; width: 100%;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.fiche:hover { border-color: var(--trait-clair); transform: translateY(-2px); box-shadow: var(--ombre); }
.fiche .rail-statut { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--st-brouillon); }
.fiche .haut { display: flex; align-items: center; justify-content: space-between; margin-bottom: auto; }
.fiche .cat { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--doux); }
.fiche .menu { color: var(--faible); font-size: 18px; line-height: 1; letter-spacing: .05em; }
.fiche .titre { font-size: 1.05rem; font-weight: 700; margin-top: 1.2rem; }
.fiche .surtitre { color: var(--doux); font-weight: 400; font-size: .92rem; }
.fiche .sous { margin-top: .35rem; color: var(--faible); font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vide { color: var(--doux); padding: 3rem 0; text-align: center; }
.vide .btn { margin-top: 1rem; }

/* apparition douce */
@media (prefers-reduced-motion: no-preference) {
  .fiche { animation: monte .32s both; }
  .fiche:nth-child(2){animation-delay:.03s}.fiche:nth-child(3){animation-delay:.06s}
  .fiche:nth-child(4){animation-delay:.09s}.fiche:nth-child(5){animation-delay:.12s}
  .fiche:nth-child(6){animation-delay:.15s}.fiche:nth-child(n+7){animation-delay:.18s}
  @keyframes monte { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ===================== MODALE ===================== */
dialog {
  border: 1px solid var(--trait); border-radius: 16px; padding: 0; color: var(--texte);
  background: linear-gradient(180deg, var(--panneau-haut), var(--panneau));
  width: min(34rem, 92vw); box-shadow: var(--ombre);
}
dialog::backdrop { background: rgba(6,8,12,.62); backdrop-filter: blur(3px); }
.modale-tete { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--trait); }
.modale-tete h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.modale-corps { padding: 1.1rem 1.25rem; max-height: 68vh; overflow: auto; }
.modale-pied { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.25rem; border-top: 1px solid var(--trait); flex-wrap: wrap; }
.fermer { background: transparent; border: 0; color: var(--doux); font-size: 20px; line-height: 1; width: 32px; height: 32px; border-radius: 8px; }
.fermer:hover { color: var(--texte); background: rgba(255,255,255,.05); }
.transitions { display: flex; gap: .5rem; flex-wrap: wrap; margin-right: auto; }
.badge-statut { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--doux); }
.badge-statut .pastille { width: 8px; height: 8px; border-radius: 50%; }

/* éditeur de permissions (rôles) */
.perm-groupe { margin-top: 1rem; }
.perm-groupe > .titre-grp { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--doux); margin-bottom: .5rem; }
.perm-ligne { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border: 1px solid var(--trait); border-radius: 8px; margin-bottom: .4rem; cursor: pointer; }
.perm-ligne:hover { border-color: var(--trait-clair); }
.perm-ligne input { width: auto; }
.perm-ligne.coche { border-color: color-mix(in srgb, var(--iris) 50%, var(--trait)); background: rgba(124,134,255,.07); }
.perm-ligne .nom { flex: 1; }
.champ-couleur { display: flex; align-items: center; gap: .6rem; }
.champ-couleur input[type=color] { width: 44px; height: 38px; padding: 2px; cursor: pointer; }
.role-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
/* Puce de rôle : ROUGE quand NON attribuée, normale quand attribuée. */
.role-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .6rem; border-radius: 999px; font-size: 12px; cursor: pointer; user-select: none; transition: border-color .12s, background .12s, color .12s;
  border: 1px solid color-mix(in srgb, var(--st-rejete) 55%, var(--trait));
  background: color-mix(in srgb, var(--st-rejete) 8%, transparent); }
.role-chip .pastille { width: 8px; height: 8px; border-radius: 50%; }
.role-chip .nom { color: var(--st-rejete); }
.role-chip.coche { border-color: var(--trait-clair); background: var(--panneau-haut); }
.role-chip.coche .nom { color: var(--texte); }
.bloc { margin-top: 1rem; }
.bloc > .mono { display: block; margin-bottom: .5rem; }

/* ===== Le Panel (tableau de bord) ===== */
.tableau{display:flex;flex-direction:column;gap:1.1rem}
.stat-grille{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:1rem}
.stat{display:flex;flex-direction:column;align-items:flex-start;gap:.15rem;text-align:left;
  background:var(--panneau);border:1px solid var(--trait);border-radius:var(--rayon);padding:1.1rem;cursor:pointer;transition:border-color .15s,transform .12s}
.stat:hover:not(:disabled){border-color:var(--trait-clair);transform:translateY(-2px)}
.stat:disabled{cursor:default;opacity:.75}
.stat-ico{color:var(--iris)}.stat-ico svg{width:22px;height:22px}
.stat-n{font-family:var(--mono);font-size:2rem;font-weight:700;color:var(--texte);margin-top:.3rem}
.stat-l{font-size:.85rem;color:var(--doux)}
.stat-blocs{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:1rem}
.stat-bloc{background:var(--panneau);border:1px solid var(--trait);border-radius:var(--rayon);padding:1.1rem}
.stat-bloc-t{font-size:.95rem;font-weight:600;margin-bottom:.8rem;display:flex;justify-content:space-between;align-items:center}
.stat-bloc-t .mono{color:var(--doux)}
.barre{display:flex;height:10px;border-radius:6px;overflow:hidden;background:#0f121a;margin-bottom:.8rem}
.barre .seg{height:100%}
.barre .seg.vide2{width:100%;background:#0f121a}
.legende{display:flex;flex-direction:column;gap:.35rem}
.legende .lg{font-size:.85rem;color:var(--doux);display:flex;align-items:center;gap:.5rem}
.legende .lg b{color:var(--texte);margin-left:auto;font-family:var(--mono)}
.legende .pt{width:9px;height:9px;border-radius:50%;flex:0 0 auto}

/* ===== Panel : bascule Gestion ⇄ Admin + jauges machines + sites ===== */
.panel-switch { display: inline-flex; border: 1px solid var(--trait); border-radius: var(--rayon-s); overflow: hidden; align-self: flex-start; }
.pswitch { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1.1rem; background: var(--panneau); border: 0; color: var(--doux); font-weight: 600; font-size: .92rem; }
.pswitch svg { width: 16px; height: 16px; }
.pswitch + .pswitch { border-left: 1px solid var(--trait); }
.pswitch.actif { color: var(--texte); background: rgba(124,134,255,.16); }
.pswitch:focus-visible { outline: 2px solid var(--iris); outline-offset: -2px; }

.jauge { margin-top: .7rem; }
.jauge-t { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .3rem; }
.jauge-t b { font-family: var(--mono); }
.barre.mince { height: 6px; margin-bottom: 0; }
.jauge-d { color: var(--faible); font-size: .8rem; margin-top: .25rem; font-family: var(--mono); }
.stat-bloc.machine .badge-statut { font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--texte); font-weight: 700; }
.stat-bloc.machine .stat-bloc-t { flex-wrap: wrap; gap: .3rem .6rem; }
.stat-bloc.machine .stat-bloc-t > .mono { white-space: nowrap; }

.chart.petite { height: 90px; }
.site-bloc .stat-bloc-t { align-items: baseline; }
.site-nom { color: var(--texte); text-decoration: none; font-weight: 700; }
.site-nom:hover { color: var(--iris); }
.site-live { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--st-valide); }
.site-live .pt { width: 8px; height: 8px; border-radius: 50%; animation: pulse 2s infinite; }
@media (prefers-reduced-motion: reduce) { .site-live .pt { animation: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.site-chiffres { display: flex; gap: 1.6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.site-chiffres > span { display: flex; flex-direction: column; }
.site-chiffres b { font-family: var(--mono); font-size: 1.25rem; }

/* ===================== RUBRIQUE IA (tchat) ===================== */
.ia { display: grid; grid-template-columns: 250px 1fr; gap: 1rem; height: calc(100dvh - 11rem); min-height: 420px; }
.ia-liste { background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: .8rem; overflow-y: auto; display: flex; flex-direction: column; gap: .35rem; }
.ia-nouvelle { width: 100%; margin-bottom: .6rem; }
.ia-item { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: .5rem .6rem; color: var(--doux); }
.ia-item:hover { background: rgba(255,255,255,.04); color: var(--texte); }
.ia-item.actif { background: rgba(124,134,255,.12); border-color: var(--trait-clair); color: var(--texte); }
.ia-item .pt { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ia-item .ia-nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ia-item .ia-x { color: var(--faible); font-size: 15px; padding: 0 .2rem; border-radius: 5px; }
.ia-item .ia-x:hover { color: var(--st-rejete); background: rgba(242,88,91,.12); }
.ia-item.remote .ia-nom { font-size: .92rem; }

.ia-tchat { display: flex; flex-direction: column; background: #07090d; /* fond noir demandé */
  border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.ia-vide { margin: auto; text-align: center; color: var(--doux); }
.ia-tete { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; border-bottom: 1px solid var(--trait); background: var(--panneau); }
.ia-titre { font-weight: 700; }
.ia-tete .btn { margin-left: auto; }
.ia-messages { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .9rem; scrollbar-width: thin; }
.ia-msg { max-width: 88%; padding: .7rem .9rem; border-radius: 12px; font-size: .95rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word; }
.ia-msg.moi { align-self: flex-end; background: #10131c; border: 1px solid var(--trait); border-bottom-right-radius: 4px; }
.ia-msg.ia-rep { align-self: flex-start; background: #0b0e15; border: 1px solid var(--trait); border-bottom-left-radius: 4px; white-space: normal; }
.ia-reponse-txt { white-space: pre-wrap; }
.ia-reflexion { margin-bottom: .5rem; }
.ia-reflexion summary { cursor: pointer; color: var(--faible); }
.ia-reflexion-txt { white-space: pre-wrap; font-size: .85rem; opacity: .85; border-left: 2px solid var(--trait-clair);
  padding-left: .7rem; margin-top: .4rem; max-height: 14rem; overflow-y: auto; scrollbar-width: thin; }
.ia-msg pre.code { background: #0a0c12; border: 1px solid var(--trait); border-radius: 8px; padding: .7rem .8rem;
  overflow-x: auto; font-family: var(--mono); font-size: .85rem; line-height: 1.5; margin: .5rem 0; white-space: pre; color: var(--texte); }
.ia-duree { margin-top: .5rem; color: var(--faible); }
.ia-attente { color: var(--faible); animation: pulse 1.4s infinite; }
.ia-saisie { display: flex; gap: .6rem; padding: .8rem; border-top: 1px solid var(--trait); background: var(--panneau); }
.ia-saisie textarea { flex: 1; resize: none; min-height: 2.6rem; max-height: 10rem; background: #07090d; }
.ia-saisie .btn { align-self: flex-end; }
.champ-couleur .doux { font-size: .85rem; }

@media (max-width: 760px) {
  .ia { grid-template-columns: 1fr; height: auto; }
  .ia-liste { max-height: 220px; }
  .ia-tchat { height: 65dvh; }
}

/* ===================== CAMEMBERTS (donuts) ===================== */
.cam-wrap { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.donut { flex: 0 0 auto; transform: rotate(0deg); }
.donut circle { transition: stroke-dasharray .4s ease; }
.cam-legende { flex: 1; min-width: 130px; }

/* ===================== MODE ÉCRAN (wallboard permanent) ===================== */
.ecran {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  padding: clamp(1rem, 2.5vw, 2.5rem); gap: clamp(.8rem, 1.5vh, 1.4rem);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124,134,255,.09), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(139,92,246,.07), transparent 60%),
    var(--nuit);
  overflow: hidden; cursor: default;
}
.ecran-chargement, .ecran-expire { margin: auto; text-align: center; color: var(--doux); font-size: 1.2rem; }
.ecran-expire h2 { margin: .8rem 0 .3rem; color: var(--texte); }
.ecran-expire .myra-vide { margin: 0 auto 1rem; }

.e-tete { display: flex; align-items: center; gap: 1.5rem; flex: 0 0 auto; }
.e-marque { display: flex; align-items: center; gap: .8rem; }
.e-marque .myra-vide { width: clamp(38px, 4vw, 56px); height: clamp(38px, 4vw, 56px); margin: 0; color: #eef0f6; }
.e-titre { font-weight: 700; letter-spacing: .2em; font-size: clamp(1rem, 1.6vw, 1.4rem); }
.e-sous { color: var(--doux); }
.e-etat { margin-left: auto; display: inline-flex; align-items: center; gap: .7rem;
  font-size: clamp(1.1rem, 2vw, 1.7rem); font-weight: 700; padding: .5rem 1.2rem;
  border-radius: 999px; border: 1px solid var(--trait); background: var(--panneau); }
.e-etat .pt.grand, .e-bloc-t .pt.grand { width: 14px; height: 14px; border-radius: 50%; }
.e-etat.vert .pt { box-shadow: 0 0 14px var(--st-valide); }
.e-etat.ambre { color: var(--st-a-valider); }
.e-etat.rouge { color: var(--st-rejete); border-color: color-mix(in srgb, var(--st-rejete) 50%, var(--trait)); }
.e-etat.rouge .pt { animation: pulse 1.2s infinite; box-shadow: 0 0 14px var(--st-rejete); }
.e-heure { font-size: clamp(1.4rem, 3vw, 2.6rem); font-weight: 700; color: var(--texte);
  text-transform: none; letter-spacing: .06em; font-variant-numeric: tabular-nums; }

.e-alertes { flex: 0 0 auto; color: var(--st-rejete); background: color-mix(in srgb, var(--st-rejete) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--st-rejete) 40%, var(--trait)); border-radius: var(--rayon-s);
  padding: .6rem 1rem; font-size: clamp(.9rem, 1.3vw, 1.15rem); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.e-grille { flex: 1; display: grid; gap: clamp(.8rem, 1.4vw, 1.3rem);
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  align-content: start; align-items: start; min-height: 0; }
.e-bloc { background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: clamp(.9rem, 1.4vw, 1.4rem); display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  max-height: calc(100vh - 14rem); }
.e-bloc-t { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; font-size: clamp(1rem, 1.5vw, 1.35rem);
  font-weight: 700; margin-bottom: .8rem; }
.e-bloc-t .e-sous { margin-left: auto; font-size: .78em; text-align: right; white-space: nowrap; }
.e-bloc-t .pt.grand { align-self: center; }
.e-bloc .jauge-t { font-size: clamp(.85rem, 1.1vw, 1.05rem); }
.e-bloc .jauge-t b { font-size: 1.25em; }
.e-bloc .barre.mince { height: 9px; }
.e-liste { overflow: hidden auto; scrollbar-width: thin; }
.e-liste .lg { font-size: clamp(.85rem, 1.1vw, 1.05rem); }
.e-chiffres { display: flex; gap: 1.6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.e-chiffres > span { display: flex; flex-direction: column; }
.e-chiffres b { font-family: var(--mono); font-size: clamp(1.6rem, 2.6vw, 2.4rem); line-height: 1.1; }
.e-pied { flex: 0 0 auto; text-align: center; color: var(--faible); }
@media (prefers-reduced-motion: reduce) { .e-etat.rouge .pt { animation: none; } }

/* toast */
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panneau-haut); border: 1px solid var(--trait-clair); color: var(--texte);
  padding: .7rem 1.1rem; border-radius: 999px; box-shadow: var(--ombre); opacity: 0;
  transition: opacity .2s, transform .2s; z-index: 50; font-size: .92rem; }
.toast.montre { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: color-mix(in srgb, var(--st-rejete) 55%, var(--trait)); }

/* ===================== TRI + BASCULE DE VUE ===================== */
.tri { width: auto; padding: .45rem 1.6rem .45rem .7rem; background-color: var(--panneau); border-color: var(--trait); color: var(--doux); font-size: 12px; }
.tri:hover { color: var(--texte); border-color: var(--trait-clair); }
.bascule-vue { display: inline-flex; border: 1px solid var(--trait); border-radius: var(--rayon-s); overflow: hidden; }
.vue-btn { width: 36px; height: 38px; display: grid; place-items: center; background: var(--panneau); border: 0; color: var(--faible); }
.vue-btn svg { width: 17px; height: 17px; }
.vue-btn:hover { color: var(--doux); }
.vue-btn.actif { color: var(--texte); background: rgba(124,134,255,.14); }
.vue-btn + .vue-btn { border-left: 1px solid var(--trait); }
.vue-btn:focus-visible { outline: 2px solid var(--iris); outline-offset: -2px; }
.avatar:hover { border-color: var(--trait-clair); color: var(--texte); }

/* ===================== KANBAN ===================== */
.grille.kanban { display: flex; gap: .9rem; align-items: flex-start; overflow-x: auto; padding-bottom: .5rem; }
.kcol { flex: 0 0 clamp(220px, 24vw, 300px); background: rgba(255,255,255,.015); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: .7rem; display: flex; flex-direction: column; min-height: 120px;
  transition: border-color .15s, background .15s; }
.kcol.survol { border-color: var(--iris); background: rgba(124,134,255,.07); }
.kcol-tete { display: flex; align-items: center; gap: .45rem; font-size: .88rem; font-weight: 600; margin-bottom: .7rem; padding: 0 .1rem; }
.kcol-tete .pastille { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.kcol-tete .mono { margin-left: auto; color: var(--doux); }
.kcol-corps { display: flex; flex-direction: column; gap: .6rem; min-height: 44px; }
.kcol .fiche { min-height: 0; padding: .7rem .8rem; cursor: grab; }
.kcol .fiche:active { cursor: grabbing; }
.kcol .fiche .titre { margin-top: .5rem; font-size: .98rem; }
.kcol .fiche.drag { opacity: .4; }

/* ============ CARTES ENRICHIES (projets + tâches + bots) ============ */
.fiche.projet .haut, .fiche.tache .haut, .fiche.bot .haut { margin-bottom: .2rem; align-items: center; }
.projet-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; line-height: 1; flex: 0 0 auto; }
.projet-ico.vide-ico { width: 0; height: 0; }
.rang { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--doux); flex: 0 0 auto; }
.rang .pastille { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.fiche.projet .titre, .fiche.tache .titre, .fiche.bot .titre { margin-top: .55rem; }
.fiche .desc { margin-top: .4rem; color: var(--doux); font-size: .9rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fiche .pied-carte { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto; padding-top: .8rem; }
.fiche.projet .lien-h, .fiche.bot .lien-h { color: color-mix(in srgb, var(--accent-projet, var(--iris)) 78%, var(--texte));
  font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fiche .pied-carte .mono { color: var(--faible); flex: 0 0 auto; }
.fiche.projet:hover, .fiche.tache:hover, .fiche.bot:hover { box-shadow: 0 14px 34px -14px color-mix(in srgb, var(--accent-projet, var(--iris)) 45%, transparent); }
.resultat-cmd { font-family: var(--mono); font-size: 11px; white-space: pre-wrap; background: #0b0e14; border: 1px solid var(--trait); border-radius: 6px; padding: .5rem; margin: .2rem 0 .5rem; max-height: 8rem; overflow: auto; }

/* tâche : priorité, échéance, assigné */
.tache-tags { display: flex; align-items: center; gap: .4rem; flex: 1; min-width: 0; }
.prio { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: .12rem .42rem; border-radius: 6px; white-space: nowrap; }
.prio.haute { color: var(--st-rejete); background: color-mix(in srgb, var(--st-rejete) 15%, transparent); }
.prio.basse { color: var(--faible); background: rgba(255,255,255,.05); }
.fiche.tache .ech { font-family: var(--mono); font-size: 11px; color: var(--faible); white-space: nowrap; }
.fiche.tache .ech.retard { color: var(--st-rejete); }
.fiche.tache .assigne { font-size: 11px; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===================== ÉTAT VIDE (mascotte) ===================== */
.vide .myra-vide { width: 84px; height: 84px; color: var(--trait-clair); display: block; margin: 0 auto 1rem; }
.vide p { margin: 0; }

/* ===================== PANEL — graphe + listes ===================== */
.panel-actions { display: flex; justify-content: flex-end; }
.chart-wrap { width: 100%; }
.chart { width: 100%; height: 120px; display: block; }
.chart .cbar { fill: var(--iris); opacity: .5; transition: opacity .15s; }
.chart .cbar:hover { opacity: 1; }
.sous-t { color: var(--doux); margin-bottom: .4rem; }
.sous-t.mt { margin-top: .9rem; }
.legende .lg .lg-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doux { color: var(--doux); font-size: .85rem; }
.sessions { display: flex; flex-direction: column; gap: .45rem; }
.session-ligne { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--doux); }
.session-ligne .pt { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.session-ligne .lg-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-ligne .mono { margin-left: auto; }

/* ===================== RESPONSIVE / MOBILE ===================== */
@media (max-width: 760px) {
  /* une seule colonne : le rail passe en barre de navigation en bas */
  .app { grid-template-columns: 1fr; }
  .vue { padding: 1.1rem 1rem 5.5rem; } /* place pour la barre du bas */

  .rail {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; width: 100%;
    flex-direction: row; align-items: center; justify-content: space-around;
    gap: .1rem; padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--trait); z-index: 30;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  #rail-nav { display: contents; } /* ses boutons deviennent des enfants directs de la barre (rangée) */
  .rail .logo, .rail .avatar, .rail-espace { display: none; }
  .rail-btn { flex: 0 0 auto; width: 46px; height: 40px; }
  .rail-btn.actif::before { display: none; }
  .rail-btn.actif { box-shadow: inset 0 -2px 0 var(--iris); }
  .rail-btn .infobulle { display: none; }

  /* en-tête empilé, outils pleine largeur */
  .entete { flex-direction: column; align-items: stretch; gap: .8rem; }
  .entete h1 { font-size: 1.55rem; }
  .outils { width: 100%; }
  .recherche { flex: 1; }
  .recherche input { width: 100%; }

  .stat-grille { grid-template-columns: 1fr 1fr; }
  .stat-blocs { grid-template-columns: 1fr; }
  .grille { grid-template-columns: 1fr; }
  .outils { flex-wrap: wrap; }
  .tri { flex: 1 1 auto; }
  .grille.kanban { gap: .6rem; }
  .kcol { flex-basis: 80vw; }
  dialog { width: 94vw; }
  .modale-pied { flex-direction: column; align-items: stretch; }
  .modale-pied .btn { width: 100%; }
  .modale-pied .transitions { width: 100%; margin-right: 0; justify-content: center; }
}
@media (max-width: 380px) {
  .stat-grille { grid-template-columns: 1fr; }
}
