/* ============================================================
   COMPOSANTS COMMUNS — interface « Panneaux »
   Grille de contenu, en-tête d'écran, et tout composant réutilisé
   par au moins deux modules : boutons, champs, tableaux, pastilles,
   feuilles, modales, messages. Un module ajoute ses styles propres
   dans son propre fichier CSS, jamais ici.

   Correspondance avec la maquette :
     .panel / .sheet      → la « feuille » : carte de papier posée dans
                            le panneau de vue, sans trait, ombre douce
     table.tbl            → le « registre » : en-têtes en petites
                            capitales, lignes séparées par un filet
     .badge               → la pastille d'état (« chip » de la maquette)
     .btn                 → la pastille d'action, .primary = encre
     .note                → le bandeau (ambre = mode dégradé)
     .balance             → la poutre d'équilibre
   Toutes les valeurs viennent de common/tokens.css.
   ============================================================ */

/* ---- Zone principale : le panneau de vue ----
   La coque (header/rail.css) place .main dans la grille ; ici, son
   contenu. Le panneau est blanc, arrondi, et porte des cartes. */
.main { grid-area: main; overflow-y: auto; padding: 0 26px 28px; }
.main::-webkit-scrollbar { width: 10px; }
.main::-webkit-scrollbar-thumb { background: var(--voile2); border-radius: var(--r-pill); border: 3px solid var(--panneau); }
.wrap { max-width: 1480px; margin: 0 auto; }

/* ---- En-tête d'écran (la « tête » de la maquette) ----
   Collée en haut du panneau pendant le défilement : le titre et les
   actions de l'écran restent sous la main. Le fil d'Ariane y est
   injecté par la coque (.fil), au-dessus du titre. */
.head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  margin: 0 -26px 8px; padding: 24px 26px 14px;
  background: var(--panneau);
}
.head > div:not(.acts):not(.fil) { min-width: 0; }
/* Le sur-titre des modules répétait le fil d'Ariane : la coque le
   remplace par le vrai fil, nommé comme la navigation. */
.head .eyebrow { display: none; }
.head h1 { margin: 0; font: 500 var(--fs-xl)/1.12 var(--sans); letter-spacing: -.03em; }
.head p.sub { margin: 7px 0 0; font-size: var(--fs-base); line-height: 1.55; color: var(--encre3); max-width: 66ch; }
.head .acts { margin-left: auto; display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }

/* Fil d'Ariane : poste / écran. */
.fil {
  flex: 1 0 100%; display: flex; align-items: center; gap: 7px; min-width: 0;
  margin-bottom: -10px; font-size: var(--fs-xs); color: var(--encre3);
}
.fil span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* background: none (0.4.13) — la règle générique .sep (filet horizontal,
   plus bas) peignait aussi le fond du « / » de la couleur du caractère :
   le séparateur du fil d'Ariane s'affichait comme un petit pavé gris. */
.fil .sep { color: var(--encre3); background: none; height: auto; flex: 0 0 auto; }
.fil .crumbs-cur { color: var(--encre3); }

/* ---- Écrans d'amorçage (boot.js) ---- */
.bootscreen {
  height: 100vh; display: grid; place-items: center; text-align: center;
  font: 400 13.5px/1.5 var(--sans); color: var(--encre3); background: var(--fond);
}
.bootscreen.bad { color: var(--alerte); }
.bootscreen .t { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.02em; color: var(--encre); margin: 0 0 var(--s3); }
.bootscreen .d { color: var(--encre3); font-size: var(--fs-sm); margin-top: var(--s5); }
.bootscreen .d .mono { font-family: var(--mono); }

/* ---- Voyant ---- */
.led { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--ok); }
.led.warn { background: var(--ambre); } .led.bad { background: var(--alerte); } .led.off { background: var(--voile2); }

/* ============================ FEUILLES ============================ */
.panel {
  background: var(--papier);
  border-radius: var(--r-carte);
  box-shadow: var(--o-carte);
  padding: 16px 18px 18px;
  min-width: 0;
}
.panel.flat { background: var(--papier); }
.panel > .ptitle, .ptitle {
  margin: 0 0 12px; font: 600 var(--fs-md)/1.3 var(--sans); letter-spacing: -.015em; color: var(--encre);
  display: flex; align-items: center; gap: 10px;
}
.ptitle .r { margin-left: auto; font: 400 12px/1.3 var(--sans); letter-spacing: 0; color: var(--encre3); display: flex; gap: 6px; align-items: center; }

.panel + .panel, .panel + .sheet, .sheet + .panel, .sheet + .sheet { margin-top: 12px; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; align-items: start; }
.grid > * { min-width: 0; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; }
.c9 { grid-column: span 9; } .c12 { grid-column: span 12; }
@media (max-width: 1180px) {
  .c3, .c4, .c5 { grid-column: span 6; }
  .c7, .c8, .c9 { grid-column: span 12; }
}
@media (max-width: 899px) {
  .c3, .c4, .c5, .c6, .c7 { grid-column: span 12; }
  .main { padding: 0 12px 24px; }
  .head { position: static; margin: 0 -12px 6px; padding: 18px 12px 10px; }
  .head h1 { font-size: 24px; }
  .head .acts { margin-left: 0; width: 100%; }
  .split { grid-template-columns: 1fr; }
  /* (0.4.13) La règle « .sheet { overflow-x: auto } » vivait ici : elle
     n'a jamais agi, la règle de base .sheet, déclarée PLUS BAS avec la même
     spécificité, l'emportait. Les tableaux défilent maintenant dans leur
     propre cadre (.tablewrap, posé par K.table). */
}
@media (max-width: 599px) {
  .head h1 { font-size: 21px; }
  .head .acts .btn { flex: 1 1 auto; justify-content: center; }
}

/* ============================ BOUTONS ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px;
  border: 0; border-radius: var(--r-pill);
  background: var(--panneau); color: var(--encre);
  box-shadow: 0 0 0 1px var(--trait), var(--o-carte);
  font: 500 13.5px/1 var(--sans); cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--voile); box-shadow: 0 0 0 1px var(--encre3); }
.btn.primary { background: var(--encre); color: var(--panneau); box-shadow: none; }
.btn.primary:hover { background: var(--marque-f); box-shadow: none; }
.btn.ghost { background: none; color: var(--encre2); box-shadow: none; }
.btn.ghost:hover { background: var(--papier); color: var(--encre); }
.btn.danger { color: var(--alerte); }
.btn.danger:hover { background: var(--alerte-voile); box-shadow: 0 0 0 1px var(--alerte); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; gap: 5px; }
/* Bouton réduit à son icône : rond, le sens passe par title/aria-label. */
.btn.icon-seule { padding: 0; width: 38px; height: 38px; justify-content: center; gap: 0; }
.btn.icon-seule.sm { width: 30px; height: 30px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--panneau); box-shadow: 0 0 0 1px var(--trait); }
.btn.primary[disabled]:hover { background: var(--encre); box-shadow: none; }

:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }
.btn:focus-visible, .navitem:focus-visible, .switch:focus-visible, .iconbtn:focus-visible,
.tab:focus-visible, .poste:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--encre); outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ---- Attribut hidden (0.4.9) ----
   Le navigateur ne cache un élément `hidden` que par une règle de très faible
   poids (display:none de sa feuille par défaut). La moindre classe qui pose un
   `display` l'écrase : c'est ce qui rendait inerte la flèche de « Paramètres
   généraux » — `.souslist { display:flex }` gardait la liste ouverte quoi que
   dise l'attribut. Une règle, ici, pour tout le projet. */
[hidden] { display: none !important; }

/* ---- Listes déroulantes (0.4.9) ----
   Les <select> sont transparents pour se fondre dans leur .inp. Sous Windows,
   la liste d'options ouverte retombe alors sur un fond blanc système tout en
   gardant la couleur d'encre du thème : en mode sombre, du gris clair sur du
   blanc, illisible. Les options reçoivent donc des couleurs explicites, et le
   contrôle annonce son schéma pour que le navigateur dessine la liste dans le
   bon thème. */
select { color-scheme: inherit; }
html[data-theme="dark"] select { color-scheme: dark; }
select option, select optgroup { background-color: var(--panneau); color: var(--encre); }
select option:disabled { color: var(--encre3); }

/* ============================ CHAMPS ============================ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: var(--fs-xs); color: var(--encre3); }
.inp {
  display: flex; align-items: center; gap: 8px; min-height: 38px;
  padding: 0 12px; border-radius: var(--r-ctl);
  background: var(--panneau); box-shadow: 0 0 0 1px var(--trait);
  font-size: 13.5px; color: var(--encre);
  transition: box-shadow var(--t-fast);
}
.inp:hover { box-shadow: 0 0 0 1px var(--encre3); }
.inp:focus-within { box-shadow: 0 0 0 2px var(--encre); }
.inp input, .inp select, .inp textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--encre);
  font: 400 13.5px/1.4 var(--sans); outline: none; padding: 9px 0;
}
.inp textarea { resize: vertical; }
.inp select { cursor: pointer; }
.inp input.num, .inp.num input { font-variant-numeric: tabular-nums; text-align: right; }
.inp .unit { font-size: 12px; color: var(--encre3); }
.inp.bad { box-shadow: 0 0 0 1.5px var(--alerte); }
.hint { font-size: var(--fs-xs); line-height: 1.5; color: var(--encre3); }
.hint.bad { color: var(--alerte); }
::placeholder { color: var(--encre3); opacity: .6; }

/* Interrupteur : la « bascule » de la maquette. */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.toggle .sw { width: 42px; height: 24px; flex: 0 0 42px; border-radius: var(--r-pill); background: var(--voile2); position: relative; transition: background var(--t-base); }
.toggle .sw i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: var(--r-dot); background: var(--knob); box-shadow: var(--o-knob); transition: left var(--t-base); }
.toggle[aria-checked="true"] .sw { background: var(--ok); }
.toggle[aria-checked="true"] .sw i { left: 21px; }
.toggle .tl { font-size: 13px; color: var(--encre2); }

/* ============================ TABLEAUX (registre) ============================ */
/* overflow: clip et non hidden (0.4.13) : les coins restent arrondis, mais le
   panneau n'est plus un conteneur de défilement. `hidden` coupait net, en
   mobile, les tableaux plus larges que lui — sans ascenseur. Ce qui déborde
   doit défiler dans son propre cadre (.tablewrap). */
.sheet { background: var(--papier); border-radius: var(--r-carte); overflow: clip; box-shadow: var(--o-carte); min-width: 0; }
.sheet .sheethead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 18px 12px; }
.sheet .sheethead .t { font: 600 var(--fs-md)/1.3 var(--sans); letter-spacing: -.015em; color: var(--encre); }
.sheet .sheethead .r { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--encre3); }
.sheetfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px 14px; font-size: 12px; color: var(--encre3); }
.tablewrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

table.tbl, table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
table.tbl th, table.table th {
  text-align: left; padding: 0 12px; height: 30px;
  font: 500 var(--fs-micro)/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--encre3);
  white-space: nowrap; background: var(--papier);
  position: sticky; top: 0; z-index: 2;
}
table.tbl td, table.table td {
  padding: 6px 12px; height: var(--ligne); border-top: 1px solid var(--trait2);
  vertical-align: middle;
}
table.tbl tbody tr:hover td, table.table tbody tr:hover td { background: var(--voile); }
table.tbl tbody tr[aria-selected="true"] td { background: var(--panneau); }
table.tbl tbody tr[aria-selected="true"] td:first-child { border-radius: 10px 0 0 10px; }
table.tbl tbody tr[aria-selected="true"] td:last-child { border-radius: 0 10px 10px 0; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; text-align: right; white-space: nowrap; }
table.tbl th.num, table.table th.num { letter-spacing: .06em; }
.ref { font: 500 12px/1.2 var(--mono); letter-spacing: -.02em; color: var(--encre2); white-space: nowrap; }
.muted { color: var(--encre3); }
.tot td { font-weight: 600; background: var(--voile2); height: 36px; }
/* Sur le fond plus soutenu d'une ligne de total, le gris atténué passait sous
   le seuil de lecture (4,1:1) : il remonte d'un cran (0.4.13). */
.tot td.muted { color: var(--encre2); }
.clickable { cursor: pointer; }
tr.clsrow td { font-weight: 500; }
tr.detrow td { color: var(--encre2); }
.caret { display: inline-block; width: 12px; color: var(--encre3); }

/* ---- Fil d'intégrité : un nœud par pièce le long du grand livre ---- */
td.thread { width: 26px; padding: 0 0 0 14px; position: relative; }
td.thread::before {
  content: ""; position: absolute; left: 19px; top: 0; bottom: 0; width: 1px;
  background: var(--trait);
}
tr:first-child td.thread::before { top: 50%; }
tr:last-child td.thread::before { bottom: 50%; }
td.thread i {
  position: absolute; left: 15px; top: 50%; margin-top: -4.5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok);
}
td.thread i.draft { background: var(--panneau); box-shadow: inset 0 0 0 1.5px var(--voile2); }
td.thread i.rev { background: var(--ambre); }
tr:hover td.thread i { box-shadow: 0 0 0 3px var(--ok-voile); }
.hashtip { font: 400 11px/1 var(--mono); color: var(--encre3); letter-spacing: -.01em; }

/* ============================ PASTILLES D'ÉTAT ============================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 11px;
  border-radius: var(--r-pill); background: var(--voile2); color: var(--encre2);
  font: 500 11.5px/1 var(--sans); white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-voile); }
.badge.warn { color: var(--ambre); background: var(--ambre-voile); }
.badge.bad { color: var(--panneau); background: var(--alerte); }
.badge.off { color: var(--encre2); background: var(--voile2); }
/* 0.4.25 : pièce échue — rouge clair, à ne pas confondre avec l'annulée (rouge plein). */
.badge.retard { color: var(--alerte); background: var(--alerte-voile); box-shadow: inset 0 0 0 1px var(--alerte); }
/* Deux tons pastel pour les mouvements de stock (0.4.7). Une SORTIE n'est
   pas un avertissement : c'est un fait normal du commerce, et l'ambre la
   rangeait avec les alertes de seuil — un historique où la moitié des lignes
   criait. Rouge pastel pour ce qui part, rose pastel pour ce qui est perdu.
   Deux tons de la même famille, lisibles ensemble, et qui ne se confondent
   pas avec le rouge franc d'un stock épuisé (.badge.bad). */
.badge.sortie { color: var(--sortie); background: var(--sortie-voile); }
.badge.rose   { color: var(--rebut);  background: var(--rebut-voile); }
.badge.solid { background: var(--encre); color: var(--panneau); }
.badge.line { background: transparent; box-shadow: inset 0 0 0 1px var(--trait); }

/* Filtres : des pastilles compactes, l'active est pleine d'encre. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px;
  border: 0; border-radius: var(--r-pill); background: var(--panneau); color: var(--encre);
  box-shadow: 0 0 0 1px var(--trait), var(--o-carte);
  font: 500 12.5px/1 var(--sans); cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--voile); }
.chip[aria-pressed="true"] { background: var(--encre); color: var(--panneau); box-shadow: none; }

/* Onglets : une rangée de pastilles sur fond papier. */
.tabs { display: flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--papier); box-shadow: var(--o-carte); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; text-align: center; padding: 0 14px; height: 32px; border-radius: var(--r-pill);
  font: 400 13px/32px var(--sans); color: var(--encre2); cursor: pointer; border: 0; background: transparent; white-space: nowrap;
}
.tab:hover { color: var(--encre); background: var(--voile); }
.tab[aria-selected="true"] { background: var(--panneau); color: var(--encre); font-weight: 500; box-shadow: 0 0 0 1px var(--trait), var(--o-survol); }

.bar { height: 6px; border-radius: var(--r-pill); background: var(--voile2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--encre); }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--ambre); } .bar.bad > i { background: var(--alerte); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--encre3); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.mono { font-family: var(--sans); }

/* Indicateur : la mesure d'une « bande » de la maquette. */
.stat .lbl { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--encre3); }
.stat .val { margin: 8px 0 0; font: 300 var(--fs-fig)/1.2 var(--sans); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .val small { font: 400 12px/1 var(--sans); color: var(--encre3); margin-left: 6px; letter-spacing: 0; }
.spark { display: flex; align-items: flex-end; gap: 5px; height: 54px; margin-top: 16px; }
.spark i { flex: 1; background: var(--voile2); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.spark i.on { background: var(--encre); }

/* Vide : une invitation à agir, pas une humeur. */
.empty { text-align: center; padding: 48px 26px; max-width: 58ch; margin: 0 auto; color: var(--encre3); }
.empty .ic { width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 50%; background: var(--voile); display: grid; place-items: center; color: var(--encre2); }
.empty h3 { margin: 0 0 8px; font: 600 20px/1.3 var(--sans); letter-spacing: -.02em; color: var(--encre); }
.empty p { margin: 0 auto 18px; font-size: var(--fs-base); line-height: 1.6; color: var(--encre3); max-width: 52ch; }
.empty .row { justify-content: center; flex-wrap: wrap; }

/* Bandeau. La variante .warn est le « mode dégradé » de la maquette. */
.note {
  padding: 14px 18px; border-radius: var(--r-carte); background: var(--voile);
  font-size: 13px; line-height: 1.5; color: var(--encre2);
  display: flex; gap: 12px; align-items: flex-start;
}
.note .led { margin-top: 6px; }
.note.warn { background: var(--ambre-voile); color: var(--ambre); }
.note.bad { background: var(--alerte-voile); color: var(--encre); }
.note.ok { background: var(--ok-voile); color: var(--ok); }
.note b { font-weight: 600; color: inherit; }
.note.bad b { color: var(--alerte); }

/* ============================ SAISIE (grille clavier) ============================ */
.gridsaisie { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.gridsaisie th {
  padding: 0 8px; height: 30px; font: 500 var(--fs-micro)/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--encre3); text-align: left; background: var(--papier);
}
.gridsaisie td { padding: 4px 4px; height: var(--ligne); border-top: 1px solid var(--trait2); vertical-align: middle; }
/* Colonnes débit et crédit teintées, comme dans le registre de la maquette. */
.gridsaisie td:nth-child(6), .gridsaisie th:nth-child(6) { background: var(--debit); }
.gridsaisie td:nth-child(7), .gridsaisie th:nth-child(7) { background: var(--credit); }
.gridsaisie tr[data-active="1"] td { background: var(--voile); }
.gridsaisie .cell {
  width: 100%; height: calc(var(--ligne) - 8px); border: 0; border-radius: 8px; background: transparent; padding: 0 8px;
  font: 400 13.5px/1.2 var(--sans); color: var(--encre); outline: none;
}
.gridsaisie .cell:hover { background: var(--voile); }
.gridsaisie .cell.mono { font: 500 12.5px/1.2 var(--mono); letter-spacing: -.02em; }
.gridsaisie .cell.amount { text-align: right; font-variant-numeric: tabular-nums; }
.gridsaisie .cell:focus { background: var(--panneau); box-shadow: 0 0 0 2px var(--encre); }
.gridsaisie .cell::placeholder { color: var(--encre3); opacity: .5; }
.gridsaisie td.del { width: 34px; text-align: center; }
.gridsaisie td.del button { border: 0; background: transparent; color: var(--encre3); cursor: pointer; font-size: 15px; line-height: 1; padding: 6px; border-radius: 50%; }
.gridsaisie td.del button:hover { color: var(--alerte); background: var(--alerte-voile); }

/* La poutre d'équilibre : barre des totaux, écart en rouge tant qu'il subsiste. */
.balance {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 10px; padding: 12px 18px; border-radius: var(--r-carte);
  background: var(--panneau); box-shadow: 0 0 0 1px var(--trait), var(--o-poutre);
}
.balance .mini { font-size: 11.5px; }
.balance .track { flex: 1 1 160px; height: 8px; border-radius: var(--r-pill); background: var(--voile2); position: relative; overflow: hidden; }
.balance .track i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: var(--r-pill); background: var(--alerte); transition: width var(--t-slow) ease, background var(--t-slow); }
.balance[data-ok="1"] .track i { background: var(--ok); }
.balance .fig { font: 400 18px/1.2 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.balance .verdict { font: 500 12.5px/1 var(--sans); color: var(--alerte); }
.balance[data-ok="1"] .verdict { color: var(--ok); }

.kbdhint { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--encre3); }
kbd {
  font: 500 11px/1 var(--sans); padding: 4px 7px; border-radius: 6px;
  background: var(--panneau); box-shadow: 0 0 0 1px var(--trait); color: var(--encre2);
}

/* ---- Contrôles du moteur ---- */

/* ============================ MODULES (console) ============================ */
.modcard {
  border-radius: var(--r-carte); background: var(--papier); box-shadow: var(--o-carte);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.modcard[data-state="disabled"] { background: none; box-shadow: inset 0 0 0 1px var(--trait); }
.modcard[data-state="disabled"] .modtop .nm { color: var(--encre3); }
.modcard .modtop { display: flex; align-items: flex-start; gap: 11px; }
.modcard .modtop .ic {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--voile2); color: var(--encre2);
}
.modcard[data-state="enabled"] .modtop .ic { background: var(--encre); color: var(--panneau); }
.modcard .modtop .nm { font-size: 14.5px; font-weight: 600; letter-spacing: -.015em; }
.modcard .modtop .lot { font-size: 11.5px; color: var(--encre3); }
.modcard .desc { font-size: 12.5px; line-height: 1.5; color: var(--encre2); min-height: 34px; }
.modcard .meta { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; line-height: 1.45; color: var(--encre3); }
.modcard .meta b { font-weight: 500; color: var(--encre2); }
.modcard .modfoot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 10px; }

.depgraph { display: flex; flex-direction: column; gap: 3px; font: 400 11.5px/1.6 var(--mono); color: var(--encre2); }
.depgraph span.dim { color: var(--encre3); }
.depgraph span.on { color: var(--ok); }
.depgraph span.offc { color: var(--alerte); }

/* ============================ COUCHES FLOTTANTES ============================ */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--voile-modal);
  backdrop-filter: blur(var(--blur-scrim)); -webkit-backdrop-filter: blur(var(--blur-scrim));
  display: grid; place-items: center; padding: var(--s7);
  /* 0.4.13 — UNE PISTE QUI NE S'ÉLARGIT PAS AU CONTENU. Une piste de grille
     implicite est dimensionnée « auto » : elle grandit jusqu'à la largeur
     MINIMALE de son contenu. Un tableau de lignes (720 px minimum) imposait
     donc 720 px à la modale, quelle que soit sa largeur déclarée : en mobile,
     la fiche article faisait 856 px sur un écran de 390, la saisie de
     mouvements 874. minmax(0, 1fr) plafonne la piste à l'écran ; les tableaux
     défilent dans leur propre cadre (.lignes-wrap, .stk-defile). */
  grid-template-columns: minmax(0, 1fr);
}
.modal {
  width: min(520px, 100%); background: var(--panneau);
  min-width: 0; max-width: 100%;
  border-radius: var(--r-pan); box-shadow: var(--o-flot);
  padding: 22px 24px;
}
.modal h2 { margin: 0 0 10px; font: 600 18px/1.3 var(--sans); letter-spacing: -.02em; }
.modal p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.55; color: var(--encre2); }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 16px; }
.modal.wide { width: min(720px, 100%); }
.modal.xwide { width: min(1180px, 100%); }
.modal.plein { width: calc(100vw - 48px); max-width: 1800px; }

/* Le corps défile dans toutes les modales : les actions restent atteignables. */
.modal .mbody {
  max-height: calc(100vh - 210px); overflow-y: auto;
  margin: 0 -24px; padding: 0 24px;
  overscroll-behavior: contain;
}
.modal .mbody::-webkit-scrollbar { width: 10px; }
.modal .mbody::-webkit-scrollbar-thumb { background: var(--voile2); border-radius: var(--r-pill); border: 3px solid var(--panneau); }
/* Une feuille posée dans une modale reste du papier, sur panneau blanc. */
.modal .panel, .modal .sheet { box-shadow: none; }

.permgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s5); }
.permbloc { break-inside: avoid; }
.permbloc .field.inline { align-items: flex-start; }
.permbloc .field.inline > input { margin-top: 2px; flex: 0 0 auto; }
.permbloc .field.inline > span { line-height: 1.35; }
@media (max-width: 760px) { .permgrid { grid-template-columns: 1fr; } }

/* ---- Bandeau d'en-tête d'une pièce ---- */
.piecehead {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; padding: 14px 16px; margin-bottom: 14px;
  background: var(--papier); border-radius: var(--r-carte);
}

/* ---- Lignes d'une pièce ---- */
table.tbl.lignes { table-layout: fixed; }
table.tbl.lignes th, table.tbl.lignes td { padding: 6px 8px; }
table.tbl.lignes tbody tr:hover td { background: transparent; }
/* Proportions revues en 0.4.9. La colonne Article prenait 27 % pour
   afficher « REF · désignation » juste à côté de la colonne Désignation :
   deux fois le même nom, et un prix unitaire tronqué (« 75,000 ») faute de
   place. L'article n'affiche plus que sa REF ; le prix, qui porte le plus de
   chiffres, reçoit la colonne la plus large des nombres. */
table.tbl.lignes .col-art { width: 150px; }
table.tbl.lignes .col-des { width: auto; }
table.tbl.lignes .col-n   { width: 78px; }
table.tbl.lignes .col-pu  { width: 112px; }
table.tbl.lignes .col-pct { width: 72px; }
table.tbl.lignes .col-u   { width: 64px; }
table.tbl.lignes .col-lot { width: 120px; }
table.tbl.lignes .col-date { width: 142px; }
table.tbl.lignes .col-tot { width: 120px; }
table.tbl.lignes .col-x   { width: 40px; }
table.tbl.lignes input[readonly] { background: transparent; box-shadow: none; color: var(--encre2); }
/* Un tableau de saisie ne se comprime pas sous la largeur de ses champs : il
   défile dans sa feuille sur un écran étroit. */
.lignes-wrap { overflow-x: auto; }
.lignes-wrap > table.tbl.lignes { min-width: 720px; }
table.tbl.lignes input, table.tbl.lignes select {
  width: 100%; height: 32px; border: 0; border-radius: 8px;
  padding: 0 9px; background: var(--panneau); color: var(--encre);
  box-shadow: 0 0 0 1px var(--trait);
  font: 400 13px var(--sans); outline: none;
}
table.tbl.lignes input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl.lignes input:focus, table.tbl.lignes select:focus { box-shadow: 0 0 0 2px var(--encre); }

/* ---- Pied de totaux ---- */
.piecetot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 26px; padding: 14px 18px; background: var(--voile); border-radius: var(--r-carte); margin-top: 10px; }
.piecetot .b { text-align: right; display: flex; flex-direction: column; gap: 3px; }
.piecetot .b .l { font-size: 11px; color: var(--encre3); }
.piecetot .b .v { font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: -.01em; }
.piecetot .b.gros .v { font-size: 18px; font-weight: 600; }

/* ---- Messages : une pastille d'encre en bas, au centre ---- */
.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(560px, calc(100vw - 24px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px 12px 20px; border-radius: 22px;
  background: var(--encre); color: var(--panneau); box-shadow: var(--o-flot);
  font-size: 13.5px; line-height: 1.45; max-width: 100%;
  animation: toastin var(--t-base) ease both;
}
.toast .led { margin-top: 6px; }
.toast .x { margin-left: 6px; cursor: pointer; opacity: .6; font-size: 16px; line-height: 1.2; }
.toast .x:hover { opacity: 1; }
.toast.bad { background: var(--alerte); color: var(--panneau); }
.toast.bad .led { background: var(--panneau); }
.toastlien {
  display: block; margin-top: 6px; padding: 0; border: 0; background: none;
  font: inherit; font-weight: 500; color: inherit; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
.toastlien:hover { opacity: .8; }
@keyframes toastin { from { opacity: 0; transform: translateY(16px); } }

/* ---- Réglages (K.reglage, K.interrupteur) ---- */
.interrupteur { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--encre2); }
.interrupteur input { accent-color: var(--encre); margin: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--encre); }

.reglages { display: flex; flex-direction: column; }
.reglage {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--trait2);
}
.reglage:first-child { border-top: 0; }
.rg-libelle { font-size: 13px; color: var(--encre2); min-width: 168px; }
.rg-controle { display: flex; align-items: center; gap: 8px; }
.rg-controle .inp { min-width: 230px; }

.rg-info {
  position: relative; cursor: help; flex: 0 0 auto;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--voile2); color: var(--encre2);
  font: 600 10px/18px var(--sans); text-align: center;
  align-self: center;
}
.rg-info:hover, .rg-info:focus-visible { background: var(--encre); color: var(--panneau); }
.rg-bulle {
  position: absolute; left: -10px; top: calc(100% + 8px);
  width: 320px; max-width: 70vw; z-index: 30;
  background: var(--encre); color: var(--panneau);
  border-radius: 12px; box-shadow: var(--o-flot); padding: 11px 14px;
  font: 400 12px/1.55 var(--sans); text-align: left;
  /* display: none au repos (0.4.13), et non plus visibility: hidden. Une
     bulle invisible gardait sa place dans la mise en page : elle élargissait
     la page de Paramètres généraux en mobile (+207 px) et créait un
     défilement horizontal fantôme dans les modales (+235 px). Le fondu est
     conservé par une animation, qui, elle, joue à l'apparition. */
  display: none;
  pointer-events: none;
}
.rg-info:hover .rg-bulle, .rg-info:focus .rg-bulle, .rg-info:focus-visible .rg-bulle {
  display: block; animation: rg-apparait var(--t-fast) ease-out;
}
@keyframes rg-apparait { from { opacity: 0; } to { opacity: 1; } }
/* K.info : le « i » posé seul dans un titre ou une ligne de texte. */
.rg-info-seul { display: inline-block; vertical-align: middle; margin-left: 6px; text-transform: none; letter-spacing: 0; }
.rg-info-seul .rg-bulle { font-weight: 400; }
/* Un « i » qui suit le titre d'un écran reste sur la même ligne que lui. */
.head h1:has(+ .rg-info-seul) { display: inline-block; }
.head h1 + .rg-info-seul { margin-left: 8px; vertical-align: 6px; }
@media (prefers-reduced-motion: reduce) { .rg-info:hover .rg-bulle, .rg-info:focus .rg-bulle { animation: none; } }
.sheet-reglages { overflow: visible; }

/* ---- Palette de commandes ---- */
.modal.palette { width: min(640px, 100%); align-self: start; margin-top: 13vh; padding: 0; overflow: hidden; }
.palette .inp { min-height: 58px; padding: 0 20px; border-radius: 0; background: none; box-shadow: none; color: var(--encre3); }
.palette .inp input { font-size: 15.5px; }
.palette .plist { max-height: 48vh; overflow-y: auto; padding: 6px 8px 8px; }
.palette .pitem { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px; cursor: pointer; font-size: 14px; color: var(--encre); }
.palette .pitem svg { color: var(--encre3); flex: 0 0 auto; }
.palette .pitem[aria-selected="true"], .palette .pitem:hover { background: var(--papier); }
.palette .pitem .g { margin-left: auto; font-size: 11.5px; color: var(--encre3); white-space: nowrap; }
.palette .pfoot { display: flex; gap: 16px; padding: 10px 20px; font-size: 11.5px; color: var(--encre3); background: var(--papier); }
@media (max-width: 599px) { .modal.palette { margin-top: 6vh; } }

/* ============================ COMPOSANTS PARTAGÉS ============================
   Classes appelées par les fonctions de rendu du noyau (K.table, K.sheet,
   K.tabs, K.kv, K.chips, K.field…). */

/* ---- Rythme vertical ---- */
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack.xs { gap: var(--s1); }
.stack.sm { gap: var(--s3); }
.stack.lg { gap: var(--s5); }

.mt { margin-top: var(--s4); }
.mt.sm { margin-top: var(--s3); }
.mt.lg { margin-top: var(--s5); }
.mb { margin-bottom: var(--s4); }
.mb.sm { margin-bottom: var(--s3); }
.mb.lg { margin-bottom: var(--s5); }
.my { margin: var(--s4) 0; }

.row.sm { gap: var(--s3); }
.row.lg { gap: var(--s5); }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.spread { justify-content: space-between; }
.push { margin-left: auto; }

.txt-xs { font-size: var(--fs-xs); }
.txt-sm { font-size: var(--fs-sm); }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--ambre); }
.tone-bad { color: var(--alerte); }

td.tblvide { padding: var(--s7) var(--s5); color: var(--encre3); font-size: var(--fs-sm); text-align: center; }

/* ---- Champs (K.field, K.formRow) ---- */
.field > span:first-child { font-size: var(--fs-xs); color: var(--encre3); }
.formrow { display: flex; gap: var(--s4); align-items: flex-end; }
.field.inline { flex-direction: row; align-items: center; gap: var(--s3); }
.field.inline > span:first-child { font-size: 13px; color: var(--encre2); }
.formrow > .field { flex: 1; min-width: 0; }
@media (max-width: 760px) { .formrow { flex-direction: column; align-items: stretch; } }

/* Cadre compact des lignes éditables de tableau. */
.inp.sm { min-height: 30px; padding: 0 var(--s3); border-radius: var(--s3); }
.inp.sm input, .inp.sm select { padding: 5px 0; font-size: 13px; }

/* ---- Onglets (K.tabs) ---- */
.tabs.left .tab { flex: 0 0 auto; }
.tabs.left { display: inline-flex; max-width: 100%; }
.tabs.wrap { flex-wrap: wrap; border-radius: 18px; }
.ecran-onglet { margin-top: var(--s4); }
.tab .cnt { margin-left: var(--s2); display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--voile2); color: var(--encre2); font: 500 10.5px/20px var(--sans); text-align: center; }
.tab[disabled] { opacity: .45; cursor: not-allowed; }

/* ============================ DIVERS ============================ */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrapgap { display: flex; flex-wrap: wrap; gap: 10px; }
.sep { height: 1px; background: var(--trait); }
/* .mono reste la fonte des CODES (comptes, pièces, dates courtes). */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mini { font: 400 11.5px/1.3 var(--sans); color: var(--encre3); }
.right { text-align: right; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--r-pill); background: var(--voile2); font: 500 11px/1 var(--sans); color: var(--encre2); white-space: nowrap; }


.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .s { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 500 11px/1 var(--sans); background: var(--voile); color: var(--encre3); }
.stepper .s.on { background: var(--encre); color: var(--panneau); }
.stepper .l { flex: 1; height: 2px; border-radius: 2px; background: var(--voile2); }
.stepper .l.on { background: var(--encre); }

/* Emplacement réservé : hachures douces, comme un maillon sauté. */
.ph {
  border-radius: var(--r-carte);
  background: repeating-linear-gradient(135deg, var(--voile) 0 7px, var(--voile2) 7px 14px);
  display: grid; place-items: center; color: var(--encre3);
  font: 500 12px/1 var(--sans);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ---- Chargement ---- */
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--voile) 25%, var(--voile2) 37%, var(--voile) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media print {
  .main { overflow: visible; padding: 0; }
  .head { position: static; }
  .panel, .sheet { break-inside: avoid; box-shadow: none; }
}

/* ---- Écran à onglets pilotés par le volet (0.4.9) ---- */
.onglets-mobile { display: none; margin: 0 0 14px; max-width: 360px; }
@media (max-width: 899px) { .onglets-mobile { display: block; } }

/* ---- Clavier (0.4.18) ------------------------------------------------------
   Tableaux focalisables : le cadre du focus au clavier, la cellule active,
   la sélection rectangulaire. Les touches, dans la liste des raccourcis et
   les bulles du volet. */
.tbl[data-grille]:focus { outline: none; }
.tbl[data-grille]:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }
.tbl td.kbd-sel { background: var(--trait); }
.tbl:focus td.kbd-cur, .tbl:focus-within td.kbd-cur { box-shadow: inset 0 0 0 2px var(--encre); }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 4px;
  background: var(--panneau); box-shadow: 0 0 0 1px var(--trait), 0 1px 0 1px var(--trait);
  font: 600 11px/1.6 var(--police-mono, ui-monospace, monospace); color: var(--encre); text-align: center;
}
.kbd-plus { margin: 0 3px; color: var(--encre3); font-size: 11px; }
.kbd-ou { margin: 0 4px; color: var(--encre3); font-size: var(--fs-xs); }
.kbd-groupes { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px 24px; }
.kbd-groupes h3 { font-size: var(--fs-sm); margin: 0 0 8px; }
.kbd-liste { border-collapse: collapse; width: 100%; }
.kbd-liste th, .kbd-liste td { padding: 5px 6px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--trait); }
.kbd-liste th { font-weight: 400; white-space: nowrap; width: 1%; }
.kbd-liste td { font-size: var(--fs-sm); }
.kbd-reglage th { font-weight: 600; width: 30%; }
.kbd-corps { margin-top: 14px; }
.bulle kbd { margin-left: 6px; }

/* ---- Boutons réduits à leur icône (.btn.icone-revele) ----
   Nés au poste Stock (0.4.6), communs depuis 0.4.19 : le poste Achats reprend
   le même en-tête. Le libellé se déplie au survol et au focus clavier ; le nom
   reste porté par `title` et `aria-label`. */
.btn.icone-revele { padding: 0 12px; gap: 0; }
/* Deux fois plus lent que les transitions courantes du noyau (0.4.7) : le
   libellé n'est pas un état qui bascule, c'est un mot qu'on lit. À la vitesse
   d'un survol de bouton, il apparaissait et disparaissait avant qu'on ait eu
   le temps de le voir — l'effet était nerveux et n'informait pas. */
.btn.icone-revele .lb {
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  transition: max-width 360ms ease, opacity 260ms ease,
              margin-left 360ms ease;
}
.btn.icone-revele:hover .lb, .btn.icone-revele:focus-visible .lb,
.btn.icone-revele:focus-within .lb { max-width: 10rem; opacity: 1; margin-left: 7px; }
@media (prefers-reduced-motion: reduce) { .btn.icone-revele .lb { transition: none; } }

/* ---- Tri par colonne (0.4.25) ---- */
.th-tri { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit;
  letter-spacing: inherit; text-transform: inherit; }
.th-tri::after { content: ''; display: inline-block; width: 9px; font-size: 9px; line-height: 1; opacity: .45; }
.th-tri:hover::after { content: '↕'; }
th[aria-sort="ascending"] .th-tri::after { content: '▲'; opacity: 1; }
th[aria-sort="descending"] .th-tri::after { content: '▼'; opacity: 1; }
.th-tri:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; border-radius: 3px; }
table.tbl:not([data-tri-k]):not(.lignes) thead th { cursor: pointer; }
table.tbl:not([data-tri-k]) thead th[aria-sort="ascending"]::after { content: ' ▲'; font-size: 9px; }
table.tbl:not([data-tri-k]) thead th[aria-sort="descending"]::after { content: ' ▼'; font-size: 9px; }

/* 0.5.0.P1 (AUD) lot 2 — code provisoire affiché une seule fois (common/comptes.js). */
.cpte-code {
  font: 600 24px/1.2 var(--mono); letter-spacing: .12em; text-align: center;
  padding: 14px; margin: 4px 0 12px; border-radius: 10px; background: var(--voile); user-select: all;
}
