/* ==========================================================================
   Document Centre — Legends Global design system.
   This is the same system as the Q&A interview app (matthewjamestaylor/
   interview, PR #14): the same tokens, the same two-ground component set
   (.ink and .paper, each redefining --bg/--fg/--line/etc. so one piece of
   markup works on either), the same Nicky Sans + DM Mono type scale, the
   same lock-up SVG. Black and white; colour appears only for meaning.

   Below the shared foundation is a compatibility section that restyles
   Document Centre's own existing component classes (.card, .table,
   .sortable-item, .q-block, .doc-paper, etc.) against these same tokens,
   so every screen in the app reads as one system without every view's
   markup needing to change.
   ========================================================================== */

/* ---------- Type: Nicky Sans (Digitype Studio, licensed by Legends
   Global) is the brand face. DM Mono (Colophon Foundry, SIL OFL 1.1)
   carries keys, times and references, because Nicky Sans has no tabular
   figures. ---------- */
@font-face { font-family: 'Nicky Sans'; font-weight: 300; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/NickySans-Light.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 300; font-style: italic; font-display: swap; src: url('/assets/fonts/nicky/NickySans-LightItalic.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/NickySans-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 400; font-style: italic; font-display: swap; src: url('/assets/fonts/nicky/NickySans-Italic.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/NickySans-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 500; font-style: italic; font-display: swap; src: url('/assets/fonts/nicky/NickySans-MediumItalic.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/NickySans-Bold.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 700; font-style: italic; font-display: swap; src: url('/assets/fonts/nicky/NickySans-BoldItalic.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 900; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/NickySans-Black.ttf') format('truetype'); }
@font-face { font-family: 'Nicky Sans'; font-weight: 900; font-style: italic; font-display: swap; src: url('/assets/fonts/nicky/NickySans-BlackItalic.ttf') format('truetype'); }
@font-face { font-family: 'DM Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/dm-mono-400.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/dm-mono-400-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Mono'; font-weight: 500; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/dm-mono-500.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Mono'; font-weight: 500; font-style: normal; font-display: swap; src: url('/assets/fonts/nicky/dm-mono-500-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  /* Header/nav chrome (darkest) vs. page canvas (one step up) are two
     distinct dark tones in the brief, not the same value. */
  --ink: #0D1116; --ink-2: #171C22; --ink-3: #1F252D; --ink-4: #293139;
  --canvas: #171C22;
  --paper: #FAFAF7; --paper-2: #ECE9E1; --paper-3: #E3E0D7; --rule: #D8D6CE;
  --grey: #454D56; --grey-2: #6B7280; --grey-3: #D5DAE0;
  /* Gold is a fixed semantic colour for the primary action and active nav
     only -- it does not flip with ground like --fg/--bg do, and it is never
     used as a status or selection colour (see .chip.is-on / .dept-picker). */
  --gold: #D8B56A; --gold-fg: #171C22;
  --sans: 'Nicky Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --radius: 14px;
  --texture: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.055) 0.7px, transparent 1.2px);
}

/* ---------- Grounds: every component below reads --bg/--fg/--line/etc,
   never a raw colour, so the same markup works on the black panel and the
   white one. ".ink" (header/nav chrome, #0D1116) and ".canvas" (the page
   background behind ivory cards, #171C22) are two different dark tones in
   the brief, but share one set of text/line/field tokens -- only --bg (and
   its ramp) differs between them. ---------- */
.ink, .canvas, body.on-ink, body.on-canvas {
  --fg: #FFFFFF; --fg-2: var(--grey-3); --fg-3: #8A9099;
  --line: rgba(255, 255, 255, 0.14); --line-2: rgba(255, 255, 255, 0.32); --line-3: rgba(255, 255, 255, 0.55);
  --btn-bg: #FFFFFF; --btn-fg: var(--ink); --field-bg: rgba(255, 255, 255, 0.04); --field-focus: rgba(255, 255, 255, 0.08);
  --sel-bg: #FFFFFF; --sel-fg: var(--ink);
  --ok: #3FBF7F; --warn: #E0A24A; --bad: #F07A72; --info: #7FB0FF;
  color: #FFFFFF;
}
.ink, body.on-ink {
  --bg: var(--ink); --bg-2: var(--ink-2); --bg-3: var(--ink-3); --bg-4: var(--ink-4);
  background-color: var(--ink);
}
.canvas, body.on-canvas {
  --bg: var(--canvas); --bg-2: var(--ink-3); --bg-3: var(--ink-4); --bg-4: var(--ink-4);
  background-color: var(--canvas);
}
/* .card/.auth-card are included here, not just given a background+color --
   they need the full set of --fg/--line/etc custom properties too, since
   everything from h1 to .small reads those rather than inheriting `color`
   directly. Without this a heading inside a card would keep resolving
   --fg from the dark canvas ground around it and render white-on-ivory. */
.paper, body.on-paper, .card, .auth-card {
  --bg: var(--paper); --bg-2: var(--paper-2); --bg-3: var(--paper-3); --bg-4: var(--rule);
  --fg: #171C22; --fg-2: var(--grey); --fg-3: var(--grey-2);
  --line: rgba(13, 17, 22, 0.12); --line-2: rgba(13, 17, 22, 0.4); --line-3: rgba(13, 17, 22, 0.65);
  --btn-bg: #171C22; --btn-fg: #FFFFFF; --field-bg: var(--paper-2); --field-focus: var(--paper-3);
  --sel-bg: #171C22; --sel-fg: #FFFFFF;
  --ok: #1F8F55; --warn: #B8711A; --bad: #C8352C; --info: #2D6FD6;
  background-color: var(--paper); color: #171C22;
}
.ink.textured, .textured { background-image: var(--texture); background-size: 4px 4px; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; background: var(--canvas); color: #FFFFFF; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
::placeholder { color: var(--grey-2, #6B7280); opacity: 1; }
:focus-visible { outline: 3px solid rgba(13, 17, 22, .6); outline-offset: 2px; border-radius: 4px; }
.ink :focus-visible { outline-color: rgba(255, 255, 255, .75); }
[hidden] { display: none !important; }
.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; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation: none !important; } }

.container { width: 100%; max-width: 74rem; margin-inline: auto; padding-inline: 1.5rem; }
.container-narrow { max-width: 30rem; }

/* ---------- Type ---------- */
.mono { font-family: var(--mono); font-size: .88em; font-variant-numeric: tabular-nums; }
.eyebrow { display: block; font-weight: 300; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--fg-2); }
.eyebrow b, .eyebrow strong { font-weight: 700; letter-spacing: .2em; color: var(--fg); }
.statement { margin: 0; font-weight: 900; font-size: 34px; line-height: 1.02; letter-spacing: .005em; text-transform: uppercase; }
.statement--xl { font-size: clamp(34px, 4vw, 48px); }
.statement--sm { font-size: 24px; }
.statement .light { font-weight: 300; letter-spacing: .06em; }
.h1 { margin: 0; font-weight: 700; font-size: 30px; line-height: 1.12; letter-spacing: -.01em; }
.h1--md { font-size: 24px; }
.lede { margin: 0; font-size: 15px; line-height: 1.55; color: var(--fg-2); max-width: 64ch; }
.small { font-size: 13px; color: var(--fg-2); line-height: 1.5; }
.faint { color: var(--fg-3); }
.label { display: block; font-weight: 300; font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--fg-2); }
.error-text { display: block; color: var(--bad); font-size: 13px; }
.muted { color: var(--fg-2); }

/* Raw elements, so every existing view (which mostly uses h1/h2/label
   directly, not utility classes) inherits the new type scale for free. */
h1 {
  margin: 0 0 1.1rem; font-family: var(--sans); font-weight: 900; font-size: 1.7rem;
  line-height: 1.04; letter-spacing: .005em; text-transform: uppercase; color: var(--fg, var(--ink));
  padding-bottom: .55rem; border-bottom: 2px solid var(--fg, var(--ink));
}
.page-head h1 { border-bottom: none; padding-bottom: 0; }
h2 {
  margin: 0 0 1rem; font-family: var(--sans); font-weight: 700; font-size: .72rem;
  letter-spacing: .24em; text-transform: uppercase; color: var(--fg-2, var(--grey));
  padding-bottom: .5rem; border-bottom: 1px solid var(--line, var(--rule));
}
/* A second (or third) h2 inside the same card -- e.g. one per signer role
   on the assign-signers screen, or several admin action sections stacked
   in one card -- needs real separation from whatever came just before it;
   the default 0 top margin leaves it sitting right under the previous
   field/paragraph with no more room than ordinary line spacing. */
.card h2:not(:first-of-type) { margin-top: 1.75rem; }
code {
  font-family: var(--mono); font-size: .84em; background: var(--bg-2, var(--paper-2));
  border: 1px solid var(--line, var(--rule)); border-radius: 6px; padding: .08em .38em; overflow-wrap: anywhere;
}

/* ---------- Lock-up: the Legends Global mark, drawn in currentColor --
   always the full linear mark, never the enso alone. ---------- */
.brandbar { display: flex; align-items: center; gap: 16px; min-height: 28px; }
.brandbar .lockup { height: 22px; width: auto; flex: 0 0 auto; display: block; }
.brandbar__sep { width: 1px; height: 22px; background: var(--line-2); flex: 0 0 auto; }
.brandbar__name { font-weight: 900; font-size: 18px; letter-spacing: .02em; }
.brandbar__right { margin-left: auto; display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }
@media (max-width: 640px) {
  .brandbar { gap: 12px; }
  .brandbar .lockup { height: 16px; } .brandbar__sep { height: 16px; } .brandbar__name { font-size: 15px; }
}

/* ---------- Buttons (both the new double-dash names and Document
   Centre's existing single-dash names point at the same look, so
   un-rewritten views keep working). ---------- */
.btn, .btn-primary, .btn-danger, .btn-block, .btn-small {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 44px; padding: 0 20px;
  border-radius: 999px; font-family: var(--sans); font-weight: 700; font-size: 14px; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; text-align: center;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease), opacity 140ms var(--ease);
}
.btn:hover, .btn-primary:hover, .btn-danger:hover { text-decoration: none; }
.btn { background: transparent; color: var(--fg); border-color: var(--line-2); font-weight: 500; }
.btn:hover { border-color: var(--line-3); }
/* Gold is the one fixed "primary action" colour app-wide -- it does not
   flip with --btn-bg/--btn-fg per ground the way everything else here does. */
.btn--primary, .btn-primary { background: var(--gold); color: var(--gold-fg); border-color: var(--gold); }
.btn--primary:hover, .btn-primary:hover { opacity: .88; }
.btn--ghost { background: transparent; color: var(--fg); border-color: var(--line-2); font-weight: 500; }
.btn--ghost:hover { border-color: var(--line-3); }
.btn--quiet { background: transparent; color: var(--fg-2); font-weight: 500; padding: 0 12px; }
.btn--quiet:hover { color: var(--fg); }
.btn--danger, .btn-danger { background: transparent; color: var(--bad); border-color: var(--line-2); font-weight: 500; }
.btn--danger:hover, .btn-danger:hover { border-color: var(--bad); }
.btn--sm, .btn-small { height: 36px; padding: 0 14px; font-size: 13px; }
.btn--lg { height: 52px; padding: 0 26px; font-size: 15px; }
.btn--block, .btn-block { width: 100%; display: flex; margin-top: 1.2rem; }
.btn:disabled, .btn-primary:disabled, .btn-danger:disabled { opacity: .4; }
.btn:active, .btn-primary:active { transform: translateY(1px); }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }
.link-btn, .linklike {
  display: inline; padding: 0; background: none; border: 0; color: var(--fg-2); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-2);
}
.link-btn:hover, .linklike:hover { color: var(--fg); text-decoration-color: currentColor; }
.inline-form { display: inline; }
a { color: var(--fg, var(--ink)); }
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(13, 17, 22, .6); outline-offset: 2px; }
.ink a:focus-visible, .ink button:focus-visible, .ink .btn:focus-visible, .ink input:focus-visible,
.ink select:focus-visible, .ink textarea:focus-visible { outline-color: rgba(255, 255, 255, .75); }

/* ---------- Fields: the new class set, plus raw elements restyled so
   every existing form (which mostly uses bare input/select/textarea plus
   a tracked-caps <label>) matches without markup changes. ---------- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field--wide, .form-grid-full { grid-column: 1 / -1; }
.input, .textarea, select.input,
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"],
select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-2, #C4C4C4);
  background: var(--field-bg, #FFFFFF); color: var(--fg, var(--ink)); font-family: var(--sans); font-size: 15px; line-height: 1.4; outline: none;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}
.input:focus, .textarea:focus, select.input:focus,
input:focus, select:focus, textarea:focus { border-color: var(--line-3, var(--ink)); background: var(--field-focus, #FFFFFF); }
input:hover, select:hover, textarea:hover { border-color: var(--line-3, var(--grey-2)); }
input[readonly], textarea[readonly] { background: var(--paper-2, var(--grey-3)); color: var(--fg-2, var(--grey)); cursor: default; }
.ink input[readonly], .ink textarea[readonly] { background: var(--bg-2); color: var(--fg-2); }
.input--mono { font-family: var(--mono); letter-spacing: .06em; }
.textarea, textarea { resize: vertical; min-height: 96px; field-sizing: content; max-height: 20em; }
select.input, select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A8A90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.ink select.input option, .ink select option { background: var(--bg-2); color: #fff; }
input[type="number"] { max-width: 12rem; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
input[type="date"], input[type="time"] { max-width: 14rem; }
.key-input { width: 100%; height: 56px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--field-bg); color: var(--fg); font-family: var(--mono); font-size: 20px; letter-spacing: .18em; text-transform: uppercase; outline: none; }
.key-input:focus { border-color: var(--line-3); background: var(--field-focus); }
.key-input.is-error, .input.is-error { border-color: var(--bad); }
.key-input--pin { letter-spacing: .3em; }
.person-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .person-fields { grid-template-columns: 1fr; } }
label {
  display: block; margin: 1.05rem 0 .35rem; font-family: var(--sans); font-weight: 700; font-size: .66rem;
  letter-spacing: .22em; text-transform: uppercase; color: var(--fg-2, var(--grey));
}
label.checkbox-line, .check-line {
  display: flex; align-items: flex-start; gap: .55rem; margin: .3rem 0 .5rem;
  font-family: var(--sans); font-size: .95rem; font-weight: 400; letter-spacing: normal; text-transform: none;
  color: var(--fg, var(--ink)); cursor: pointer;
}
label.checkbox-line input[type="checkbox"], .check-line input { width: auto; margin-top: .15rem; flex: none; accent-color: var(--fg, var(--ink)); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--fg, var(--ink)); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--fg-2); font-size: 13px; font-weight: 500; transition: all 120ms var(--ease); }
.chip:hover { border-color: var(--line-3); color: var(--fg); }
.chip.is-on { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 12px 18px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--fg); text-align: left; font-size: 15px; transition: all 120ms var(--ease); }
.choice:hover { border-color: var(--line-3); }
.choice.is-on { background: var(--sel-bg); color: var(--sel-fg); border-color: var(--sel-bg); font-weight: 700; }

/* ---------- Status ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 300; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--fg); white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--tone, var(--fg-2)); flex: 0 0 auto; }
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); font-size: 14px; line-height: 1.5; color: var(--fg); }
.banner--amber { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.banner--blue { border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.banner--rose { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px; background: var(--sel-bg); color: var(--sel-fg); font-weight: 700; font-size: 12px; letter-spacing: .04em; flex: 0 0 auto; }
.avatar--sm { width: 28px; height: 28px; font-size: 10px; }

/* Existing status/alert classes, restyled */
.flash {
  display: flex; align-items: flex-start; gap: 12px; background: var(--bg, var(--paper)); border: 1px solid var(--line, var(--rule));
  border-left: 3px solid var(--fg, var(--ink)); border-radius: 10px; padding: 14px 16px; margin: 0 0 1.1rem; font-size: .95rem;
}
.flash-success { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--bad); }
.flash-warning { border-left-color: var(--warn); }
.panel-alert { margin: 0 0 .6rem; padding: .5rem .7rem; font-size: .85rem; }
.badge {
  display: inline-flex; align-items: center; gap: .5em; padding: 4px 11px; border: 1px solid var(--line-2, var(--rule));
  border-radius: 999px; background: var(--bg, var(--paper)); color: var(--fg-2, var(--grey)); font-family: var(--sans);
  font-size: 10px; font-weight: 300; letter-spacing: .2em; text-transform: uppercase; white-space: nowrap; vertical-align: middle;
}
.badge .mono { font-size: inherit; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: var(--fg-2, var(--grey-2)); flex: none; }
.badge-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line, var(--rule))); }
.badge-ok::before { background: var(--ok); }
.badge-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line, var(--rule))); }
.badge-bad::before { background: var(--bad); }

/* ---------- Cards and rows ----------
   Cards are fixed ivory islands on the dark canvas -- unlike most
   components here they do NOT read --bg/--fg from the surrounding ground,
   so a card looks the same whether it sits in the dark .work__body or
   inside an .ink panel. */
.card, .auth-card { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.card:not(.auth-card) { padding: 1.5rem 1.6rem; }
.auth-card { max-width: 26rem; margin: clamp(1.5rem, 9vh, 6rem) auto 0; padding: 1.8rem 1.9rem; }
.empty { display: flex; flex-direction: column; gap: 10px; padding: 32px 24px; align-items: flex-start; color: var(--fg-2); font-size: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 10px; }
.section-head:first-child { margin-top: 0; }
.card-grid { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr)); margin-top: 1.2rem; }
.card-grid > *, .two-col > * { min-width: 0; }
/* Pin each document card's "Start this document" button to the same
   baseline across a grid row, regardless of how long that card's
   description happens to be (/catalogue/{id}). */
.card-grid > .card:not(.cat-card) { display: flex; flex-direction: column; }
.card-grid > .card:not(.cat-card) > form, .card-grid > .card:not(.cat-card) > .btn { margin-top: auto; padding-top: .8rem; }
.two-col { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); align-items: start; margin-top: 1rem; }
.editor-grid { display: grid; gap: 1.2rem; grid-template-columns: minmax(0, 3fr) minmax(min(16rem, 100%), 1fr); align-items: start; margin-top: 1rem; }
@media (max-width: 60rem) { .editor-grid { grid-template-columns: 1fr; } }
.card.narrow { max-width: 44rem; }
.iv-row { display: flex; align-items: center; gap: 18px; padding: 18px 22px; border-top: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.iv-row:first-child { border-top: 0; }
a.iv-row:hover { background: var(--bg-2); text-decoration: none; }
.iv-row .main { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.iv-row .title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iv-row .sub { font-size: 13px; color: var(--fg-2); }
.iv-row .facts { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; font-size: 12px; color: var(--fg-2); }
.iv-row .chev { color: var(--fg-3); flex: 0 0 auto; }
@media (max-width: 760px) { .iv-row { flex-wrap: wrap; } .iv-row .chev { display: none; } }
.stat-card { display: flex; align-items: center; gap: 18px; padding: 16px 22px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); color: #171C22; min-width: 240px; text-decoration: none; }
.stat-card:hover { text-decoration: none; opacity: .92; }
.stat-card .num { font-weight: 300; font-size: 44px; line-height: .9; letter-spacing: -.03em; }
.stat-card .txt { font-size: 13px; line-height: 1.35; color: var(--grey); flex: 1 1 auto; }
.pill-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 24px; }
.meta-grid div { display: flex; flex-direction: column; gap: 3px; }
.meta-grid .k { font-weight: 300; font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--fg-2); }
.meta-grid .v { font-size: 14px; }

/* Page head, data tables, lists — Document Centre's existing admin pattern */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; padding-bottom: .6rem; border-bottom: 2px solid var(--fg, var(--ink)); }
.page-head h1 { margin: 0; }
.mt { margin-top: 1.1rem; }
.block { display: block; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: .25rem 0; }
.problem-list { margin: .4rem 0; padding-left: 1.2rem; }
.problem-list li { color: var(--bad); padding: .15rem 0; }
.datalist { display: grid; grid-template-columns: minmax(7.5rem, max-content) minmax(0, 1fr); gap: .45rem 1rem; margin: 0; }
.datalist dt { font-family: var(--sans); font-size: .64rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2, var(--grey)); padding-top: .2em; }
.datalist dd { margin: 0; overflow-wrap: anywhere; }
.datalist code { display: inline-block; max-width: 100%; word-break: break-all; }
.nowrap { white-space: nowrap; }
/* A horizontally-scrollable table needs a visible cue, not just a working
   scrollbar an OS might auto-hide (findings on /admin/employees,
   /admin/documents, /admin/documents/{id}, /admin/status/{id},
   /documents/{id}/done on narrower viewports). */
.table-wrap { overflow-x: auto; scrollbar-width: thin; }
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
/* Stage 8: an alternative presentation for a document list below the admin
   shell's own 900px breakpoint (see .shell/.rail-nav further down) --
   NOT a squeezed table (that's what .table-wrap above is already for), but
   a second, independent rendering of the same rows as .iv-row cards
   (My/Team Documents). CSS just picks one; see those views for the markup. */
.doc-list-cards { display: none; }
@media (max-width: 900px) {
  .doc-list-table { display: none; }
  .doc-list-cards { display: block; }
}
/* Stage 11: same dual-render-at-900px pattern as .doc-list-table/
   .doc-list-cards above, for the Catalogue & Access admin grid. Unlike that
   pair, each row's actual EDITOR is not duplicated between the two --
   .cat-editors sits outside both and is never hidden by this breakpoint, so
   whichever rendering is visible opens the one shared form (see
   catalogue-access.js). */
.cat-access-cards { display: none; }
@media (max-width: 900px) {
  .cat-access-table { display: none; }
  .cat-access-cards { display: block; }
}
/* Stage 12a: same dual-render-at-900px pattern again, for the Resource
   Library's merged SOP/reference listing (/library). */
.lib-cards { display: none; }
@media (max-width: 900px) {
  .lib-table { display: none; }
  .lib-cards { display: block; }
}
.lib-row-hidden { opacity: .6; }
/* The shared .iv-row .title rule (used by My/Team Documents too) truncates
   to one line -- fine there, but a job description's title is the position
   name alone (ResourceLibraryController::referenceRows()), short enough
   that truncating it on a phone just cuts the word in half for no reason
   (found live, issue #65). Scoped to this page only. */
.lib-cards .iv-row .title { white-space: normal; overflow: visible; text-overflow: clip; }
.cat-access-bar {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; justify-content: space-between;
  padding: .6rem .9rem; margin: 0 0 .8rem; border: 1px solid var(--line-2, var(--rule)); border-radius: 10px;
  background: var(--bg-2, var(--paper-2));
}
.cat-pending-badge { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line, var(--rule))); }
.cat-pending-badge::before { background: var(--warn); }
.cat-row td { vertical-align: middle; }
.cat-editor-panel { margin-bottom: 1rem; }
.cat-card .facts { gap: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .6rem .6rem; border-bottom: 1px solid var(--line, var(--rule)); vertical-align: top; }
.table th { font-family: var(--sans); font-size: .62rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--fg-2, var(--grey)); border-bottom: 2px solid var(--fg, var(--ink)); padding-bottom: .5rem; }
@media (hover: hover) { .table tbody tr:hover { background: var(--bg-2, var(--paper-2)); } }
.table tbody tr:last-child td { border-bottom: none; }
.table code { white-space: nowrap; overflow-wrap: normal; }
.table .btn { vertical-align: middle; }
/* Two side-by-side action buttons in a narrow table cell (the admin status
   detail page's per-signer actions) run off the edge of the card rather
   than wrapping sensibly -- stack them instead. */
.signer-actions { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; }

/* Sortable lists, row-action popovers */
.sortable { list-style: none; margin: 0; padding: 0; }
.sortable-item { display: flex; align-items: flex-start; gap: .6rem; flex-wrap: wrap; padding: .7rem .5rem; border-bottom: 1px solid var(--line, var(--rule)); background: var(--bg, var(--paper)); }
@media (hover: hover) { .sortable-item:hover { background: var(--bg-2, var(--paper-2)); } }
.sortable-item.dragging { opacity: .5; }
.drag-handle { cursor: grab; color: var(--fg-2, var(--grey)); user-select: none; padding: .45rem; margin: -.35rem 0 -.35rem -.35rem; touch-action: none; line-height: 1; }
.grow { flex: 1; min-width: 0; }
/* Give every sortable row the same two-line shape (name, then badges)
   regardless of how much horizontal room the name leaves — otherwise rows
   zig-zag in height purely because of where a badge happened to wrap
   (/admin/categories and similar admin lists). */
.sortable-item > .grow { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; }
.row-actions { display: flex; gap: .35rem; align-items: flex-start; position: relative; flex-wrap: wrap; }
.row-actions summary { list-style: none; cursor: pointer; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions[open] { flex: 1 1 100%; }
.popover-form { background: var(--bg-2, var(--paper-2)); border: 1px solid var(--line, var(--rule)); border-radius: 10px; padding: .9rem 1.1rem 1.1rem; margin: .6rem 0 .2rem; min-width: min(16rem, 100%); }
.popover-form label:first-of-type { margin-top: 0; }
.row-actions-panel { flex: 1 1 100%; margin-top: .5rem; max-width: 28rem; }
.row-actions-panel-wide { max-width: 44rem; }
.row-actions-extra { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--line, var(--rule)); }
.row-actions-extra .panel-alert { flex-basis: 100%; margin: 0; }
.section-divider { padding: .5rem .4rem .3rem; margin-top: 1rem; font-family: var(--sans); font-weight: 700; font-size: .62rem; color: var(--fg-2, var(--grey)); text-transform: uppercase; letter-spacing: .24em; }
.cat-icon, .cat-card-icon { filter: grayscale(1) contrast(1.05); }
.tox .tox-tbtn--enabled, .tox .tox-tbtn--enabled:hover { background: var(--line, var(--rule)) !important; }
.orphan-banner { border-color: var(--warn); margin-top: 1rem; }
.orphan-row { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; flex-wrap: wrap; }
.meta-line { display: flex; flex-wrap: wrap; gap: .1rem .55rem; align-items: baseline; }
.meta-line > * { white-space: nowrap; }
.row-hidden td { color: var(--fg-3, var(--grey-2)); }

/* Reveal disclosure, card head, form grid */
.reveal { margin-bottom: 1.2rem; }
.reveal > summary { list-style: none; display: inline-flex; width: auto; cursor: pointer; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal-body { margin-top: .8rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.card-head h2 { margin: 0; }
.search-inline { display: flex; gap: .4rem; flex-wrap: wrap; }
.search-inline input { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.1rem; }
@media (max-width: 40rem) { .form-grid { grid-template-columns: 1fr; } }
.dept-picker { list-style: none; padding: 0; margin: .3rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.dept-picker li { padding: 0; }
.dept-picker .checkline { position: relative; border: 1px solid var(--line-2, var(--rule)); border-radius: 999px; padding: .4rem .9rem; margin: 0; font-weight: 500; background: var(--bg, var(--paper)); cursor: pointer; }
.dept-picker .checkline input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dept-picker .checkline:has(input:checked) { background: var(--sel-bg, var(--ink)); color: var(--sel-fg, #fff); border-color: var(--sel-bg, var(--ink)); }
.checkline { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.checkline input { width: auto; margin: 0; }

/* Options + conditions builders */
.option-row { display: flex; gap: .4rem; margin-bottom: .4rem; }
.option-row input { min-width: 0; }
.cond-group { border: 1px solid var(--line, var(--rule)); border-radius: 10px; padding: .7rem .9rem .8rem; margin: .8rem 0; }
.cond-group legend { font-family: var(--sans); font-size: .62rem; font-weight: 700; color: var(--fg-2, var(--grey)); text-transform: uppercase; letter-spacing: .2em; padding: 0 .35rem; }
.cond-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: .4rem; margin-bottom: .4rem; align-items: center; }
.cond-row select:first-child { grid-column: 1 / -1; }
.cond-row > * { min-width: 0; }
.cond-group .btn-row .btn-danger { margin-left: auto; }
#template_html { min-height: 500px; width: 100%; font-family: var(--mono); font-size: .82rem; color: var(--fg-2, var(--grey)); }
.editor-help dt { margin-top: .6rem; }
.editor-help dd { margin: 0 0 .3rem; color: var(--fg-2, var(--grey)); }
.editor-help code { white-space: normal; display: inline-block; max-width: 100%; overflow-wrap: anywhere; }

/* Questionnaire field rendering (used inside the fill flow's paper panel,
   the admin template preview, and the employee collaborative-fill page). */
.q-block { margin: 0 0 1.25rem; }
.q-hidden { display: none !important; }
.q-label { font-family: var(--sans); font-size: .98rem; font-weight: 500; color: var(--fg, var(--ink)); margin: 1.15rem 0 .3rem; }
.q-required { color: var(--bad); }
.q-help { margin: .1rem 0 .35rem; color: var(--fg-2, var(--grey)); font-size: .85em; }
.q-error { color: var(--bad); font-size: .9rem; margin: .2rem 0; }
.q-section { font-family: var(--sans); font-size: .72rem; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: var(--fg-2, var(--grey)); border-bottom: 1px solid var(--line, var(--rule)); padding-bottom: .5rem; margin: 1.6rem 0 1rem; }
.card > form > .q-section:first-of-type, .card > .q-section:first-child, .split__body .q-section:first-child { margin-top: 0; }
.choice-row { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.choice-col { display: flex; flex-direction: column; gap: .1rem; }
.other-input { margin-top: .35rem; }
.position-lookup-grid { display: flex; gap: .6rem; flex-wrap: wrap; }
.position-lookup-grid select { flex: 1 1 14rem; min-width: 0; }

/* Numbered stepper (template preview step overview; the live fill flow
   uses .step-rail in the split's ink panel instead, see below). */
.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem 1rem; list-style: none; margin: 1.1rem 0 1.4rem; padding: 0; counter-reset: step; }
.stepper li { counter-increment: step; display: flex; align-items: center; gap: .55rem; font-family: var(--sans); font-size: .64rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--fg-2, var(--grey)); }
.stepper li::before { content: counter(step, decimal-leading-zero); display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border: 1px solid var(--line-2, var(--rule)); border-radius: 50%; background: var(--bg, var(--paper)); font-family: var(--mono); font-size: .6rem; font-weight: 500; letter-spacing: .02em; color: var(--fg-2, var(--grey)); }
.stepper li.current { color: var(--fg, var(--ink)); }
.stepper li.current::before { background: var(--sel-bg, var(--ink)); border-color: var(--sel-bg, var(--ink)); color: var(--sel-fg, #fff); }
.stepper li.done { color: var(--fg-2, var(--grey)); }
.stepper li.done::before { content: "✓"; background: var(--bg, var(--paper)); border-color: var(--fg, var(--ink)); color: var(--fg, var(--ink)); }

/* Document sheet (preview / signing) */
.doc-paper { background: #fff; border: 1px solid var(--rule); border-top: 3px solid var(--ink); border-radius: 4px; box-shadow: 0 18px 40px rgba(10, 10, 11, .12); max-width: 8.5in; margin: 1.4rem auto; padding: 2.6rem 2.75rem; overflow-x: auto; color: var(--ink); }
.doc-paper-landscape { max-width: 11in; }
/* The real rendered PDF, embedded directly — not an HTML approximation of
   it. An HTML re-rendering of the same content never guarantees the same
   line-wrapping, font metrics or page breaks as the actual Dompdf output
   (confirmed by direct repro: a preview that showed one page finalized
   into two, with the signature section split by the real break). Embedding
   the PDF itself removes that whole class of mismatch — what's shown here
   is byte-for-byte what finalizing (or signing) produces. */
.doc-pdf-wrap { max-width: 8.5in; margin: 1.4rem auto; border: 1px solid var(--rule); border-top: 3px solid var(--ink); border-radius: 4px; box-shadow: 0 18px 40px rgba(10, 10, 11, .12); overflow: hidden; }
.doc-pdf-frame { display: block; width: 100%; height: 80vh; min-height: 520px; border: 0; background: #fff; }
.cat-card { display: flex; gap: .95rem; text-decoration: none; color: var(--fg, var(--ink)); align-items: flex-start; }
@media (hover: hover) { .cat-card:hover { border-color: var(--fg, var(--ink)); } }
/* Always stack the category name above its document-count badge instead of
   letting the badge wrap onto its own line only for longer names -- without
   this, cards in the same grid row end up different heights for no reason
   a viewer can see (/catalogue, /). */
.cat-card > span:last-child { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; }
.cat-card-icon { font-size: 1.7rem; line-height: 1.25; }
.sig-pad-wrap { border: 1.5px dashed var(--line-3, var(--grey)); border-radius: 10px; background: var(--field-bg, #fff); touch-action: none; }
.sig-pad-wrap canvas { display: block; width: 100%; height: 180px; border-radius: 6px; }
.sig-preview { display: inline-block; padding: .5rem .9rem; margin: .4rem 0 .8rem; border: 1px solid var(--line, var(--rule)); border-radius: 10px; background: var(--field-bg, #fff); }
.sig-preview img { display: block; max-height: 70px; max-width: 260px; }
.saved-sig-offer { margin-bottom: 1rem; }
.qr-box { max-width: 300px; margin: .8rem auto; }
.qr-box svg { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--rule); border-radius: 6px; }

/* ---------- Primary chrome ----------
   A compact sidebar on tablet/desktop; a slim top header + fixed bottom tab
   bar + off-canvas drawer below the 900px breakpoint. The primary
   destinations (Home, Create a document, Documents, Print sets -- plus
   Resource library for supervisor and above) live in `.rail-nav__links`
   (sidebar) and are mirrored in `.bottom-tabs` (mobile), which sizes each
   `.bottom-tabs__item` as an equal share of the bar (flex: 1 1 0) so the
   count isn't fixed at 4; secondary items (Team documents, Administration)
   and the account block live only in `.rail-nav`, which becomes the mobile
   drawer. */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 300px minmax(0, 1fr); background: var(--canvas); }
.rail-nav { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 22px; padding: 24px; }
.rail-nav .brandbar .lockup { height: 20px; } .rail-nav .brandbar__sep { height: 20px; } .rail-nav .brandbar__name { font-size: 17px; }
.rail-nav__scroll { display: flex; flex-direction: column; gap: 22px; min-height: 0; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; margin: 0 -8px; padding: 0 8px; }
.rail-nav__links { display: flex; flex-direction: column; gap: 2px; }
.rail-nav__link { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--fg-2); }
.rail-nav__link:hover { color: var(--fg); text-decoration: none; }
.rail-nav__link.is-active, .rail-nav__link.is-on { background: var(--gold); color: var(--gold-fg); font-weight: 700; }
/* Team documents: a secondary link, not a primary destination -- a
   narrower, occasional tool (reviewing colleagues' generated documents),
   unlike Resource library which IS a primary .rail-nav__links item. Shown
   right below Documents, indented and slightly smaller. Lives in its own
   .rail-nav__secondary block (see layout.php), NOT inside .rail-nav__links,
   because that list is display:none on mobile and this one has no
   bottom-tab mirror. */
.rail-nav__link--sub { margin-left: 14px; font-size: 13px; min-height: 44px; }
.rail-nav__link--sub::before { content: ''; width: 5px; height: 5px; border-radius: 999px; background: currentColor; opacity: .5; margin-right: 2px; flex: 0 0 auto; }
.rail-nav__secondary { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.rail-nav__panel { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
/* Visual break between the primary links and the single Administration
   entry -- a divider, not another item mixed into the same list. */
.rail-nav__divider { height: 1px; background: var(--line); margin: 6px 12px 10px; flex: none; }
.rail-nav__close { display: none; }
.rail-nav__user { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.rail-nav__who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rail-nav__who .avatar { background: #fff; color: var(--ink); }
.rail-nav__who .t { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.rail-nav__who .t b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-nav__who .t span { font-size: 11px; color: var(--fg-3); }
.rail-nav__acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.rail-nav__acts a, .rail-nav__acts button { display: inline-flex; align-items: center; min-height: 44px; color: var(--fg-2); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-2); }
.rail-nav__acts a:hover, .rail-nav__acts button:hover { color: var(--fg); }
.idle { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.idle .d { width: 6px; height: 6px; border-radius: 999px; background: var(--ok); }
.work { min-width: 0; display: flex; flex-direction: column; }

/* Slim mobile header and fixed bottom tab bar -- both hidden on tablet/
   desktop, where the sidebar above is always visible instead. See the
   900px media query below for their mobile layout. */
.top-header, .bottom-tabs { display: none; }

.work__bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 36px; border-bottom: 1px solid var(--line); min-height: 72px; }
.crumb { display: flex; align-items: center; gap: 10px; font-weight: 300; font-size: 12px; letter-spacing: .24em; text-transform: uppercase; color: var(--fg-2); min-width: 0; }
.crumb .cur { color: var(--fg); font-weight: 700; letter-spacing: .18em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb .sep { color: var(--fg-3); }
.search { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--fg-2); min-width: 240px; margin-left: auto; }
.search input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; color: var(--fg); height: auto; }
.work__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.work__body { flex: 1 1 auto; padding: 28px 36px 56px; display: flex; flex-direction: column; gap: 24px; }
.page { display: flex; flex-direction: column; gap: 24px; }
.page--narrow { max-width: 820px; }
.page-head__text { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  /* The sidebar becomes an off-canvas drawer, sliding in from the left,
     for secondary links (Team documents, Administration) and the account
     block. The 4 primary destinations live in the bottom tab bar instead,
     so the drawer hides its own primary link list -- otherwise every
     destination would be reachable twice. */
  .rail-nav {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; width: min(300px, 86vw);
    z-index: 220; padding: 18px; gap: 16px;
    transform: translateX(-100%); transition: transform 220ms var(--ease);
    box-shadow: 10px 0 32px rgba(0, 0, 0, .35);
  }
  body.nav-open .rail-nav { transform: translateX(0); }
  .rail-nav .brandbar { display: none; } /* the top header already shows the brand */
  .rail-nav__close { display: inline-flex; align-items: center; justify-content: center; align-self: flex-end; width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line-2); color: #fff; margin: -6px -6px -8px auto; flex: none; }
  .rail-nav__links { display: none; }
  .rail-nav__scroll { margin: 0; padding: 0; gap: 10px; }
  .rail-nav__panel { padding-top: 2px; }
  .rail-nav__divider { margin: 0 0 10px; }
  .rail-nav__user { display: flex; }

  .nav-scrim { position: fixed; inset: 0; z-index: 210; background: rgba(10, 10, 11, .5); }
  body:not(.nav-open) .nav-scrim { display: none; }

  /* Slim top header: menu control, brand mark, current page's title.
     Browsing between sections uses Home/Documents/etc, not this bar. */
  .top-header { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 150; height: 56px; padding: 0 14px; background: var(--ink); border-bottom: 1px solid var(--line); color: #fff; }
  .top-header__menu { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 44px; height: 44px; margin-left: -8px; border-radius: 999px; border: 1px solid var(--line-2); color: #fff; }
  .top-header__brand { display: flex; align-items: center; flex: 0 0 auto; }
  .top-header__brand .lockup { height: 18px; width: auto; display: block; }
  .top-header__title { min-width: 0; padding-left: 10px; border-left: 1px solid var(--line); font-weight: 700; font-size: 13px; letter-spacing: .02em; color: var(--grey-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Fixed bottom tab bar: the 4 primary destinations, always reachable. */
  .bottom-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 180; background: var(--ink); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0); }
  .bottom-tabs__item { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; padding: 7px 4px; color: var(--fg-2); font-size: 11px; font-weight: 500; }
  .bottom-tabs__item:hover { text-decoration: none; }
  .bottom-tabs__item svg { width: 21px; height: 21px; flex: none; }
  .bottom-tabs__item.is-active { color: var(--gold); }

  .work__body { padding: 20px 20px 92px; }
}
@media (min-width: 901px) { .nav-scrim { display: none; } }

/* ---------- Brand moments: the split ("the black panel presents, the
   white panel is where the person acts") and the hero (sign-in, key
   entry) — both ink/paper grounds live inside the SAME page here. ---------- */
.p-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.split { flex: 1; display: flex; flex-wrap: wrap; min-height: 100dvh; }
.split__ink { flex: 1 1 440px; min-width: 0; display: flex; flex-direction: column; padding: 28px 48px 32px; }
.split__paper { flex: 1.15 1 520px; min-width: 0; display: flex; flex-direction: column; padding: 40px 48px; }
.split__copy { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 40px 0 36px; max-width: 580px; }
.split__foot { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--fg-3); }
.split__body { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: flex-start; gap: 22px; max-width: 760px; width: 100%; }
.split__nav { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); max-width: 760px; }
.split__nav .nav { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.saved { font-family: var(--mono); font-size: 12px; color: var(--fg-3); white-space: nowrap; }
/* The step rail inside .split__ink — same information as .stepper, styled
   for the dark ground and a vertical list instead of a horizontal row. */
.step-rail { display: flex; flex-direction: column; gap: 10px; }
.step-rail .row { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--fg-3); }
.step-rail .row.is-done { color: var(--fg-2); }
.step-rail .row.is-cur { color: var(--fg); font-weight: 700; }
.step-rail .mark { width: 22px; height: 22px; border-radius: 999px; border: 1px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; flex: 0 0 auto; }
.step-rail .row.is-done .mark { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.step-rail .row.is-cur .mark { border-color: var(--fg); }
@media (max-width: 900px) {
  .split { min-height: 0; align-content: flex-start; }
  .split__ink { flex-basis: 100%; padding: 18px 20px 24px; }
  .split__copy { padding: 22px 0 0; gap: 14px; justify-content: flex-start; }
  .split__paper { flex-basis: 100%; padding: 24px 20px 28px; }
  .split__nav { margin-top: 20px; padding-top: 18px; gap: 14px; }
  .split__nav .nav { width: 100%; margin-left: 0; justify-content: space-between; }
  .split__foot { display: none; }
}

/* ---------- Continuous-scroll document fill (Stage 7a) — every section of
   the questionnaire on one page at once (see questionnaire.php's
   $sectionCards), each its own light .card on the dark canvas .work__body
   already provides, with a persistent jump-to-section column on wider
   screens and a compact <select> on phones. Autosave-as-you-type is a
   later stage, not this one: .fill-actions' two buttons are still the only
   thing that saves anything here. ---------- */
.fill-layout { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 28px; align-items: start; }
.fill-layout--single { grid-template-columns: minmax(0, 1fr); }
.fill-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.fill-nav__heading { font-weight: 300; font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--fg-3); padding: 0 12px 6px; }
.fill-nav__link { display: block; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--fg-2); text-decoration: none; }
.fill-nav__link:hover { color: var(--fg); background: var(--bg-2); text-decoration: none; }
.fill-jump { display: none; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.fill-jump label { font-weight: 300; font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--fg-3); }
.fill-form { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.fill-sections { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.fill-actions { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius); }
.fill-actions .btn--primary { order: 2; }
.fill-actions .btn--ghost { order: 1; }
/* Stage 7b: real background autosave status, next to the two explicit save
   actions -- reuses the existing .pill/.dot component (dashboard.php,
   signing/sign.php) and its --tone custom property as-is, no new colors,
   just placed first in the bar so the two buttons stay flush right. */
.fill-status { order: 0; margin-right: auto; }
.fill-error-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fill-error-list a { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 900px) {
  .fill-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .fill-nav { display: none; }
  .fill-jump { display: flex; }
  .fill-actions { position: static; flex-wrap: wrap; }
}

.hero { position: relative; flex: 1; min-height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: right center; z-index: 0; }
.hero__shade { position: absolute; inset: 0; z-index: 0; background: linear-gradient(to right, #0A0A0B 0%, rgba(10, 10, 11, .92) 30%, rgba(10, 10, 11, .55) 44%, rgba(10, 10, 11, 0) 60%); }
.hero > .brandbar { position: relative; z-index: 1; padding: 28px 48px 0; }
.hero__body { position: relative; z-index: 1; flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; gap: 20px; padding: 40px 48px 44px; max-width: 580px; width: 100%; }
.hero__body form { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; max-width: 420px; }
.hero__body .help { font-size: 13px; line-height: 1.5; color: var(--fg-2); }
.promises { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.promises li { display: flex; gap: 14px; font-size: 14px; line-height: 1.5; color: var(--fg-2); max-width: 48ch; }
.promises .n { font-family: var(--mono); font-size: 11px; color: var(--fg); flex: 0 0 22px; padding-top: 3px; }
@media (max-width: 900px) {
  .hero__img, .hero__shade { display: none; }
  .hero > .brandbar { padding: 18px 20px 0; }
  .hero__body { padding: 28px 20px 28px; justify-content: flex-start; gap: 16px; }
  .hero__body form { max-width: none; }
}

/* ---------- Auth brand block (legacy centred-card login, kept only as a
   fallback container on non-hero bare pages such as the PIN-change
   screen). ---------- */
.auth-brand { text-align: center; margin: clamp(1.5rem, 7vh, 4rem) 0 1.4rem; }
.auth-brand .lockup { height: 48px; width: auto; color: var(--ink); }
.auth-brand .auth-brand-name { display: block; margin-top: 1rem; font-family: var(--sans); font-size: .74rem; font-weight: 500; letter-spacing: .24em; text-transform: uppercase; color: var(--ink); }
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { width: 100%; max-width: 30rem; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem 1.25rem; flex-wrap: wrap; padding: .9rem 1.5rem; }
.footer { border-top: 1px solid var(--rule); padding: 1.1rem 0 1.3rem; background: #fff; }
.footer-inner { display: flex; align-items: center; gap: .9rem; max-width: 74rem; margin-inline: auto; padding-inline: 1.5rem; }
.footer-inner .lockup { height: 15px; width: auto; color: var(--ink); opacity: .85; }
.footer-tag { font-size: .78rem; color: var(--grey); }

/* Impersonation banner — deliberately loud: amber is the one semantic use
   of colour here (warning), never the brand's own accent. */
.impersonation-banner { position: sticky; top: 0; z-index: 100; background: #B8711A; color: #fff; }
.impersonation-banner-inner { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; padding: .6rem 1.5rem; font-size: .9rem; }
.impersonation-banner strong { font-weight: 700; }
.impersonation-banner .btn { background: #fff; color: var(--ink); border-color: #fff; flex: none; }

@media (max-width: 40rem) {
  .btn, .btn-primary, .btn-danger { white-space: normal; }
  .card:not(.auth-card), .auth-card { padding: 1.2rem 1.1rem; }
  .doc-paper { padding: 1.4rem 1.1rem; }
  .datalist { grid-template-columns: 1fr; gap: .1rem; }
  .datalist dt { margin-top: .7rem; }
  .datalist dt:first-of-type { margin-top: 0; }
  .row-actions { flex-basis: 100%; justify-content: flex-start; }
  .btn-row .btn, .btn-row .btn-primary { flex: 1 1 auto; }
  .btn-row .inline-form { flex: 1 1 auto; display: flex; }
  .btn-row .inline-form .btn { flex: 1 1 auto; }
  /* A row of status filter chips (/admin/status) isn't a stacked group of
     actions -- stretching whichever chip lands alone on the last wrapped
     line to the full row width (while its neighbours above stay pill-sized)
     reads as broken, so opt this row out of the stretch-to-fill rule above. */
  .btn-row--filters .btn, .btn-row--filters .btn-primary { flex: 0 1 auto; }
}

/* ---------- Print: the finalized document, as a document ---------- */
@media print {
  @page { margin: 16mm; }
  .rail-nav, .work__bar, .top-header, .bottom-tabs, .toast, [data-noprint] { display: none !important; }
  body, .shell, .work, .work__body { background: #fff !important; color: #000 !important; display: block !important; padding: 0 !important; min-height: 0 !important; }
}
