/* ============================================================
   PRIMORDIAL DESIGN SYSTEM — components.css  (v3.4, Oct 2026)
   App (dense product UI) components. Load after colors_and_type.css.
   Rules of thumb:
   · Radius — buttons, dialogs, menus, toasts, tooltips: 0 · inputs,
     segmented, small marks: 4 · cards: 8 · tags, chips: pill.
   · Type — only the --text-app-* steps inside product screens.
   · States — colour shift only; focus is always the 2px purple-03 ring
     (keyboard) or --focus-halo (text fields).
   ============================================================ */

/* The hidden attribute must win over component display rules. Scoped, no !important,
   so an app can still reveal a hidden element with a more specific rule. */
:is(.btn, .btn-link, .input, .select, .select-menu, .checkbox, .tag, .chip, .chip-group, .seg, .tabs, .tab, .table-bar, .batch-bar, .table-foot, .card, .section-foot, .choice, .choice-group, .steps, .step, .step-strip, .stages, .stage, .menu, .menu-item, .tooltip, .toast, .dialog, .callout, .pager, .dropzone, .page-head, .page-actions, .nav-sub, .nav-item, .num-stepper, .chat-bubble)[hidden] { display: none; }

/* ── Buttons (extends .btn / .btn-primary / .btn-secondary / .btn-ghost) ── */
.btn-md { font-size: var(--text-app-xl); padding: 11px 18px 9px; }   /* App default. +1/-1 optical centring for Founders caps */
.btn-sm { font-size: var(--text-app-md); padding: 8px 14px 6px; }
.btn-xs { font-size: var(--text-app-sm); padding: 5px 10px 4px; gap: 6px; }
.btn-neutral { background: var(--bg-surface); color: var(--fg-brand); border-color: var(--border-default); }
.btn-neutral:hover { border-color: var(--color-purple-03); color: var(--color-purple-03); }
.btn-neutral:active { background: var(--state-hover-tint); transform: translateY(1px); }
.btn-danger { background: transparent; color: var(--state-error-ink); border-color: color-mix(in srgb, var(--state-error) 40%, transparent); }
.btn-danger:hover { background: var(--state-error-bg); border-color: var(--state-error); color: var(--state-error-ink); }
.btn-neutral:disabled, .btn-danger:disabled, .btn-neutral[aria-disabled="true"], .btn-danger[aria-disabled="true"] { background: transparent; color: var(--state-disabled-fg); border-color: var(--state-disabled-border); cursor: not-allowed; transform: none; }
.btn-icon { width: 32px; height: 32px; padding: 0; background: var(--bg-surface); color: var(--fg-subtle); border-color: var(--border-default); }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn-icon:hover { color: var(--color-purple-03); border-color: var(--color-purple-03); }
.btn-link { background: none; border: 0; padding: 0; font: inherit; font-size: var(--text-app-md); color: var(--fg-link); cursor: pointer; white-space: nowrap; }
.btn-link:hover { color: var(--color-purple-04); text-decoration: underline; text-underline-offset: 2px; }
.btn-group { display: flex; gap: var(--space-sm); flex-wrap: wrap; align-items: center; }

/* ── Inputs ─────────────────────────────────────────────────── */
.input-sm { font-size: var(--text-app-md); padding: 7px 10px; line-height: 1.3; }
select.input { appearance: none; padding-right: 30px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--fg-subtle) 50%), linear-gradient(135deg, var(--fg-subtle) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-search { padding-left: 30px; background-image: radial-gradient(circle at 11px 50%, transparent 4px, var(--fg-muted) 4px, var(--fg-muted) 5.5px, transparent 5.5px); background-repeat: no-repeat; }
.input-auto { width: auto; }
.input.is-needed { border-color: var(--state-progress); background-color: var(--state-progress-bg); }   /* waiting on an answer — never use the focus halo for this */
.field { display: grid; gap: 6px; }
.field-label { font-family: var(--font-mono); font-size: var(--text-app-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--fg-subtle); }
.field-hint { font-size: var(--text-app-sm); color: var(--fg-subtle); }

.checkbox { appearance: none; width: 16px; height: 16px; margin: 0; flex: none; border: 1px solid var(--border-default); border-radius: var(--radius-xs); background: var(--input-bg); cursor: pointer; display: inline-grid; place-content: center; transition: var(--transition-state); }
.checkbox:hover { border-color: var(--color-purple-03); }
.checkbox:checked, .checkbox:indeterminate { background: var(--color-purple-03); border-color: var(--color-purple-03); }
.checkbox:checked::after { content: ""; width: 8px; height: 4px; border: solid var(--color-white); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.checkbox:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--color-white); }
.checkbox:disabled { background: var(--state-disabled-bg); border-color: var(--state-disabled-bg); cursor: not-allowed; }
.check-label { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-app-md); color: var(--fg-subtle); cursor: pointer; }

/* ── Tags (status, read-only) ───────────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: 6px; width: max-content; max-width: 100%; padding: 4px 9px 3px; border-radius: var(--radius-badge); border: 1px solid transparent; font-family: var(--font-mono); font-size: var(--text-app-xs); line-height: 1.2; letter-spacing: 0.02em; white-space: nowrap; background: var(--state-neutral-bg); color: var(--state-neutral-ink); }
.tag-success  { background: var(--state-success-bg);  color: var(--state-success-ink); }
.tag-warning  { background: var(--state-warning-bg);  color: var(--state-warning-ink); }
.tag-error    { background: var(--state-error-bg);    color: var(--state-error-ink); }
.tag-info     { background: var(--state-info-bg);     color: var(--state-info-ink); }
.tag-progress { background: var(--state-progress-bg); color: var(--state-progress-ink); }
.tag-solid    { background: var(--color-purple-03); color: var(--color-white); }
.tag-outline  { background: transparent; border-color: var(--border-default); color: var(--fg-subtle); }
.tag-caps     { text-transform: uppercase; letter-spacing: var(--tracking-wider); font-size: var(--text-app-2xs); }
.tag-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Chips (filters, clickable) ─────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { appearance: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 5px; border-radius: var(--radius-pill); border: 1px solid var(--border-default); background: transparent; color: var(--fg-subtle); font-family: var(--font-mono); font-size: var(--text-app-xs); line-height: 1.2; cursor: pointer; transition: var(--transition-state); }
.chip:hover { border-color: var(--color-purple-03); color: var(--color-purple-03); }
.chip.is-on, .chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--color-purple-03); border-color: var(--color-purple-03); color: var(--color-white); }
.chip .count { opacity: .75; }
.chip:disabled { color: var(--state-disabled-fg); border-color: var(--state-disabled-border); background: transparent; cursor: not-allowed; }

/* ── Segmented control ──────────────────────────────────────── */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-surface); overflow: hidden; }
.seg-opt { appearance: none; border: 0; border-right: 1px solid var(--border-subtle); background: transparent; padding: 7px 12px 6px; font-family: var(--font-primary); font-size: var(--text-app-md); font-weight: 500; color: var(--fg-subtle); cursor: pointer; white-space: nowrap; transition: var(--transition-state); }
.seg-opt:last-child { border-right: 0; }
.seg-opt:hover { background: var(--state-hover-tint); color: var(--color-purple-01); }
.seg-opt.is-on, .seg-opt[aria-pressed="true"] { background: var(--color-purple-03); color: var(--color-white); }
.seg-opt .count { font-family: var(--font-mono); font-size: var(--text-app-2xs); margin-left: 6px; opacity: .75; }
.seg-opt:focus-visible { outline-offset: -2px; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; box-shadow: inset 0 -1px var(--border-subtle); overflow-x: auto; overflow-y: hidden; }
.tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 16px 10px; font-family: var(--font-primary); font-size: var(--text-app-md); font-weight: 600; color: var(--fg-subtle); cursor: pointer; white-space: nowrap; transition: var(--transition-state); }
.tab:hover { color: var(--color-purple-03); }
.tab.is-on, .tab[aria-selected="true"] { color: var(--color-purple-01); border-bottom-color: var(--color-purple-03); }
.tabs-lg .tab { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: 0.02em; text-transform: uppercase; padding: 14px 20px 12px; }
.tab:focus-visible { outline-offset: -2px; }

/* ── Table ──────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-app-md); color: var(--fg-default); background: var(--bg-surface); }
.table th, .table td { text-align: left; padding: 11px 12px; border-top: 1px solid var(--border-subtle); vertical-align: top; }
.table th { border-top: 0; background: var(--bg-raised); font-family: var(--font-mono); font-size: var(--text-app-2xs); font-weight: 500; letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--fg-subtle); white-space: nowrap; vertical-align: middle; }
.table tbody tr { transition: var(--transition-state); }
.table tbody tr:hover td { background: var(--state-hover-tint); }
.table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .mono { font-family: var(--font-mono); font-size: var(--text-app-sm); }
.table .sub { display: block; font-size: var(--text-app-sm); color: var(--fg-subtle); margin-top: 3px; }
.table-compact th, .table-compact td { padding: 8px 10px; }
/* Sorting: a <button class="th-sort"> inside the <th>, with aria-sort on the <th> */
.th-sort { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.th-sort::after { content: ""; width: 0; height: 0; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 4px solid currentColor; opacity: .3; transition: var(--transition-state); }
.th-sort:hover { color: var(--color-purple-03); }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--color-purple-03); }
th[aria-sort="ascending"] .th-sort::after { opacity: 1; transform: rotate(180deg); }
th[aria-sort="descending"] .th-sort::after { opacity: 1; }
/* Selection mode: checkboxes appear only after the user presses “Select”.
   Exception: when selecting rows IS the task of the screen (e.g. grouping
   folders into catalogs), keep checkboxes visible — add .is-selecting in
   markup and omit the Select button. */
.table .col-check { width: 44px; }
.table:not(.is-selecting) .col-check, .table:not(.is-selecting) th.cell-check, .table:not(.is-selecting) td.cell-check { display: none; }
.table td.cell-check, .table th.cell-check { padding-right: 0; vertical-align: middle; }
.table tr.is-selected td { background: var(--state-hover-tint); }
.table-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.table-bar .grow { flex: 1 1 auto; }
.batch-bar { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; padding: 10px 16px; background: var(--state-hover-tint); border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; z-index: 5; }
.batch-bar[hidden] { display: none; }
.batch-count { font-family: var(--font-mono); font-size: var(--text-app-xs); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--color-purple-01); }
.batch-count b { color: var(--color-purple-03); }
.batch-bar .btn-link { margin-left: auto; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border-subtle); font-size: var(--text-app-sm); color: var(--fg-subtle); }
.table-empty td { padding: 28px 16px; text-align: center; color: var(--fg-subtle); }

/* ── Cards & sections ───────────────────────────────────────── */
.card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); }
.card-raised { box-shadow: var(--shadow-sm); border-color: var(--border-default); transition: var(--transition-state); }
a.card-raised:hover, button.card-raised:hover, .card-raised.is-link:hover { border-color: var(--color-purple-03); box-shadow: var(--shadow-md); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-app-lg); letter-spacing: 0.02em; text-transform: uppercase; color: var(--color-purple-01); }
.card-body { padding: 16px 20px; }
.section-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border-subtle); }
.section-foot .note { font-size: var(--text-app-sm); color: var(--fg-subtle); }
.label-slash { font-family: var(--font-mono); font-size: var(--text-app-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--fg-subtle); }
.label-slash::before { content: "// "; color: var(--color-muted-pink); }
.kpi-value { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: var(--lh-snug); color: var(--color-purple-01); }

/* ── Choice card (pick one of several) ──────────────────────── */
.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.choice { appearance: none; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; font: inherit; color: var(--fg-default); background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-card); padding: 12px 14px; cursor: pointer; transition: var(--transition-state); }
.choice:hover { border-color: var(--color-purple-03); }
.choice.is-on, .choice[aria-pressed="true"], .choice[aria-checked="true"] { border-color: var(--color-purple-03); box-shadow: inset 0 0 0 1px var(--color-purple-03); background: var(--state-progress-bg); }
.choice:disabled { color: var(--state-disabled-fg); background: transparent; border-color: var(--state-disabled-bg); cursor: not-allowed; }
.choice-title { font-weight: 600; font-size: var(--text-app-lg); }
.choice-desc { font-size: var(--text-app-sm); color: var(--fg-subtle); }
.choice.is-recommended .choice-title::after { content: "Recommended"; margin-left: 8px; font-family: var(--font-mono); font-size: var(--text-app-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--color-purple-03); }

/* ── Stepper (vertical checklist + horizontal strip) ────────── */
.steps { display: grid; }
.step { display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border-subtle); }
.step:first-child { border-top: 0; }
.step-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mono); font-size: var(--text-app-xs); border: 1px solid var(--border-default); color: var(--fg-subtle); background: var(--bg-surface); }
.step-title { font-weight: 600; font-size: var(--text-app-xl); color: var(--color-purple-01); }
.step-sum { font-size: var(--text-app-sm); color: var(--fg-subtle); margin-top: 2px; }
.step.is-done .step-n { background: var(--color-purple-03); border-color: var(--color-purple-03); color: var(--color-white); }
.step.is-current .step-n { border: 2px solid var(--color-purple-03); color: var(--color-purple-03); }
.step.is-needed .step-n { background: var(--state-progress-bg); border-color: var(--state-progress); color: var(--state-progress-ink); }
.step.is-locked .step-title, .step.is-locked .step-n { color: var(--state-disabled-fg); border-color: var(--state-disabled-bg); }
.step-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--bg-surface); overflow: hidden; }
.step-strip > * { padding: 12px 14px; border-left: 1px solid var(--border-subtle); min-width: 0; }
.step-strip > *:first-child { border-left: 0; }
.step-strip .k { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: var(--text-app-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--fg-subtle); }
.step-strip .k::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--border-default); }
.step-strip .is-done .k::before { background: var(--color-purple-03); border-color: var(--color-purple-03); }
.step-strip .is-current .k::before { border: 2px solid var(--color-purple-03); }
.step-strip .v { font-size: var(--text-app-md); margin-top: 6px; color: var(--fg-default); }

/* ── Overlays: dialog, menu, tooltip, toast (all sharp) ────── */
.dialog-overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--color-purple-01) 50%, transparent); display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.dialog-overlay.is-open { display: flex; }
.dialog { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-modal); box-shadow: var(--shadow-modal); width: 480px; max-width: 100%; padding: 28px 28px 20px; }
.dialog-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.15; text-transform: uppercase; color: var(--color-purple-01); margin: 0 0 10px; }
.dialog-body { font-size: var(--text-app-lg); color: var(--fg-subtle); line-height: var(--lh-relaxed); }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-sm); margin-top: 24px; }
.dialog-actions .check-label { margin-right: auto; }
.menu { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 0; box-shadow: var(--shadow-dropdown); padding: 4px; min-width: 184px; display: grid; }
.menu-item { appearance: none; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; background: transparent; border: 0; text-align: left; font-family: var(--font-primary); font-size: var(--text-app-md); color: var(--fg-default); cursor: pointer; transition: var(--transition-state); }
.menu-item:hover { background: var(--state-hover-tint); color: var(--color-purple-03); }
.menu-item.is-danger { color: var(--state-error-ink); }
.menu-item.is-danger:hover { background: var(--state-error-bg); }
.menu-sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.tooltip { background: var(--bg-surface); border: 1px solid var(--border-default); box-shadow: var(--shadow-dropdown); padding: 12px 14px; max-width: 340px; font-size: var(--text-app-sm); line-height: var(--lh-relaxed); color: var(--fg-subtle); }
.toast { display: flex; align-items: flex-start; gap: 12px; background: var(--bg-surface); border: 1px solid var(--border-default); border-left: 0; box-shadow: var(--shadow-toast); padding: 12px 14px; max-width: 360px; font-size: var(--text-app-md); color: var(--fg-default); }
.toast .btn-link { margin-left: auto; }

/* ── Inline content ─────────────────────────────────────────── */
.source-ref { display: block; font-family: var(--font-mono); font-size: var(--text-app-xs); line-height: 1.5; color: var(--fg-subtle); margin-top: 4px; }
.source-ref::before { content: "// "; color: var(--color-muted-pink); }
.callout { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 12px; padding: 12px 16px; background: var(--bg-raised); border: 1px solid var(--border-subtle); font-size: var(--text-app-md); line-height: var(--lh-relaxed); color: var(--fg-subtle); }
.callout > .label-slash { padding-top: 2px; }
.callout.is-progress { background: var(--state-progress-bg); border-color: color-mix(in srgb, var(--state-progress) 25%, transparent); }
.callout.is-warning { background: var(--state-warning-bg); border-color: color-mix(in srgb, var(--state-warning) 25%, transparent); }

/* ── Focus for non-native interactive elements ──────────────── */
.chip:focus-visible, .tab:focus-visible, .seg-opt:focus-visible, .choice:focus-visible, .th-sort:focus-visible, .btn-link:focus-visible, .menu-item:focus-visible, .step[role="button"]:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: var(--focus-ring-offset);
}
.menu-item:focus-visible, .step[role="button"]:focus-visible { outline-offset: -2px; }

/* ── Select (v3.3): custom dropdown — labelled trigger + .menu popup ── */
/* Use native select.input inside forms; use .select for filter bars, where the trigger shows "KEY: value"
   and the menu may need search. States live on the wrapper: .is-open, .has-value (a non-default pick). */
.select { position: relative; display: inline-block; }
.select-trigger { appearance: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px 7px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-input); background: var(--bg-surface); color: var(--fg-default); font-family: var(--font-mono); font-size: var(--text-app-xs); letter-spacing: var(--tracking-wide); line-height: 1.3; white-space: nowrap; cursor: pointer; transition: var(--transition-state); }
.select-trigger:hover { border-color: var(--color-purple-03); color: var(--color-purple-03); }
.select-trigger:disabled { color: var(--state-disabled-fg); border-color: var(--border-subtle); cursor: not-allowed; }
.select-key { color: var(--fg-subtle); text-transform: uppercase; }
.select-key::after { content: ":"; }
.select-value { font-weight: 600; color: var(--fg-default); }
.select-chev { color: var(--fg-subtle); font-size: var(--text-app-2xs); margin-left: 2px; transition: transform var(--motion-fast) var(--ease-standard); }
.select.has-value .select-trigger, .select.is-open .select-trigger { border-color: var(--color-purple-03); }
.select.has-value .select-value, .select.is-open .select-chev { color: var(--color-purple-03); }
.select.is-open .select-chev { transform: rotate(180deg); }
.select-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 240px; max-height: 320px; overflow-y: auto; }
.select-search { appearance: none; border: 0; border-bottom: 1px solid var(--border-subtle); margin: -4px -4px 4px; padding: 10px 12px; font-family: var(--font-primary); font-size: var(--text-app-md); color: var(--fg-default); background: transparent; outline: none; }
.select-search::placeholder { color: var(--fg-muted); }
.select-menu .menu-item[aria-selected="true"] { background: var(--state-hover-tint); color: var(--color-purple-03); font-weight: 600; }
.select-trigger:focus-visible, .select-search:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: var(--focus-ring-offset); }

/* ── App shell (v3.3): nav rail, page head ───────────────────── */
.nav { background: var(--color-ui-purple); color: var(--color-white); padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.nav-section { font-family: var(--font-mono); font-size: var(--text-app-2xs); letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--color-muted-grey); padding: 0 10px; }
.nav-section .slash { color: var(--color-muted-pink); margin-right: 4px; }   /* markup: <div class="nav-section"><span class="slash">//</span> Workspace</div> */
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: color-mix(in srgb, var(--color-white) 78%, transparent); font-size: var(--text-app-md); cursor: pointer; transition: var(--transition-state); }
.nav-item:hover { background: color-mix(in srgb, var(--color-white) 5%, transparent); color: var(--color-white); }
.nav-item.is-on, .nav-item[aria-current="page"] { background: color-mix(in srgb, var(--color-white) 10%, transparent); color: var(--color-white); }
.nav-item .check { width: 14px; height: 14px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--color-white) 20%, transparent); margin-left: auto; }
.nav-item.is-done .check { background: var(--color-cyan); border-color: var(--color-cyan); }
.nav-item.is-on .check { background: var(--color-cyan); border-color: var(--color-cyan); box-shadow: inset 0 0 0 3px var(--color-ui-purple); }
.nav-sub { display: flex; flex-direction: column; margin: -4px 0 4px 30px; padding-left: var(--space-sm); border-left: 1px solid color-mix(in srgb, var(--color-white) 8%, transparent); }
.nav-subitem { display: block; padding: 6px 10px; font-family: var(--font-mono); font-size: var(--text-app-sm); letter-spacing: var(--tracking-wide); color: color-mix(in srgb, var(--color-white) 55%, transparent); cursor: pointer; transition: var(--transition-state); }
.nav-subitem:hover { color: var(--color-white); background: color-mix(in srgb, var(--color-white) 5%, transparent); }
.nav-subitem.is-on, .nav-subitem[aria-current="page"] { color: var(--color-cyan); background: color-mix(in srgb, var(--color-cyan) 10%, transparent); }
.nav-subitem:focus-visible { outline: 2px solid var(--color-cyan); outline-offset: -2px; }
.nav-item .num { font-family: var(--font-mono); font-size: var(--text-app-2xs); color: var(--color-muted-pink); width: 18px; flex: 0 0 18px; }
.nav-item.is-on .num, .nav-item[aria-current="page"] .num { color: var(--color-cyan); }
.nav-item:focus-visible { outline: 2px solid var(--color-cyan); outline-offset: -2px; }   /* cyan on the dark rail: purple-03 fails contrast here */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h2); line-height: var(--lh-snug); letter-spacing: var(--tracking-tight); text-transform: uppercase; color: var(--color-purple-01); margin: 0; }
.page-title .accent { color: var(--color-purple-03); }
.page-sub { color: var(--fg-subtle); font-size: var(--text-app-xl); line-height: 1.55; max-width: 620px; margin-top: 10px; text-wrap: pretty; }
.page-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* ── Dropzone (v3.3) — a row inside a card; .dropzone-boxed stands alone ── */
.dropzone { position: relative; display: flex; align-items: center; gap: 14px; padding: 24px 20px; cursor: pointer; transition: var(--transition-state); }
.dropzone:hover, .dropzone.is-over { background: var(--state-hover-tint); }
.dropzone.is-off { opacity: 1; color: var(--state-disabled-fg); cursor: not-allowed; }
.dropzone-boxed { border: 1px dashed var(--border-default); border-radius: var(--radius-card); background: var(--bg-surface); }
.dropzone-boxed:hover, .dropzone-boxed.is-over { border-color: var(--color-purple-03); }
.dropzone-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; text-transform: uppercase; }
.dropzone-meta { color: var(--fg-subtle); font-size: var(--text-app-sm); margin-top: 4px; }

/* ── Controls (v3.3): range, number stepper, stage pills ───────── */
.range { position: relative; height: 6px; background: var(--border-subtle); border-radius: var(--radius-xs); margin: 14px 0 8px; }
.range .fill { position: absolute; top: 0; bottom: 0; background: var(--color-purple-03); border-radius: var(--radius-xs); }
.range .pin { position: absolute; top: -5px; width: 16px; height: 16px; border-radius: var(--radius-circle); background: var(--color-white); border: 2px solid var(--color-purple-03); transform: translateX(-50%); box-shadow: var(--shadow-xs); }
.range-labels { display: flex; justify-content: space-between; gap: 18px; font-family: var(--font-mono); font-size: var(--text-app-2xs); color: var(--fg-subtle); }
.num-stepper { display: flex; align-items: center; gap: var(--space-sm); }
.num-stepper button { width: 28px; height: 28px; border: 1px solid var(--border-default); background: var(--bg-surface); border-radius: var(--radius-sm); color: var(--fg-subtle); font-size: var(--text-app-lg); cursor: pointer; transition: var(--transition-state); }
.num-stepper button:hover { border-color: var(--color-purple-03); color: var(--color-purple-03); }
.num-stepper .v { font-family: var(--font-mono); font-weight: 600; min-width: 32px; text-align: center; }
.stages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stage { appearance: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-default); background: var(--bg-surface); border-radius: var(--radius-pill); padding: 6px 14px 6px 6px; font-family: var(--font-primary); font-size: var(--text-app-md); font-weight: 600; color: var(--fg-subtle); cursor: pointer; transition: var(--transition-state); }
.stage:hover:not(:disabled) { border-color: var(--color-purple-03); }
.stage-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--state-neutral-bg); font-family: var(--font-mono); font-size: var(--text-app-2xs); }
.stage[aria-current="true"], .stage.is-on { border-color: var(--color-purple-03); color: var(--fg-default); }
.stage[aria-current="true"] .stage-n, .stage.is-on .stage-n { background: var(--color-purple-03); color: var(--color-white); }
.stage.is-done .stage-n { background: var(--state-progress-bg); color: var(--state-progress-ink); }
.stage:disabled { color: var(--state-disabled-fg); border-color: var(--state-disabled-border); cursor: not-allowed; }

/* ── Chat (v3.3) ────────────────────────────────────────────── */
.chat-bubble { font-size: var(--text-app-md); line-height: 1.5; padding: 8px 10px; border-radius: var(--radius-card); overflow-wrap: anywhere; max-width: 92%; }
.chat-bubble.is-user { background: color-mix(in srgb, var(--color-purple-05) 22%, transparent); border: 1px solid color-mix(in srgb, var(--color-purple-05) 45%, transparent); color: var(--fg-default); align-self: flex-end; max-width: 86%; white-space: pre-wrap; }
.chat-bubble.is-assistant { background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--fg-subtle); align-self: flex-start; }

/* ── Pager (v3.2) ───────────────────────────────────────────── */
.pager { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.pager-status { font-family: var(--font-mono); font-size: var(--text-app-xs); color: var(--fg-subtle); padding: 0 6px; white-space: nowrap; }
.tbl-pager[hidden] { display: none; }
tr[data-pg-off] { display: none !important; }
/* "Load more" row for tables embedded in a card: one full-width clickable row. */
.tbl-more-row td { padding: 10px 12px; text-align: center; font-family: var(--font-mono); font-size: var(--text-app-xs); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--color-purple-03); border-top: 1px solid var(--border-subtle); cursor: pointer; }
.tbl-more-row:hover td { color: var(--color-purple-04); background: var(--state-hover-tint); }
.tbl-more-row:focus-visible { outline: 2px solid var(--color-purple-03); outline-offset: -2px; }

/* ── Dark surfaces (v3.2) ───────────────────────────────────────
   Tokens flip under [data-theme="dark"] (colors_and_type.css). These
   rules only cover text that is brand-purple on light and must turn
   white on purple. */
:is([data-theme="dark"], .theme-dark) :is(.card-title, .step-title, .dialog-title, .kpi-value, .batch-count, .tab.is-on, .tab[aria-selected="true"], .seg-opt:hover) { color: var(--fg-default); }
:is([data-theme="dark"], .theme-dark) :is(th[aria-sort="ascending"], th[aria-sort="descending"]) .th-sort, :is([data-theme="dark"], .theme-dark) .th-sort:hover { color: var(--fg-default); }
:is([data-theme="dark"], .theme-dark) .batch-count b { color: var(--color-purple-04); }
:is([data-theme="dark"], .theme-dark) .menu-item:hover { color: var(--fg-default); }
:is([data-theme="dark"], .theme-dark) .chip.is-on, :is([data-theme="dark"], .theme-dark) .chip[aria-pressed="true"] { color: var(--color-white); }
:is([data-theme="dark"], .theme-dark) .table th { color: var(--fg-muted); }
:is([data-theme="dark"], .theme-dark) .dialog-overlay { background: color-mix(in srgb, black 55%, transparent); }

/* ============================================================
   v3.4 (Oct 2026) — patterns promoted from the Primordial demo
   ============================================================ */

/* Table cells: secondary line, truncating name + "+N" trigger, reference link */
.cell-sub{display:block;margin-top:2px;font-size:var(--text-app-xs);color:var(--fg-subtle)}
.cell-name{display:flex;align-items:baseline;gap:4px;min-width:0}
.cell-name .nm{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.cell-name .cell-more{flex:0 0 auto}
.cell-more{font-family:var(--font-mono);font-size:var(--text-app-xs);color:var(--color-purple-03);border-bottom:1px dotted currentColor;cursor:help}
.cell-more:focus-visible{outline:2px solid var(--color-purple-03);outline-offset:2px}
.ref-link{appearance:none;background:none;border:0;padding:0;font:inherit;color:var(--color-purple-03);cursor:pointer;text-align:left;text-decoration:underline;text-decoration-color:transparent;text-underline-offset:3px;transition:color 120ms,text-decoration-color 120ms}
.ref-link:hover{color:var(--color-purple-03);text-decoration-color:currentColor}
.ref-link:focus-visible{outline:2px solid var(--color-purple-03);outline-offset:2px}
.ref-link.mono{white-space:nowrap}
.ref-link.mono:hover{color:var(--color-purple-04)}
.is-flash{animation:dsFlash 1.8s ease}@keyframes dsFlash{0%,45%{background:var(--state-hover-tint)}100%{background:transparent}}

/* Numbered pager (long admin lists) */
.pager-btn{appearance:none;min-width:30px;height:30px;padding:0 9px;border:1px solid var(--border-default);border-radius:var(--radius-sm);background:var(--bg-surface);font-family:var(--font-mono);font-size:var(--text-app-xs);color:var(--fg-subtle);cursor:pointer;white-space:nowrap}
.pager-btn:hover:not(:disabled){border-color:var(--color-purple-03);color:var(--color-purple-03)}
.pager-btn.is-on,.pager-btn[aria-current="page"]{background:var(--color-purple-03);border-color:var(--color-purple-03);color:var(--color-white);cursor:default}
.pager-btn:disabled:not(.is-on){color:var(--state-disabled-fg);border-color:var(--border-subtle);cursor:not-allowed}
.pager-gap{font-family:var(--font-mono);font-size:var(--text-app-xs);color:var(--fg-subtle);padding:0 2px}

/* Stat strip: a row of key figures sharing one border */
.stat-strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:1px;background:var(--border-subtle);border:1px solid var(--border-subtle);border-radius:var(--radius-card);overflow:hidden}
.stat-strip>div{background:var(--bg-surface);padding:12px 14px;display:grid;gap:2px;min-width:0}
.stat-strip .k{font-family:var(--font-mono);font-size:var(--text-app-2xs);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--fg-subtle)}
.stat-strip .v{font-weight:600;font-size:var(--text-app-lg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.stat-strip .s{font-size:var(--text-app-xs);color:var(--fg-subtle)}

/* Side drawer: edit or inspect one record without leaving the page */
.drawer-overlay{position:fixed;inset:0;background:color-mix(in srgb,var(--color-purple-01) 30%,transparent);z-index:190;display:none}
.drawer-overlay.is-open{display:block}
.drawer{position:fixed;top:0;right:0;bottom:0;width:560px;max-width:100%;background:var(--bg-surface);border-left:1px solid var(--border-default);box-shadow:var(--shadow-modal);z-index:191;display:none;flex-direction:column}
.drawer.is-open{display:flex}
.drawer:focus{outline:none}
.drawer-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;padding:20px 22px 14px;border-bottom:1px solid var(--border-subtle)}
.drawer-head h3{margin:0;font-size:var(--text-app-xl);line-height:1.25}
.drawer-body{overflow-y:auto;padding:16px 22px 24px;display:grid;gap:22px;align-content:start}
.drawer-foot{padding:14px 22px;border-top:1px solid var(--border-subtle);display:flex;gap:8px;justify-content:flex-end;align-items:center;flex-wrap:wrap}
.drawer-foot .note{margin-right:auto;font-size:var(--text-app-sm);color:var(--fg-subtle)}
.drawer-sec{display:grid;gap:8px}
.drawer-sec>.k{font-family:var(--font-mono);font-size:var(--text-app-2xs);letter-spacing:var(--tracking-wide);text-transform:uppercase;color:var(--fg-subtle)}

/* Field list with provenance: each value says where it came from */
.field-list{display:grid;grid-template-columns:132px minmax(0,1fr);border:1px solid var(--border-subtle)}
.field-list>div{padding:9px 12px;border-top:1px solid var(--border-subtle);min-width:0}
.field-list>div:nth-child(-n+2){border-top:0}
.field-list .f{color:var(--fg-subtle);font-size:var(--text-app-sm)}
.field-list .val{display:grid;gap:2px}
.field-src{font-size:var(--text-app-xs);color:var(--fg-subtle)}
.field-src.is-edited{color:var(--color-purple-03)}
@media (max-width:560px){.field-list{grid-template-columns:minmax(0,1fr)}.field-list>div:nth-child(2){border-top:0}.field-list .f{padding-bottom:0}.field-list .val{padding-top:2px;border-top:0}}

/* Coverage grid: one cell per period. .in data · .wait waiting on the user · .gap missing · empty none */
.coverage{display:grid;gap:3px;align-items:center;justify-content:start;min-width:max-content}
.coverage .p{font-size:var(--text-app-md);padding-right:12px;white-space:nowrap}
.coverage .y{font-family:var(--font-mono);font-size:var(--text-app-2xs);color:var(--fg-subtle);letter-spacing:.04em;border-left:1px solid var(--border-subtle);padding-left:4px}
.coverage .c{width:16px;height:16px;border-radius:var(--radius-xs);background:var(--bg-surface);border:1px solid var(--border-subtle)}
.coverage .c.in{background:var(--chart-1);border-color:var(--chart-1)}
.coverage .c.wait,.coverage-legend i.wait{background:color-mix(in srgb,var(--chart-1) 14%,transparent);border:1.5px solid var(--chart-1)}
.coverage .c.gap,.coverage-legend i.gap{background:var(--state-warning-bg);border:1.5px solid var(--state-warning)}
.coverage .c[title]{cursor:help}
.coverage-legend{display:flex;flex-wrap:wrap;gap:18px;font-family:var(--font-mono);font-size:var(--text-app-2xs);color:var(--fg-subtle)}
.coverage-legend span{display:flex;align-items:center;gap:7px}
.coverage-legend i{width:12px;height:12px;border-radius:var(--radius-xs);background:var(--bg-surface);border:1px solid var(--border-subtle)}
.coverage-legend i.in{background:var(--chart-1);border-color:var(--chart-1)}

/* Guide bar: the next thing the user has to do (progress = waiting on the user; .is-ok on the count = all done) */
.guide-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:10px 20px;background:var(--state-progress-bg);border-bottom:1px solid color-mix(in srgb,var(--state-progress) 25%,transparent)}
.guide-bar[hidden]{display:none}
.guide-bar-n{display:flex;align-items:center;gap:8px;font-size:var(--text-app-md);color:var(--state-progress-ink)}
.guide-bar-n b{font-family:var(--font-mono);font-weight:600}
.guide-bar-n i{width:8px;height:8px;border-radius:50%;background:var(--state-progress);flex:0 0 8px}
.guide-bar-n.is-ok{color:var(--state-success-ink)}.guide-bar-n.is-ok i{background:var(--state-success)}
.guide-bar:has(.is-ok){background:var(--state-success-bg);border-bottom-color:color-mix(in srgb,var(--state-success) 25%,transparent)}
