/* ── Le Chai · design system sombre chaleureux ─────────────────────────── */
:root {
  --bg: #1C1510;            /* surface validée (contraste ramp ≥ 3:1) */
  --bg-raised: #262019;
  --bg-card: #2B241B;
  --line: #3C3428;
  --ink: #F2E9DC;
  --ink-2: #C7B9A4;
  /* --ink-3 : contraste WCAG vérifié (luminance relative, formule WCAG 2.x).
     Ancien #94876F : 4.34:1 sur --bg-card #2B241B → insuffisant pour du texte < 18px (seuil AA 4.5:1).
     Nouveau #9C8F76 : 4.82:1 sur --bg-card, 5.67:1 sur --bg, 5.07:1 sur --bg-raised → AA partout,
     même famille de bruns chauds (un cran plus clair, teinte inchangée). */
  --ink-3: #9C8F76;
  --accent: #D08A55;   /* cuivre de la marque, version claire pour le fond sombre (5,6:1 sur carte) */
  --warn: #E4572E;
  --ok: #7FB069;
  --bg-nav: #171009;        /* fond de la barre de navigation */
  /* UNE seule encre sur or : le texte posé sur --accent (boutons, badges,
     cellules chaudes). #1C1510 retenu — le plus sombre des trois qui
     coexistaient (#241C13 / #1C1510 / #241A0E), donc le plus lisible. */
  --encre-sur-or: #1C1510;
  /* ramp âge — validé validate_palette.js (dark, #1C1510) */
  --age-0: #F5E3B3; --age-1: #EBC878; --age-2: #DFA94D;
  --age-3: #C98A38; --age-4: #AC6F2B; --age-5: #935E26;
  /* --radius (cartes) et --radius-controle (boutons, champs) : alias des
     jetons --r-m / --r-s déclarés dans polices.css, communs aux deux thèmes. */
  /* ── Rythme d'espacement — grille 4/8 (paliers 4·8·12·16·20·24·32·48) ── */
  --esp-1: 4px; --esp-2: 8px; --esp-3: 12px; --esp-4: 16px;
  --esp-5: 20px; --esp-6: 24px; --esp-7: 32px; --esp-8: 48px;
  --gouttiere: 28px;   /* gouttière horizontale des écrans (multiple de 4) */
  --carte-pad: 16px;   /* LE padding de carte — une seule valeur partout */
  /* ── Rôles typographiques, alias de l'échelle --t-* (polices.css) ──
     héros d'assistant/document · titre d'écran & de modale ·
     titre de section & de carte · titre de tuile/sous-carte. */
  --titre-0: var(--t-2xl); --titre-1: var(--t-xl); --titre-2: var(--t-l); --titre-3: var(--t-base);
  --hint: var(--t-s);  /* texte secondaire : UNE taille, encre --ink-3 */
  --serif: "Iowan Old Style", "Palatino", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  /* ── Échelle d'élévation unique — ombres chaudes (noir brun #0A0603, jamais
     de gris bleuté) + liseré haut « matière » intégré (inset 1px clair).
     --ombre-1 : carte posée · --ombre-2 : survolée / menu / tooltip · --ombre-3 : modale. */
  --ombre-1: inset 0 1px 0 rgba(255,255,255,.04), 0 1px 2px rgba(10,6,3,.35), 0 3px 10px rgba(10,6,3,.20);
  --ombre-2: inset 0 1px 0 rgba(255,255,255,.05), 0 4px 12px rgba(10,6,3,.42), 0 12px 32px rgba(10,6,3,.28);
  --ombre-3: inset 0 1px 0 rgba(255,255,255,.05), 0 18px 44px rgba(10,6,3,.55), 0 34px 90px rgba(10,6,3,.42);
  font-size: var(--t-base);
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .stat-value, .nav-title, .connexion-titre { font-family: var(--serif); }

/* ── Résumés dépliables : un chevron SVG commun à la place du triangle natif ──
   Les blocs qui ont déjà leur propre repère (+/−, chevron maison) sont exclus.
   Valable pour les deux thèmes : vit donc ici, pas dans theme-clair.css. */
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
:where(details:not(.aide-terme, .anx-prov, .drm-compte, .fil-notes-bloc, .lot-notes-detail,
    .prod-parcours-complet, .mat-complements, .fp-panel, .fp-inner, .phys-plus, .menu-deroulant)) > summary::before {
  content: ""; display: inline-block; flex: none; vertical-align: -2px;
  width: 14px; height: 14px; margin-inline-end: 8px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .15s ease;
}
:where(details[open]:not(.aide-terme, .anx-prov, .drm-compte, .fil-notes-bloc, .lot-notes-detail,
    .prod-parcours-complet, .mat-complements, .fp-panel, .fp-inner, .phys-plus, .menu-deroulant)) > summary::before {
  transform: rotate(90deg);
}
@media (prefers-reduced-motion: reduce) { summary::before { transition: none; } }

/* « En savoir plus » : l'explication d'un écran repliée sous le geste et le
   chiffre (Stocks, DRM). Résumé de 44 px, chevron commun ci-dessus. */
.en-savoir-plus { margin-top: 4px; }
.en-savoir-plus > summary {
  display: inline-flex; align-items: center; min-height: 44px; cursor: pointer;
  color: var(--ink-2); font-size: var(--t-s); font-weight: 600;
  border-radius: var(--r-s);
}
.en-savoir-plus > summary:hover { color: var(--ink); }
.en-savoir-plus > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.en-savoir-plus > :not(summary) { margin: 0 0 4px; }

/* ── Sélection de texte dorée — cohérente avec l'accent ── */
::selection { background: rgba(223, 169, 77, .30); color: #F5EDDF; }

/* ── Grands chiffres Georgia : chiffres modernes alignés (lnum) + tabulaires ── */
.stat-value, .bord-hero .valeur, .sante-valeur, .sante-score,
.anx-carte-val, .d-hero .v, .sw-lapbig, .sw-quick-code, .drm-month-label {
  font-feature-settings: "lnum" 1, "tnum" 1;
}

/* ── Entrée de vue : fondu + léger glissement à chaque changement de hash.
      Hook CSS pur : quand [hidden] tombe, display none → block relance
      l'animation. prefers-reduced-motion (plus haut) la neutralise. ── */
@keyframes vue-entree { from { opacity: 0; transform: translateY(6px); } }
.view-alt, #view-chai { animation: vue-entree .18s ease-out; }

/* ── Accessibilité de base ── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -48px; left: 16px; z-index: 200;
  background: var(--accent); color: var(--encre-sur-or); padding: 8px 16px;
  border-radius: 0 0 var(--r-m) var(--r-m); font-weight: 600; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; }
:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-s);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
.ico { stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Tactile : pas de délai 300 ms sur les commandes (double-tap zoom coupé) ── */
button, [role="button"], [role="tab"], [role="radio"], a, select, summary, label {
  touch-action: manipulation;
}
/* le flash de tap mobile suit la palette (doré translucide = --accent),
   au lieu du gris-vert système qui jurait avec le brun/or */
html { -webkit-tap-highlight-color: rgba(223, 169, 77, .18); }

/* ── Shell : sidebar + contenu ── */
body { display: grid; grid-template-columns: 236px 1fr; min-height: 100dvh; }
.nav {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg-nav); border-right: 1px solid var(--line); padding: 20px 16px;
  z-index: 50;
}
/* ── Indices de défilement de la nav (voiles créés par app.js) ──
   Un fondu au bas de la liste (bureau) ou au bord droit (mobile) signale que
   la nav continue ; app.js retire la classe en fin de liste — le dernier
   élément n'est jamais voilé une fois atteint. */
.nav-fade, .nav-fade-droite {
  position: absolute; pointer-events: none; opacity: 0;
  transition: opacity .18s ease; z-index: 5;
}
/* ancré au pied de nav (bottom 100 %) : colle au bas de la liste sans calcul */
.nav-fade {
  bottom: 100%; left: -16px; right: -16px; height: 34px;  /* suit le padding 16px de la nav */
  background: linear-gradient(to bottom, transparent, var(--bg-nav) 82%);
}
.nav-deborde-bas .nav-fade { opacity: 1; }
.nav-fade-droite {
  top: 0; bottom: 0; width: 44px;
  background: linear-gradient(to right, transparent, var(--bg-nav) 82%);
}
.nav-deborde-droite .nav-fade-droite { opacity: 1; }
.nav-brand { display: flex; gap: 12px; align-items: center; padding: 2px 8px 16px; color: var(--accent); }
.nav-title { font-family: var(--serif); font-size: var(--t-xl); color: var(--ink); }
.nav-sub { color: var(--ink-3); font-size: var(--t-xs); margin-top: 1px; }
/* flex:1 1 auto + min-height:0 (et min-width:0, utile en ligne mobile) : SANS
   ça, un enfant flex ne rétrécit jamais sous sa hauteur de contenu — la liste
   poussait .nav-foot hors de l'écran et la molette scrollait la PAGE au lieu
   du menu (rien n'était réellement en overflow sur .nav-items lui-même). */
.nav-items { display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
             flex: 1 1 auto; min-height: 0; min-width: 0; overscroll-behavior: contain; }
.nav-principale, .nav-secondaire { display: flex; flex-direction: column; gap: 2px; flex: none; }
.nav-secondaire[hidden], .nav-analyses-toggle[hidden] { display: none; }
.nav-analyses-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex: none; width: 100%; min-height: 44px; margin-top: 14px; padding: 10px 12px;
  border: 0; border-top: 1px solid var(--line); border-radius: 0;
  background: transparent; color: var(--ink-2); font: inherit; font-size: var(--t-s);
  text-align: left; cursor: pointer;
}
.nav-analyses-toggle:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.nav-analyses-toggle:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.nav-chevron { font-size: var(--t-l); }
.nav-analyses-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.nav-groupe {
  color: var(--ink-3); font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 16px 12px 4px;
}
.nav-pastille {
  display: inline-block; min-width: 18px; padding: 1px 8px; margin-left: 8px;
  background: var(--warn); color: #fff; border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 700; text-align: center; vertical-align: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: var(--r-m); color: var(--ink-2); text-decoration: none; font-size: var(--t-m);
  min-height: 44px; border-left: 2px solid transparent; transition: background .12s, color .12s;
}
/* Bureau, pointeur fin (souris) : la cible 44 px est une règle tactile — la
   nav peut se compacter pour que les ~15 écrans tiennent sans scroll sur les
   hauteurs de portable (720 px), sans devenir illisible pour autant. */
@media (min-width: 1024px) and (pointer: fine) {
  .nav { padding: 16px 14px; }
  .nav-brand { padding: 0 6px 10px; }
  .nav-item { min-height: 34px; padding: 6px 10px; gap: 10px; font-size: var(--t-m); }
  .nav-groupe { padding: 10px 10px 3px; }
  .nav-foot { padding-top: 10px; gap: 8px; }
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--ink); }
.nav-item:active { background: rgba(255,255,255,.07); }
.nav-item[aria-current="page"] {
  background: var(--bg-card); color: var(--ink);
  border-left-color: var(--accent); font-weight: 600;
}
.nav-item[aria-current="page"] .ico { color: var(--accent); }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 16px; position: relative; }
.btn-new {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--encre-sur-or); border: none; border-radius: var(--r-m);
  padding: 12px 16px; font-size: var(--t-m); font-weight: 650; cursor: pointer;
  min-height: 44px; transition: filter .12s, transform .06s, box-shadow .12s;
  box-shadow: var(--ombre-1);
}
.btn-new:hover { filter: brightness(1.08); box-shadow: var(--ombre-2); }
.btn-new:active { transform: translateY(1px); filter: brightness(.96); box-shadow: none; }
.nav-source { display: grid; gap: 2px; color: var(--ink-3); font-size: var(--t-xs); line-height: 1.35; padding: 0 8px; }
.nav-source strong { color: var(--ink-2); font-size: var(--t-xs); font-weight: 600; }

.shell { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 96%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);   /* le texte qui défile dessous ne transparaît plus */
}
.view-title { font-size: var(--titre-1); letter-spacing: .3px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ico { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.search-wrap input {
  width: 250px; padding: 8px 40px 8px 36px; min-height: 44px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-m);
  color: var(--ink); font-size: var(--t-m); outline: none; transition: border-color .15s;
}
.search-wrap input:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search-wrap kbd {
  position: absolute; right: 10px; color: var(--ink-3); font-size: var(--t-xs);
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 1px 4px;
}
main:focus { outline: none; }
.view-alt { padding: 8px 28px 48px; }

/* ── Squelettes de chargement — mêmes radius, bordure et élévation que les
      vraies cartes : le contenu arrive sans saut visuel ── */
.skel {
  position: relative; overflow: hidden; background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--ombre-1);
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  animation: skel 1.2s infinite;
}
@keyframes skel { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Mobile : bande principale pleine largeur, analyses dans le flux ── */
@media (max-width: 1023px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: relative; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; padding: 8px 16px; gap: 8px;
    border-right: none; border-bottom: 1px solid var(--line); min-width: 0;
  }
  .nav-brand { padding: 0; flex: 1; }
  .nav-sub { display: none; }
  .nav-title { font-size: var(--t-l); white-space: nowrap; }
  .nav-foot { order: 1; flex: none; flex-direction: row; align-items: center; padding: 0; gap: 8px; margin: 0; }
  .nav-items { order: 2; flex: 0 0 100%; overflow: visible; }
  .nav-principale {
    flex-direction: row; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent;
  }
  .nav-principale .nav-item { flex: none; white-space: nowrap; }
  .nav-item { min-height: 44px; font-size: var(--t-s); }
  .nav-analyses-toggle { margin-top: 4px; }
  .nav-secondaire { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 8px; }
  .nav-secondaire .nav-item { padding: 8px; gap: 8px; overflow-wrap: anywhere; }
  .nav-secondaire .ico { flex: none; }
  .nav-fade { display: none; }
  .btn-new span { display: none; }
  .nav-source { display: none; }
  /* Le menu ouvert ne reste pas plaqué devant les commandes métier au scroll. */
  .topbar { position: static; backdrop-filter: none; background: var(--bg); }
}

/* ── Barre d'onglets au pouce (tablette, téléphone) ──
   Les activités principales quittent le haut de l'écran pour une barre fixe
   en bas : icône au-dessus du libellé, cible ≥ 56 px de haut, zone de
   sécurité de l'iPhone respectée. Le contenu réserve sa hauteur. */
@media (max-width: 1023px) {
  .nav-principale {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; flex-direction: row; gap: 0; justify-content: space-between;
    padding: 4px 6px max(4px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg-nav) 92%, transparent);
    backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(10, 6, 3, .12);
    overflow-x: auto; scrollbar-width: none;
  }
  .nav-principale::-webkit-scrollbar { display: none; }
  .nav-principale .nav-item {
    flex: 1 0 64px; flex-direction: column; justify-content: center; gap: 3px;
    min-height: 56px; padding: 6px 4px; border-left: 0 !important; border-radius: var(--r-m);
    font-size: var(--t-xs); line-height: 1.15; text-align: center; white-space: normal;
  }
  .nav-principale .nav-item .ico { width: 22px; height: 22px; }
  .nav-principale .nav-item[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .shell { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
}
@media print { .nav-principale { position: static !important; } }

/* ── Écrans étroits : la topbar passe sur deux rangées (titre / recherche),
      rien ne déborde, et les gouttières passent de 28 à 16 px ── */
@media screen and (max-width: 639px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 12px 16px; }
  .view-title { font-size: var(--t-l); min-width: 0; }
  .topbar-droite { flex: 1 1 100%; }
  .search-wrap { flex: 1 1 auto; min-width: 0; }
  .search-wrap input { width: 100%; }
  .search-wrap kbd { display: none; }   /* raccourci clavier sans objet au doigt */
  .view-alt { padding-left: 16px; padding-right: 16px; }
  .kpis { padding-left: 16px; padding-right: 16px; }
  .toolbar { padding-left: 16px; padding-right: 16px; }
  .layout { padding-left: 16px; padding-right: 16px; }
  .drawer-inner { padding: 16px 16px; }
}

/* ── iOS zoome sur tout champ < 16px : on garantit 16px au doigt.
      !important assumé : garde-fou matériel, prime sur les tailles d'écran. ── */
@media screen and (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    font-size: var(--t-champ) !important;
  }
}

/* ── KPIs ── */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; padding: 24px 28px 8px;
}
.stat {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--carte-pad); box-shadow: var(--ombre-1);
}
.stat .label { color: var(--ink-2); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-size: var(--t-2xl); margin-top: 8px; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-value small { font-size: var(--t-base); color: var(--ink-2); font-family: inherit; }   /* --ink-3 = 4,2:1 */
.stat .delta { font-size: var(--t-s); margin-top: 4px; color: var(--ink-3); }
.stat.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .06s;
}
.stat.warn .stat-value { color: var(--warn); }
.stat.warn:hover { background: color-mix(in srgb, var(--warn) 8%, var(--bg-card)); box-shadow: var(--ombre-2); }
.stat.warn:active { transform: scale(.995); }

/* ── Toolbar / légende ── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 16px 28px;
}
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select {
  appearance: none; -webkit-appearance: none; min-height: 44px; font: 500 var(--t-m) var(--sans);
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%239e4f27' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-controle); padding: 8px 38px 8px 14px; cursor: pointer;
}
.filters select:hover { border-color: var(--accent); }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: var(--t-m); cursor: pointer; }
.legend { display: flex; gap: 8px; align-items: center; font-size: var(--t-xs); color: var(--ink-3); flex-wrap: wrap; }
.legend .lg-label { margin-right: 4px; }
/* chips de légende : petites pastilles arrondies, propres et régulières */
.legend .sw {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.03); border: 1px solid var(--line); color: var(--ink-2);
}
.legend .chip { width: 14px; height: 14px; border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px rgba(0,0,0,.28); }
.legend .chip.empty { border: 1.5px dashed var(--ink-3); background: transparent; box-shadow: none; }

/* ── Layout ── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; padding: 8px 28px 48px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* ── Le chai : sections par localisation ── */
.loc { margin-bottom: 24px; }
.loc-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.loc-head h2 { font-size: var(--titre-2); }
.loc-head .meta { color: var(--ink-3); font-size: var(--t-s); }
.grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Le fût (bouton accessible) ── */
.fut {
  appearance: none; padding: 0; border: none; font: inherit;
  width: 30px; height: 38px; position: relative; cursor: pointer;
  border-radius: 42% 42% 42% 42% / 16% 16% 16% 16%;
  background:
    linear-gradient(180deg, rgba(255,255,255,.16), rgba(0,0,0,.18) 55%, rgba(0,0,0,.28)),
    var(--c, var(--age-2));
  background-blend-mode: overlay, normal;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.fut::before, .fut::after {   /* cerclages */
  content: ""; position: absolute; left: 6%; right: 6%; height: 2px;
  background: rgba(0,0,0,.32); border-radius: 2px;
}
.fut::before { top: 26%; } .fut::after { bottom: 26%; }
/* survol : le fût se soulève, reflet haut plus marqué (bois ciré) */
.fut:hover {
  transform: translateY(-3px) scale(1.12);
  box-shadow: var(--ombre-2), inset 0 0 0 1px rgba(0,0,0,.35);
  z-index: 2;
}
.fut:active { transform: translateY(-1px) scale(1.06); transition-duration: .06s; }
.fut.empty {
  background: transparent; box-shadow: none;
  border: 1.5px dashed color-mix(in srgb, var(--ink-3) 55%, transparent);
}
.fut.empty::before, .fut.empty::after { background: color-mix(in srgb, var(--ink-3) 30%, transparent); }
.fut.ibc, .fut.cuve { border-radius: var(--r-s); width: 34px; }
.fut.seau { width: 22px; height: 26px; border-radius: 20% 20% 35% 35% / 15% 15% 30% 30%; }
.fut .dot {
  position: absolute; top: -4px; right: -4px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--warn); border: 2px solid var(--bg);
}
/* fût sélectionné : halo doré (anneau accent + lueur chaude) */
.fut.selected {
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 12px color-mix(in srgb, var(--accent) 35%, transparent),
    inset 0 0 0 1px rgba(0,0,0,.35);
  z-index: 2;
}
.fut.empty.selected { box-shadow: 0 0 0 2px var(--accent), 0 0 12px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Tactile (tablette au chai — LE geste principal) : fûts agrandis à 36×46 et
   espacés de 12 px. Cible effective par fût = dessin + espacement exclusif
   ≈ 48×58, au-dessus de la recommandation 44 px, sans chevauchement possible
   entre deux cibles (référentiel UI : touch-target ≥ 44 px, spacing ≥ 8 px). */
@media (max-width: 1023px), (pointer: coarse) {
  .grid { gap: 8px; }
  .fut { width: 40px; height: 50px; touch-action: manipulation; }
  .fut.ibc, .fut.cuve { width: 42px; }
  .fut.seau { width: 28px; height: 32px; }
}
/* Tablette / doigt : le fût est LE geste principal au chai → cible ≥ 44 px.
   (Les seaux, rares et secondaires, montent à 36×44 : hauteur AA, largeur assumée.) */
@media (pointer: coarse) {
  .grid { gap: 8px; }
  .fut { width: 44px; height: 54px; }
  .fut.ibc, .fut.cuve { width: 48px; }
  .fut.seau { width: 36px; height: 44px; }
  .grid .fut.seau { width: 44px; height: 44px; }   /* Les fûts : seau en cible pleine */
}
.fut.dim { opacity: .18; pointer-events: none; }
.fut.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 0%,100% { outline: 2.5px solid transparent; } 50% { outline: 2.5px solid var(--accent); outline-offset: 3px; } }

/* ── Panneau droit ── */
.card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--carte-pad); margin-bottom: var(--esp-4); box-shadow: var(--ombre-1);
}
.card h2 { font-size: var(--titre-2); }
.hint { color: var(--ink-3); font-size: var(--hint); margin: 4px 0 16px; }
/* fond d'alerte + texte d'alerte (blanc sur --warn ne faisait que 3,7:1) */
.badge-warn {
  display: inline-block; background: var(--alerte-fond); color: var(--warn-texte); border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--alerte-bord);
  font-size: var(--t-xs); font-weight: 600; padding: 2px 8px; vertical-align: 2px; font-family: var(--chiffres);
}

/* pyramide (SVG) */
#ages svg { width: 100%; height: auto; display: block; }
#ages text { font-family: var(--chiffres); font-variant-numeric: tabular-nums; }

/* table anomalies */
/* position:relative : ancre les .sr-only (position:absolute) DANS le conteneur
   défilant — sinon ils s'ancrent à la page et créent un faux scroll horizontal */
.table-wrap { max-height: 300px; overflow: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-s); }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); }
/* en-têtes : fond légèrement distinct de la carte + soulignage 2px */
th {
  color: var(--ink-3); font-weight: 500; position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg-raised) 65%, var(--bg-card));
  border-bottom: 2px solid var(--line);
}
td.num, th.num { font-variant-numeric: tabular-nums; }
td.num { text-align: right; }
td .neg { color: var(--warn-texte); } td .pos { color: var(--ok-texte); }   /* ≥ 4,5:1 dans les deux thèmes */
/* zébrage ultra-subtil des corps de tableau (posé sur le tr : les fonds d'état
   des cellules — alertes, sélections — restent au-dessus) */
tbody tr:nth-child(even) { background: rgba(255,255,255,.015); }
tr.row-click { cursor: pointer; }
tr.row-click:hover { background: rgba(223,169,77,.05); }
@media (pointer: coarse) { tr.row-click, tr.row-click > td { height: 44px; } }   /* ligne cliquable : 44 px au doigt */

/* ── Drawer fiche barrique ── */
.drawer-veil {
  position: fixed; inset: 0; background: rgba(12,8,5,.55); z-index: 95;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 94vw); z-index: 96;
  overscroll-behavior: contain;
  background: var(--bg-raised); border-left: 1px solid var(--line);
  box-shadow: var(--ombre-3);
  animation: slide .18s ease; overflow-y: auto;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-inner { padding: 24px; }
/* téléphone : la fiche prend tout l'écran, le bouton fermer reste à portée de pouce */
@media screen and (max-width: 559px) {
  .drawer { width: 100%; border-left: none; }
}
.d-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 4px; }
.d-head h2 { font-size: var(--titre-0); }
.d-close {
  background: none; border: none; color: var(--ink-3); font-size: var(--t-xl); cursor: pointer;
  border-radius: var(--r-m); transition: color .12s, background .12s;
}
.d-close:hover { color: var(--ink); background: rgba(255,255,255,.05); }
.d-close:active { background: rgba(255,255,255,.08); }
.d-sub { color: var(--ink-2); font-size: var(--t-s); margin-bottom: 16px; }
.d-hero {
  display: flex; align-items: baseline; gap: 8px; padding: 16px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: 16px;
}
.d-hero .v { font-family: var(--serif); font-size: var(--t-hero); font-variant-numeric: tabular-nums; }
.d-hero .u { color: var(--ink-3); }
.d-hero .tav { margin-left: auto; color: var(--ink-2); font-size: var(--t-m); }
.d-alert {
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line));
  border-radius: var(--r-m); padding: 12px 16px; font-size: var(--t-s); margin-bottom: 16px; line-height: 1.45;
}
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.d-item { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 12px; }
.d-item .k { color: var(--ink-3); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; }
.d-item .v { font-size: var(--t-base); margin-top: 4px; }
.d-prov {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--bg-card)), var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--r-m); padding: 16px; margin-bottom: 16px; font-size: var(--t-m); line-height: 1.6;
}
.d-prov b { color: var(--accent); }
.d-histoire { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--bg-card); }
.d-histoire ul { margin: 8px 0; padding-left: 20px; }
.d-histoire li { margin: 4px 0; overflow-wrap: anywhere; }
.d-histoire small { display: block; color: var(--ink-2); line-height: 1.5; }
.d-section-title { font-size: var(--t-xs); color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; margin: 16px 0 8px; }
.tl { list-style: none; padding: 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl li { position: relative; padding: 0 0 16px 24px; font-size: var(--t-s); }
.tl li::before {
  content: ""; position: absolute; left: 2px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--age-2); border: 2.5px solid var(--bg-raised);
}
.tl li.out::before { background: var(--warn); }
.tl li.in::before { background: var(--ok); }
.tl .d { color: var(--ink-3); font-size: var(--t-xs); }
.tl .op { font-weight: 600; }
.tl .q { font-variant-numeric: tabular-nums; }
.tl .cm { color: var(--ink-2); font-size: var(--t-xs); margin-top: 2px; font-style: italic; }
.tl .doc { color: var(--ink-3); font-size: var(--t-xs); }

/* ── Correction (contre-passation) dans la timeline ── */
.tl li.annulee { opacity: .55; }
.tl li.annulee .op, .tl li.annulee .q { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--warn) 70%, transparent); }
.tl li.annulee::before { background: var(--ink-3); }
.tl li.inverse::before { background: var(--accent); }
.corr-lien { color: var(--ink-3); font-size: var(--t-xs); font-style: italic; margin-top: 4px; }
.corr-lien.accent { color: var(--accent); }
.corr-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  background: none; border: none; padding: 2px 0; cursor: pointer;
  color: var(--ink-3); font-size: var(--t-xs); font-family: inherit;
}
.corr-btn:hover { color: var(--warn); text-decoration: underline; }
.corr-form {
  display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 8px 12px;
  background: var(--bg-card); border-radius: var(--r-m);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line));
}
.corr-label { color: var(--ink-2); font-size: var(--t-xs); }
.corr-form input {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-controle);
  color: var(--ink); font-size: var(--t-s); padding: 8px 8px; outline: none; transition: border-color .15s;
}
.corr-form input:focus { border-color: var(--accent); }
.corr-actions { display: flex; gap: 8px; }
.corr-actions .btn-new, .corr-actions .btn-ghost {
  flex: none; min-height: 34px; padding: 8px 12px; font-size: var(--t-s);
}
.corr-erreur { color: var(--warn); font-size: var(--t-xs); line-height: 1.45; }
/* la fiche papier reste un état des lieux : pas d'actions de correction imprimées */
@media print {
  body.fiche-printing #drawer .corr-btn,
  body.fiche-printing #drawer .corr-form { display: none !important; }
}

/* tooltip */
.tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  background: #0F0B07; color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 8px 12px; font-size: var(--t-s); line-height: 1.5;
  box-shadow: var(--ombre-2); max-width: 240px;
}
.tooltip .t-code { font-weight: 700; font-size: var(--t-m); }
.tooltip .t-dim { color: var(--ink-3); }

/* Garde universelle : l'attribut hidden gagne toujours, quel que soit le display des modules */
[hidden] { display: none !important; }

/* ── Bouton d'aide (topbar) ── */
.topbar-droite { display: flex; align-items: center; gap: 8px; }
.btn-aide {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-m); cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--ink-2);
  transition: color .12s, border-color .12s;
}
.btn-aide:hover { color: var(--accent); border-color: var(--accent); }
.btn-aide:active { background: var(--bg-card); transform: translateY(1px); }

/* ── Actions de la fiche fût ── */
.d-actions { display: flex; gap: 8px; margin: 2px 0 16px; }
.d-actions .btn-new { flex: 1; }
.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; color: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 12px 16px; font-size: var(--t-m); cursor: pointer;
  min-height: 44px; transition: border-color .12s, color .12s, background .12s, transform .06s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--ink); }
.btn-ghost:active { background: var(--bg-card); transform: translateY(1px); }

/* ── Fiche barrique imprimable : seul le drawer sort sur le papier ── */
@media print {
  body.fiche-printing > :not(#drawer) { display: none !important; }
  body.fiche-printing { display: block; background: #fff; }
  body.fiche-printing #drawer {
    position: static; width: auto; max-width: none; height: auto;
    background: #fff; color: #000; border: none; box-shadow: none;
    transform: none; padding: 0;
  }
  body.fiche-printing #drawer .drawer-inner { padding: 10mm; color: #000; }
  body.fiche-printing #drawer h2,
  body.fiche-printing #drawer .d-hero .v { color: #000; }
  body.fiche-printing #drawer .d-close,
  body.fiche-printing #drawer .d-actions { display: none !important; }
  body.fiche-printing #drawer .d-item,
  body.fiche-printing #drawer .d-prov,
  body.fiche-printing #drawer .d-alert { border-color: #bbb; background: #fff; color: #000; }
  body.fiche-printing #drawer .tl li { color: #000; border-color: #ccc; }
}
.d-alert-expl { color: var(--ink-2); font-size: var(--t-s); }

/* ── Écran « en construction » ── */
.chantier { display: grid; place-items: center; min-height: 60dvh; padding: 40px 28px; }
.chantier-carte {
  max-width: 560px; text-align: center; background: var(--bg-card);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: var(--r-l); padding: 44px 40px;
}
.chantier-ico { color: var(--accent); opacity: .85; margin-bottom: 4px; }
.chantier-badge {
  display: inline-block; margin: 8px 0 16px; padding: 4px 12px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.chantier-carte h2 { font-size: var(--titre-1); margin-bottom: 8px; }
.chantier-quoi { color: var(--ink-2); font-size: var(--t-base); line-height: 1.65; }
.chantier-note {
  color: var(--ink-3); font-size: var(--t-s); line-height: 1.6; margin-top: 16px;
  border-top: 1px solid var(--line); padding-top: 16px;
}

/* panneau de réglage discret (Ctrl+Maj+C) */
#chantier-panneau {
  position: fixed; top: 70px; right: 20px; z-index: 300;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 16px 16px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--ombre-2); font-size: var(--t-m); min-width: 240px;
}
#chantier-panneau label { display: flex; gap: 8px; align-items: center; cursor: pointer; color: var(--ink-2); }
#chantier-panneau label:hover { color: var(--ink); }
.chantier-pan-titre { font-weight: 700; color: var(--ink); font-size: var(--t-s); margin-bottom: 2px; }
.chantier-pan-pied { color: var(--ink-3); font-size: var(--t-xs); margin-top: 4px; border-top: 1px solid var(--line); padding-top: 8px; }

/* ── Barres de défilement — fines, sombres, invisibles au repos ──────────────
   La scrollbar système grise jurait avec le thème (vu en démo Chrome/macOS).
   Règle globale : piste invisible, curseur brun translucide qui ne se révèle
   qu'au survol de la zone. Firefox : scrollbar-width thin + couleurs. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 135, 111, .35) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(148, 135, 111, .28);
  border-radius: var(--r-m);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: rgba(223, 169, 77, .5); }
*::-webkit-scrollbar-corner { background: transparent; }
/* la nav : pas de barre visible du tout (elle scrolle rarement, au clavier/molette) */
.nav-items { scrollbar-width: none; }
.nav-items::-webkit-scrollbar { display: none; }

/* ── Rôle « lecture » : les commandes d'écriture du SOCLE (celles que porte
      app.js lui-même : le grand bouton de saisie, les actions de la fiche de
      fût) disparaissent — classe posée sur body par app.js. Confort d'écran
      uniquement : la vraie garde reste le 403 serveur.
      Les écrans, EUX, gardent leurs actions VISIBLES et désactivées avec
      l'explication au survol (patron `aria-disabled` de stock.js/drm.js/
      plan.js…) : le comptable doit comprendre pourquoi c'est grisé, pas croire
      que l'outil est incomplet. Ne PAS remettre ici de sélecteur appartenant à
      un écran — `[data-action="toggle-move"]` (plan.js) a été retiré pour cette
      raison : la règle globale l'effaçait avant que son propre état ne
      s'applique. ── */
body.est-lecture #btn-saisie,
body.est-lecture .d-actions .btn-new,
body.est-lecture .corr-btn,
body.est-lecture .corr-form { display: none !important; }

/* ── Recherche : « aucun fût » — petite bulle sous le champ (créée par app.js) ── */
#search-vide {
  position: fixed; z-index: 90; max-width: 260px;
  background: color-mix(in srgb, var(--warn) 14%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--ink); border-radius: var(--r-m); padding: 8px 12px;
  font-size: var(--t-s); line-height: 1.45; box-shadow: var(--ombre-2);
}

/* ── Plan : l'en-tête d'un lieu mène à la grille filtrée ── */
.pl-room-lien {
  appearance: none; background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
  border-radius: var(--r-s); text-decoration: underline dotted transparent;
  text-underline-offset: 3px; transition: color .12s, text-decoration-color .12s;
}
.pl-room-lien:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ── État vide générique : icône discrète + phrase + action ── */
.vide-etat {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 48px 24px; text-align: center; color: var(--ink-3);
}
.vide-etat .ico { opacity: .55; }
.vide-etat p { font-size: var(--t-m); line-height: 1.6; max-width: 42ch; }
.vide-etat .btn-ghost { min-height: 40px; padding: 8px 16px; font-size: var(--t-s); }

/* ── Connexion & comptes (palier SaaS) ───────────────────────────────────
   L'écran de connexion et la gestion des comptes réutilisent le langage
   visuel existant : variables, cartes, boutons btn-new / btn-ghost / don-*,
   champs reg-*. Ici, uniquement la mise en place. */

/* écran de connexion plein écran — affiché AVANT toute donnée */
.connexion {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.connexion-carte {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: 32px 32px; box-shadow: var(--ombre-3);
}
.connexion-marque { display: flex; gap: 12px; align-items: center; color: var(--accent); }
.connexion-titre { font-family: var(--serif); font-size: var(--titre-1); color: var(--ink); }
.connexion-nom { color: var(--ink-3); font-size: var(--t-xs); margin-top: 1px; }
.connexion-hint { color: var(--ink-2); font-size: var(--t-s); line-height: 1.5; margin: 2px 0 8px; }
.connexion-lbl {
  color: var(--ink-3); font-size: var(--t-xs); text-transform: uppercase;
  letter-spacing: .08em; margin-top: 4px;
}
.connexion-carte input {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-m);
  color: var(--ink); font-size: var(--t-m); padding: 12px 12px; min-height: 44px;
  outline: none; transition: border-color .15s;
}
.connexion-carte input:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.connexion-carte input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.connexion-btn { margin-top: 12px; }
.connexion-btn:disabled { opacity: .65; cursor: progress; }
.connexion-erreur { color: var(--warn); font-size: var(--t-s); line-height: 1.5; margin-top: 4px; }
/* message neutre (compte créé, déconnexion volontaire) : jamais en rouge —
   rien d'anormal ne s'est produit, ce n'est pas une erreur */
.connexion-erreur.connexion-info { color: var(--ink-2); }

/* badge utilisateur + déconnexion, en pied de nav (uniquement comptes activés) */
.nav-compte {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--line); padding: 12px 8px 0;
}
.nav-compte-id { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.nav-compte-nom {
  color: var(--ink); font-size: var(--t-s); font-weight: 600;
  overflow-wrap: anywhere; min-width: 0;
}
.nav-compte-role {
  color: var(--accent); font-size: var(--t-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; flex: none;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--r-pill); padding: 1px 8px;
}
.nav-compte-sortie { min-height: 36px; padding: 8px 8px; font-size: var(--t-s); gap: 6px; }
@media (max-width: 1023px) {
  /* nav en barre supérieure : le nom passe, seul le bouton reste à portée —
     réduit à une icône (aria-label conservé) pour ne pas manger la largeur
     que réclame la bande de navigation elle-même */
  .nav-compte { border-top: none; padding: 0; flex-direction: row; align-items: center; }
  .nav-compte-id { display: none; }
  .nav-compte-sortie { width: 40px; min-height: 40px; padding: 0; }
  .nav-compte-sortie span { display: none; }
}

/* bandeau « accès réservé » (403) — furtif, jamais un écran cassé */
.acces-bandeau {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 350;
  display: flex; gap: 8px; align-items: center;
  background: color-mix(in srgb, var(--warn) 14%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--ink); border-radius: var(--r-m); padding: 8px 16px;
  font-size: var(--t-s); box-shadow: var(--ombre-2); max-width: min(92vw, 480px);
}
.acces-bandeau .ico { color: var(--warn); }

/* ── écran Réglages : grille de formulaire dédiée (reg-*) ────────────────────
   Libellé sur UNE ligne (ellipsis + title au survol), rangée
   [saisie (flex) | unité | bouton] à hauteur constante 44 px : les cellules
   restent alignées à toute largeur, plus jamais de saisie tronquée. Les
   champs texte longs (raison sociale, adresse, service douanier) prennent
   toute la largeur (reg-champ-large). */
.reg-grille {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
@media (max-width: 600px) {
  .reg-grille { grid-template-columns: minmax(0, 1fr); }
  .reg-rangee { align-items: stretch; flex-wrap: wrap; }
  .reg-rangee .reg-in { flex-basis: 100%; }
}
.reg-champ { display: block; min-width: 0; }
.reg-champ-large { grid-column: 1 / -1; }
.reg-lbl {
  display: block; color: var(--ink-3); font-size: var(--t-xs);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reg-rangee { display: flex; align-items: center; gap: 8px; min-width: 0; }
.reg-rangee .don-btn { flex: none; }
.reg-in {
  flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius-controle); padding: 0 8px; min-height: 44px;
  transition: border-color .15s;
}
.reg-in:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.reg-in:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.reg-in input, .reg-in select {
  flex: 1; min-width: 0; width: 100%; background: none; border: none; outline: none;
  color: var(--ink); font-size: var(--t-m); font-variant-numeric: tabular-nums;
  padding: 8px 0;
}
.reg-in select { cursor: pointer; }
.reg-in select option { background: var(--bg-raised); color: var(--ink); }
.reg-in input[type="date"] { color-scheme: dark; }  /* icône du sélecteur natif lisible sur fond sombre */
.reg-unite { color: var(--ink-3); font-size: var(--t-xs); white-space: nowrap; flex: none; }

/* modification d'un taux fiscal : formulaire inline sous la ligne du taux */
.reg-taux-form {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px 16px; align-items: end; padding: 8px 0 4px;
}
.reg-taux-actions { display: flex; gap: 8px; align-items: center; }
.reg-taux-note {
  color: var(--ink-3); font-size: var(--t-xs); line-height: 1.5;
  margin: 8px 0 4px; max-width: 70ch;
}
.reg-taux-histo { margin-top: 12px; }
.reg-taux-histo summary { cursor: pointer; color: var(--ink-2); font-size: var(--t-s); padding: 4px 0; }
.reg-taux-histo summary:hover { color: var(--ink); }
.reg-taux-histo .table-wrap { margin-top: 8px; }

/* section Réglages → Comptes & accès */
.cpt-sous-titre { font-size: var(--titre-3); color: var(--ink); margin-bottom: 8px; }
.cpt-avert {
  color: var(--ink-2); font-size: var(--t-m); line-height: 1.6; margin: 0 0 16px;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--r-m); padding: 12px 16px;
}
.cpt-avert b { color: var(--accent); }
.cpt-vous {
  display: inline-block; margin-left: 8px; padding: 1px 8px; vertical-align: 1px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.cpt-etat { color: var(--ok); font-size: var(--t-s); }
.cpt-etat-off { color: var(--warn); }
tr.cpt-inactif td { color: var(--ink-3); }
tr.cpt-inactif td b { color: var(--ink-3); }
.cpt-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.cpt-mdp-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 4px 0; }
.cpt-mdp-form .reg-in { flex: 1 1 220px; }
.cpt-mdp-form input {
  flex: 1; min-width: 0; width: 100%; background: none; border: none; outline: none;
  color: var(--ink); font-size: var(--t-m); padding: 8px 0;
}
/* matrice de visibilité : cases par écran, par rôle */
.cpt-matrice-role { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.cpt-matrice-role:first-of-type { border-top: none; padding-top: 0; margin-top: 4px; }
.cpt-cases {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 8px 16px; margin-bottom: 12px;
}
.cpt-case {
  display: flex; gap: 8px; align-items: center; cursor: pointer;
  color: var(--ink-2); font-size: var(--t-m); min-height: 32px;
}
.cpt-case:hover { color: var(--ink); }
.cpt-case input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

/* Le routeur donne le focus à <main> pour les lecteurs d'écran : pas de cadre visuel. */
#main:focus, #main:focus-visible { outline: none; }
/* Texte secondaire : plancher de 13 px, 14 px au doigt (audit UI du 05/10). */
@media (pointer: coarse) { :root { --hint: var(--t-m); } }

/* ── Navigation au pouce : 5 onglets, en-tête sur une rangée (≤ 1023 px) ── */
[data-nm], .nm-voile, .nm-panneau { display: none; }
@media (max-width: 1023px) {
  /* barre du bas : Accueil · Stocks · ＋ · Les fûts · Production · Plus ; Douanes et états et Pilotage sont dans « Plus » (lot K) */
  .nav-principale .nav-item[data-view="drm"], .nav-principale .nav-item[data-view="sante"] { display: none; }   /* Production reste dans la barre : c'est un écran du quotidien */
  .btn-new-haut { display: none; }
  .nav-principale [data-nm] { display: flex; }
  .nav-principale .nav-item { flex: 1 1 0; min-width: 0; }
  .nav-principale { overflow: visible; justify-content: space-around; }
  .nm-saisir { color: var(--ink-2); }
  .nm-saisir-rond {
    display: grid; place-items: center; width: 46px; height: 46px; margin-top: -20px; border-radius: 50%;
    background: var(--accent); color: var(--encre-sur-or); box-shadow: var(--ombre-2);
    border: 3px solid var(--bg-nav);
  }
  .nm-saisir-rond .ico { width: 22px; height: 22px; }
  .nm-saisir.nm-actif { color: var(--accent); font-weight: 650; }
  .nm-plus.nm-actif { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .nm-plus { font: inherit; background: none; border: 0; cursor: pointer; }
  .nm-saisir { font: inherit; background: none; border: 0; cursor: pointer; }

  /* l'en-tête latéral se réduit à rien : la barre du haut porte le titre.
     La grille du corps ne doit pas lui donner la moitié d'un écran court. */
  body { grid-template-rows: auto 1fr; }
  .nav { padding: 0; border: 0; min-height: 0; height: auto; }
  .nav-brand, .nav-foot, .nav-analyses-toggle, .nav-secondaire { display: none !important; }

  .nm-voile:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 190; background: rgba(20, 12, 6, .45); }
  .nm-panneau:not([hidden]) {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    max-height: 82dvh; overflow-y: auto; padding: 12px 16px max(20px, env(safe-area-inset-bottom));
    background: var(--bg-card); border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: var(--ombre-3);
    animation: nm-monte .22s ease-out both;
  }
  .nm-tete { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; border-bottom: 1px solid var(--line); }
  .nm-tete strong { flex: 1; font: 500 var(--t-xl) var(--serif); color: var(--ink); }
  .nm-theme { height: 44px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; font: 600 var(--t-s) var(--sans); border-radius: var(--r-m); border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink-2); cursor: pointer; }
  .nm-fermer { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink-2); cursor: pointer; }
  .nm-grille { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 14px; }
  .nm-lien {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 84px; padding: 10px 6px;
    border-radius: var(--r-l); background: var(--bg-raised); color: var(--ink); text-decoration: none; text-align: center; font-size: var(--t-s); line-height: 1.2;
  }
  .nm-lien[aria-current="page"] { color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; }
  .nm-lien .ico { width: 24px; height: 24px; color: var(--accent); }
  @keyframes nm-monte { from { transform: translateY(24px); opacity: 0; } }
}
@media (max-width: 1023px) and (prefers-reduced-motion: reduce) { .nm-panneau { animation: none; } }

/* En-tête sur une seule rangée au téléphone : la recherche se replie en icône
   et s'ouvre sur toute la largeur au toucher. */
@media (max-width: 600px) {
  .topbar { flex-wrap: nowrap; gap: 8px; padding: 10px 16px; }
  .topbar .view-title { flex: 1; min-width: 0; font-size: var(--t-l); line-height: 1.15; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .topbar-droite { flex: none; width: auto; flex-wrap: nowrap; gap: 6px; }
  .search-wrap { width: 44px; flex: none; }
  .search-wrap input { width: 44px; height: 44px; padding: 0 0 0 44px; color: transparent; cursor: pointer; }
  .search-wrap input::placeholder { color: transparent; }
  .search-wrap kbd { display: none; }
  .search-ico { left: 14px; }
  .search-wrap:focus-within { position: absolute; left: 12px; right: 12px; width: auto; z-index: 45; }
  .search-wrap:focus-within input { width: 100%; padding-left: 40px; color: var(--ink); cursor: text; background: var(--bg-card); }
  .search-wrap:focus-within input::placeholder { color: var(--ink-3); }
  .topbar { position: relative; }
  .topbar-droite .btn-aide { width: 44px; min-width: 44px; height: 44px; padding: 0; }
  .topbar-droite .btn-theme { display: none; }   /* dans le panneau « Plus » au téléphone */
  /* bouton d'effacement natif (bleu) de la recherche : retiré */
  .search-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
}

/* Fenêtres natives (<dialog>) : la remise à zéro globale des marges
   (* { margin: 0 }) annulait leur centrage. Centrées partout ; au téléphone,
   feuille plein écran défilante avec le pied d'actions toujours visible. */
dialog:modal { margin: auto; max-height: calc(100dvh - 32px); overflow-y: auto; }
@media (max-width: 600px) {
  dialog:modal:not(.retours-dialog):not(.confirmation) {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  dialog:modal :is(.dialog-actions, .modal-actions, .actions, footer, menu):last-child {
    position: sticky; bottom: 0; background: inherit; padding-top: 12px; z-index: 1;
  }
}

/* Recherche : jamais le « × » bleu natif, quelle que soit la largeur */
.search-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
/* Graphiques SVG : police de l'interface, chiffres tabulaires */
#ages svg text, .age-chart text { font-family: var(--chiffres); font-variant-numeric: tabular-nums; }

/* panneau « Plus » : titre et bouton sur une ligne au téléphone */
@media (max-width: 1023px) { .nm-tete strong { white-space: nowrap; font-size: var(--t-l, 18px); } .nm-theme span { white-space: nowrap; } }

/* Panneau « Plus » au téléphone : la croix reste toujours visible.
   Bouton Thème en icône seule 44×44, titre compressible, croix figée. */
@media (max-width: 600px) {
  .nm-tete { min-width: 0; }
  .nm-tete strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .nm-theme { width: 44px; padding: 0; justify-content: center; flex: none; }
  .nm-theme span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nm-fermer, .nm-tete .retours-global { flex: none; }
}

/* « Les fûts » a sa propre recherche (filtre de la liste et de la scène) : celle du haut s'efface, pour ne pas en montrer deux. */
body[data-vue="futs"] .search-wrap { display: none; }

/* ── Tablette (601–1100 px) : la barre du haut garde la place du titre de l'écran ──
   La recherche se replie en loupe (elle s'ouvre sur toute la largeur au toucher, comme au téléphone), « Journal » et le thème
   deviennent des icônes de 44 px : plus de « Produ » écrasé par une boîte de recherche, plus de résultats qui passent sous la barre latérale. */
@media (min-width: 601px) and (max-width: 1100px) {
  .topbar { gap: 10px; padding: 12px 20px; position: relative; }
  .topbar .view-title { flex: 1 1 auto; min-width: 0; white-space: normal; line-height: 1.15; }
  .topbar-droite { flex: none; gap: 8px; }
  .search-wrap { width: 44px; flex: none; }
  .search-wrap input { width: 44px; height: 44px; padding: 0 0 0 44px; color: transparent; cursor: pointer; }
  .search-wrap input::placeholder { color: transparent; }
  .search-wrap kbd { display: none; }
  .search-ico { left: 14px; }
  .search-wrap:focus-within { position: absolute; left: 20px; right: 20px; width: auto; z-index: 45; }
  .search-wrap:focus-within input { width: 100%; padding: 8px 14px 8px 40px; color: var(--ink); cursor: text; background: var(--bg-card); }
  .search-wrap:focus-within input::placeholder { color: var(--ink-3); }
  .search-wrap:focus-within .rech-panneau { left: 0; right: 0; width: auto; }
  .topbar-droite .btn-journal, .topbar-droite .btn-theme { width: 44px; min-width: 44px; height: 44px; padding: 0; justify-content: center; }
  .topbar-droite .btn-journal span, .topbar-droite .btn-theme span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar-droite .btn-aide { width: 44px; min-width: 44px; height: 44px; padding: 0; }
}

/* Tableaux dans un cadre qui défile : un fondu en bas dit qu'il y a une suite, et une marge basse laisse la dernière ligne entière
   (avant : la dernière ligne paraissait coupée par le cadre). */
.table-wrap, .ages-eng-wrap, .ages-mat-wrap, .don-tab-wrap, .don-trace-wrap { padding-bottom: 20px; }
.table-wrap::after, .ages-eng-wrap::after, .ages-mat-wrap::after, .don-tab-wrap::after, .don-trace-wrap::after {
  content: ""; display: block; position: sticky; bottom: -20px; left: 0; right: 0; height: 28px; margin-top: -28px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg-card) 92%, transparent));
}
@media print { .table-wrap::after, .ages-eng-wrap::after, .ages-mat-wrap::after, .don-tab-wrap::after, .don-trace-wrap::after { display: none; } }
abbr.sigle { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
