/* ============================================================
   COQUE — barre de contexte, rail des postes, volet, vue
   Spécifique à la coque : aucun module n'émet ces classes.
   Maquette « Panneaux » : des panneaux qui flottent sur le fond,
   séparés par du vide ; le rail sombre ancre toute la fenêtre.

   Trois régimes selon la largeur (valeurs de --bp-* en clair, var()
   étant interdit dans @media) :
     ≥ 1200 px   colonne   rail + volet + vue côte à côte
     900–1199    flottant  le volet recouvre la vue, à la demande
     < 900       onglets   rail et volet deviennent deux rangées
                           horizontales au-dessus de la vue
   ============================================================ */

/* ---- Grille racine ----
   data-rail = wide (volet ouvert) | icons (volet replié) | hidden
   data-flottant = 1 : volet déplié par-dessus la vue (régime flottant) */
.app {
  position: relative; z-index: 1;
  height: 100vh;
  display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 62px 252px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "rail volet main";
}
.app[data-rail="icons"] { grid-template-columns: 62px 0 minmax(0, 1fr); }
.app[data-rail="icons"] .volet { display: none; }
.app[data-rail="hidden"] { grid-template-columns: 0 0 minmax(0, 1fr); column-gap: 0; }
.app[data-rail="hidden"] .rail, .app[data-rail="hidden"] .volet { display: none; }

/* La vue : un panneau blanc qui porte des cartes. */
.app > .main { background: var(--panneau); border-radius: var(--r-pan); box-shadow: var(--o-pan); }

/* ============================ BARRE DE CONTEXTE ============================ */
.ctx {
  grid-area: top; display: flex; align-items: center; gap: 6px; min-height: 56px; min-width: 0;
  padding: 8px 10px 8px 8px;
  background: var(--panneau); border-radius: var(--r-pan); box-shadow: var(--o-pan);
}
.ctx-dossier {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px;
  flex: 0 1 auto; min-width: 0; max-width: 300px;
  background: var(--papier); border: 0; border-radius: var(--r-pill); text-align: left; color: var(--encre);
}
button.ctx-dossier { cursor: pointer; }
button.ctx-dossier:hover { background: var(--voile2); }
.puce {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; display: grid; place-items: center;
  background: var(--encre); color: var(--panneau); font: 600 12px/1 var(--sans); letter-spacing: .01em;
}
.ctx-nom { min-width: 0; }
.ctx-nom b { display: block; font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-nom small { display: block; color: var(--encre3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-dossier .chev { color: var(--encre3); margin-left: auto; display: grid; }

.ctx-exo { display: flex; align-items: center; gap: 8px; padding: 0 6px; min-width: 0; overflow: hidden; flex: 0 1 auto; }
.exo-item {
  display: flex; align-items: baseline; gap: 6px; padding: 6px 13px; border-radius: var(--r-pill);
  background: var(--papier); white-space: nowrap; flex: 0 0 auto;
}
.exo-item > span { font-size: 11px; color: var(--encre3); }
.exo-item strong { font: 500 12.5px/1.3 var(--sans); font-variant-numeric: tabular-nums; }
.verrou { display: inline-flex; align-items: center; gap: 5px; color: var(--encre); }
.verrou svg { align-self: center; }
/* Sélecteur posé dans une pastille : il en prend l'allure, la flèche native
   est remplacée par le chevron de la maquette. */
.exo-choix { position: relative; align-items: center; cursor: pointer; padding-right: 30px; }
.exo-choix:hover { background: var(--voile2); }
.exo-choix select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer;
  font: 500 12.5px/1.3 var(--sans); color: var(--encre); padding: 0; max-width: 190px; outline: none;
}
.exo-choix:focus-within { box-shadow: 0 0 0 2px var(--encre); }
.exo-choix > svg { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--encre3); pointer-events: none; }

.ctx-recherche { flex: 1 1 180px; min-width: 150px; display: flex; align-items: center; padding: 0 6px; }
.recherche {
  flex: 1 1 0; min-width: 0; max-width: 420px; display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill); background: var(--papier); color: var(--encre3); cursor: text; font-size: 13px; text-align: left;
}
.recherche:hover { background: var(--voile2); }
.recherche > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recherche kbd { margin-left: auto; flex: 0 0 auto; white-space: nowrap; background: var(--panneau); box-shadow: none; color: var(--encre3); }

.ctx-outils { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }

/* Bouton rond d'outil. Les modules en déposent aussi (K.boutonBarre). */
.iconbtn {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; color: var(--encre2); cursor: pointer; position: relative;
}
.iconbtn:hover { background: var(--papier); color: var(--encre); }
.iconbtn[aria-pressed="true"], .iconbtn[aria-expanded="true"] { background: var(--encre); color: var(--panneau); }
.iconbtn .dot {
  position: absolute; top: 5px; right: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--alerte); border: 2px solid var(--panneau); box-sizing: content-box;
}
/* Pastille CHIFFRÉE : le nombre est l'information utile. */
.iconbtn .dot.nb {
  width: auto; min-width: 16px; height: 16px; top: 1px; right: 1px; padding: 0 4px; box-sizing: border-box;
  border-radius: var(--r-pill); color: var(--panneau); font: 600 10px/12px var(--sans); text-align: center;
}
.iconbtn.sm { width: 26px; height: 26px; flex: 0 0 26px; font-size: 13px; line-height: 1; }
.iconbtn.sm[disabled] { opacity: .35; cursor: not-allowed; }

/* Profil : bouton + menu de compte (0.4.9). */
.moi-zone { position: relative; flex: 0 0 auto; margin-left: 4px; }
.moi {
  display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 6px; flex: 0 0 auto;
  border: 0; border-radius: 12px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.moi:hover, .moi[aria-expanded="true"] { background: var(--voile); }
.moi-chev { color: var(--encre3); display: grid; place-items: center; }
.moi-voile { position: fixed; inset: 0; z-index: 70; }
.moi-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 71; min-width: 260px;   /* 0.5.0.P1 : « Changer mon mot de passe » sur une ligne */
  background: var(--panneau); border-radius: 14px; box-shadow: var(--o-flot), 0 0 0 1px var(--trait);
  padding: 6px;
}
.moi-menu-tete { padding: 8px 10px 10px; border-bottom: 1px solid var(--trait2); margin-bottom: 4px; }
.moi-menu-tete b { display: block; font-size: 13px; font-weight: 500; }
.moi-menu-tete small { display: block; font-size: 11.5px; color: var(--encre3); }
.moi-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 9px; background: none; cursor: pointer;
  font: 400 13px var(--sans); color: var(--encre); text-align: left;
}
.moi-item:hover, .moi-item:focus-visible { background: var(--alerte-voile); color: var(--alerte); }
/* 0.5.0.P1 (AUD) lot 2 : gestes du compte (mot de passe, invitations). Le rouge reste à la déconnexion. */
.moi-item.neutre:hover, .moi-item.neutre:focus-visible { background: var(--voile); color: var(--encre); }
.moi-pastille {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--alerte); color: var(--panneau); font: 600 10.5px/18px var(--sans); text-align: center;
}
.moi { position: relative; }
.moi-dot {
  position: absolute; top: 0; left: 26px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: var(--r-pill); background: var(--alerte); border: 2px solid var(--panneau); color: var(--panneau);
  font: 600 10px/12px var(--sans); text-align: center;
}
.moi .av {
  width: 32px; height: 32px; border-radius: 50%; background: var(--encre); color: var(--panneau);
  display: grid; place-items: center; font: 600 12px/1 var(--sans);
}
.moi b { font-size: 13px; font-weight: 500; display: block; white-space: nowrap; }
.moi small { font-size: 11px; color: var(--encre3); display: block; white-space: nowrap; }

/* ============================ RAIL DES POSTES ============================ */
.rail {
  grid-area: rail; background: var(--rail); border-radius: var(--r-pan);
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0;
  overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail hr { width: 20px; height: 1px; background: var(--rail-trait); border: 0; margin: 6px 0; flex: 0 0 1px; }
.rail hr.railpied { margin-top: auto; }
.poste {
  width: 44px; height: 44px; flex: 0 0 44px; border: 0; background: none; border-radius: 14px;
  display: grid; place-items: center; cursor: pointer; color: var(--rail-encre); position: relative;
}
.poste:hover { background: var(--rail-actif); color: var(--rail-vif); }
.poste[aria-current="true"] { background: var(--poste-actif-fond); color: var(--poste-actif-texte); }
.poste[data-etat="off"] { opacity: .38; }
.poste[data-etat="off"]::after { content: ""; position: absolute; left: 11px; right: 11px; top: 21px; height: 1px; background: currentColor; transform: rotate(-35deg); }
.poste .pt { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--ambre); }
.poste:focus-visible { outline-color: var(--rail-vif); }
/* L'étiquette du poste, au survol. Position fixe : le rail défile, une
   bulle en position absolue y serait rognée. */
.poste .bulle {
  position: fixed; left: 76px; transform: translateY(-50%) scale(.96); transform-origin: left center;
  margin-top: 22px; white-space: nowrap; background: var(--encre); color: var(--panneau);
  font-size: 12px; padding: 6px 10px; border-radius: 8px; opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast); z-index: 40; box-shadow: var(--o-flot);
}
.poste:hover .bulle, .poste:focus-visible .bulle { opacity: 1; transform: translateY(-50%) scale(1); }

/* ============================ VOLET DES ÉCRANS ============================ */
.volet {
  grid-area: volet; background: var(--panneau); border-radius: var(--r-pan); box-shadow: var(--o-pan);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.volet-tete { padding: 20px 18px 14px; }
.volet-tete h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.volet-tete p { margin: 4px 0 0; font-size: 12px; color: var(--encre3); line-height: 1.45; }
.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--voile2); border-radius: var(--r-pill); border: 2px solid var(--panneau); }
.navitem {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; flex: 0 0 auto;
  border-radius: 12px; color: var(--encre2); font-size: 13.5px; cursor: pointer; text-decoration: none;
}
.navitem:hover { background: var(--voile); color: var(--encre); }
.navitem[aria-current="page"] {
  background: var(--panneau); color: var(--encre); font-weight: 500;
  box-shadow: 0 0 0 1px var(--trait), var(--o-survol);
}
.navitem .lb { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navitem .cnt {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  background: var(--voile2); color: var(--encre2); font: 500 11px/22px var(--sans); text-align: center;
}
.navitem .cnt[data-ton="alerte"] { background: var(--alerte); color: var(--panneau); }
.navitem .cnt[data-ton="ambre"] { background: var(--ambre-voile); color: var(--ambre); }
/* ---- Sous-liste dépliable d'un écran (0.4.7) ----
   « Paramètres généraux » porte dix-sept onglets. Les atteindre demandait
   d'ouvrir l'écran puis de chercher : ils se déplient maintenant sous leur
   écran, dans le volet, derrière une flèche. Repliés par défaut — le volet
   reste une liste d'écrans, pas un sommaire. */
.navgroupe { position: relative; display: flex; align-items: center; flex: 0 0 auto; }
.navgroupe > .navitem { padding-right: 40px; }
/* La flèche est posée AU BOUT de l'entrée qu'elle déplie (0.4.9). Bouton
   distinct du lien : cliquer le libellé ouvre l'écran, cliquer la flèche
   ne fait que plier. */
.volet-plier {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--encre3);
}
.volet-plier:hover { background: var(--voile2); color: var(--encre); }
.volet-plier svg { transition: transform 240ms ease; }
.volet-plier[aria-expanded="true"] svg { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .volet-plier svg { transition: none; } }

.souslist { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 22px;
  padding-left: 10px; border-left: 1px solid var(--trait); }
.sousitem {
  padding: 5px 10px; border-radius: 8px; font-size: 12.5px; color: var(--encre3);
  text-decoration: none; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sousitem:hover { background: var(--voile); color: var(--encre); }
.sousitem[aria-current="true"] { color: var(--encre); font-weight: 500; background: var(--voile2); }

.volet-vide { margin: 4px 12px; font-size: 12.5px; color: var(--encre3); }
.volet-pied { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: var(--encre3); line-height: 1.55; }
.volet-pied b { font-weight: 600; color: var(--ambre); }

/* ============================ EN-TÊTE RÉDUIT AU FIL ============================ */
.head.head-fil { padding-bottom: 6px; }
.head.head-fil .fil { margin-bottom: 0; }

/* ============================ TABLEAU DE BORD ============================ */
/* Bande d'indicateurs : autant de cartes que de mesures. */
.bande { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.bande > .stat { background: var(--papier); border-radius: var(--r-carte); padding: 16px 18px; box-shadow: var(--o-carte); min-width: 0; }
.bande .stat .val small { white-space: nowrap; }

.dashwrap { position: relative; }
.dashwrap > .panel, .dashwrap > section, .dashwrap > .bande { outline: 1.5px dashed var(--encre3); outline-offset: 4px; }
.dashbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 5px 6px 5px 12px; border-radius: var(--r-pill); background: var(--voile);
}

/* ============================ FILE DES FAITS ============================ */
.voile-faits { position: fixed; inset: 0; z-index: 61; }
.faits {
  position: fixed; top: 10px; right: 10px; bottom: 10px; width: 372px; max-width: calc(100vw - 20px); z-index: 62;
  background: var(--panneau); border-radius: var(--r-pan); box-shadow: var(--o-flot);
  display: flex; flex-direction: column; animation: faitsin var(--t-base) ease both;
}
@keyframes faitsin { from { transform: translateX(calc(100% + 16px)); } }
.faits > header { display: flex; align-items: center; gap: 10px; padding: 18px 12px 12px 18px; }
.faits > header h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.faits > header .iconbtn { margin-left: auto; }
.faits .liste { overflow-y: auto; padding: 0 10px 10px; flex: 1 1 auto; }
.faits-t { margin: 10px 12px 4px; font-size: 11.5px; color: var(--encre3); }
.faits-vide { margin: 8px 12px; font-size: 13px; color: var(--encre3); line-height: 1.55; }
.fait { display: grid; gap: 5px; padding: 12px; border-radius: 12px; justify-items: start; }
.fait:hover { background: var(--papier); }
button.fait { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; color: var(--encre); }
.fait .l1 { display: flex; align-items: center; gap: 8px; width: 100%; }
.fait .ev { font: 500 12px/1 var(--mono); }
.fait .ev-tx { font-size: 13px; font-weight: 500; }
.fait .h { margin-left: auto; font-size: 11.5px; color: var(--encre3); }
.fait p { margin: 0; font-size: 12.5px; color: var(--encre2); }
.faits > footer {
  display: grid; gap: 10px; justify-items: start;
  padding: 16px 18px; font-size: 11.5px; color: var(--encre3); line-height: 1.55;
  background: var(--papier); border-radius: 0 0 var(--r-pan) var(--r-pan);
}

/* ============================ ADAPTATIF ============================ */
@media (max-width: 1600px) {
  .exo-dossier { display: none; }
}
@media (max-width: 1440px) {
  .exo-devise { display: none; }
}
@media (max-width: 1199px) {
  /* Régime « flottant » : le volet ne pousse plus la vue, il la recouvre. */
  .exo-verrou { display: none; }
  .ctx-recherche { flex: 0 0 auto; }
  .recherche { width: 36px; max-width: 36px; flex: 0 0 36px; justify-content: center; padding: 0; }
  .recherche span, .recherche kbd { display: none; }
  .moi small { display: none; }
  .app, .app[data-rail="icons"], .app[data-rail="wide"] { grid-template-columns: 62px 0 minmax(0, 1fr); }
  .app .volet { display: none; }
  .app[data-flottant="1"] .volet {
    display: flex; position: fixed; left: 82px; top: 86px; bottom: 10px; width: 252px; z-index: 30; box-shadow: var(--o-flot);
  }
  .app[data-rail="hidden"] { grid-template-columns: 0 0 minmax(0, 1fr); }
  .app[data-rail="hidden"] .volet { display: none; }
}
@media (max-width: 899px) {
  /* Régime « onglets » : tout s'empile, la page défile en entier. */
  body { overflow-x: hidden; overflow-y: auto; }
  .app, .app[data-rail] {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "top" "rail" "volet" "main";
    height: auto; min-height: 100vh; gap: 8px; padding: 8px;
  }
  .ctx { flex-wrap: wrap; position: sticky; top: 8px; z-index: 20; }
  .ctx-dossier { width: 100%; max-width: none; }
  .ctx-exo { flex: 1; overflow-x: auto; scrollbar-width: none; }
  .ctx-exo::-webkit-scrollbar { display: none; }
  .ctx-volet { display: none; }
  .moi .moi-tx { display: none; }

  .app[data-rail] .rail { display: flex; flex-direction: row; overflow-x: auto; padding: 8px; gap: 6px; border-radius: var(--r-carte); }
  .rail hr { width: 1px; height: 26px; margin: 0 4px; flex: 0 0 1px; align-self: center; }
  .rail hr.railpied { margin: 0 4px 0 auto; }
  .app .poste .bulle { display: none; }

  .app[data-rail] .volet, .app[data-flottant] .volet {
    display: flex; position: static; width: auto; flex-direction: row; box-shadow: var(--o-pan);
    border-radius: var(--r-carte); overflow-x: auto; scrollbar-width: none;
  }
  .volet::-webkit-scrollbar { display: none; }
  .volet-tete, .volet-pied { display: none; }
  .nav { flex-direction: row; gap: 6px; padding: 8px; overflow: visible; }
  .navitem { width: auto; white-space: nowrap; }
  .navgroupe > .navitem { padding-right: 12px; }
  .volet-plier, .souslist { display: none !important; }

  .app > .main { overflow: visible; border-radius: var(--r-carte); }
  .faits { left: 8px; right: 8px; top: 8px; bottom: 8px; width: auto; animation-name: faitsbas; }
  @keyframes faitsbas { from { transform: translateY(calc(100% + 16px)); } }
}
@media (max-width: 599px) {
  .ctx-exo { display: none; }
  .bande { grid-template-columns: 1fr; }
  .bande > .stat { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .bande .stat .val { margin-top: 0; font-size: 20px; }
}
@media (pointer: coarse) {
  .iconbtn { width: 40px; height: 40px; flex-basis: 40px; }
  .poste .bulle { display: none !important; }
}
@media print {
  .rail, .volet, .ctx, .faits, .toasts { display: none !important; }
  body { overflow: visible; background: var(--impression-fond); }
  .app, .app[data-rail] { display: block; height: auto; padding: 0; }
  .app > .main { box-shadow: none; }
}
