/* ================= Caisse Audit Admin — design system ================= */
/* Refonte UI/UX 2026-10-22 (docs/superpowers/specs/2026-10-22-ui-ux-refonte-design.md).
   Light base, tokens on :root, dark theme only overrides tokens.
   Vendored fonts; browsers silently fall back to the system stacks if absent. */
@font-face {
  font-family: "Inter var";
  src: url("../fonts/Inter-roman.var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;          /* table heads, toolbars, inset panels */
  --surface-hover: #f1f5fb;
  --border: #e3e8ef;
  --border-strong: #cfd6e2;
  --text: #0f172a;
  --text-muted: #556175;
  --text-subtle: #8792a5;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf1fe;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --ncm: #dc2626;
  --ncmin: #ea580c;
  --pv: #ca8a04;
  --done: #16a34a;
  /* badge pair tokens — AA contrast on light surfaces */
  --badge-ok-bg: #dcfce7;     --badge-ok-fg: #15803d;
  --badge-warn-bg: #fef3c7;   --badge-warn-fg: #b45309;
  --badge-danger-bg: #fee2e2; --badge-danger-fg: #b91c1c;
  --badge-ncmin-bg: #ffedd5;  --badge-ncmin-fg: #c2410c;
  --badge-muted-bg: #eef1f5;  --badge-muted-fg: #556175;
  --badge-accent-bg: #e0eaff; --badge-accent-fg: #1d4ed8;
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .08);
  --font-sans: "Inter var", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
[data-theme="dark"] {
  --bg: #0b111c;
  --surface: #121a28;
  --surface-2: #162032;
  --surface-hover: #1a2539;
  --border: #243049;
  --border-strong: #31405e;
  --text: #e6eaf2;
  --text-muted: #9aa6ba;
  --text-subtle: #6f7c93;
  --accent: #3b82f6;
  --accent-strong: #5b9af8;
  --accent-soft: color-mix(in srgb, #3b82f6 18%, #121a28);
  --badge-ok-bg: color-mix(in srgb, #16a34a 22%, #121a28);
  --badge-ok-fg: #4ade80;
  --badge-warn-bg: color-mix(in srgb, #d97706 22%, #121a28);
  --badge-warn-fg: #fbbf24;
  --badge-danger-bg: color-mix(in srgb, #dc2626 22%, #121a28);
  --badge-danger-fg: #f87171;
  --badge-ncmin-bg: color-mix(in srgb, #ea580c 22%, #121a28);
  --badge-ncmin-fg: #fb923c;
  --badge-muted-bg: #222d42;
  --badge-muted-fg: #9aa6ba;
  --badge-accent-bg: color-mix(in srgb, #4f8cf7 22%, #121a28);
  --badge-accent-fg: #93b6fb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1 { font-size: 22px; font-weight: 680; letter-spacing: -.01em; margin: 0 0 var(--s4); line-height: 1.25; }
h2 { font-size: 15.5px; font-weight: 640; margin: var(--s5) 0 var(--s3); line-height: 1.35; }
h3 { font-size: 14px; font-weight: 620; margin: var(--s4) 0 var(--s2); }
p { margin: var(--s2) 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: 12.5px; }
:where(h1, h2, h3) .mono { font-size: .92em; letter-spacing: -.01em; }
h1.mono { font-size: 20px; } h2.mono { font-size: 14.5px; } h3.mono { font-size: 13.5px; }
small { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.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; }

/* ---- icons (inline sprite, components/icons.html) ---- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px; height: 18px; flex-shrink: 0; vertical-align: -4px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; vertical-align: -3px; }
.icon-lg { width: 22px; height: 22px; }

/* ================= application shell ================= */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .18s ease;
}
.sidebar-head { height: var(--topbar-h); display: flex; align-items: center; padding: 0 var(--s3); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 2px 6px color-mix(in srgb, #2563eb 35%, transparent);
}
.brand-mark .icon { width: 19px; height: 19px; stroke-width: 2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2) var(--s4); display: flex; flex-direction: column; gap: 2px; }
.nav-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--s3); }
.nav-section-title {
  display: block; padding: var(--s2) var(--s3) var(--s1);
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-subtle);
  white-space: nowrap;
}
.sidebar-nav a {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px; border-radius: 8px;
  color: var(--text-muted); font-weight: 520; font-size: 13.5px; white-space: nowrap;
}
.sidebar-nav a .icon { color: var(--text-subtle); }
.sidebar-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidebar-nav a:hover .icon { color: var(--text-muted); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.sidebar-nav a.active .icon { color: var(--accent); }
.sidebar-nav a.active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-label { overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot { border-top: 1px solid var(--border); padding: var(--s2); display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.user-card { display: flex; align-items: center; gap: 10px; padding: var(--s2); border-radius: 8px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: var(--accent-soft); color: var(--accent);
}
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-actions { display: flex; gap: 2px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidebar-collapse { width: 100%; justify-content: flex-start; display: flex; align-items: center; gap: 10px; padding: 0 var(--s3); font: inherit; font-size: 13px; }

/* collapsed rail (desktop) — html.sb-collapsed set before paint by base.html */
@media (min-width: 901px) {
  .sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  .sb-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
  .sb-collapsed .brand-text, .sb-collapsed .nav-label, .sb-collapsed .user-meta,
  .sb-collapsed .collapse-label { display: none; }
  .sb-collapsed .nav-section-title { font-size: 0; padding: var(--s2) 0 0; margin: 0 var(--s3); border-top: 1px solid var(--border); }
  .sb-collapsed .nav-section:first-child .nav-section-title { border-top: 0; }
  .sb-collapsed .sidebar-head { justify-content: center; padding: 0; }
  .sb-collapsed .sidebar-nav { overflow: visible; }
  .sb-collapsed .sidebar-nav a { justify-content: center; padding: 0; }
  .sb-collapsed .sidebar-nav a:hover::after {
    content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--text); color: var(--surface); font-size: 12px; font-weight: 550; padding: 4px 8px; border-radius: 6px;
    white-space: nowrap; pointer-events: none; z-index: 50; box-shadow: var(--shadow);
  }
  .sb-collapsed .user-card { flex-direction: column; justify-content: center; gap: 4px; padding: var(--s1) 0; }
  .sb-collapsed .foot-actions { flex-direction: column; align-items: center; }
  .sb-collapsed .sidebar-collapse { justify-content: center; padding: 0; }
  .sb-collapsed .sidebar-collapse .icon { transform: scaleX(-1); }
}

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; transition: margin-left .18s ease; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s5); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar-spacer { flex: 1; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--text-muted); font-size: 13px; min-width: 0; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs > span:last-child { color: var(--text); font-weight: 560; }
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: var(--s2); height: 34px; padding: 0 6px 0 10px; min-width: 240px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-subtle);
  font: inherit; font-size: 13px; cursor: pointer;
}
.cmdk-trigger:hover { border-color: var(--border-strong); color: var(--text-muted); }
.cmdk-trigger .kbd { margin-left: auto; }
.kbd {
  display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 5px; line-height: 18px;
}
.content { padding: 20px var(--s5) var(--s7); min-width: 0; }
.user-menu { display: flex; align-items: center; gap: var(--s3); font-size: 13px; }
.role-badge { margin-right: .5rem; }

.theme-ico-light { display: none; }
[data-theme="dark"] .theme-ico-light { display: inline; }
[data-theme="dark"] .theme-ico-dark { display: none; }

/* ---- environment badge (always visible, anti cross-wiring) ---- */
.env-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; padding: 3px 10px; border-radius: 999px; text-transform: uppercase;
}
.env-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.env-dev { background: #dbeafe; color: #1d4ed8; }
.env-preprod { background: #fef3c7; color: #b45309; }
.env-prod { background: #fee2e2; color: #b91c1c; }
.env-test { background: #e5e7eb; color: #374151; }

/* ---- global htmx progress bar ---- */
#hx-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 100; pointer-events: none; opacity: 0; transition: opacity .15s;
  overflow: hidden;
}
#hx-progress::after {
  content: ""; display: block; height: 100%; width: 40%;
  background: var(--accent); animation: hx-slide 1s linear infinite;
}
body.hx-loading #hx-progress { opacity: 1; }
@keyframes hx-slide { from { transform: translateX(-250%); } to { transform: translateX(350%); } }

/* ---- command palette (Ctrl K) ---- */
.cmdk { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding: 12vh var(--s4) var(--s4); background: rgba(15, 23, 42, .38); backdrop-filter: blur(2px); }
.cmdk[hidden] { display: none; }
.cmdk-panel { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.cmdk-input-row { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); border-bottom: 1px solid var(--border); }
.cmdk-input-row .icon { color: var(--text-subtle); }
.cmdk-input { flex: 1; border: 0 !important; outline: 0; background: transparent !important; box-shadow: none !important; font-size: 15px !important; height: 52px; padding: 0 !important; }
.cmdk-mode { font-size: 12px; }
.cmdk-list { overflow-y: auto; padding: var(--s2); }
.cmdk-group { padding: var(--s2) var(--s3) var(--s1); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-subtle); }
.cmdk-item { display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3); border-radius: 8px; color: var(--text); cursor: pointer; }
.cmdk-item .icon { color: var(--text-subtle); }
.cmdk-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.cmdk-item-text small { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item[aria-selected="true"] { background: var(--accent-soft); }
.cmdk-item[aria-selected="true"] .icon { color: var(--accent); }
.cmdk-item:hover { text-decoration: none; }
.cmdk-enter { opacity: 0; font-size: 12px; color: var(--text-muted); }
.cmdk-item[aria-selected="true"] .cmdk-enter { opacity: 1; }
.cmdk-empty { padding: var(--s5); text-align: center; color: var(--text-muted); font-size: 13px; }
.cmdk-foot { display: flex; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-muted); }

/* ================= page structure ================= */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-header h1 { margin: 0; }
.page-heading { min-width: 0; flex: 1 1 420px; }
.page-lead { margin: 6px 0 0; color: var(--text-muted); max-width: 90ch; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.section-title { margin-top: var(--s6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin: var(--s6) 0 var(--s3); }
.section-head h2 { margin: 0; }

/* collapsible "À propos" note: keeps the regulatory wording one click away */
.info-note { margin: -8px 0 var(--s5); font-size: 13px; color: var(--text-muted); }
.info-note > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  color: var(--text-muted); font-weight: 550; border-radius: 6px; padding: 2px 4px; margin-left: -4px;
}
.info-note > summary::-webkit-details-marker { display: none; }
.info-note > summary:hover { color: var(--accent); }
.info-note > summary .icon-chev { transition: transform .15s; }
.info-note[open] > summary .icon-chev { transform: rotate(90deg); }
.info-note-body { margin-top: var(--s2); padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); max-width: 110ch; line-height: 1.6; }
.info-note-body p { margin: 0 0 var(--s2); }
.info-note-body p:last-child { margin-bottom: 0; }

/* ---- cards / panels ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s4) var(--s5); box-shadow: var(--shadow-sm);
}
.card > h2:first-child, .card > h3:first-child, .card > .card-head:first-child { margin-top: 0; }
:where(section.card, .card) + :where(section.card) , :where(section.card) + :where(.card) { margin-top: var(--s4); }
a.card { color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .text-muted { font-size: 12.5px; }
.card-block { display: block; margin-bottom: var(--s3); }
.card-accent-warn { border-left: 4px solid var(--warn); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s4); margin-top: var(--s4); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }

/* panel = card hosting a toolbar + a flush table + a footer */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
:where(.panel) + :where(.panel, .card), :where(.card) + :where(.panel) { margin-top: var(--s4); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: var(--s2); }
.panel-head .text-muted { font-size: 12.5px; }
.panel-body { padding: var(--s4); }
.panel-note { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); background: var(--surface-2); }
.panel > .empty-state { padding: var(--s5) var(--s4); }
.panel > .empty-state .empty-state-icon { width: 36px; height: 36px; margin-bottom: var(--s2); }
.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface); }
.toolbar .search-field { flex: 0 1 360px; }
.toolbar-count { font-size: 12.5px; color: var(--text-muted); margin-left: auto; }
/* legacy markup: a table directly in a card becomes a flush panel */
.card.table-scroll { padding: 0; overflow: auto; }

/* ---- KPI tiles ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.kpi-tile {
  --tone: transparent;
  position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s4) var(--s4) var(--s4) 18px; box-shadow: var(--shadow-sm); color: var(--text);
}
.kpi-tile::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--tone); }
.kpi-accent { --tone: var(--accent); }
.kpi-ok { --tone: var(--ok); }
.kpi-warn { --tone: var(--warn); }
.kpi-danger { --tone: var(--danger); }
.kpi-muted { --tone: var(--border-strong); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.kpi-label { color: var(--text-muted); font-size: 12px; font-weight: 560; letter-spacing: .02em; }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent); }
.kpi-muted .kpi-icon, .kpi-tile:not([class*="kpi-"]) .kpi-icon { color: var(--text-muted); background: var(--surface-2); }
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 4px; overflow-wrap: anywhere; }
.kpi-delta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi-spark { height: 32px; margin-top: var(--s2); }
a.kpi-tile { transition: border-color .15s, box-shadow .15s, transform .15s; }
a.kpi-tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
a.kpi-tile .kpi-go { position: absolute; right: 12px; bottom: 12px; color: var(--text-subtle); opacity: 0; transition: opacity .15s; }
a.kpi-tile:hover .kpi-go { opacity: 1; }
.kpi-row + .kpi-footnote { margin-top: calc(-1 * var(--s5) + 4px); }
.fiscal-panel > .kpi-row { margin-bottom: 0; }
.fiscal-panel > .kpi-row + .kpi-footnote { margin-top: -10px; }
.kpi-row.compact { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi-row.compact .kpi-value { font-size: 20px; }
.kpi-row.compact .kpi-tile { padding-top: 12px; padding-bottom: 12px; }

/* ---- badges (paired bg/fg tokens, AA contrast, dark-aware) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.6; white-space: nowrap; vertical-align: middle;
  background: var(--badge-muted-bg); color: var(--badge-muted-fg);
}
.badge-ok, .badge-done { background: var(--badge-ok-bg); color: var(--badge-ok-fg); }
.badge-warn, .badge-pv { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.badge-danger, .badge-ncm { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.badge-ncmin { background: var(--badge-ncmin-bg); color: var(--badge-ncmin-fg); }
.badge-muted { background: var(--badge-muted-bg); color: var(--badge-muted-fg); }
.badge-accent { background: var(--badge-accent-bg); color: var(--badge-accent-fg); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-inline {
  display: inline-block; padding: 0 6px; border-radius: 4px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
}
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-subtle); flex-shrink: 0; vertical-align: middle; }
.status-dot.status-ok { background: var(--ok); }
.status-dot.status-warn { background: var(--warn); }
.status-dot.status-ncmin { background: var(--ncmin); }
.status-dot.status-danger { background: var(--danger); }

/* ---- pills (segmented switchers) ---- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px;
  padding: 0 var(--s3); border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); font: inherit; font-weight: 560;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.pill:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill .mono { font-size: 11.5px; opacity: .8; }
.pill-count { font-size: 11px; font-weight: 650; padding: 0 6px; border-radius: 999px; background: var(--badge-muted-bg); color: var(--badge-muted-fg); }
.pill.active .pill-count { background: rgba(255, 255, 255, .22); color: #fff; }
.pill.pill-empty:not(.active) { color: var(--text-subtle); }

/* ---- tabs (restaurant fiche sub-views) ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--s4); }
.tab-btn, a.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px var(--s3); margin-bottom: -1px; border: none; border-bottom: 2px solid transparent;
  background: none; font: inherit; font-weight: 560; color: var(--text-muted); cursor: pointer;
}
.tab-btn .icon, a.tab .icon { width: 16px; height: 16px; }
.tab-btn:hover, a.tab:hover { color: var(--text); text-decoration: none; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { min-height: 120px; }

/* ================= tables ================= */
.table-scroll { overflow: auto; }
.table-scroll.fill { max-height: calc(100vh - 230px); }
table.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px;
}
.panel table.data-table, .card.table-scroll table.data-table, .panel .table-scroll table.data-table { border: 0; border-radius: 0; }
table.data-table th, table.data-table td { padding: 9px var(--s3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data-table th:first-child, table.data-table td:first-child { padding-left: var(--s4); }
table.data-table th:last-child, table.data-table td:last-child { padding-right: var(--s4); }
table.data-table th {
  color: var(--text-muted); font-size: 11.5px; font-weight: 620; text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table tbody tr:hover { background: var(--surface-hover); }
table.data-table td.num, table.data-table th.num { text-align: right; }
table.data-table td.actions { text-align: right; white-space: nowrap; }
table.data-table .cell-strong { font-weight: 600; color: var(--text); }
table.data-table .cell-sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }
table.data-table td > .empty-state { padding: var(--s6) var(--s4); }
/* keep an empty state readable when its table scrolls sideways (phones) */
.table-scroll table.data-table td > .empty-state { position: sticky; left: 0; max-width: calc(100vw - 2 * var(--s4)); }
table.data-table pre { margin: 0; white-space: pre-wrap; }
/* whole row clickable (app.js: first a.row-link / first link of the row) */
[data-row-link] tbody tr { cursor: pointer; }
[data-row-link] tbody tr:has(td > .empty-state) { cursor: default; }
.row-link { font-weight: 600; color: var(--text); }
.row-link:hover { color: var(--accent); }
.row-chev { color: var(--text-subtle); width: 16px; height: 16px; }
tr:hover .row-chev { color: var(--accent); }
.row-error, table.data-table tbody tr.row-error { background: color-mix(in srgb, var(--danger) 8%, transparent); }
table.data-table tbody tr.row-error:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* sort headers */
table.data-table th a { color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
table.data-table th a:hover { color: var(--text); text-decoration: none; }
table.data-table th a.sort-active { color: var(--accent); }
.sort-arrow { font-size: 10px; }

/* weekly-hours mini grid (identite tab) */
table.hours-grid { width: 100%; border-collapse: collapse; }
table.hours-grid th {
  text-align: left; color: var(--text-muted); font-weight: 550; text-transform: capitalize;
  padding: 7px var(--s3) 7px 0; width: 140px;
}
table.hours-grid td { padding: 7px 0; border-bottom: 1px solid var(--border); }
table.hours-grid tr:last-child td, table.hours-grid tr:last-child th { border-bottom: 0; }
table.hours-grid th { border-bottom: 1px solid var(--border); }

/* ---- pagination ---- */
.pagination {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 10px var(--s4); font-size: 13px; color: var(--text-muted);
  border-top: 1px solid var(--border); background: var(--surface);
}
.pagination .spacer { flex: 1; }
.page-link {
  min-width: 30px; height: 30px; padding: 0 8px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.page-link:hover { border-color: var(--border-strong); background: var(--surface-hover); text-decoration: none; }
.page-current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.page-current:hover { background: var(--accent); }
.page-ellipsis { padding: 2px 4px; }

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 580; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { border-color: var(--text-subtle); background: var(--surface-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .pill:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ================= forms ================= */
input[type="text"], input[type="password"], input[type="date"], input[type="search"],
input[type="email"], input[type="number"], input[type="file"], select, textarea {
  width: 100%; height: 38px; padding: 0 var(--s3); border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: var(--s2) var(--s3); line-height: 1.5; resize: vertical; }
select[multiple] { height: auto; padding: var(--s1); }
input[type="file"] { padding: 5px 6px; height: auto; color: var(--text-muted); }
input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 4px 12px; border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 560; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-hover); }
input:hover, select:hover, textarea:hover { border-color: var(--text-subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
label { display: block; margin: var(--s3) 0 6px; font-weight: 580; font-size: 13px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); margin: var(--s4) 0 0; }
legend { padding: 0 var(--s2); font-weight: 620; font-size: 13px; color: var(--text-muted); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { margin: 0; font-weight: 580; font-size: 13px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.45; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3) var(--s4); }
:where(.field-row, .field) + :where(.field-row, .field) { margin-top: var(--s4); }
.field-row > .field { margin-top: 0; }
.required::after { content: " *"; color: var(--danger); }
.search-field { position: relative; display: block; margin: 0; font-weight: 400; }
.search-field .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); width: 16px; height: 16px; pointer-events: none; }
.search-field input { padding-left: 34px; }

/* settings-style form: section title + help on the left, fields on the right */
.form-page { max-width: 1180px; }
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-section { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: var(--s5); padding: var(--s5); border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-head h2 { margin: 0 0 6px; font-size: 14.5px; display: flex; align-items: center; gap: var(--s2); }
.form-section-head p { margin: 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.form-section-body { min-width: 0; max-width: 720px; }
.form-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap;
  padding: var(--s3) var(--s5); background: var(--surface-2); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); position: sticky; bottom: 0; z-index: 5;
}
.form-actions .form-actions-note { margin-right: auto; font-size: 12.5px; color: var(--text-muted); }
.form-section-details { border-bottom: 1px solid var(--border); }
.form-section-details > summary {
  display: flex; align-items: center; gap: 6px; padding: 14px var(--s5); cursor: pointer; list-style: none;
  font-weight: 600; font-size: 13.5px; color: var(--text-muted);
}
.form-section-details > summary::-webkit-details-marker { display: none; }
.form-section-details > summary:hover { color: var(--text); background: var(--surface-hover); }
.form-section-details > .form-section { border-top: 1px solid var(--border); border-bottom: 0; }
.icon-chev { transition: transform .15s; }
details[open] > summary .icon-chev { transform: rotate(90deg); }
.mt-4 { margin-top: var(--s4); }
/* checkbox / radio chips */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s2); }
.check-chip {
  display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 9px var(--s3);
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
  font-weight: 560; font-size: 13px; line-height: 1.35; transition: border-color .12s, background .12s;
}
.check-chip input { margin-top: 1px; }
.check-chip:hover { border-color: var(--border-strong); }
.check-chip:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.check-chip small { display: block; font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--text-muted); }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; padding: 2px; }
.check-chip[hidden] { display: none; }
.toolbar-inline { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.toolbar-inline .search-field { flex: 0 1 300px; }
.toolbar-inline .check-tools { margin: 0; }
.check-tools { display: flex; gap: var(--s2); margin-bottom: var(--s2); }
.check-tools button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; }
.check-tools button:hover { text-decoration: underline; }
.segmented { align-self: flex-start; display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; gap: 2px; }
.segmented label { margin: 0; display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 7px; cursor: pointer; font-weight: 560; color: var(--text-muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented label:has(input:focus-visible) { box-shadow: var(--ring); }
/* date range + quick presets */
.date-range { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.date-range .field { flex: 0 1 170px; }
.date-presets { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 38px; }
.date-presets button {
  height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 560; cursor: pointer;
}
.date-presets button:hover { border-color: var(--accent); color: var(--accent); }
.filter-bar { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; padding: 10px var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--s4); box-shadow: var(--shadow-sm); }
.filter-bar .field > label { font-size: 12px; color: var(--text-muted); }
.filter-hint { align-self: center; color: var(--text-subtle); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; cursor: help; }
.filter-hint:hover { color: var(--accent); background: var(--surface-hover); }
.filter-bar .date-range { flex: 0 1 auto; }
.filter-bar .date-range .field { flex-basis: 150px; }
@media (min-width: 1200px) { .filter-bar .date-range { flex: 0 0 auto; flex-wrap: nowrap; } .filter-bar .date-presets { flex-wrap: nowrap; flex-shrink: 0; } }
.filter-bar .filter-note { flex: 1 1 100%; font-size: 12px; color: var(--text-muted); margin-top: -4px; }

/* legacy form bits */
.export-form { display: flex; flex-direction: column; gap: var(--s3); }
.search-form { display: flex; gap: var(--s2); }
.search-form input { width: 260px; }
.search-input { display: block; max-width: 420px; margin-bottom: var(--s4); }
.masked-notice { color: var(--warn); font-size: 12px; margin: 0 0 var(--s2); }
label.col-check { display: flex; align-items: center; gap: var(--s2); margin: 2px 0; font-weight: 400; }
label.col-check input { width: auto; }
label.col-check.col-masked { color: var(--text-muted); }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px var(--s3); }
.date-filter { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; margin: var(--s4) 0; }
.date-filter label { margin: 0; }
.fiscal-panel { display: flex; flex-direction: column; gap: var(--s4); }
.inline-form { display: inline; }

/* ================= feedback ================= */
.alert {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--radius-sm); margin: var(--s3) 0; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text);
}
.alert > .icon { color: var(--accent); margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-body > :first-child { margin-top: 0; }
.alert-body > :last-child { margin-bottom: 0; }
p.alert { display: block; }
.alert-danger {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--badge-danger-fg);
}
.alert-danger > .icon { color: var(--danger); }
.alert-warn { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.alert-warn > .icon { color: var(--warn); }
.alert-success { background: color-mix(in srgb, var(--ok) 8%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-success > .icon { color: var(--ok); }

.empty-state { text-align: center; padding: var(--s6) var(--s5); color: var(--text-muted); }
.empty-state-icon { width: 44px; height: 44px; margin: 0 auto var(--s3); border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-subtle); font-size: 20px; }
.empty-state-icon .icon { width: 22px; height: 22px; }
.empty-state-title { font-weight: 620; color: var(--text); margin: 0 0 var(--s1); }
.empty-state-hint { font-size: 13px; margin: 0 auto; max-width: 60ch; }
.empty-state-action { margin-top: var(--s4); }

.error-card { max-width: 640px; margin: 8vh auto 0; }

/* ---- charts ---- */
.chart { width: 100%; }
.chart-fallback { color: var(--text-muted); font-size: 13px; text-align: center; padding: var(--s5); }
.sparkline { display: block; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.chart-grid > .card h2 { margin-top: 0; }
.chart-sm { height: 240px; }
.chart-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.chart-card-head h2 { margin: 0; font-size: 14px; }
.chart-card-head .text-muted { font-size: 12px; }

/* ---- progress ---- */
.progress { background: var(--badge-muted-bg); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--ok); height: 100%; border-radius: 999px; }
.evidence-pre { font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s3); margin: var(--s2) 0; }

/* ---- interaction states (keyboard a11y baseline) ---- */
a:focus-visible, button:focus-visible, .btn:focus-visible, .pill:focus-visible,
.tab-btn:focus-visible, summary:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ================= login ================= */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.login-aside {
  position: relative; overflow: hidden; color: #e8eefc; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -20%, #3b82f6 0%, transparent 55%), radial-gradient(900px 500px at 120% 120%, #1e40af 0%, transparent 55%), #0b1530;
}
.login-aside .brand { color: #fff; }
.login-aside .brand-text small { color: #a9bbe8; }
.login-pitch h2 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 var(--s4); color: #fff; max-width: 18ch; }
.login-pitch p { color: #b9c7ea; max-width: 52ch; }
.login-points { list-style: none; padding: 0; margin: var(--s5) 0 0; display: flex; flex-direction: column; gap: var(--s3); }
.login-points li { display: flex; gap: var(--s3); align-items: flex-start; color: #d6e0fa; }
.login-points .icon { color: #7fb0ff; margin-top: 2px; }
.login-foot { font-size: 12px; color: #8ea2d4; }
.login-main { display: grid; place-items: center; padding: var(--s6) var(--s5); background: var(--bg); }
.login-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 36px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 21px; margin-bottom: 6px; }
.login-hint { color: var(--text-muted); font-size: 13px; margin-top: 0; }
.login-card .btn { width: 100%; margin-top: var(--s5); height: 42px; }
.login-card .field + .field { margin-top: var(--s4); }
.login-card form { margin-top: var(--s5); }

/* ================= restaurant workspace ================= */
.ws-header { margin: -4px 0 var(--s4); }
.ws-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.ws-title { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.ws-avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; font-size: 15px; color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); }
.ws-title h1 { margin: 0; font-size: 21px; }
.ws-meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.ws-meta .sep { color: var(--border-strong); }
.ws-switch { margin-left: var(--s2); }
.copy-chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 6px; padding: 0 6px; height: 22px; color: var(--text-muted); cursor: pointer; font-family: var(--font-mono); font-size: 11.5px;
}
.copy-chip:hover { color: var(--text); border-color: var(--border-strong); }
.copy-chip .icon { width: 12px; height: 12px; }
.copy-chip.copied { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.ws-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-top: var(--s3); overflow-x: auto; }
.ws-tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 580; white-space: nowrap; }
.ws-tab .icon { width: 16px; height: 16px; }
.ws-tab:hover { color: var(--text); text-decoration: none; }
.ws-tab.is-current { color: var(--accent); border-bottom-color: var(--accent); }
.subtabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: var(--s4); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.subtabs .tab-btn { border: 0; margin: 0; padding: 6px 12px; border-radius: 7px; font-size: 13px; }
.subtabs .tab-btn:hover { background: var(--surface-hover); }
.subtabs .tab-btn.active { background: var(--accent-soft); color: var(--accent); }

/* ================= domain blocks ================= */
/* vertical rhythm of stacked panels (sync detail, fiscal tabs, reports) */
.sync-panel, .stack-panels { display: flex; flex-direction: column; gap: var(--s4); }
.sync-panel > .kpi-row, .stack-panels > .kpi-row { margin-bottom: 0; }
.sync-panel .panel + .panel, .stack-panels .panel + .panel, .fiscal-panel .panel + .panel { margin-top: 0; }
.panel > .pagination:first-child { border-top: 0; }
.grid-2 > .panel, .grid-2 > .card { margin: 0; min-width: 0; }

/* dashboard: attention list */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: var(--s4); align-items: start; margin-bottom: var(--s5); }
.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); border-bottom: 1px solid var(--border); }
.attention-list li:last-child { border-bottom: 0; }
.attention-list a.attention-name { font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.attention-list a.attention-name:hover { color: var(--accent); }
.attention-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.attention-ico .icon { width: 16px; height: 16px; }
.attention-ico.tone-danger { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.attention-ico.tone-warn { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.attention-ico.tone-muted { background: var(--badge-muted-bg); color: var(--badge-muted-fg); }
.attention-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.attention-text small { color: var(--text-muted); }
.pack-form { display: flex; gap: var(--s2); flex-wrap: wrap; }
.pack-form select { flex: 1 1 260px; width: auto; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s3); }
.quick-links-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-link { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.quick-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.quick-link .kpi-icon { --tone: var(--accent); }
.quick-link strong { display: block; font-size: 13.5px; }
.quick-link small { color: var(--text-muted); }

/* JET rows tinted by R19 code family (leading digit of code_event) */
.jet-table tr.jet-fam-1 td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.jet-table tr.jet-fam-2 td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.jet-table tr.jet-fam-3 td:first-child { box-shadow: inset 3px 0 0 var(--pv); }
.jet-table tr.jet-fam-4 td:first-child { box-shadow: inset 3px 0 0 var(--ncmin); }
.jet-table tr.jet-fam-5 td:first-child { box-shadow: inset 3px 0 0 var(--ncm); }

/* identity tab (fiscal identity dl grid) */
.identity-grid { display: grid; grid-template-columns: max-content 1fr; gap: 10px var(--s5); margin: var(--s3) 0 0; }
.identity-grid dt { color: var(--text-muted); font-size: 12px; font-weight: 560; align-self: center; }
.identity-grid dd { margin: 0; font-weight: 520; }
.fiche-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.fiche-grid > .card { margin: 0 !important; }
.fiche-grid .span-all { grid-column: 1 / -1; }

/* fiscal document timeline (tickets/notes accordion) */
.timeline { display: flex; flex-direction: column; gap: 6px; }
.sig-card { padding: 0; border-left: 3px solid var(--border); overflow: hidden; }
.sig-card[open] { border-left-color: var(--accent); }
.sig-card > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s4);
  cursor: pointer; list-style: none; font-size: 13px; padding: 10px var(--s4);
}
.sig-card > summary:hover { background: var(--surface-hover); }
.sig-card > summary::-webkit-details-marker { display: none; }
.sig-card > summary::before { content: "\25B8"; color: var(--text-muted); width: 10px; }
.sig-card[open] > summary::before { content: "\25BE"; }
.sig-card > :not(summary) { margin-left: var(--s4); margin-right: var(--s4); }
.sig-card > :last-child { margin-bottom: var(--s4); }
.sig-card h3 { font-size: 13px; color: var(--text-muted); margin: var(--s4) var(--s4) var(--s2); }
.sig-total { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.sig-fields {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px var(--s4);
  margin-top: 0; padding-top: var(--s3); border-top: 1px solid var(--border);
}
.sig-fields dt { color: var(--text-muted); }
.sig-fields dd { margin: 0; word-break: break-all; }

/* verifier verdict banner */
.verdict-banner {
  --tone: var(--warn);
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2) var(--s5); align-items: center;
  border-left: 6px solid var(--tone); padding: var(--s5);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 8%, var(--surface)), var(--surface) 60%);
}
.verdict-banner h1 { color: var(--tone); font-size: 34px; letter-spacing: -.02em; margin: 0; grid-row: span 3; align-self: center; }
.verdict-banner > p, .verdict-banner > ul { grid-column: 2; margin: 0; }
.verdict-pass { --tone: var(--ok); }
.verdict-fail { --tone: var(--danger); }
.verdict-incomplete { --tone: var(--warn); }
.report-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: var(--s4) 0; position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 4; }
.report-nav a { font-size: 12.5px; }

/* lab */
.mutation { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s2); padding: 3px 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end; }
.row-actions form { display: inline; }
.option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.option-card { display: flex; gap: var(--s4); align-items: flex-start; padding: var(--s4) var(--s5); }
.option-card h3 { margin: 0 0 4px; color: var(--text); display: flex; align-items: center; gap: var(--s2); }
.option-card p { margin: 0; font-size: 13px; }
.option-card .kpi-icon { --tone: var(--accent); width: 40px; height: 40px; border-radius: 10px; }
.option-card .kpi-icon .icon { width: 20px; height: 20px; }

/* campaigns */
.campaign-card h3 { margin: 0 0 var(--s2); display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.campaign-card .progress { margin: var(--s3) 0 var(--s2); }
.exec-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.exec-form select { width: 100px; height: 32px; }
.exec-form input[type="text"] { width: 200px; height: 32px; }
.exec-form input[type="file"] { width: 200px; font-size: 12px; }
.exec-form .btn { height: 32px; }

/* audits board */
.constat-card { display: flex; flex-direction: column; gap: 6px; }
.constat-card[hidden] { display: none; }
.constat-card h3 { margin: 4px 0 0; font-size: 13px; color: var(--accent); }
.constat-card p { margin: 0; font-size: 13px; color: var(--text); }
.constat-badges { display: flex; gap: 6px; }
.legend-list { list-style: none; padding: 0; margin: var(--s2) 0 0; display: flex; gap: var(--s4); flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.legend-list strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* access */
.one-time-password { font-size: 16px; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); border: 1px dashed var(--border-strong); user-select: all; }
.scope-list { list-style: none; padding: 0; margin: var(--s3) 0 0; display: flex; flex-direction: column; gap: 6px; }
.scope-list li { display: flex; gap: var(--s2); align-items: baseline; flex-wrap: wrap; }

/* sidebar sections legacy hooks (kept for docs workspace markup) */
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.doc-list li { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }

/* ================= docs center: document viewer / editor typography ================= */
/* ---- docscenter: landing page (category tree + list) ---- */
.two-pane { display: grid; grid-template-columns: 220px 1fr; gap: var(--s5); align-items: start; }
.pane-left { position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.pane-right { min-width: 0; display: flex; flex-direction: column; gap: var(--s4); }
.cat-tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cat-tree a { display: block; padding: var(--s1) var(--s3); border-radius: var(--radius); color: var(--text-muted); font-weight: 550; font-size: 13px; }
.cat-tree a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.icon-lock { color: var(--text-muted); flex-shrink: 0; }
.search-results { list-style: none; margin: var(--s4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.search-results li { padding: var(--s3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* ---- docscenter: document viewer (body + meta/toc/history rail) ---- */
.doc-layout { display: grid; grid-template-columns: 1fr 300px; gap: var(--s5); align-items: start; }
.doc-side { display: flex; flex-direction: column; gap: var(--s4); position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.meta-card dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s3); margin: var(--s3) 0 0; }
.meta-card dt { color: var(--text-muted); font-size: 12px; }
.meta-card dd { margin: 0; }
.toc-card, .history-card { font-size: 13px; }
.toc-card ul { padding-left: var(--s4); margin: var(--s2) 0; }
.git-history { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.git-history li { font-size: 12px; color: var(--text-muted); }
.git-history code { color: var(--text); }
.git-history time { display: block; font-size: 11px; }

/* rendered markdown typography (document body + live preview pane) */
.doc-body, .preview-body { line-height: 1.6; }
.doc-body h1, .doc-body h2, .doc-body h3, .preview-body h1, .preview-body h2, .preview-body h3 { margin-top: var(--s5); }
.doc-body p, .preview-body p { margin: var(--s2) 0; }
.doc-body pre, .preview-body pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s3); overflow: auto; font-family: var(--font-mono); font-size: 12px;
}
.doc-body code, .preview-body code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.doc-body pre code, .preview-body pre code { background: none; padding: 0; }
.doc-body table, .preview-body table { width: 100%; border-collapse: collapse; margin: var(--s3) 0; }
.doc-body th, .doc-body td, .preview-body th, .preview-body td { border: 1px solid var(--border); padding: var(--s2) var(--s3); text-align: left; }

/* ---- docscenter: markdown editor (two-pane textarea + live preview) ---- */
.editor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }
.editor-pane { display: flex; flex-direction: column; gap: var(--s3); }
.editor-textarea { width: 100%; font-family: var(--font-mono); font-size: 13px; resize: vertical; }
.editor-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.diff-card { margin-top: var(--s3); }
.diff-pre {
  font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s3); max-height: 400px; overflow: auto;
}

/* ================= docs center — dedicated workspace (spec docs-workspace) ================= */
.docs-body { background: var(--bg); }
.docs-shell { display: flex; flex-direction: column; min-height: 100vh; }
.docs-topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s4);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.docs-back { white-space: nowrap; color: var(--text-muted); }
.docs-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; padding: 0 var(--s2); border-left: 1px solid var(--border); margin-left: 2px; }
.docs-brand .icon { color: var(--accent); }
.docs-nav { display: flex; gap: 2px; margin-left: var(--s2); }
.docs-nav a {
  padding: 6px 10px; border-radius: 8px; color: var(--text-muted); font-weight: 560; font-size: 13px; white-space: nowrap;
}
.docs-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.docs-nav a.active { background: var(--accent-soft); color: var(--accent); }
.docs-search { flex: 1; min-width: 160px; max-width: 360px; margin-left: auto; }
.docs-search input { width: 100%; height: 34px; }
.docs-topbar .user-menu { gap: 4px; margin-left: 2px; }
.docs-main { display: grid; grid-template-columns: 300px minmax(0, 1fr); flex: 1; align-items: start; }
.docs-rail {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto;
  background: var(--surface); border-right: 1px solid var(--border); padding: var(--s3); font-size: 13px;
}
.docs-content { padding: var(--s5); min-width: 0; }
.docs-content .breadcrumbs { margin-bottom: var(--s3); }
@media (min-width: 901px) {
  .docs-rail-collapsed .docs-main { grid-template-columns: minmax(0, 1fr); }
  .docs-rail-collapsed .docs-rail { display: none; }
}
.page-lead { margin: var(--s1) 0 0; max-width: 72ch; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.section-title { margin-top: var(--s6); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.card-head h2, .card-head h3 { margin: 0; }

/* explorer rail (mirrors docs-audit/) */
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.rail-root { font-weight: 600; color: var(--text); }
.rail-new { padding: 2px 8px; font-size: 12px; }
.rail-filter { width: 100%; margin-bottom: var(--s3); }
.tree-root, .tree-root ul { list-style: none; margin: 0; padding: 0; }
.tree-root ul { padding-left: var(--s4); border-left: 1px dashed var(--border); margin-left: 7px; }
.tree-root details > summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius);
  list-style: none; user-select: none;
}
.tree-root details > summary::-webkit-details-marker { display: none; }
.tree-root details > summary:hover { background: var(--bg); }
.tree-caret { width: 0; height: 0; border-left: 5px solid var(--text-muted); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; flex-shrink: 0; }
details[open] > summary .tree-caret { transform: rotate(90deg); }
.tree-cat-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.tree-label { font-weight: 600; }
.tree-dir { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { margin-left: auto; font-size: 11px; color: var(--text-muted); background: var(--bg); border-radius: 10px; padding: 0 6px; }
.tree-doc { margin: 1px 0; border-radius: var(--radius); }
.tree-doc a { display: flex; align-items: center; gap: 6px; padding: 3px 6px; color: var(--text); border-radius: var(--radius); }
.tree-doc a:hover { background: var(--bg); text-decoration: none; }
.tree-doc.current > a { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); font-weight: 600; }
.tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-slug { display: block; padding-left: 20px; color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-lock, .tree-media { font-size: 11px; color: var(--text-muted); }
.tree-format { font-size: 10px; padding: 0 5px; }
.tree-doc.filtered-out, .tree-cat.filtered-out, .tree-att-folder.filtered-out { display: none; }
.rail-legend { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; }
.rail-empty { padding: var(--s3); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; vertical-align: middle; }
.status-dot.status-ok { background: var(--ok); }
.status-dot.status-warn { background: var(--warn); }
.status-dot.status-ncmin { background: var(--ncmin); }
.status-dot.status-danger { background: var(--danger); }

/* parcours d'audit: one card per step, info left / status form right */
.parcours-steps { gap: var(--s3); }
.parcours-steps > li.parcours-step { display: block; border-left: 4px solid var(--border-strong); }
.parcours-step.step-ok { border-left-color: var(--ok); }
.parcours-step.step-warn { border-left-color: var(--warn); }
.parcours-step.step-danger { border-left-color: var(--danger); }
.step-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.step-head h4 { margin: 0; font-size: 14.5px; }
.step-clauses { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.step-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr); gap: var(--s5); align-items: start; }
.step-info p { margin-top: 0; }
.step-info ul { margin: 4px 0 0; padding-left: 18px; }
.parcours-step-form { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.parcours-step-form .field + .field { margin-top: 0; }
.step-actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
@media (max-width: 1100px) { .step-body { grid-template-columns: minmax(0, 1fr); } }

/* référentiel matrix: long attachment lists fold, each line stays on one row */
.referentiel-matrix .att-line, .referentiel-matrix td:first-child { white-space: nowrap; }
.cell-more > summary { cursor: pointer; color: var(--accent); font-weight: 560; }
.cell-more[open] > summary { margin-bottom: 4px; }

/* overview */
.docs-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-card-wide { grid-column: 1 / -1; }
.docs-chart { width: 100%; }
.coverage-table { margin-top: var(--s3); font-size: 13px; }
.docs-categories { display: flex; flex-direction: column; gap: var(--s4); }
.cat-card h3 { margin: 0; }
.doc-list li { flex-wrap: wrap; }
.doc-summary { flex-basis: 100%; padding-left: 16px; font-size: 12px; }
.doc-att a { color: var(--text); }

/* explorer page */
.explorer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s5); align-items: start; }
.explorer-table { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.explorer-cat > summary { display: flex; align-items: center; gap: var(--s2); cursor: pointer; list-style: none; flex-wrap: wrap; }
.explorer-cat > summary::-webkit-details-marker { display: none; }
.explorer-cat[open] > summary { margin-bottom: var(--s3); }
.explorer-rows { font-size: 13px; }
table.explorer-rows th { position: static; }      /* no sticky header inside the scroll box */
table.explorer-rows th:first-child { min-width: 300px; }
.explorer-path { font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }
.explorer-path code { font-size: 11px; }
.explorer-rows td.num, .explorer-rows th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.explorer-rows td { vertical-align: top; }
.explorer-files { font-size: 11px; }
.explorer-actions { white-space: nowrap; }
.explorer-att td:first-child { padding-left: var(--s5); }
.explorer-side { position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.ascii-tree {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.45; white-space: pre; overflow: auto; max-height: 70vh;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3); margin: 0;
}

/* document page */
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.doc-title { margin: 0 0 var(--s2); }
.doc-head-meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 13px; }
.doc-path { color: var(--text-muted); font-size: 12px; }
.docs-content .doc-layout { grid-template-columns: minmax(0, 1fr) 320px; }
.doc-body img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); display: block; margin: var(--s3) 0; }
.toc-card { max-height: 50vh; overflow: auto; }
.toc-card ul ul { padding-left: var(--s3); }
.toc-card a { color: var(--text-muted); }
.toc-card a:hover, .toc-card a.active { color: var(--accent); }
.media-gallery { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--border); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s3); }
.media-thumb { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-muted); }
.media-thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin: 0; }

/* editor */
.editor { display: flex; flex-direction: column; gap: var(--s4); }
.meta-form { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); margin: 0; }
.meta-form legend { font-weight: 600; padding: 0 var(--s2); }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3) var(--s4); }
.meta-grid label, .meta-grid .label-text { display: block; font-size: 13px; color: var(--text-muted); }
.meta-grid label input[type="text"], .meta-grid label select { display: block; width: 100%; margin-top: 4px; }
.meta-grid label.inline { display: inline-flex; align-items: center; gap: 4px; margin-right: var(--s3); color: var(--text); }
.meta-grid .span-2 { grid-column: span 2; }
.editor-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.editor-toolbar .btn { padding: 2px 8px; font-size: 12px; }
.toolbar-spacer { flex: 1; }
.editor-stats { font-size: 12px; font-variant-numeric: tabular-nums; }
.editor-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s3); align-items: stretch; }
.editor-outline { font-size: 12px; max-height: 640px; overflow: auto; padding: var(--s2); }
.editor-outline p { margin: 0 0 var(--s1); font-weight: 600; }
.editor-outline button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text-muted); padding: 2px 4px; cursor: pointer; border-radius: 4px; font: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-outline button:hover { background: var(--bg); color: var(--text); }
.editor-outline .lvl-2 { padding-left: 12px; } .editor-outline .lvl-3 { padding-left: 22px; } .editor-outline .lvl-4 { padding-left: 32px; }
.editor-textarea { min-height: 640px; line-height: 1.5; tab-size: 2; }
.preview-pane { max-height: 80vh; overflow: auto; position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.search-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.search-snippet { margin: var(--s2) 0; font-size: 13px; color: var(--text-muted); }
.search-snippet mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 2px; }
.new-doc-form { display: flex; flex-direction: column; gap: var(--s4); }

@media (max-width: 1500px) {
  .explorer-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .docs-charts { grid-template-columns: minmax(0, 1fr); }
  .explorer-side { position: static; }
  .docs-content .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-body { grid-template-columns: minmax(0, 1fr); }
  .editor-outline { max-height: 160px; }
}
@media (max-width: 900px) {
  .docs-main { grid-template-columns: minmax(0, 1fr); }
  .docs-content > *, .docs-categories > *, .explorer-layout > *, .doc-layout > * { min-width: 0; }
  .doc-body table, .preview-body table { display: block; overflow-x: auto; }
  .search-results a, .doc-path, .explorer-path, .step-info a, .doc-list a { overflow-wrap: anywhere; }
  .coverage-table { display: block; overflow-x: auto; }
  .chart-card { min-width: 0; overflow: hidden; }
  .explorer-table .table-scroll, .explorer-cat .table-scroll { max-width: 100%; }
  .page-header .search-form { width: 100%; }
  .page-header .search-form input { flex: 1; width: auto; }
  .docs-rail { position: fixed; left: 0; width: 300px; max-width: 85vw; transform: translateX(-100%); transition: transform .2s ease; z-index: 30; }
  .docs-rail.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .docs-nav { display: none; }
  .docs-brand, .docs-back-label, .docs-topbar .env-badge { display: none; }
  .docs-content { padding: var(--s4); }
}

/* ---- docs center: xlsx viewer / editor (spec docs-xlsx) ---- */
.xl-book { margin-top: var(--s3); }
.xl-tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: var(--s2); }
.xl-tab { background: none; border: 1px solid transparent; border-bottom: 0; padding: 6px 12px; border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--text-muted); }
.xl-tab:hover { background: var(--bg); color: var(--text); }
.xl-tab[aria-selected="true"] { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; margin-bottom: -1px; }
.xl-toolbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.xl-filter { max-width: 280px; }
.xl-stats { font-size: 12px; font-variant-numeric: tabular-nums; }
.xl-scroll { overflow: auto; max-height: calc(100vh - 300px); min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.xl-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.xl-grid th, .xl-grid td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 3px 6px; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; }
.xl-grid th { background: var(--bg); color: var(--text-muted); font-weight: 600; text-align: center; position: sticky; z-index: 2; font-size: 11px; font-family: var(--font-mono); white-space: nowrap; }
.xl-grid thead th { top: 0; }
.xl-grid th.xl-rowhead, .xl-grid th.xl-corner { left: 0; text-align: right; }
.xl-grid th.xl-corner { z-index: 3; }
.xl-rowhead-col { width: 48px; }
.xl-grid td.xl-n, .xl-grid td.xl-d { text-align: right; }
.xl-grid td.xl-b { text-align: center; }
.xl-grid td.xl-f { color: var(--accent); }
.xl-grid td.xl-e { color: var(--danger, #b91c1c); }
.xl-grid tr.xl-frozen td { font-weight: 600; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.xl-editing .xl-grid td { cursor: text; min-height: 1.35em; }
.xl-editing .xl-grid td:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.xl-grid td.xl-dirty { background: color-mix(in srgb, var(--warn, #f59e0b) 28%, var(--surface)) !important; }
.xl-grid td.xl-conflict { outline: 2px dashed var(--danger, #b91c1c); outline-offset: -2px; }
.xl-status { margin-top: var(--s2); font-size: 12px; display: flex; gap: var(--s2); align-items: baseline; }
.xl-status [data-xlsx-raw] { white-space: pre-wrap; overflow-wrap: anywhere; }
.xl-editor-help { font-size: 13px; margin-bottom: var(--s3); line-height: 1.5; }
.xl-editor-help kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--bg); }
.xl-side { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-top: var(--s4); }
@media (max-width: 900px) { .xl-side { grid-template-columns: minmax(0, 1fr); } .xl-scroll { max-height: 70vh; } }
.xl-savebar { position: sticky; top: var(--topbar-h); z-index: 6; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: var(--s2) 0; margin-bottom: var(--s2); background: var(--bg); border-bottom: 1px solid var(--border); font-size: 13px; }
/* stacking: row numbers (2) < frozen rows (3) < column letters (4) < corner (5) */
.xl-grid tbody tr.xl-frozen { position: sticky; z-index: 3; }
.xl-grid thead th { z-index: 4; }
.xl-grid th.xl-corner { z-index: 5; }
.xl-grid tr.xl-frozen td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.xl-grid tr.xl-hidden-row, .xl-grid .xl-hidden-col { display: none; }
.xl-show-hidden .xl-grid tr.xl-hidden-row { display: table-row; }
.xl-show-hidden .xl-grid .xl-hidden-col { display: table-cell; }
.xl-show-hidden .xl-grid tr.xl-hidden-row > *, .xl-show-hidden .xl-grid .xl-hidden-col { background-image: repeating-linear-gradient(45deg, transparent 0 6px, color-mix(in srgb, var(--text-muted) 12%, transparent) 6px 7px); }
.xl-hidden-toggle { font-size: 12px; }

/* ================= responsive ================= */
.sidebar-toggle { display: none; }
@media (max-width: 1500px) {
  .ws-switch .btn-label { display: none; }
  .ws-switch { padding: 0 8px; }
}
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .form-section-body { max-width: none; }
}
@media (max-width: 1200px) {
  .docs-back-label, .docs-brand { display: none; }
  .docs-search { min-width: 120px; }
  .docs-nav a { padding: 6px 8px; }
}
@media (max-width: 1100px) {
  .cmdk-trigger { min-width: 0; }
  .cmdk-trigger .cmdk-trigger-label, .cmdk-trigger .kbd { display: none; }
  .fiche-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .two-pane, .doc-layout, .editor-layout, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .pane-left, .doc-side { position: static; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: 272px; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .45); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: inline-grid; }
  .sidebar-collapse { display: none; }
  .topbar { padding: 0 var(--s4); gap: var(--s2); }
  .content { padding: var(--s4) var(--s4) var(--s6); }
  .breadcrumbs { font-size: 0; }
  .breadcrumbs > :not(:last-child) { display: none; }
  .breadcrumbs > :last-child { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .login-page { grid-template-columns: minmax(0, 1fr); }
  .login-aside { display: none; }
  .verdict-banner { grid-template-columns: minmax(0, 1fr); }
  .verdict-banner h1 { grid-row: auto; }
  .verdict-banner > p, .verdict-banner > ul { grid-column: 1; }
  .table-scroll.fill { max-height: none; }
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .env-badge { padding: 3px 7px; letter-spacing: .04em; }
  .form-actions { padding: var(--s2) var(--s4); flex-wrap: nowrap; }
  .form-actions .form-actions-note { display: none; }
  .form-actions .btn { white-space: normal; text-align: center; line-height: 1.2; }
  .form-section { padding: var(--s4); }
  .ws-header { margin-bottom: var(--s4); }
  .ws-avatar { width: 36px; height: 36px; border-radius: 10px; font-size: 13px; }
  .ws-title h1 { font-size: 17px; }
  .ws-top { gap: var(--s3); }
  .ws-top .page-actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ws-top .page-actions .btn { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .ws-tabs { margin-top: var(--s3); }
  .ws-tab { padding: 8px 10px; }
  h1 { font-size: 19px; }
  .page-actions { width: 100%; }
  .ws-switch .btn-label { display: none; }
  .filter-bar .field { flex: 1 1 140px; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 22px; }
}

/* ================= print (verification reports, fiches) ================= */
@media print {
  .sidebar, .topbar, .page-actions, .report-nav, .cmdk, .ws-tabs, .ws-switch, #hx-progress { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .panel, .kpi-tile { box-shadow: none; break-inside: avoid; }
  .table-scroll, .table-scroll.fill { max-height: none; overflow: visible; }
}
