/* ============================================================
   Plateforme fiches techniques - charte docs-entreprise (clair)
   Accent vert #70A25B · Inter · surfaces claires · A4
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --tete: 52px;           /* hauteur des deux en-têtes, recherche et document */
  /* Palette claire - blanc pur + gris bleuté violet doux, accent vert */
  --bg:        #f3f4fa;   /* fond zone document (gris bleuté violet light) */
  --shell:     #ffffff;   /* header / panneau - blanc pur */
  --ink:       #1c1f2b;   /* texte fort */
  --ink-2:     #565a72;   /* texte secondaire */
  --ink-3:     #8b8fa6;   /* texte tertiaire */
  --line:      #e6e7f1;   /* bordures */
  --line-2:    #eef0f7;   /* bordures très douces */
  --field:     #f5f6fc;   /* fonds de champ */

  /* Damier de l'aperçu (échiquier discret gris bleuté violet) */
  --damier:      #e7e9f3;
  --damier-size: 24px;

  /* Accent (identique au catalogue docs-entreprise.com) */
  --accent:      #70A25B;
  --accent-ink:  #4d7a3b;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, #ffffff);
  --accent-line: color-mix(in srgb, var(--accent) 40%, #ffffff);
  --halo:        0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);

  --danger: #c8492f;

  --shadow-card: 0 1px 2px rgba(28,30,46,.05), 0 8px 24px rgba(28,30,46,.07);
  --shadow-sheet: 0 1px 3px rgba(28,30,46,.10), 0 12px 30px rgba(28,30,46,.10);
  --shadow-pop: 0 10px 34px rgba(28,30,46,.16);
  --radius: 12px;
}

html, body { height: 100%; }

body {
  background: var(--shell);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--shell);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 20;
}
.brand-ico { flex: 0 0 auto; display: block; border-radius: 8px; }
.brand { flex: 1; min-width: 0; }
.brand-title { font-weight: 650; font-size: .95rem; letter-spacing: -.01em; }
.brand-sub { font-size: .72rem; color: var(--ink-3); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.account { display: flex; align-items: center; gap: 8px; }

/* Bouton aide (?) */
.icon-help {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--shell);
  color: var(--ink-2);
  font-size: .9rem; font-weight: 700;
  cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}
.icon-help:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  box-shadow: var(--halo);
}
/* Bouton carré d'action du header (paramètres) */
.icon-square {
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--shell);
  color: var(--ink-2);
  cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}
.icon-square .ic { width: 17px; height: 17px; }
.icon-square:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  box-shadow: var(--halo);
}
.account .user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-ink);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: .74rem;
  font-weight: 550;
}
.account .user-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}

/* ---------- Boutons pilule ---------- */
/* Icônes SVG maison */
.ic { display: block; width: 1em; height: 1em; flex: 0 0 auto; }
.pill .ic { width: 15px; height: 15px; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--shell);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  font-size: .74rem;
  font-family: inherit;
  font-weight: 500;
  padding: 6px 13px;
  cursor: pointer;
  transition: background .14s, border-color .14s, box-shadow .14s, color .14s;
  white-space: nowrap;
}
.pill:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}
.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  font-weight: 600;
}
.pill.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.pill.accent:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: #fff;
  box-shadow: var(--halo);
}
.pill.danger { color: var(--danger); }
.pill.danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, #fff);
  border-color: color-mix(in srgb, var(--danger) 45%, #fff);
  color: var(--danger);
}
.pill:disabled { opacity: .45; cursor: default; box-shadow: none; }
.pill:focus-visible { outline: none; box-shadow: var(--halo); }

/* Bouton rond nav (mobile) */
.nav-round {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--shell);
  color: var(--ink);
  cursor: pointer;
  transition: background .14s, box-shadow .14s;
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.nav-round .ic { width: 20px; height: 20px; }
.nav-round:hover { background: var(--accent-soft); box-shadow: var(--halo); }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- Panel gauche ---------- */
.panel {
  width: 322px;
  flex: 0 0 322px;
  display: flex;
  flex-direction: column;
  background: var(--shell);
  border-right: 1px solid var(--line);
  min-height: 0;
  position: relative;
}
.panel[hidden] { display: none; }
.cb {
  font-size: .62rem; font-weight: 700; border-radius: 6px; padding: 2px 6px;
  background: var(--field); color: var(--ink-3);
}
.cb-ko   { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.cb-err  { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.cb-warn { background: rgba(240, 170, 50, .16); color: #b07818; }
.cb-chg  { background: rgba(240, 170, 50, .16); color: #b07818; }
.cb-done { background: var(--accent-soft); color: var(--accent-ink); }
.crb-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.crb-title {
  font-size: .68rem; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crb-sub { font-size: .6rem; color: var(--ink-3); white-space: nowrap; }
/* Ce qui attend le correcteur, porté par le même bouton */
.crb-tag {
  flex: none; margin-left: 2px;
  font-size: .64rem; font-weight: 650; white-space: nowrap;
  border-radius: 999px; padding: 4px 9px;
}
.crb-tag.reco { background: var(--accent-soft); color: var(--accent-ink); }
.crb-tag.auto { background: rgba(240, 170, 50, .18); color: #8a5e12; }

/* Modale : correction proposée par analogie (référence sœur approuvée) */
.modal.modal-large { max-width: 720px; }
.cf {
  font-size: .69rem; color: var(--ink-2, var(--ink)); background: var(--field);
  border-radius: 7px; padding: 6px 9px; display: flex; gap: 7px; line-height: 1.4;
}
.dossier-pane .cf { margin-bottom: 4px; }
.dossier-pane .cs-titre { margin-top: 2px; }
.cf.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.cpg-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  max-height: 168px; overflow: auto; padding: 1px;
}
.cpg-item {
  position: relative; aspect-ratio: 1 / 1; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.cpg-item:hover { border-color: var(--accent-line); }
.cpg-item.on { border-color: var(--accent); box-shadow: var(--halo); }
.cpg-item.ko { opacity: .35; }
.cpg-item img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cpg-item .cpg-num {
  position: absolute; top: -5px; left: -5px; min-width: 16px; height: 16px;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-size: .6rem; font-weight: 800; font-style: normal;
  display: flex; align-items: center; justify-content: center;
}
.cpg-item .cpg-num:empty { display: none; }
.cpg-item .cpg-from {
  position: absolute; bottom: 2px; right: 3px;
  font-size: .52rem; font-style: normal; font-weight: 700; letter-spacing: .03em;
  color: var(--ink-3); background: rgba(255, 255, 255, .82); border-radius: 4px; padding: 0 3px;
}
.cpg-vide { grid-column: 1 / -1; font-size: .7rem; color: var(--ink-3); padding: 8px 2px; }
.cpg-actions { display: flex; gap: 6px; margin-top: 7px; }
.cpg-actions button {
  flex: 1; padding: 6px 8px; border-radius: 8px;
  font-family: inherit; font-size: .7rem; font-weight: 650; cursor: pointer;
  border: 1px solid var(--line); background: var(--shell); color: var(--ink);
}
.cpg-actions .cpg-save { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); }
.cpg-actions .cpg-save:hover:not(:disabled) { background: var(--accent); color: #fff; }
.cpg-actions button:disabled { opacity: .5; cursor: default; }
.cpg-help { margin-top: 6px; font-size: .62rem; color: var(--ink-3); line-height: 1.45; }
.cf-sugg { color: var(--accent-ink); font-size: .66rem; }
.cp-motif {
  background: var(--field); border: 1px solid var(--line); color: var(--ink-3);
  border-radius: 999px; font-family: inherit; font-size: .64rem; font-weight: 600;
  padding: 3px 9px; cursor: pointer;
}
.cp-motif.on {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: var(--danger); color: var(--danger);
}

/* Modale récap des anomalies */
.dossier-pane .cf-liste { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; max-height: 320px; overflow-y: auto; }

/* Vue Éléments (checklist complète, dépliée sous la barre) */
/* État de la vérification : menu déroulant ancré sous l'anneau */
/* Dimensions FIXES : le dossier ne change ni de largeur ni de hauteur selon
   la référence ouverte - ce sont les panneaux internes qui défilent. */
.modal.modal-dossier {
  width: 880px; height: 620px;
  max-width: none; max-height: none;
  padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal.modal-dossier .m-btns {
  margin: 0; padding: 10px 18px; flex: none;
  border-top: 1px solid var(--line); background: var(--shell);
}
.dossier-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px 12px;
}
.modal.modal-dossier h3 { font-size: .86rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.modal.modal-dossier .m-sub {
  font-size: .7rem; color: var(--ink-3); margin: 2px 0 0;
  text-transform: uppercase; letter-spacing: .04em;
}

.dossier-body { display: flex; flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.dossier-head { flex: none; }
.dossier-col { min-width: 0; }
.dossier-etat { flex: 0 0 34%; padding: 14px 16px 16px; overflow-y: auto; min-height: 0; background: var(--shell); }
.dossier-detail {
  flex: 1 1 66%; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; padding: 12px 6px 0 14px;
}

/* Onglets : contrôle segmenté discret */
.dossier-tabs {
  display: inline-flex; gap: 2px; margin: 0 8px 10px 0; padding: 2px;
  background: var(--field); border-radius: 9px; align-self: flex-start;
}
.dossier-tabs button {
  background: none; border: none; border-radius: 7px;
  color: var(--ink-3); font-family: inherit; font-size: .7rem; font-weight: 650;
  padding: 5px 12px; cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s;
}
.dossier-tabs button:hover { color: var(--ink); }
.dossier-tabs button i {
  font-style: normal; font-size: .6rem; font-weight: 700;
  background: var(--line-2); color: var(--ink-3);
  border-radius: 999px; padding: 1px 6px; margin-left: 5px;
  vertical-align: 1px;
}
.dossier-tabs button.active i { background: var(--accent-soft); color: var(--accent-ink); }
.dossier-tabs button.active { background: var(--shell); color: var(--ink); box-shadow: 0 1px 2px rgba(28,30,46,.08); }
.dossier-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 14px 0; }
.dossier-apply { width: 100%; margin-top: 12px; }

/* Colonne état */
.cs-etat { border-radius: 10px; padding: 10px 12px; font-size: .74rem; font-weight: 600; line-height: 1.35; }
.cs-etat span { display: block; font-weight: 450; font-size: .68rem; margin-top: 3px; opacity: .85; }
.cs-bloc { margin-top: 16px; }
.cs-titre {
  font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin-bottom: 7px;
}
.cs-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; background: var(--line-2); }
.cs-bar span { display: block; }
.cs-bar .ok { background: var(--accent); }
.cs-bar .ko { background: var(--danger); }
.cs-bar .chg { background: #d9a13a; }
.cs-bar .none { background: var(--line); }
.cs-legende { margin-top: 10px; display: flex; flex-direction: column; }
.cs-lg {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; font-size: .72rem; color: var(--ink-2, var(--ink));
}
.cs-lg + .cs-lg { border-top: 1px solid var(--line-2); }
.cs-lg span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-lg b { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cs-lg.vide { color: var(--ink-3); }
.cs-lg.vide b { color: var(--ink-3); font-weight: 600; }
.cs-pastille { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
.cs-pastille.ok { background: var(--accent); }
.cs-pastille.ko { background: var(--danger); }
.cs-pastille.chg { background: #d9a13a; }
.cs-pastille.none { background: var(--line); border: 1px solid var(--ink-3); }
.cs-pastille.reco { background: var(--accent-ink); }
.cs-pastille.man { background: #4b6bd6; }
.cs-txt { font-size: .72rem; color: var(--ink-2, var(--ink)); line-height: 1.45; }
.cs-corr { display: flex; align-items: baseline; gap: 6px; padding: 2px 0; font-size: .71rem; color: var(--ink-2, var(--ink)); }
.cs-fine { margin-top: 5px; font-size: .66rem; color: var(--ink-3); }
.cs-etat {
  border-radius: 9px; padding: 9px 11px; font-weight: 650; line-height: 1.4;
  background: var(--field); color: var(--ink);
}
.cs-etat span { display: block; font-weight: 500; font-size: .7rem; color: var(--ink-3); margin-top: 3px; }
.cs-etat.ok { background: var(--accent-soft); color: var(--accent-ink); }
.cs-etat.ok span { color: var(--accent-ink); opacity: .8; }
.cs-etat.chg { background: rgba(240, 170, 50, .16); color: #8a5e12; }
.cs-etat.chg span { color: #8a5e12; opacity: .85; }
.cs-btn {
  display: block; width: 100%; margin-top: 9px;
  padding: 7px 10px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: .72rem; font-weight: 650;
  cursor: pointer; transition: filter .12s;
}
.cs-btn:hover { filter: brightness(1.06); }
.cs-btn:active { filter: brightness(.95); }
.cs-bloc { margin-top: 12px; }
.cs-titre {
  font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); margin-bottom: 5px;
}
.cs-l { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.cs-l.vide { opacity: .45; }
.cs-l b { min-width: 18px; text-align: right; font-weight: 700; }
.cs-pastille { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); }
.cs-pastille.ok { background: var(--accent); }
.cs-pastille.ko { background: var(--danger); }
.cs-pastille.chg { background: #d9a13a; }
.cs-pastille.none { background: var(--line); border: 1px solid var(--ink-3); }
.cs-txt { color: var(--ink-2, var(--ink)); line-height: 1.45; }
.cs-pastille.reco { background: var(--accent-ink); }
.cs-pastille.man { background: #4b6bd6; }

/* Journal : une ligne par action, la plus récente en haut */
.cs-j {
  display: flex; gap: 8px; align-items: baseline;
  padding: 7px 8px; line-height: 1.35; border-radius: 7px;
  font-size: .73rem; color: var(--ink-2, var(--ink));
}
.cs-j + .cs-j { border-top: 1px solid var(--line-2); border-radius: 0; }
.cs-j:last-child { border-bottom: none; }
.cs-j-main { flex: 1 1 55%; min-width: 0; }
.cs-j-val {
  flex: 0 1 45%; min-width: 0; text-align: right; color: var(--ink-3);
  font-size: .7rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.cs-j b { color: var(--ink); font-weight: 650; }
.cs-j-meta { display: block; font-size: .64rem; color: var(--ink-3); margin-top: 1px; }
.cs-j-val.cs-j-img { flex: none; display: flex; justify-content: flex-end; }
.cs-j-val.cs-j-img img {
  width: 26px; height: 26px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 2px;
}
.cs-j-val.cs-j-img.ko::after { content: "image introuvable"; font-size: .64rem; color: var(--danger); }
.cs-j-val.cs-j-img.ko img { display: none; }

/* Liste des données de la référence (onglet du dossier) */
.ce-groupe {
  position: sticky; top: 0; z-index: 1;
  background: var(--shell);
  font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); padding: 10px 8px 4px;
}
.ce-groupe:first-child { padding-top: 2px; }
.ce {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer;
  font-size: .73rem; color: var(--ink);
}
.ce:hover { background: var(--field); }
.ce-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--line); }
.ce-dot.ok { background: var(--accent); }
.ce-dot.ko { background: var(--danger); }
.ce-dot.stale { background: #d9a13a; }
.ce-flag { width: 6px; height: 6px; border-radius: 50%; flex: none; background: #d9a13a; }
.ce-flag.err { background: var(--danger); }
.ce-label, .ce-val {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
}
.ce-label { flex: 1 1 42%; min-width: 0; font-weight: 550; }
.ce-val { flex: 1 1 58%; min-width: 0; color: var(--ink-3); text-align: right; }
/* Élément visuel : vignette à droite plutôt qu'un nom de fichier */
.ce-val.ce-img { display: flex; justify-content: flex-end; }
.ce-val.ce-img img {
  width: 28px; height: 28px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px;
}
.ce-val.ce-img.ko::after {
  content: "image introuvable";
  font-size: .66rem; color: var(--danger);
}
.ce-val.ce-img.ko img { display: none; }
/* Les deux en-têtes - la recherche à gauche, le document à droite - partagent
   une hauteur unique : leurs contenus se posent sur la même ligne et le filet
   du bas traverse l'écran d'un bord à l'autre. */
.panel-search {
  height: var(--tete);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.panel-search .ps-field { flex: 1; }
.panel-search .ps-field {
  position: relative;
  display: flex;
  align-items: center;
}
.panel-search .ps-ico {
  position: absolute;
  left: 11px; top: 50%; transform: translateY(-50%);
  display: flex;
  color: var(--ink-3);
  pointer-events: none;
}
.panel-search .ps-ico .ic { width: 16px; height: 16px; }
.panel-search input {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 32px 9px 34px;
  font-size: .84rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.panel-search input::placeholder { color: var(--ink-3); }
.panel-search input::-webkit-search-cancel-button { display: none; }
.panel-search input:focus {
  background: var(--shell);
  border-color: var(--accent-line);
  box-shadow: var(--halo);
}
.panel-search .ps-clear {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px;
  border: none; background: var(--line);
  color: var(--ink-2);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s;
}
.panel-search .ps-clear .ic { width: 11px; height: 11px; }
.panel-search .ps-clear:hover { background: var(--ink-3); color: #fff; }

/* ---------- Onglets : contrôle segmenté à projecteur ---------- */
/* Toggle segmenté (Références / Dossiers) - minimaliste, sobre.
   Pas de bordure : le curseur (thumb) se cale pile sur le padding-box,
   ce qui évite le décalage d'1px hérité de la bordure. */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 2px 14px 8px;
  padding: 4px;
  background: var(--field);
  border-radius: 12px;
  overflow: hidden;
  isolation: isolate;
}
.seg-btn {
  position: relative;
  z-index: 2;
  background: none;
  border: none;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-2);
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s;
}
.seg-btn:hover { color: var(--accent-ink); }
.seg-btn.active,
.seg-btn.active:hover { color: #fff; }
/* Curseur actif (glisse d'un onglet à l'autre) */
.seg-thumb {
  position: absolute;
  z-index: 1;
  top: 0; left: 0;
  width: 0; height: 0;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 36%, transparent);
  transition: transform .3s cubic-bezier(.34, 1.28, .5, 1), width .3s cubic-bezier(.34, 1.28, .5, 1);
  will-change: transform, width;
}
/* Projecteur qui suit la souris */
.seg-glow {
  position: absolute;
  z-index: 1;
  top: -30%; left: 0;
  width: 118px; height: 160%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, transparent), transparent 72%);
  opacity: 0;
  transform: translateX(-200px);
  transition: opacity .22s ease;
  pointer-events: none;
  will-change: transform, opacity;
}
.seg.lit .seg-glow { opacity: 1; }
/* Compteur de résultats - barre fixe en bas du panneau. */
.panel-count {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: .66rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-top: 1px solid var(--line);
  background: var(--shell);
}
.panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 16px;
}

/* Item de liste */
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  position: relative;
}
.item:hover { background: var(--field); }
.item.active {
  background: var(--field);
  border-color: transparent;
}
.item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px;
  background: var(--ink);
}
.item-main { flex: 1; min-width: 0; }
.item-name {
  font-size: .82rem;
  font-weight: 550;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-sub {
  font-size: .69rem;
  color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 1px;
}
/* Pastille de statut d'une référence (données approuvées / ouvrage) */
.item-badge {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: .62rem; font-weight: 700; line-height: 1;
}
.item-badge.ok { background: var(--accent-soft); color: var(--accent-ink); }
.item-badge.bib { background: var(--field); color: var(--ink-3); font-style: italic; }
.item.approved .item-name { color: var(--ink); }

/* Filtres de statut (sous les onglets du panneau) */
.statut-chips {
  flex: 0 0 auto;
  display: flex; gap: 6px;
  padding: 0 14px 10px;
}
.statut-chips .chip {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--shell);
  font: inherit; font-size: .68rem; font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.statut-chips .chip:hover { color: var(--accent-ink); border-color: var(--accent-line); }
.statut-chips .chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

.item input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 auto; }
.item .folder-ico { flex: 0 0 auto; color: var(--accent); display: flex; }
.item .folder-ico .ic { width: 17px; height: 17px; }
.folder-head h1 .fh-ico { display: inline-flex; vertical-align: -3px; color: var(--accent); }
.folder-head h1 .fh-ico .ic { width: 18px; height: 18px; }

/* Barre mode sélection */
.select-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: .74rem;
  background: var(--shell);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(28,32,24,.05);
}
.select-bar span { flex: 1; color: var(--ink-2); }

/* Message panneau */
.panel-note {
  padding: 26px 18px;
  font-size: .78rem;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.55;
}
.panel-note .pill { margin-top: 12px; }

/* ---------- Zone droite ---------- */
.viewer {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, var(--damier) 25%, transparent 25%, transparent 75%, var(--damier) 75%),
    linear-gradient(45deg, var(--damier) 25%, transparent 25%, transparent 75%, var(--damier) 75%);
  background-size: var(--damier-size) var(--damier-size);
  background-position: 0 0, calc(var(--damier-size) / 2) calc(var(--damier-size) / 2);
}
.viewer-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-3);
  padding: 20px;
}
.viewer-empty-icon {
  font-size: 2.6rem;
  color: var(--accent);
  opacity: .55;
}
.viewer-empty-title { font-size: .95rem; font-weight: 650; color: var(--ink-2); }
.viewer-empty-sub { font-size: .8rem; text-align: center; }

.viewer-content { min-height: 100%; }

/* ---------- Barre d'outils document ---------- */
/* Sticky robuste : fond opaque (pas de backdrop-filter qui saccade au scroll),
   bouton PDF centré + nom du fichier final. */
.doc-toolbar {
  position: sticky;
  /* En côte à côte, le viewer défile aussi HORIZONTALEMENT : sans « left »,
     la barre part avec les pages (mesuré : -400 px pour un défilement de 400).
     Sa largeur est calée sur la partie visible par fitSheets, d'où l'ancrage
     aux deux bords. */
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--tete);
  box-sizing: border-box;
  padding: 0 22px;
  background: var(--shell);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}
/* Le choix du document ouvre la barre, ce qu'on emporte la ferme. */
.doc-toolbar .dt-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
/* État d'approbation des données : c'est lui qui ouvre ou ferme l'export. */
.doc-toolbar .dt-approval {
  flex-basis: 100%;
  order: 3;
  text-align: center;
  font-size: .69rem;
  font-weight: 600;
  margin-top: -2px;
}
.doc-toolbar .dt-approval.ok { color: var(--accent-ink); }
.doc-toolbar .dt-approval.wait { color: var(--ink-3); font-weight: 500; }
.doc-toolbar .pill[disabled] { opacity: .45; cursor: not-allowed; }
.doc-toolbar .dt-fname {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: min(34vw, 420px);
}
.doc-toolbar #pdfBtn { flex: none; }
.doc-toolbar .dt-docs { flex: none; }
.doc-toolbar .dt-side {
  position: absolute;
  right: 22px; top: 50%; transform: translateY(-50%);
}
/* ---------- Étage des pages A4 ----------
   Le gabarit vient du moteur partagé (assets/fiche-sheet.css, tout entier
   porté par .fiche-sheet-doc). Ici, seulement la MISE EN SCÈNE : l'étage,
   l'ombre des feuilles et la disposition côte à côte. */
.doc-stage { padding: 26px 22px 30px; }
.fiche-sheet-doc .sheet {
  box-shadow: 0 1px 2px rgba(20,24,18,.06), 0 12px 28px rgba(20,24,18,.10);
  border-radius: 2px;
}


/* ---------- Vue dossier ---------- */
.folder-view { max-width: 780px; margin: 0 auto; padding: 26px 24px 40px; }
.folder-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.folder-head h1 { font-size: 1.1rem; font-weight: 650; flex: 1; min-width: 160px; }
.folder-sub { font-size: .74rem; color: var(--ink-3); margin-bottom: 16px; }
.folder-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.folder-items { display: flex; flex-direction: column; gap: 5px; }
.folder-items .item { background: var(--shell); border: 1px solid var(--line); }
.folder-items .item:hover { border-color: var(--accent-line); }
.folder-items .item .rm {
  flex: 0 0 auto;
  background: none; border: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 5px; border-radius: 6px;
  display: flex; align-items: center;
  transition: background .12s, color .12s;
}
.folder-items .item .rm .ic { width: 13px; height: 13px; }
.folder-items .item .rm:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, #fff); }
.folder-empty { font-size: .78rem; color: var(--ink-3); padding: 20px 4px; }

/* ---------- Dropdown ---------- */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 40;
}
.dropdown button {
  display: block; width: 100%; text-align: left;
  background: none; border: none;
  color: var(--ink);
  font-family: inherit; font-size: .78rem;
  padding: 8px 11px; border-radius: 7px; cursor: pointer;
}
.dropdown button:hover { background: var(--accent-soft); color: var(--accent-ink); }
.dropdown .dd-sep { border-top: 1px solid var(--line); margin: 5px 0; }
.dropdown .dd-note { padding: 8px 11px; font-size: .72rem; color: var(--ink-3); }
.dropdown .dd-count { color: var(--ink-3); }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(28,32,24,.42);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  /* Au-dessus du voile du tutoriel (300/340) pour rester visible pendant un tuto. */
  z-index: 400; padding: 20px;
}
.modal {
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  width: 100%; max-width: 440px; max-height: 84vh;
  overflow-y: auto;
  padding: 24px 24px 20px;
}
.modal h3 { font-size: 1rem; font-weight: 650; margin-bottom: 4px; }
.modal .m-sub { font-size: .76rem; color: var(--ink-2); margin-bottom: 16px; line-height: 1.5; }
.modal .m-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.modal .m-list button {
  text-align: left;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit; font-size: .82rem;
  border-radius: 9px; padding: 10px 13px; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.modal .m-list button:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

/* Connexion : identifiants regroupés par service */
.modal .m-services { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.modal .m-svc-title {
  font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 7px; padding-left: 2px;
}
.modal .m-svc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.modal .m-svc-grid button {
  text-align: left;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit; font-size: .8rem;
  border-radius: 9px; padding: 9px 12px; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.modal .m-svc-grid button:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}
.modal .m-svc-grid button .m-lock {
  width: 13px; height: 13px;
  float: right; margin-top: 2px;
  opacity: .55;
}
.modal input[type=text], .modal input[type=password], .modal textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 9px; padding: 9px 12px;
  font-size: .82rem; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.modal input:focus, .modal textarea:focus {
  background: var(--shell);
  border-color: var(--accent-line);
  box-shadow: var(--halo);
}
.modal textarea { min-height: 110px; resize: vertical; }
.modal .m-error { font-size: .73rem; color: var(--danger); margin-top: 8px; min-height: 1em; }
.modal .m-report {
  font-size: .73rem; line-height: 1.5; margin-top: 10px;
  background: var(--field); border-radius: 8px; padding: 10px 12px;
  max-height: 160px; overflow-y: auto;
}
.modal .m-report .ko { color: var(--danger); }
.modal .m-report .ok { color: var(--accent-ink); }
.modal .m-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Modale guide d'utilisation */
.modal.modal-guide { max-width: 620px; }
.guide-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.guide-head .g-ico {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
}
.guide-head h3 { font-size: 1.05rem; }
.guide-sec {
  display: flex; gap: 13px;
  padding: 14px 2px;
  border-top: 1px solid var(--line-2);
}
.guide-sec:first-of-type { border-top: none; }
.guide-sec .g-num {
  flex: 0 0 auto;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.guide-sec .g-body { flex: 1; min-width: 0; }
.guide-sec h4 { font-size: .86rem; font-weight: 650; margin-bottom: 4px; }
.guide-sec p { font-size: .8rem; color: var(--ink-2); line-height: 1.55; }
.guide-sec p + p { margin-top: 5px; }
.guide-sec .kbd {
  display: inline-block;
  min-width: 18px; text-align: center;
  background: var(--field); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px;
  font-size: .72rem; font-weight: 600; color: var(--ink);
}
.guide-sec b { color: var(--ink); font-weight: 600; }
.guide-note {
  margin-top: 14px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 11px 14px;
  font-size: .77rem; color: var(--ink-2); line-height: 1.55;
}
.guide-note b { color: var(--ink); }

/* Bouton « Démarrer le tutoriel » dans le guide */
.guide-sec .tuto-start {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 9px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent-ink); font-family: inherit; font-size: .72rem; font-weight: 650;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  transition: background .14s, box-shadow .14s;
}
.guide-sec .tuto-start .ic { width: 12px; height: 12px; }
.guide-sec .tuto-start:hover { background: var(--accent); color: #fff; box-shadow: var(--halo); }

/* ---------- Tutoriel interactif guidé ---------- */
/* Projecteur : un trou transparent sur la cible + une ombre géante qui
   assombrit tout le reste. La cible n'étant jamais recouverte, elle reste
   nette quel que soit son contexte d'empilement (barre sticky, panneau…). */
.tuto-spot {
  position: fixed; z-index: 300;
  border-radius: 11px;
  pointer-events: none;
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
  animation: tutoPulse 1.9s ease-in-out infinite;
}
@keyframes tutoPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 26%, transparent), 0 0 0 4000px rgba(15, 18, 13, .64); }
  50%      { box-shadow: 0 0 0 2px var(--accent), 0 0 0 7px color-mix(in srgb, var(--accent) 13%, transparent), 0 0 0 4000px rgba(15, 18, 13, .64); }
}
/* Fin de tutoriel : voile plein écran dédié (au-dessus de tout sauf la carte). */
.tuto-done-veil {
  position: fixed; inset: 0; z-index: 335;
  background: rgba(15, 18, 13, .66);
  animation: tutoFadeIn .2s ease;
}
@keyframes tutoFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Bulle indicatrice + flèche */
.tuto-tip {
  position: fixed; z-index: 340; max-width: 260px;
  background: #14161a; color: #fff;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px; padding: 11px 14px;
  font-size: .8rem; line-height: 1.45;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .5);
  animation: tutoPop .25s cubic-bezier(.34, 1.4, .5, 1);
}
.tuto-tip b { font-weight: 800; color: var(--accent); }
.tuto-tip.nudge { animation: tutoShake .4s; }
/* Flèche dessinée à la main pointant vers la cible */
.tuto-tip .tt-arrow { position: absolute; width: 44px; height: 26px; color: var(--accent); pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
.tuto-tip .tt-arrow svg { width: 100%; height: 100%; overflow: visible; }
.tuto-tip[data-arrow="left"]   .tt-arrow { left: -42px;   transform: translateY(-50%); }
.tuto-tip[data-arrow="right"]  .tt-arrow { right: -42px;  transform: translateY(-50%) scaleX(-1); }
.tuto-tip[data-arrow="top"]    .tt-arrow { top: -38px;    transform: translateX(-50%) rotate(90deg); }
.tuto-tip[data-arrow="bottom"] .tt-arrow { bottom: -38px; transform: translateX(-50%) rotate(-90deg); }
@keyframes tutoPop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes tutoShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* Carte guide flottante (bas-droite) */
.tuto-card {
  position: fixed; right: 22px; bottom: 22px; z-index: 340; width: 320px; max-width: calc(100vw - 32px);
  background: var(--shell); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-pop); padding: 16px 16px 14px;
  animation: tutoSlide .3s cubic-bezier(.34, 1.3, .5, 1);
}
@keyframes tutoSlide { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.tuto-card .tc-head { font-size: .9rem; font-weight: 650; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.tuto-card .tc-badge {
  font-size: .58rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: var(--accent); color: #fff; padding: 3px 8px; border-radius: 999px;
}
.tuto-card .tc-badge.tc-ok { background: var(--accent-ink); }
.tuto-card p { font-size: .8rem; color: var(--ink-2); line-height: 1.5; margin-top: 7px; }
.tuto-card .tc-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.tuto-card .tc-progress { display: flex; gap: 5px; }
.tuto-card .tc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s; }
.tuto-card .tc-dot.on { background: var(--accent); }
.tuto-card .tc-btns { display: flex; gap: 7px; }

/* Carte de réussite recentrée en fin de tutoriel */
.tuto-card.center {
  right: auto; bottom: auto; left: 50%; top: 50%;
  width: 380px; text-align: center; overflow: visible;
  padding: 26px 26px 20px;
  transform: translate(-50%, -50%);
  animation: tutoZoom .32s cubic-bezier(.34, 1.4, .5, 1);
}
@keyframes tutoZoom { from { opacity: 0; transform: translate(-50%, -50%) scale(.88); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.tuto-card.center .tc-head { justify-content: center; font-size: 1.06rem; font-weight: 800; }
.tuto-card.center p { text-align: center; font-size: .82rem; line-height: 1.55; margin-top: 6px; }
.tuto-card.center .tc-next { display: inline-block; margin-top: 5px; color: var(--ink-3); }
/* Actions empilées : l'action principale en haut, « Fermer » en retrait dessous.
   Les libellés longs (nom du tutoriel suivant) tiennent sans passer à la ligne. */
.tuto-card.center .tc-actions {
  flex-direction: column-reverse; align-items: stretch; gap: 8px; margin-top: 16px;
}
.tuto-card.center .tc-actions .pill { justify-content: center; width: 100%; }
.tuto-card.center .tc-actions #tutoDone { background: none; border-color: transparent; color: var(--ink-3); }
.tuto-card.center .tc-actions #tutoDone:hover { background: var(--hover, rgba(0, 0, 0, .04)); color: var(--ink); }
/* Pastille de rappel : ce que l'utilisateur vient d'obtenir (1 ligne, tronquée) */
.tuto-card .tc-chip {
  margin-top: 12px; padding: 9px 12px; border-radius: 11px; text-align: left;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.tuto-card .tch-label {
  display: block; font-size: .6rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink, var(--accent));
}
.tuto-card .tch-value {
  display: block; margin-top: 2px; font-size: .8rem; font-weight: 650; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Avancement dans la série de tutoriels */
.tuto-card .tc-steps {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line);
  font-size: .68rem; color: var(--ink-3);
}
.tuto-card .tc-check {
  position: relative; z-index: 2;
  width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  animation: tutoCheck .45s cubic-bezier(.34, 1.6, .5, 1) both;
}
.tuto-card .tc-check svg { width: 26px; height: 26px; }
@keyframes tutoCheck { from { transform: scale(0) rotate(-25deg); } to { transform: scale(1) rotate(0); } }
/* Feu d'artifice / confettis */
.tc-confetti { position: absolute; left: 50%; top: 42px; width: 0; height: 0; pointer-events: none; z-index: 1; }
.tc-confetti i {
  position: absolute; left: 0; top: 0; display: block; opacity: 0;
  animation: cfPop 1.05s cubic-bezier(.15, .7, .3, 1) var(--d) forwards;
}
@keyframes cfPop {
  0%   { transform: translate(0, 0) rotate(0) scale(.3); opacity: 0; }
  12%  { opacity: 1; }
  72%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(1); opacity: 0; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  color: #fff;
  font-size: .8rem; padding: 11px 20px;
  z-index: 200; max-width: 90vw;
}

/* ---------- Erreur fetch (file://) ---------- */
.fatal {
  max-width: 540px; margin: 60px auto;
  background: var(--shell);
  border: 1px solid var(--accent-line);
  border-radius: 12px; padding: 28px 30px;
  font-size: .86rem; line-height: 1.6;
  box-shadow: var(--shadow-card);
}
.fatal h2 { font-size: 1.05rem; margin-bottom: 10px; color: var(--accent-ink); }
.fatal code {
  background: var(--field); border-radius: 5px; padding: 1px 6px; font-size: .8rem;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd3ca; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b4b9ad; }
::-webkit-scrollbar-track { background: transparent; }
.panel ::-webkit-scrollbar-thumb { border-color: var(--shell); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-round { display: flex; }
  .panel {
    position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 60; width: min(322px, 86vw);
    background: var(--shell);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-pop);
    border-right: 1px solid var(--line);
    padding-top: 8px;
  }
  .panel.open { transform: translateX(0); }
  .doc-stage { padding: 16px 10px 30px; }
}

/* ---------- Impression : feuilles A4 réelles ---------- */
/* ============================================================
   Paramètres (modale) - profil, thème, fond d'aperçu, sens des pages.
   Réglages purement locaux : ils vivent dans un cookie du navigateur.
   ============================================================ */
.modal-settings { max-width: 520px; }
.set-sec { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.set-sec:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.set-sec h4 { font-size: .82rem; font-weight: 700; color: var(--ink); }
.set-sec .set-sub { font-size: .72rem; color: var(--ink-3); margin-top: 1px; line-height: 1.45; }
.set-grp { margin-top: 12px; }
.set-grp + .set-grp { margin-top: 16px; }
.set-lab { font-size: .72rem; font-weight: 650; color: var(--ink-2); margin-bottom: 7px; }

/* Synchronisation serveur (mode correcteur) */
.sync-fields { display: grid; gap: 10px; }
.sync-field { display: grid; gap: 5px; font-size: .72rem; font-weight: 650; color: var(--ink-2); }
.sync-field input {
  width: 100%; padding: 8px 10px; font: inherit; font-weight: 500;
  color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 9px;
}
.sync-field input:focus { outline: none; border-color: var(--accent-line); }
.sync-state { font-size: .76rem; color: var(--ink-2); display: grid; gap: 4px; }
.sync-state b { color: var(--accent-ink); font-weight: 700; }
.sync-log {
  margin-top: 14px; padding: 9px 12px; font-size: .74rem; line-height: 1.5;
  color: var(--ink-2); background: var(--field);
  border: 1px solid var(--line); border-radius: 9px; white-space: pre-wrap;
}
.modal-sync .m-btns { flex-wrap: wrap; justify-content: flex-end; }

/* Profil */
.set-profil {
  display: flex; align-items: center; gap: 12px;
  background: var(--field); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.set-profil .sp-ava {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent-ink); font-weight: 800; font-size: .86rem;
}
.set-profil .sp-txt { min-width: 0; flex: 1; }
.set-profil .sp-nom { font-size: .86rem; font-weight: 700; color: var(--ink); }
.set-profil .sp-role { font-size: .72rem; color: var(--ink-3); margin-top: 1px; }
.set-profil .pill { flex: 0 0 auto; }

/* Choix illustrés (2 options par ligne) */
/* Les vignettes de choix (thème, fond, sens de lecture) ont disparu avec
   les réglages : la présentation est fixe. */

/* ---------- Fond de la zone d'aperçu : uni ---------- */
:root[data-fond="uni"] .viewer { background-image: none; }

/* ---------- Sens de lecture : pages côte à côte ----------
   Le scroll reste possible dans les deux sens ; la molette verticale est
   convertie en défilement horizontal par l'app (voir wheel dans app.js). */
:root[data-pages="horizontal"] .fiche-sheet-doc .doc-pages {
  display: flex; align-items: flex-start; gap: 26px; width: auto;
}
:root[data-pages="horizontal"] .fiche-sheet-doc .sheet { margin: 0; flex: 0 0 auto; }
:root[data-pages="horizontal"] .doc-stage { padding: 24px 22px 28px; }
:root[data-pages="horizontal"] .viewer { overflow: auto; }

/* ============================================================
   Thème sombre - chrome sombre, feuille A4 toujours imprimée clair
   ============================================================ */
:root[data-theme="sombre"] {
  color-scheme: dark;
  --bg:        #12141b;
  --shell:     #1a1d25;
  --ink:       #e9ebf3;
  --ink-2:     #a6abbd;
  --ink-3:     #757b90;
  --line:      #2a2e3a;
  --line-2:    #22262f;
  --field:     #222633;
  --damier:    #191c24;
  --accent:      #7cb063;
  --accent-ink:  #a9d492;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, #1a1d25);
  --accent-line: color-mix(in srgb, var(--accent) 42%, #1a1d25);
  --danger:      #e2795f;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .40), 0 8px 24px rgba(0, 0, 0, .34);
  --shadow-sheet: 0 2px 6px rgba(0, 0, 0, .50), 0 18px 44px rgba(0, 0, 0, .48);
  --shadow-pop:  0 12px 40px rgba(0, 0, 0, .55);
}
/* La feuille est un document : elle garde la palette d'impression, sinon son
   texte deviendrait clair sur papier blanc. */
:root[data-theme="sombre"] .sheet {
  --ink:   #1c1f2b;
  --ink-2: #565a72;
  --ink-3: #8b8fa6;
  --line:  #e6e7f1;
  --line-2:#eef0f7;
  --field: #f5f6fc;
  --bg:    #f3f4fa;
  --accent-ink:  #4d7a3b;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, #ffffff);
  --accent-line: color-mix(in srgb, var(--accent) 40%, #ffffff);
}
/* Éléments à couleur écrite en dur : on les rattrape ici. */
:root[data-theme="sombre"] .toast { background: #2b3040; color: #eceef6; }
:root[data-theme="sombre"] .modal-backdrop { background: rgba(6, 8, 12, .60); }
:root[data-theme="sombre"] .pill.accent { color: #11210d; }
:root[data-theme="sombre"] .pill.accent:hover {
  background: color-mix(in srgb, var(--accent) 78%, #ffffff);
  border-color: color-mix(in srgb, var(--accent) 78%, #ffffff);
  color: #11210d;
}
:root[data-theme="sombre"] .seg-btn.active,
:root[data-theme="sombre"] .seg-btn.active:hover { color: #11210d; }
:root[data-theme="sombre"] .pill.danger:hover {
  background: color-mix(in srgb, var(--danger) 18%, var(--shell));
  border-color: color-mix(in srgb, var(--danger) 45%, var(--shell));
}
:root[data-theme="sombre"] .guide-sec .tuto-start:hover,
:root[data-theme="sombre"] .panel-search .ps-clear:hover { color: #11210d; }
:root[data-theme="sombre"] .opt-vis { border-color: #343a49; }

@media print {
  /* À l'impression, les pages redeviennent une pile verticale sur fond blanc,
     quels que soient les réglages d'écran. */
  :root[data-pages="horizontal"] .fiche-sheet-doc .doc-pages { display: block; }
  :root[data-theme="sombre"] .sheet { color: #1c1f2b; }
  .topbar, .panel, .doc-toolbar, .select-bar, .toast { display: none !important; }
  body { overflow: visible; background: #fff; }
  .viewer { overflow: visible; background: #fff; }
  .doc-stage { padding: 0; }
  .doc-pages { width: auto; transform: none !important; }
  .sheet {
    box-shadow: none; border-radius: 0; margin: 0;
    width: 210mm; height: 297mm;
    padding: 12mm 14mm 10mm;
    page-break-after: always;
  }
}

/* ============================================================
   Édition d'une référence (FTEdit) - la plateforme est la source
   ============================================================ */
.panel-actions { padding: 0 14px 10px; }
.panel-actions .pill { width: 100%; justify-content: center; }

.modal-edition .ed-kind { display: flex; gap: 6px; margin-bottom: 16px; }
.modal-edition .ed-kind .chip {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--shell);
  font: inherit; font-size: .72rem; font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.modal-edition .ed-kind .chip:hover { color: var(--accent-ink); border-color: var(--accent-line); }
.modal-edition .ed-kind .chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

.modal-edition .ed-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 12px;
}
.modal-edition .ed-f { display: flex; flex-direction: column; gap: 5px; }
.modal-edition .ed-f > span {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-2);
}
.modal-edition .ed-f > span em { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8; }
.modal-edition .ed-req > span { color: var(--accent-ink); }
.modal-edition .ed-full { margin-bottom: 12px; }
.modal-edition input[type=text], .modal-edition textarea { width: 100%; }

.modal-edition .ed-sec {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-2); margin: 4px 0 8px;
}
.modal-edition .ed-caracs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.modal-edition .ed-carac-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; }
.modal-edition .ed-del {
  border: 1px solid var(--line); background: var(--field); color: var(--ink-2);
  border-radius: 8px; width: 30px; cursor: pointer; font-size: 1rem; line-height: 1;
}
.modal-edition .ed-del:hover { color: var(--danger); border-color: var(--danger); }
.modal-edition .ed-add { margin-bottom: 14px; }

.modal-edition .ed-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
}
.modal-edition .ed-actions-right { display: flex; gap: 8px; }
.modal-edition .ed-err {
  margin-top: 10px; padding: 9px 12px; border-radius: 9px;
  background: var(--danger-soft, rgba(200,60,50,.08));
  color: var(--danger); font-size: .78rem;
}
@media (max-width: 640px) {
  .modal-edition .ed-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Administration des comptes (FTComptes)
   ============================================================ */
.modal-comptes .cp-roles {
  display: flex; flex-direction: column; gap: 3px;
  font-size: .74rem; color: var(--ink-2);
  background: var(--field); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.modal-comptes .cp-roles b { color: var(--ink); }

.modal-comptes .cp-list { display: flex; flex-direction: column; gap: 6px; }
.modal-comptes .cp-row {
  display: grid; grid-template-columns: 1fr 130px auto auto auto;
  gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; background: var(--shell);
}
.modal-comptes .cp-row.cp-off { opacity: .5; }
.modal-comptes .cp-nom { font-size: .82rem; font-weight: 600; }
.modal-comptes .cp-svc { font-size: .68rem; font-weight: 500; color: var(--ink-3); margin-top: 1px; }
.modal-comptes .cp-soi {
  font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 999px; padding: 1px 6px; margin-left: 4px;
}
.modal-comptes .cp-lock { font-size: .7rem; margin-left: 4px; }
.modal-comptes .cp-row select, .modal-comptes .cp-new select,
.modal-comptes .cp-new input {
  font: inherit; font-size: .76rem;
  background: var(--field); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 8px;
}
.modal-comptes .cp-row .pill { font-size: .7rem; padding: 5px 9px; }

.modal-comptes .cp-sec {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-2); margin: 18px 0 8px;
}
.modal-comptes .cp-new {
  display: grid; grid-template-columns: 1fr 1fr 130px 1fr auto; gap: 6px; align-items: center;
}
.modal-comptes .cp-err {
  margin-top: 12px; padding: 9px 12px; border-radius: 9px;
  background: var(--danger-soft, rgba(200,60,50,.08)); color: var(--danger); font-size: .78rem;
}
@media (max-width: 720px) {
  .modal-comptes .cp-row, .modal-comptes .cp-new { grid-template-columns: 1fr; }
}
.set-admin { display: flex; gap: 8px; flex-wrap: wrap; }
.set-admin .pill { text-decoration: none; }

/* ============================================================
   Visuels d'une référence (galerie du formulaire d'édition)
   ============================================================ */
.modal-edition .ed-vis { margin-bottom: 14px; }
.modal-edition .ed-vis-liste {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.modal-edition .ed-vis-vide { font-size: .76rem; color: var(--ink-3); padding: 4px 0 2px; }

.modal-edition .ed-vig {
  position: relative; margin: 0; width: 86px; height: 86px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); overflow: hidden; cursor: grab;
}
.modal-edition .ed-vig img { width: 100%; height: 100%; object-fit: contain; display: block; }
.modal-edition .ed-vig-prise { opacity: .4; cursor: grabbing; }
.modal-edition .ed-vig figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: .58rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  text-align: center; padding: 2px 0;
  background: var(--accent-soft); color: var(--accent-ink);
}
.modal-edition .ed-vig-del {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; line-height: 18px; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--shell); color: var(--ink-2);
  font-size: .9rem; cursor: pointer; padding: 0;
}
.modal-edition .ed-vig-del:hover { color: var(--danger); border-color: var(--danger); }

.modal-edition .ed-vis-zone {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1.5px dashed var(--line); border-radius: 10px;
  padding: 16px 12px; text-align: center;
  font-size: .76rem; color: var(--ink-2);
  transition: border-color .12s, background .12s;
}
.modal-edition .ed-vis-zone strong { font-size: .82rem; color: var(--ink); font-weight: 600; }
.modal-edition .ed-vis-survol { border-color: var(--accent-line); background: var(--accent-soft); }
.modal-edition .ed-vis-occupe { opacity: .55; }
.modal-edition .ed-lien {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--accent-ink); text-decoration: underline; cursor: pointer;
}
.modal-edition .ed-vis-url { display: flex; gap: 6px; margin-top: 8px; }
.modal-edition .ed-vis-url input { flex: 1; }

/* ============================================================
   Accueil : trois modules, trois intentions
   ============================================================ */
.accueil {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 24px 48px;
}
.acc-inner { width: 100%; max-width: 940px; }

.acc-tete { text-align: center; margin-bottom: 30px; }
.acc-tete h1 {
  font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em;
  color: var(--ink); margin: 0 0 6px;
}
.acc-tete p { font-size: .88rem; color: var(--ink-2); margin: 0; }

.acc-cartes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 660px; margin: 0 auto; }

.acc-carte {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  text-align: left; font: inherit; cursor: pointer;
  background: var(--shell); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px 20px 18px;
  transition: border-color .14s, box-shadow .14s, transform .14s, background .14s;
}
.acc-carte:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop, 0 8px 24px rgba(0,0,0,.07));
}
.acc-carte:focus-visible { outline: none; box-shadow: var(--halo); }

.acc-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--accent-line);
}
.acc-carte:hover .acc-ic { background: var(--shell); }
.acc-ic svg { width: 21px; height: 21px; }

.acc-nom { font-size: 1rem; font-weight: 650; color: var(--ink); letter-spacing: -.01em; }
.acc-desc { font-size: .78rem; line-height: 1.5; color: var(--ink-2); }
.acc-carte .acc-etat {
  margin-top: 4px; font-size: .68rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--accent-ink);
}

/* Module fermé (droit manquant) : visible, mais visiblement fermé. */
.acc-carte.acc-verrou { opacity: .55; }
.acc-carte.acc-verrou:hover { transform: none; background: var(--shell); border-color: var(--line); }
.acc-carte.acc-verrou .acc-etat { color: var(--ink-3); }

.acc-pied {
  margin-top: 26px; text-align: center;
  font-size: .74rem; color: var(--ink-3);
}

/* Étiquette du module dans l'en-tête */
.brand-module {
  font-size: .66rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent-ink); margin-top: 1px;
}

@media (max-width: 780px) {
  .acc-cartes { grid-template-columns: 1fr; }
  .accueil { align-items: flex-start; padding-top: 20px; }
}

/* Retour aux modules : contrairement au bouton de liste (mobile seulement),
   il doit rester visible partout - c'est la sortie de secours. */
#homeBtn.nav-round { display: flex; width: 36px; height: 36px; }
#homeBtn .ic { width: 17px; height: 17px; }
#homeBtn[hidden] { display: none; }
/* Pose immédiate du curseur d'onglets (entrée dans un module). */
.seg-thumb.sans-transition { transition: none !important; }
.modal .set-version {
  float: right; font-size: .64rem; font-weight: 600; letter-spacing: .04em;
  color: var(--ink-3); margin-top: -18px;
}

/* Pied de l'accueil : sauvegarde et repère de version, discrets. */
.acc-pied {
  margin-top: 26px; text-align: center;
  font-size: .72rem; color: var(--ink-3);
}
.acc-pied .acc-lien { color: var(--ink-3); text-decoration: underline; }
.acc-pied .acc-lien:hover { color: var(--accent-ink); }
.acc-pied .acc-sep { margin: 0 6px; opacity: .6; }

/* Terme cherché, dans la liste : bien plus gras que le reste, sans changer
   la couleur ni la taille (la ligne doit rester lisible d'un coup d'œil). */
.item-name .hit { font-weight: 800; }
.item-sub .hit  { font-weight: 800; color: var(--ink-2); }

/* Bouton occupé (fabrication d'un PDF) : on montre que ça travaille. */
.pill.is-busy { opacity: .6; cursor: progress; }

/* Sélecteur de document dans la barre d'aperçu (fiche / affiche). */
.dt-docs { display: flex; gap: 6px; }
.dt-docs .chip {
  padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--shell);
  font: inherit; font-size: .72rem; font-weight: 600;
  color: var(--ink-3); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.dt-docs .chip:hover { color: var(--accent-ink); border-color: var(--accent-line); }
.dt-docs .chip.active {
  background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink);
}

/* ---------- Modale « Enregistrer l'affiche » ----------
   Une affiche part en impression ou dans un courriel : on montre d'abord ce
   qui va sortir, puis on choisit le support. L'aperçu est la feuille déjà
   rendue, clonée et réduite - donc exactement ce qui sera capturé. */
.modal.modal-affiche { max-width: 560px; }
.modal-affiche .ax-corps {
  display: grid;
  grid-template-columns: 238px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.modal-affiche .ax-vue {
  width: 238px;
  height: 337px;                       /* 794 × 1123 réduits de 30 % */
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 24, 18, .06), 0 8px 20px rgba(20, 24, 18, .08);
}
.modal-affiche .ax-scene {
  width: 794px; height: 1123px;
  pointer-events: none;
  transform: scale(.3);              /* 794 → 238 px */
  transform-origin: top left;
}
.modal-affiche .ax-scene .doc-pages { transform: none; }
.modal-affiche .ax-scene .sheet { box-shadow: none; margin: 0; }
.modal-affiche .ax-vide {
  display: flex; align-items: center; justify-content: center;
  width: 238px; height: 337px;
  border: 1px dashed var(--line); border-radius: 6px;
  color: var(--ink-3); font-size: .78rem;
}
.modal-affiche .ax-choix { display: flex; flex-direction: column; gap: 8px; }
.modal-affiche .ax-opt {
  display: flex; flex-direction: column; gap: 2px;
  padding: 11px 13px;
  text-align: left;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  transition: border-color .14s, background .14s, box-shadow .14s;
}
.modal-affiche .ax-opt:hover { border-color: var(--accent-line); }
.modal-affiche .ax-opt.is-on {
  background: var(--shell);
  border-color: var(--accent-line);
  box-shadow: var(--halo);
}
.modal-affiche .ax-opt-lab { font-size: .82rem; font-weight: 650; }
.modal-affiche .ax-opt-sub { font-size: .72rem; color: var(--ink-2); }
.modal-affiche .ax-opt.is-on .ax-opt-lab { color: var(--accent-ink); }
.modal-affiche .m-btns { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 560px) {
  .modal-affiche .ax-corps { grid-template-columns: 1fr; justify-items: center; }
}

/* ---------- Porte d'entrée ----------
   Elle couvre tout et elle est là dès le HTML : la plateforme n'apparaît
   jamais, même brièvement, avant que le code ait été donné. */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.gate[hidden] { display: none; }
.gate-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 34px 38px 30px;
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(20, 24, 18, .05), 0 18px 44px rgba(20, 24, 18, .10);
}
.gate-logo { height: 54px; width: auto; margin-bottom: 4px; }
.gate-titre { font-size: .96rem; font-weight: 650; letter-spacing: -.01em; }
.gate-sous { font-size: .76rem; color: var(--ink-2); margin-top: -8px; }
.gate-pave { display: flex; gap: 9px; margin-top: 4px; }
.gate-case {
  width: 46px; height: 56px;
  text-align: center;
  font-size: 1.4rem; font-weight: 650; font-family: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.gate-case:focus { background: var(--shell); border-color: var(--accent-line); box-shadow: var(--halo); }
.gate-pave.is-ko { animation: gate-non .32s; }
.gate-pave.is-ko .gate-case { border-color: #d8534f; }
@keyframes gate-non {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}
.gate-msg {
  min-height: 18px;
  font-size: .74rem;
  font-weight: 600;
  color: #c9403c;
  text-align: center;
}
.gate-msg.neutre { color: var(--ink-2); font-weight: 500; }

/* ---------- Aperçu des affiches : toujours côte à côte ----------
   Ces deux feuilles ne se lisent pas l'une après l'autre : elles se comparent.
   Elles s'alignent donc quel que soit le sens de lecture réglé pour les
   fiches. Le nom vit dans un bloc À CÔTÉ de la feuille, jamais dedans : la
   capture ne prend que .sheet, l'étiquette ne peut pas la suivre. */
.fiche-sheet-affiche .doc-pages {
  display: flex; align-items: flex-start; gap: 26px; width: auto;
}
.fiche-sheet-affiche .doc-pages .sheet-bloc { flex: 0 0 auto; }
.fiche-sheet-affiche .doc-pages .sheet { margin: 0; }


/* Nom de chaque affiche au-dessus de sa feuille, dans l'aperçu.
   Posé hors de .sheet : la capture ne le prend jamais. */
.doc-stage .sheet-nom {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 8px 2px;
}
