/* ============================================================
 * Power Funding Solutions CRM: core stylesheet (Task 6.3b)
 *
 * The sections below are copied VERBATIM from fundivi-crm
 * public/styles.css, with no pruning, so a later merge of these
 * sections is an empty diff. Each block is fenced by
 *   @fundivi-begin <first>-<last>  ...  @fundivi-end
 * naming its Fundivi line range; public/assets.test.ts checks
 * every block against Fundivi's file. Never edit inside a block:
 * PFS colours live in brand.css, PFS additions in brand.css too.
 * ============================================================ */

/* ---------- Self-hosted fonts (OFL, see /static/fonts/OFL.txt) ---------- */
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/plus-jakarta-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/plus-jakarta-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/plus-jakarta-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/static/fonts/plus-jakarta-sans-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('/static/fonts/plus-jakarta-sans-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/jetbrains-mono-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url('/static/fonts/jetbrains-mono-latin-700-normal.woff2') format('woff2'); }

/* @fundivi-begin 1-2054 (1-14 Tokens through Notifications) */
/* ============================================================
 * Fundivi CRM — Portal stylesheet
 * Phase 1 (shell, tokens, primitives). Class names preserved
 * so existing EJS views keep rendering without changes.
 * ============================================================ */

/* ---------- 1. Tokens ---------- */

:root {
  color-scheme: light;

  /* Brand */
  --brand-h: 256;
  --brand: oklch(52% 0.18 var(--brand-h));
  --brand-strong: oklch(44% 0.19 var(--brand-h));
  --brand-soft: oklch(96% 0.04 var(--brand-h));
  --brand-soft-2: oklch(92% 0.06 var(--brand-h));
  --brand-ink: oklch(34% 0.17 var(--brand-h));

  /* Surfaces (warm-tinted toward brand for cohesion) */
  --bg: oklch(98.5% 0.006 var(--brand-h));
  --surface: oklch(100% 0 0);
  --surface-2: oklch(97% 0.008 var(--brand-h));
  --surface-3: oklch(94% 0.012 var(--brand-h));
  --line: oklch(91% 0.014 var(--brand-h));
  --line-strong: oklch(84% 0.018 var(--brand-h));
  /* Border for text fields and selects. --line-strong is a decorative divider tone
     (about 1.6:1); a control edge that carries the affordance needs 3:1 on --surface. */
  --control-line: oklch(63% 0.02 var(--brand-h));
  /* Sidebar canvas — tinted a step below --bg so the nav reads as the app
     frame and the content column reads as the elevated work surface. */
  --sidebar-bg: oklch(97.2% 0.01 var(--brand-h));

  /* Text */
  --ink: oklch(20% 0.028 var(--brand-h));
  --ink-2: oklch(32% 0.022 var(--brand-h));
  --mute: oklch(48% 0.02 var(--brand-h));
  /* was 60%, which measured 3.94:1 on --surface and 3.62:1 on --surface-2,
     under the 4.5:1 AA floor for text. 53% clears every surface that carries
     real text: --surface 5.27, --surface-2 4.84, --bg 5.05, --sidebar-bg 4.87.
     It sits at 4.43 on --surface-3, whose only --mute-soft consumer is the
     decorative .empty-state__icon glyph (the empty state's actual title and
     body use --ink-2), so that one is deliberately left. Do not push this
     darker to chase it: --mute is 48% and the two tones would converge. */
  --mute-soft: oklch(53% 0.018 var(--brand-h));

  /* Status (semantic OKLCH; chroma tuned for clarity, ink tuned for contrast) */
  --ok: oklch(56% 0.15 155);
  --ok-soft: oklch(95% 0.05 155);
  --ok-ink: oklch(32% 0.13 155);

  --warn: oklch(68% 0.16 75);
  --warn-soft: oklch(95% 0.055 75);
  --warn-ink: oklch(38% 0.14 60);

  --danger: oklch(56% 0.20 28);
  --danger-soft: oklch(96% 0.045 28);
  --danger-ink: oklch(38% 0.18 28);

  --info: oklch(58% 0.15 230);
  --info-soft: oklch(96% 0.04 230);
  --info-ink: oklch(34% 0.15 230);

  --violet: oklch(56% 0.18 290);
  --violet-soft: oklch(96% 0.045 290);
  --violet-ink: oklch(34% 0.17 290);

  --teal: oklch(56% 0.13 195);
  --teal-soft: oklch(95% 0.04 195);
  --teal-ink: oklch(32% 0.11 195);

  /* Spacing (4pt) */
  --s1: 0.25rem; --s2: 0.5rem;  --s3: 0.75rem; --s4: 1rem;
  --s5: 1.25rem; --s6: 1.5rem; --s8: 2rem;    --s10: 2.5rem;
  --s12: 3rem;  --s16: 4rem;

  /* Radius / shadow / motion */
  --r-sm: 6px;
  --r:    8px;
  --r-md: 10px;
  --r-lg: 12px;
  /* Cards in enterprise CRMs read as flat surfaces delineated by hairlines,
     not as elevated material. Shadows reserved for popovers / drawers. */
  --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.03);
  --shadow-2: 0 1px 2px oklch(0% 0 0 / 0.04), 0 6px 16px -8px oklch(0% 0 0 / 0.08);
  --shadow-pop: 0 8px 24px -10px oklch(0% 0 0 / 0.24), 0 2px 4px oklch(0% 0 0 / 0.06);
  /* Two-layer focus ring. The old single translucent ring measured 1.72:1
     against --surface (light) and 2.42:1 (dark), under the 3:1 WCAG 1.4.11
     floor, and :focus-visible sets outline:none so there was no UA fallback.
     Solid --brand is 5.6:1 light / 7.2:1 dark; the inner --surface layer keeps
     the ring readable when it is clipped by a table cell or sticky header, and
     lets it sit on a tinted or brand-filled control without muddying. */
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Ink for text/glyphs that sit ON a tone-filled surface. Hardcoded white
     fails in dark mode, where --brand and --danger are ~20 points lighter
     (white on dark --brand measures 2.55:1). */
  --on-brand: oklch(100% 0 0);
  --on-danger: oklch(100% 0 0);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --num: tabular-nums lining-nums;
  --fs-base: 13px;
  --fs-sm: 12px;
  --fs-xs: 11px;
  --fs-xxs: 10px;

  /* Layout */
  --sidebar-w: 224px;
  /* Rail width. 48px is not arbitrary: the nav keeps its full-width layout when
     collapsed and is simply clipped, so the icons land at x=16..31 and 48
     centres them. Changing this without changing the nav padding decentres
     every glyph in the rail. */
  --sidebar-w-collapsed: 48px;
  --topbar-h: 48px;
  --view-banner-h: 32px;   /* height of the sticky view/QA banner when shown */
  --top-offset: 0px;       /* sticky-chrome height above the topbar; set only when a view banner shows */
  --content-max: none;

  /* Sizing — components share these so a single change ripples everywhere */
  --ctrl-h:    28px;   /* default input/button height */
  --ctrl-h-sm: 24px;   /* small button / filter-bar input height */
  --ctrl-h-xs: 20px;   /* micro pill button */
  --ctrl-px:   0.65rem; /* default control horizontal padding */
  --ctrl-px-sm: 0.5rem;
  --cell-py:   0.4rem; /* table cell vertical padding */
  --cell-px:   0.6rem;
  --panel-pad: 0.85rem; /* default panel interior */
}

[data-theme="dark"] {
  color-scheme: dark;

  --brand: oklch(72% 0.17 var(--brand-h));
  --brand-strong: oklch(80% 0.15 var(--brand-h));
  --brand-soft: oklch(28% 0.08 var(--brand-h));
  --brand-soft-2: oklch(34% 0.10 var(--brand-h));
  --brand-ink: oklch(85% 0.14 var(--brand-h));

  --bg: oklch(15% 0.02 var(--brand-h));
  --surface: oklch(19% 0.022 var(--brand-h));
  --surface-2: oklch(23% 0.024 var(--brand-h));
  --surface-3: oklch(27% 0.026 var(--brand-h));
  --line: oklch(30% 0.024 var(--brand-h));
  --line-strong: oklch(38% 0.028 var(--brand-h));
  --control-line: oklch(55% 0.025 var(--brand-h));
  --sidebar-bg: oklch(17% 0.021 var(--brand-h));

  --ink: oklch(97% 0.01 var(--brand-h));
  --ink-2: oklch(87% 0.014 var(--brand-h));
  --mute: oklch(72% 0.02 var(--brand-h));
  /* Dark moves the opposite way to light: measured 4.28:1 on --surface-2 at
     60%, so this goes lighter, not darker. 66% clears 4.5:1 on every surface
     including --surface-3, the deepest one (64% left it at 4.48). */
  --mute-soft: oklch(66% 0.02 var(--brand-h));

  --ok:         oklch(72% 0.16 155);
  --ok-soft:    oklch(28% 0.07 155);
  --ok-ink:     oklch(85% 0.14 155);
  --warn:       oklch(78% 0.16 75);
  --warn-soft:  oklch(30% 0.08 75);
  --warn-ink:   oklch(88% 0.15 75);
  --danger:     oklch(70% 0.20 28);
  --danger-soft: oklch(28% 0.09 28);
  --danger-ink:  oklch(85% 0.16 28);
  --info:       oklch(72% 0.15 230);
  --info-soft:  oklch(28% 0.07 230);
  --info-ink:   oklch(85% 0.14 230);
  --violet:     oklch(72% 0.17 290);
  --violet-soft: oklch(28% 0.08 290);
  --violet-ink:  oklch(85% 0.15 290);
  --teal:       oklch(72% 0.13 195);
  --teal-soft:  oklch(28% 0.07 195);
  --teal-ink:   oklch(85% 0.12 195);

  --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.25);
  --shadow-2: 0 1px 2px oklch(0% 0 0 / 0.35), 0 8px 22px -10px oklch(0% 0 0 / 0.45);
  --shadow-pop: 0 10px 32px -12px oklch(0% 0 0 / 0.6), 0 2px 6px oklch(0% 0 0 / 0.4);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);

  /* Dark --brand/--danger are light enough that white text on them is
     2.55:1 / 2.98:1. Flip the ink to the dark surface ink instead: 7.1:1. */
  --on-brand: oklch(20% 0.028 var(--brand-h));
  --on-danger: oklch(20% 0.03 28);
}

/* ---------- 2. Reset / base ---------- */

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* The [hidden] attribute must always win. Several primitives (.btn-*, etc.)
   set an explicit `display`, which would otherwise override the UA
   `[hidden] { display: none }` rule and leave hidden elements visible
   (e.g. the Edit-panel Save/Cancel buttons before Edit is clicked). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Contextual alternates only — Plus Jakarta Sans has no ss01/cv11.
     Tabular figures are applied per-context via font-variant-numeric. */
  font-feature-settings: "calt" 1;
  letter-spacing: -0.005em;
}

/* Numbers should ALWAYS be tabular by default — data alignment is what
   makes a CRM read as professional rather than consumer. */
.num, .data-table td, .data-table th, .kv dd,
.stat-value, .big-stat,
.list-kpi-tile__value, .stat-card .stat-value {
  font-variant-numeric: tabular-nums lining-nums;
}

/* IDs, slugs, codes, addresses — anything that's data not prose — should
   read as monospace so the eye treats it as code, not language. */
code, .mono, .id-mono, .code-id,
.data-table .ext-id, .data-table .id-cell,
.lead-row-id, .application-id, .funded-id,
.dialer-lead-id, .webhook-url, .totp-secret-code {
  font-family: var(--font-mono);
  font-feature-settings: "zero" 1;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.022em; font-weight: 700; }
h2 { font-size: 1.0625rem; line-height: 1.3; letter-spacing: -0.012em; font-weight: 700; }
h3 { font-size: 0.875rem; line-height: 1.35; color: var(--ink-2); font-weight: 600; letter-spacing: -0.005em; }
h4 { font-size: 0.75rem; line-height: 1.3; color: var(--mute); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
p  { margin: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

button { font-family: inherit; cursor: pointer; }

code, pre, kbd, samp { font-family: var(--font-mono); }
code {
  background: var(--surface-3);
  color: var(--ink-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

::selection { background: color-mix(in oklch, var(--brand) 25%, transparent); }

/* Thin, quiet scrollbars everywhere — the chunky OS default reads dated
   on an app shell. Firefox via scrollbar-width, WebKit via pseudo. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--line-strong); }

/* utilities */
.muted { color: var(--mute); }
.muted-soft { color: var(--mute-soft); }
.small { font-size: 0.78rem; }
.num { font-variant-numeric: var(--num); }
.mono { font-family: var(--font-mono); font-variant-numeric: var(--num); }
.inline-form { display: inline; }
.center { text-align: center; }
.spacer { flex: 1; }
.hint { font-size: 0.78rem; color: var(--mute); margin: var(--s1) 0 0; }
.hint a { font-weight: 600; }

/* Visually hidden but read by screen readers. The app had no such utility, so
   glyph-only controls and live regions had nowhere to put their text.
   .inbox-sr predates this and is kept as an alias so nothing breaks. */
.sr-only, .inbox-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
/* Skip link: hidden until focused, then pinned to the top of the viewport. */
.skip-link:focus-visible {
  position: fixed; top: var(--s2); left: var(--s2); z-index: 3000;
  width: auto; height: auto; margin: 0; padding: var(--s2) var(--s3);
  clip: auto; clip-path: none; overflow: visible;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
}

/* --- htmx in-flight layer ---------------------------------------------
   There was no loading state anywhere: hx-indicator appeared zero times
   against 80 htmx triggers, and .wf-row.htmx-request was the only state rule
   in the whole stylesheet. So a multi-second AI job looked identical to a
   dead button. These two rules cover every htmx endpoint at once.
   Deliberately NOT inside a prefers-reduced-motion guard: this is a state
   signal, not decoration, and it must show for everyone. */
.htmx-request {
  opacity: 0.62;
  transition: opacity 0.12s var(--ease);
}
button.htmx-request,
.htmx-request button[type="submit"],
form.htmx-request button[type="submit"] {
  cursor: progress;
  pointer-events: none;
}
/* Busy controls get a small spinner so a slow request reads as working,
   not stuck. Uses currentColor so it inherits any button tone. */
button.htmx-request::after,
form.htmx-request button[type="submit"]::after {
  content: "";
  width: 0.75em; height: 0.75em;
  margin-left: 0.45em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: fv-spin 0.6s linear infinite;
}
@keyframes fv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  button.htmx-request::after,
  form.htmx-request button[type="submit"]::after { animation-duration: 1.6s; }
}

/* --- Toasts ------------------------------------------------------------
   Server errors used to surface through window.alert: an unstyled, unbranded,
   focus-stealing OS dialog that blocks the page. "Composed, precise, calm" is
   not an alert box. The stack is an aria-live region, which is also the app's
   first live region, so htmx errors are now announced instead of silent. */
.fv-toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  /* Above the My Work panel (9100) and every modal and palette: a toast is the
     only feedback for a failed save, and underneath the panel it was never seen. */
  z-index: 9800;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(380px, calc(100vw - var(--s8)));
  pointer-events: none;
}
.fv-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s3);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
/* Tone is a tinted full border plus a surface tint. No side stripes: those are
   an explicit anti-pattern in this product. */
/* Mixed toward `transparent`, NOT toward --line. Mixing two chromatic colours
   in oklch interpolates hue along the shorter arc, and --line sits at hue 256
   while --danger sits at 28, so `color-mix(in oklch, var(--danger) 45%,
   var(--line))` resolves to oklch(0.75 0.098 315) - a magenta border on a red
   toast. Measured, not theoretical. Mixing with transparent premultiplies and
   keeps the hue. */
.fv-toast--error {
  background: var(--danger-soft);
  border-color: color-mix(in oklch, var(--danger) 55%, transparent);
  color: var(--danger-ink);
}
.fv-toast--ok {
  background: var(--ok-soft);
  border-color: color-mix(in oklch, var(--ok) 55%, transparent);
  color: var(--ok-ink);
}
.fv-toast__msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fv-toast__close {
  flex: none;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: inherit;
  opacity: 0.7;
  font-size: 15px;
  line-height: 1;
}
.fv-toast__close:hover { opacity: 1; background: color-mix(in oklch, currentColor 12%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  .fv-toast { animation: 0.18s var(--ease) both fv-toast-in; }
  @keyframes fv-toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ---------- 3. App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  width: 100%;
}
/* Collapsed = an icon rail, not a hidden panel. The old behaviour was
   `display: none`, which took the only control that could bring the sidebar
   back down with it, a one-way door, which is why nothing in the app shipped
   a button for it. The rail keeps the group icons and the collapse control on
   screen, hovering it peeks the full nav as an overlay, and the control pins it
   open again.

   Desktop only. Under 901px the sidebar is already an off-canvas drawer driven
   by the topbar hamburger, and a rail there would just eat 48px of a phone. */
@media (min-width: 901px) {
  body.sidebar-collapsed .app-shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

  /* Peeked: wider than its own grid track, so it floats over the content
     instead of pushing it. Only the expand is delayed: a pointer crossing the
     rail on its way somewhere else should not open it, but leaving should
     close it at once.

     The peek is a body class set from foot.ejs, NOT :hover/:focus-within. With
     the CSS states, clicking collapse left the panel stuck open: the pointer
     was still inside it and the button still had focus, so the content track
     shrank and slid under a sidebar that never moved. JS can say "collapse
     now, and do not peek again until the pointer has actually left". */
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w);
    box-shadow: var(--shadow-pop);
    transition: width 0.15s var(--ease) 0.12s, box-shadow 0.15s var(--ease);
  }
  /* Rail: collapsed and not being peeked. The nav keeps its full 224px layout
     and the sidebar clips it. That is what holds every icon at the same x in
     both states, with no per-row restyling and no reflow when the peek opens. */
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar {
    width: var(--sidebar-w-collapsed);
    box-shadow: none;
    transition-delay: 0s;
  }
  body.sidebar-collapsed .sidebar-nav { min-width: var(--sidebar-w); }

  /* Sub-items carry no icon of their own, so in the rail they would clip to
     blank strips. Drop them; the group icon stands in until the peek opens. */
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-group-items { display: none; }

  /* Brand row: wordmark and portal tag out, collapse control centred. */
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-brand {
    justify-content: center;
    padding-inline: 0;
  }
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-brand-link,
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-portal-tag { display: none; }

  /* Footer stacks instead of clipping. Half a density button sliced by the
     rail edge reads as a rendering bug. */
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-tools {
    flex-direction: column;
    padding-inline: 0;
  }
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-user {
    justify-content: center;
    padding-inline: 0;
  }
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-user-meta,
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-user-caret { display: none; }
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-user-glyph { display: block; }

  /* Where-am-I in the rail: the group holding the active item wears the active
     tint, since the item itself is hidden. */
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-group:has(.sidebar-nav-item.active) > .sidebar-group-head {
    background: var(--brand-soft);
    color: var(--brand-ink);
  }
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-group:has(.sidebar-nav-item.active) > .sidebar-group-head .sidebar-group-icon { color: var(--brand-ink); }

  /* A count badge inside a collapsed group survives as a dot on the icon. The
     number is what the peek is for; the job of the badge is only to say there
     is work in here. */
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-group:has(.nav-count) > .sidebar-group-head::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 21px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand);
  }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
}

/* No divider under the brand — the sidebar is one uninterrupted column;
   structure comes from spacing, not boxes. */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s3);
  height: var(--topbar-h);
  flex-shrink: 0;
}
.sidebar-brand-link { display: inline-flex; align-items: center; line-height: 0; }
.sidebar-logo { height: 18px; width: auto; display: block; }
[data-theme="dark"] .sidebar-logo,
[data-theme="dark"] .auth-logo img,
[data-theme="dark"] .landing-logo { filter: brightness(0) invert(1); }
.sidebar-portal-tag { margin-left: auto; }

/* Collapse control. Quiet until the row is hovered: it is chrome for the
   chrome, and it should not compete with the logo for a first read. */
.sidebar-collapse {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-left: auto;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--mute-soft);
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.sidebar-portal-tag + .sidebar-collapse { margin-left: 0; }
.sidebar-brand:hover .sidebar-collapse { color: var(--mute); }
.sidebar-collapse:hover { background: var(--surface); color: var(--ink); }
.sidebar-collapse:focus-visible { outline: none; box-shadow: var(--ring); color: var(--ink); }
.sidebar-collapse svg { width: 15px; height: 15px; }
.sidebar-collapse-out { display: none; }
body.sidebar-collapsed .sidebar-collapse-in { display: none; }
body.sidebar-collapsed .sidebar-collapse-out { display: block; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--s1) var(--s2) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
/* The nav is a scroll container, so its direct children must never shrink.
   .sidebar-nav-item sets overflow:hidden, which zeroes a flex item's automatic
   min-size — without this the solo items (My Work / Dashboard / My earnings)
   get crushed and their text clipped once the nav overflows. Let it scroll. */
.sidebar-nav > * { flex-shrink: 0; }

.sidebar-group { display: flex; flex-direction: column; gap: 0; }
.sidebar-group-label,
.sidebar-section-label {
  padding: var(--s2) var(--s3) var(--s1);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Collapsible group head (uses <details>/<summary>) */
.sidebar-group-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0.4rem var(--s2);
  /* Anchors the rail's count dot (see the collapsed block in section 3). */
  position: relative;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.sidebar-group-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--mute);
  transition: color 0.12s var(--ease);
}
.sidebar-group-head:hover .sidebar-group-icon,
.sidebar-group[open] > .sidebar-group-head .sidebar-group-icon { color: var(--ink); }
.sidebar-group-head::-webkit-details-marker { display: none; }
.sidebar-group-head::marker { content: ''; }
.sidebar-group-head:hover { background: var(--surface); color: var(--ink); }
.sidebar-group-head:focus-visible { outline: none; box-shadow: var(--ring); }
.sidebar-group-label-text { flex: 1; min-width: 0; }
.sidebar-group-chevron {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: var(--mute-soft);
  opacity: 0;
  transition: transform 0.18s var(--ease), opacity 0.12s var(--ease);
}
.sidebar-group-head:hover .sidebar-group-chevron,
.sidebar-group:focus-within .sidebar-group-chevron,
.sidebar-group[open] > .sidebar-group-head .sidebar-group-chevron { opacity: 1; }
.sidebar-group[open] > .sidebar-group-head .sidebar-group-chevron { transform: rotate(90deg); }

/* Indent rail — sub-items nest under the group icon with a 1px guide so
   hierarchy is visible without per-item icons. The rail centers under the
   group icon (s2 head padding + half of 15px icon ≈ 15px). */
.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 2px 15px;
  padding-left: 7px;
  border-left: 1px solid var(--line-strong);
}

/* Smooth expand/collapse — progressive enhancement, no-op where
   ::details-content isn't supported. */
@supports (interpolate-size: allow-keywords) {
  .sidebar-group { interpolate-size: allow-keywords; }
  .sidebar-group::details-content {
    height: 0;
    overflow: clip;
    transition: height 0.18s var(--ease), content-visibility 0.18s allow-discrete;
  }
  .sidebar-group[open]::details-content { height: auto; }
}

/* Solo item (no group wrapper) — minor margin so it sits cleanly */
.sidebar-nav-item.solo { margin: 0; font-weight: 600; }


.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0.3rem var(--s2);
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--r-md);
  text-decoration: none;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
  position: relative;
  white-space: nowrap;
}
/* Flat items (My Work, Dashboard, My earnings) carry a glyph so they line up
   with the group heads they sit beside, and so they stay identifiable once the
   collapsed rail clips their label. */
.sidebar-item-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--mute);
  transition: color 0.12s var(--ease);
}
.sidebar-nav-item:hover .sidebar-item-icon { color: var(--ink); }
.sidebar-nav-item.active .sidebar-item-icon { color: var(--brand-ink); }
/* Ellipsis lives on the label span so the item itself can stay
   overflow-visible for the rail's active marker. first-of-type, not
   first-child: the flat items now lead with an <svg>. */
.sidebar-nav-item > span:first-of-type {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hover pops to the elevated surface color — reads as "lift", not "tint". */
.sidebar-nav-item:hover {
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.sidebar-nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
}
/* Active item inside a group also marks its rail segment. */
.sidebar-group-items .sidebar-nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.sidebar-nav-item .nav-count {
  margin-left: auto;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--mute);
  background: var(--surface-3);
  padding: 0 0.35rem;
  height: 15px;
  line-height: 15px;
  border-radius: 999px;
  font-variant-numeric: var(--num);
}
.sidebar-nav-item.active .nav-count { background: var(--surface); color: var(--brand-ink); }

/* Footer — single compact user card; account actions live in a popover
   so the three least-used links in the app stop occupying permanent space. */
.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: var(--s2);
  flex-shrink: 0;
}
/* Appearance toggles, relocated from the topbar. Their own row above the
   account card: at 224px there is not room to sit beside the name without
   ellipsing the email away. */
.sidebar-tools {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: 0 var(--s2) var(--s1);
}
.sidebar-tool {
  display: inline-grid;
  place-items: center;
  width: var(--ctrl-h);
  height: var(--ctrl-h);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--mute);
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.sidebar-tool:hover { background: var(--surface); color: var(--ink); }
.sidebar-tool:focus-visible { outline: none; box-shadow: var(--ring); }
.sidebar-tool svg { width: 16px; height: 16px; }
.sidebar-user-menu { position: relative; }
.sidebar-user-menu > .sidebar-user::-webkit-details-marker { display: none; }
.sidebar-user-menu > .sidebar-user::marker { content: ''; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0.4rem var(--s2);
  border-radius: var(--r-md);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.12s var(--ease);
}
.sidebar-user:hover,
.sidebar-user-menu[open] > .sidebar-user { background: var(--surface); }
.sidebar-user:focus-visible { outline: none; box-shadow: var(--ring); }
.sidebar-user-caret {
  width: 13px; height: 13px;
  flex-shrink: 0;
  color: var(--mute-soft);
  transition: color 0.12s var(--ease);
}
.sidebar-user:hover .sidebar-user-caret,
.sidebar-user-menu[open] .sidebar-user-caret { color: var(--ink-2); }
/* Stands in for the account card in the collapsed rail, where the name and
   email are clipped away. Hidden everywhere else: the expanded card is name +
   email + caret and stays that way. */
.sidebar-user-glyph {
  display: none;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--mute);
}
.sidebar-user-meta { min-width: 0; flex: 1; }
.sidebar-user-name { font-size: 0.76rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 0.68rem; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-user-pop {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(100% + 6px);
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  z-index: 30;
}
.sidebar-action {
  display: block;
  padding: 0.32rem var(--s2);
  background: none; border: none;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 0.74rem; font-weight: 500;
  color: var(--ink-2);
  text-align: left; text-decoration: none; cursor: pointer; width: 100%;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.sidebar-action:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.sidebar-signout { color: var(--danger-ink); }
.sidebar-signout:hover { background: var(--danger-soft); color: var(--danger-ink); }

/* (sidebar-collapsed = 48px icon rail, see the @media block in section 3) */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* When a sticky view/QA banner is shown (View-as, impersonate, "my work"),
   reserve its height above the topbar so the banner and the topbar stack
   instead of overlapping. --top-offset stays 0 (a no-op) on every normal
   page, so this cannot affect layout outside view-banner mode. */
body:has(> .view-banner) { --top-offset: var(--view-banner-h); }

/* ---------- 4. Top bar ---------- */

.topbar {
  position: sticky;
  top: var(--top-offset);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: var(--topbar-h);
  padding: 0 var(--s4);
  background: color-mix(in oklch, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-toggle {
  display: inline-grid; place-items: center;
  width: var(--ctrl-h); height: var(--ctrl-h);
  background: none; border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--mute);
}
.topbar-toggle:hover { background: var(--surface-2); color: var(--ink); }
.topbar-toggle svg { width: 18px; height: 18px; }

.topbar-search {
  flex: 1;
  max-width: 460px;
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search input {
  width: 100%;
  height: var(--ctrl-h);
  padding: 0 0.7rem 0 1.85rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-base);
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.topbar-search input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: var(--ring); }
.topbar-search input::placeholder { color: var(--mute-soft); }
.topbar-search svg {
  position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--mute);
  pointer-events: none;
}
/* Search plus the controls that act on what you are looking at (view switcher,
   primary create). The group carries the auto margins so the search field stays
   optically centred while its two companions ride along to its right. */
.topbar-center {
  display: flex;
  align-items: center;
  gap: var(--s2);
  /* Grows to claim the row and centres its contents, rather than sizing to
     content with auto margins. With `flex: 0 1 auto` the group sized to its
     own max-content and let the search collapse to 184px even with 370px of
     slack in the row, because the search is the only shrinkable child. */
  flex: 1 1 auto;
  min-width: 0;
  /* Flush left, not centred: the group reads as one working row that starts
     where the content does, rather than floating in the middle of the bar. */
  justify-content: flex-start;
}
/* The group owns the centring now, so the search drops its own auto margins
   but keeps its 520px basis and a floor so it degrades instead of vanishing. */
.topbar-center .topbar-search-wrap { margin: 0; min-width: 220px; }

.topbar-actions { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.topbar-icon-btn {
  display: inline-grid; place-items: center;
  width: var(--ctrl-h); height: var(--ctrl-h);
  background: none; border: 1px solid transparent; color: var(--mute);
  border-radius: var(--r-sm);
  text-decoration: none;
  position: relative;
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topbar-icon-btn svg { width: 16px; height: 16px; }
.topbar-icon-btn .dot {
  position: absolute; top: 6px; right: 7px;
  width: 6px; height: 6px;
  border-radius: 999px; background: var(--brand);
  border: 2px solid var(--surface);
}

/* Enrichment-backfill progress capsule — anchored right edge of the
   Contacts /admin/outreach Enrichment status bar.
   Layout: pulsing dot + two-line text (label + count) + percent badge.
   A hairline progress track sits at the bottom edge of the capsule
   and fills with `--p` (set inline) — reads 0.5% as a real sliver,
   unlike the prior background-fill which was invisible at low %.
   Polls via htmx every 60s. See lib/enrichmentBackfill.ts. */
.enrich-progress {
  --enrich-glow: color-mix(in oklch, var(--brand) 22%, transparent);

  position: relative;
  display: inline-flex; align-items: center; gap: 0.625rem;
  padding: 0.45rem 0.7rem 0.55rem 0.55rem; /* extra bottom padding for the track */
  background: var(--surface);
  border: 1px solid color-mix(in oklab, var(--brand) 24%, var(--line));
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  box-shadow:
    0 1px 0 color-mix(in oklch, var(--brand) 8%, transparent) inset,
    0 1px 2px rgba(0,0,0,0.04),
    0 4px 12px -8px var(--enrich-glow);
  transition: box-shadow 200ms ease, transform 200ms ease, border-color 200ms ease;
}
.enrich-progress:hover {
  border-color: color-mix(in oklab, var(--brand) 36%, var(--line));
  transform: translateY(-1px);
  text-decoration: none;
  box-shadow:
    0 1px 0 color-mix(in oklch, var(--brand) 10%, transparent) inset,
    0 2px 4px rgba(0,0,0,0.05),
    0 10px 24px -12px var(--enrich-glow);
}
.enrich-progress:focus-visible {
  outline: none;
  box-shadow: var(--ring),
    0 1px 0 color-mix(in oklch, var(--brand) 10%, transparent) inset,
    0 4px 12px -8px var(--enrich-glow);
}

/* Indicator dot — refined halo pulse (scale + expanding brand glow). */
.enrich-progress-dot {
  position: relative;
  display: inline-grid; place-items: center;
  width: 16px; height: 16px; flex: 0 0 auto;
  color: var(--brand-strong);
}
.enrich-progress-dot::before {
  content: "";
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--brand-strong);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--brand) 45%, transparent);
}
.enrich-progress.is-running .enrich-progress-dot::before {
  animation: enrichDotPulse 1.6s ease-in-out infinite;
}
.enrich-progress.is-done .enrich-progress-dot::before { display: none; }
.enrich-progress.is-done .enrich-progress-dot svg {
  width: 14px; height: 14px;
}

/* Text stack — small uppercase label + figures. */
.enrich-progress-meta {
  display: flex; flex-direction: column;
  line-height: 1.15;
  min-width: 0; flex: 0 0 auto;
}
.enrich-progress-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--mute);
  text-transform: uppercase;
}
.enrich-progress-figures {
  display: inline-flex; align-items: baseline; gap: 0.25rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  margin-top: 1px;
}
.enrich-progress-count {
  font-size: 0.9rem; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em;
}
.enrich-progress-of {
  font-size: 0.72rem; font-weight: 500; color: var(--mute);
}

/* Percent badge — divider on the left, brand-ink tinted. */
.enrich-progress-pct {
  margin-left: 0.5rem; padding-left: 0.625rem;
  border-left: 1px solid color-mix(in oklab, var(--brand) 18%, var(--line));
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 0.78rem; font-weight: 700;
  color: var(--brand-ink);
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}
.enrich-progress.is-done .enrich-progress-pct { color: var(--brand-strong); }

/* Bottom progress track — sits flush against the capsule's bottom edge.
   At low percentages the track-style fill is visibly honest in a way
   the previous background-gradient fill was not. */
.enrich-progress-track {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: color-mix(in oklch, var(--brand) 8%, transparent);
  overflow: hidden;
  pointer-events: none;
}
.enrich-progress-fill {
  display: block;
  position: absolute; inset: 0;
  width: var(--p, 0%);
  background: linear-gradient(
    90deg,
    color-mix(in oklch, var(--brand) 75%, transparent) 0%,
    var(--brand-strong) 100%
  );
  transition: width 800ms cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: 0 0 6px -1px var(--enrich-glow);
}
/* Subtle white shimmer slides across the filled portion while
   running — communicates "actively working" even at low percent. */
.enrich-progress.is-running .enrich-progress-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in oklch, white 55%, transparent) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: enrichTrackShimmer 1.8s linear infinite;
}

@keyframes enrichDotPulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0   color-mix(in oklch, var(--brand) 45%, transparent); }
  70%  { transform: scale(1.12); box-shadow: 0 0 0 7px color-mix(in oklch, var(--brand)  0%, transparent); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0   color-mix(in oklch, var(--brand)  0%, transparent); }
}
@keyframes enrichTrackShimmer {
  0%   { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .enrich-progress.is-running .enrich-progress-dot::before,
  .enrich-progress.is-running .enrich-progress-fill::after {
    animation: none;
  }
}
@media (max-width: 900px) {
  /* Drop on narrow screens — the stats bar wraps and the widget would
     end up on a row by itself. The full backfill page is still linked
     from the page-head actions. */
  .enrich-progress { display: none; }
}

/* Breadcrumb (under topbar) */
.crumb {
  display: flex; align-items: center; gap: var(--s2);
  padding: 0.35rem var(--s3);
  font-size: 0.7rem;
  color: var(--mute);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.crumb a { color: var(--mute); font-weight: 500; }
.crumb a:hover { color: var(--ink); text-decoration: none; }
.crumb .sep { color: var(--mute-soft); opacity: 0.6; }
.crumb .here { color: var(--ink); font-weight: 600; }

.breadcrumb { /* legacy */
  margin: 0 0 var(--s2);
  font-size: 0.78rem;
  color: var(--mute);
}
.breadcrumb a { color: var(--mute); font-weight: 500; }
.breadcrumb a:hover { color: var(--ink); text-decoration: none; }

/* ---------- 5. Main content ---------- */

.app-main {
  flex: 1;
  padding: var(--s3) var(--s3) var(--s6);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}
.app-main h1 { margin: 0 0 2px; font-size: 1.2rem; letter-spacing: -0.018em; font-weight: 700; }
.app-main h2 { font-size: 0.88rem; font-weight: 700; }
.app-main h3 { font-size: 0.8rem; font-weight: 700; }

.app-main > .page-head:first-child,
.app-main > h1:first-child { margin-top: 0; }

.app-footer {
  padding: var(--s4);
  text-align: center;
  color: var(--mute);
  font-size: 0.72rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* Page header (title row) */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s3);
  margin-bottom: var(--s3);
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.2rem; letter-spacing: -0.018em; }
.page-head h2 { margin: 0; }
.page-head .lede { color: var(--mute); margin-top: 2px; font-size: 0.78rem; }
.page-head-actions { display: inline-flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* ---------- 6. Cards / panels ---------- */

.panel {
  margin-top: var(--s3);
  padding: var(--panel-pad);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.panel + .panel { margin-top: var(--s2); }
.panel h2 { margin: 0 0 var(--s2); font-size: 0.82rem; font-weight: 700; color: var(--ink); letter-spacing: -0.005em; }
.panel h2 + .panel-sub { margin-top: calc(-1 * var(--s1)); margin-bottom: var(--s2); color: var(--mute); font-size: 0.74rem; }
.panel h3 { font-size: 0.78rem; margin: 0 0 var(--s2); font-weight: 700; }

.panel-flush { padding: 0; }
.panel-flush > .panel-head,
.panel-head {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
}
.panel-flush > .panel-body { padding: var(--panel-pad); }
.panel-flush > table.data-table { margin: 0; }
.panel-flush > table.data-table thead th { background: var(--surface-2); }

/* Full-bleed children (tab bars, toolbars, thead bands, meta rows) must
   follow the panel's rounded corners or their backgrounds poke square
   edges past the radius. overflow:hidden would be simpler but breaks
   position:sticky table headers, so round the children instead. Tables
   need it at cell level — a radius on <table> doesn't clip th/td
   backgrounds under border-collapse: separate. */
.panel-flush > :first-child:not(table) {
  border-top-left-radius: calc(var(--r-md) - 1px);
  border-top-right-radius: calc(var(--r-md) - 1px);
}
.panel-flush > :last-child:not(table) {
  border-bottom-left-radius: calc(var(--r-md) - 1px);
  border-bottom-right-radius: calc(var(--r-md) - 1px);
}
.panel-flush > table.data-table:first-child thead th:first-child { border-top-left-radius: calc(var(--r-md) - 1px); }
.panel-flush > table.data-table:first-child thead th:last-child { border-top-right-radius: calc(var(--r-md) - 1px); }
.panel-flush > table.data-table:last-child tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--r-md) - 1px); }
.panel-flush > table.data-table:last-child tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--r-md) - 1px); }

/* Two-column grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
}
@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.grid-2 .panel, .grid-3 .panel { margin-top: 0; }

/* Key-value list */
.kv {
  display: grid;
  /* minmax(0, 1fr): a long unbroken value (a landing URL) wraps inside its column
     instead of stretching the grid and the whole page sideways. */
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--s1) var(--s4);
  margin: 0;
  font-size: 0.8rem;
}
.kv dt { color: var(--mute); font-weight: 500; }
.kv dd { min-width: 0; margin: 0; color: var(--ink); font-weight: 500; font-variant-numeric: var(--num); overflow-wrap: anywhere; }

/* ---------- 7. Buttons ---------- */

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 var(--ctrl-px);
  min-height: var(--ctrl-h);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease), box-shadow 0.12s var(--ease), transform 0.06s var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
/* Physical press — 1px of travel makes every control feel engineered,
   not painted. */
.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled),
.btn-ghost:active:not(:disabled),
.btn-danger:active:not(:disabled) {
  transform: translateY(1px);
}
.btn-primary:disabled, .btn-primary[aria-disabled="true"],
.btn-secondary:disabled, .btn-secondary[aria-disabled="true"],
.btn-ghost:disabled, .btn-ghost[aria-disabled="true"],
.btn-danger:disabled, .btn-danger[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary carries a faint brand shadow + top highlight so it reads as the
   one raised control on the page; everything else stays flat. */
.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 1px 2px color-mix(in oklch, var(--brand) 30%, transparent),
              inset 0 1px 0 oklch(100% 0 0 / 0.12);
}
.btn-primary:hover { background: var(--brand-strong); text-decoration: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--line-strong); text-decoration: none; }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }

.btn-danger { background: var(--danger); color: var(--on-danger); }
/* was a hardcoded oklch(46% 0.20 28), which did not track the theme and got
   lighter-on-lighter in dark mode. --danger-ink is the tone's own dark step. */
.btn-danger:hover { background: var(--danger-ink); text-decoration: none; }

/* Quiet danger: rides on .btn-secondary (keeps the shared base, focus ring,
   press travel) and recolors it. For destructive ENTRY points that sit on a
   card all day, e.g. "Decline lead"; the solid .btn-danger stays for the
   final confirm step, where loud is correct. */
.btn-secondary.btn-danger-quiet {
  color: var(--danger-ink);
  border-color: color-mix(in oklab, var(--danger) 35%, var(--line-strong));
}
.btn-secondary.btn-danger-quiet:hover { background: var(--danger-soft); }

.btn-sm { padding: 0 var(--ctrl-px-sm); min-height: var(--ctrl-h-sm); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-xs { padding: 0 0.45rem; min-height: var(--ctrl-h-xs); font-size: var(--fs-xs); border-radius: var(--r-sm); font-weight: 600; }
.btn-block { width: 100%; }

/* Icon-only button — square, same radius as text buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ctrl-h);
  height: var(--ctrl-h);
  padding: 0;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease), transform 0.06s var(--ease);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon:active:not(:disabled) { transform: translateY(1px); }
.btn-icon:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-icon.btn-sm { width: var(--ctrl-h-sm); height: var(--ctrl-h-sm); }

.link-btn {
  background: none; border: none; padding: 0;
  color: var(--brand); cursor: pointer; font: inherit; font-weight: 600; font-size: var(--fs-base);
  border-radius: var(--r-sm);
}
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.link-btn.danger { color: var(--danger-ink); }
.link-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 8. Forms ---------- */

input, select, textarea {
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--mute-soft); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--mute);
  cursor: not-allowed;
}

.stacked-form,
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  max-width: 560px;
}
.stacked-form label,
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: none;
  letter-spacing: 0;
}
.stacked-form input,
.stacked-form select,
.stacked-form textarea,
.auth-form input {
  padding: 0 var(--ctrl-px);
  min-height: var(--ctrl-h);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.stacked-form textarea { padding: 0.4rem var(--ctrl-px); }
.stacked-form textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.stacked-form input:hover:not(:focus),
.stacked-form select:hover:not(:focus),
.stacked-form textarea:hover:not(:focus),
.auth-form input:hover:not(:focus) {
  border-color: color-mix(in oklab, var(--brand) 30%, var(--line-strong));
}
.stacked-form input:focus,
.stacked-form select:focus,
.stacked-form textarea:focus,
.auth-form input:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.auth-form button[type="submit"] {
  margin-top: var(--s2);
  padding: 0 1rem;
  min-height: 34px;
  background: var(--brand); color: var(--on-brand);
  border: none; border-radius: var(--r-sm);
  font-size: 0.86rem; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: background 0.12s var(--ease);
}
.auth-form button[type="submit"]:hover { background: var(--brand-strong); }
.auth-form button[type="submit"]:focus-visible { outline: none; box-shadow: var(--ring); }

.form-actions {
  display: flex;
  gap: var(--s3);
  align-items: center;
  margin-top: var(--s2);
}
.stacked-form .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Checkbox grid in a fieldset (partner required fields, multi-toggle pickers) */
.check-grid-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s4);
  margin: 0;
}
.check-grid-fieldset legend {
  padding: 0 var(--s2);
  font-size: 0.74rem; font-weight: 700; color: var(--mute);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.check-grid-fieldset .hint { margin-bottom: var(--s3); }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--s2);
}
/* scoped to beat .stacked-form label (column) specificity */
.check-grid .check-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s2);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.84rem; font-weight: 500; color: var(--ink-2);
  text-transform: none; letter-spacing: 0;
  transition: border-color 0.12s, background 0.12s;
}
.check-grid .check-inline:hover { border-color: var(--line-strong); }
.check-grid .check-inline:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.check-grid .check-inline:has(input:checked) {
  border-color: color-mix(in oklab, var(--brand) 35%, var(--line));
  background: color-mix(in oklab, var(--brand-soft) 40%, var(--surface));
  color: var(--ink);
}
.check-inline input[type="checkbox"] {
  margin: 0; flex: 0 0 auto;
  width: 15px; height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* Form field primitives (small, composable) */
.field-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.field-hint {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--mute);
  margin-top: 4px;
  line-height: 1.4;
}
.field-error {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--danger-ink);
  margin-top: 4px;
  line-height: 1.4;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar input[type="search"],
.filter-bar select {
  padding: 0 var(--ctrl-px-sm);
  min-height: var(--ctrl-h-sm);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.filter-bar input[type="search"]:hover:not(:focus),
.filter-bar select:hover:not(:focus) {
  border-color: color-mix(in oklab, var(--brand) 30%, var(--line-strong));
}
.filter-bar input[type="search"] { flex: 1; min-width: 220px; }
.filter-bar .btn-primary { min-height: var(--ctrl-h-sm); padding: 0 0.7rem; font-size: var(--fs-sm); }

/* Filter chip (saved view) */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}
.filter-chip:hover { background: var(--brand-soft); color: var(--brand-ink); border-color: color-mix(in oklab, var(--brand) 25%, var(--line)); text-decoration: none; }
.saved-filters-pinned {
  display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center;
  padding: var(--s3) var(--s4);
}
.save-filter-form {
  display: inline-flex; align-items: center; gap: var(--s2);
  margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--line);
}
.save-filter-form input[type="text"] {
  padding: 0.4rem 0.6rem; font-size: 0.82rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
}
.saved-filter-rows { list-style: none; padding: 0; margin: var(--s3) 0 0; display: flex; flex-direction: column; gap: var(--s2); }
.saved-filter-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: var(--s3); align-items: center;
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 0.82rem;
}
.saved-filter-name { font-weight: 600; color: var(--ink); }

/* ---------- 9. Status + tag pills ---------- */

.status-pill, .tag {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.12rem 0.45rem;
  min-height: 16px;
  border-radius: var(--r-sm);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: middle;
  font-variant-numeric: var(--num);
  line-height: 1.3;
  text-transform: uppercase;
}
.status-pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.75;
  flex-shrink: 0;
}

/* Status palette — semantic, OKLCH */
.status-pill.status-new,
.status-pill.status-contacted          { background: var(--info-soft);   color: var(--info-ink); }
.status-pill.status-follow_up,
.status-pill.status-requested_statements,
.status-pill.status-requesting_docs,
.status-pill.status-docs_requested     { background: var(--warn-soft);   color: var(--warn-ink); }
.status-pill.status-qualified,
.status-pill.status-ready_to_submit,
.status-pill.status-docs_in            { background: var(--teal-soft);   color: var(--teal-ink); }
.status-pill.status-application_sent,
.status-pill.status-submitted,
.status-pill.status-docs_out,
.status-pill.status-underwriting       { background: var(--violet-soft); color: var(--violet-ink); }
.status-pill.status-offers,
.status-pill.status-funded             { background: var(--ok-soft);     color: var(--ok-ink); }
.status-pill.status-merchant_declined,
.status-pill.status-soft_decline,
.status-pill.status-hard_decline,
.status-pill.status-lost,
.status-pill.status-no_interest,
.status-pill.status-missing_information,
.status-pill.status-deferred           { background: var(--danger-soft); color: var(--danger-ink); }

/* Partner-portal application stages (card #469). A separate, coarser palette
   than the status one above because a partner never sees a raw status: they see
   the five buckets in lib/partnerApplicationView.ts. */
.status-pill.stage-review        { background: var(--info-soft);   color: var(--info-ink); }
.status-pill.stage-underwriting  { background: var(--violet-soft); color: var(--violet-ink); }
.status-pill.stage-approved      { background: var(--teal-soft);   color: var(--teal-ink); }
.status-pill.stage-funded        { background: var(--ok-soft);     color: var(--ok-ink); }
.status-pill.stage-closed        { background: var(--surface-3);   color: var(--ink-2); }

h1 .status-pill, h2 .status-pill { margin-left: var(--s2); font-size: 0.62rem; vertical-align: middle; }

.tag-admin   { background: var(--brand-soft);  color: var(--brand-ink); }
.tag-lender  { background: var(--teal-soft);   color: var(--teal-ink); }
.tag-client  { background: var(--violet-soft); color: var(--violet-ink); }
.tag-internal { background: var(--warn-soft);  color: var(--warn-ink); }
.tag-partner { background: var(--ok-soft);     color: var(--ok-ink); }

.flag-warn { background: var(--warn-soft); color: var(--warn-ink); padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
/* Triage's read of an UNROUTED lender mail. An approval is the one a person
   must act on, so it gets the positive tone and reads first in the row. */
.flag-approval { background: var(--ok-soft); color: var(--ok-ink); padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.flag-note { background: var(--surface-3); color: var(--mute); padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.status-pill.outcome-approval { background: var(--ok-soft); color: var(--ok-ink); }
.status-pill.outcome-decline { background: var(--warn-soft); color: var(--warn-ink); }
.status-pill.outcome-stips,
.status-pill.outcome-other { background: var(--surface-3); color: var(--mute); }
.flag-ok   { background: var(--ok-soft);   color: var(--ok-ink);   padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.flag-muted { background: var(--surface-3); color: var(--mute); padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }

/* ---------- Inbound-email triage page ----------
   The rail of /admin/inbound-emails/:id: the AI's read of which deal the
   mail is about, the ranked guesses, and the Find the deal box. Token-only
   (every token is redefined under [data-theme="dark"], so no dark block),
   oklab mixes only, no side stripes, no literal colours. */

/* A stacked form that fills its panel instead of stopping at 560px. */
.stacked-form--wide { max-width: none; }

/* One-line copy inside a rail panel, above a form or a hint. */
.triage-copy { margin: 0 0 var(--s2); font-size: 0.82rem; color: var(--ink-2); line-height: 1.45; }

/* A panel that carries a warning tone: the router's suggested link. */
.panel--warn {
  border-color: color-mix(in oklab, var(--warn) 35%, var(--line));
  background: var(--warn-soft);
}

/* The AI panel. data-state drives the tone: a finished read with a deal
   gets the brand tint so the eye lands on the one button that matters. */
.triage-ai { display: flex; flex-direction: column; gap: var(--s2); }
.triage-ai[data-state="done"] {
  border-color: color-mix(in oklab, var(--brand) 28%, var(--line));
  background: color-mix(in oklab, var(--brand-soft) 45%, var(--surface));
}
.triage-ai[data-state="failed"] { border-color: color-mix(in oklab, var(--danger) 30%, var(--line)); }
.triage-ai__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.triage-ai__head .rail-card-title { margin: 0; }
.triage-ai__pulse {
  flex: none; width: 8px; height: 8px; border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--brand) 45%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .triage-ai__pulse { animation: triage-ai-pulse 1.4s var(--ease) infinite; }
  @keyframes triage-ai-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--brand) 45%, transparent); }
    70%  { box-shadow: 0 0 0 7px color-mix(in oklab, var(--brand) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--brand) 0%, transparent); }
  }
}
.triage-ai__empty { margin: 0; font-size: 0.84rem; color: var(--ink-2); line-height: 1.45; }
.triage-ai__match { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.triage-ai__company { font-size: 0.98rem; letter-spacing: -0.01em; color: var(--ink); overflow-wrap: anywhere; }
.triage-ai__meta { margin: 0; font-size: 0.78rem; color: var(--mute); font-variant-numeric: var(--num); }
.triage-ai__reason { margin: 0; font-size: 0.8rem; color: var(--ink-2); line-height: 1.5; }
.triage-ai__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s1); }
.triage-ai__form { display: inline-flex; align-items: center; gap: var(--s2); margin: 0; }
.triage-ai__form--lender { display: flex; flex-direction: column; align-items: stretch; width: 100%; }
.triage-ai__lender { display: flex; flex-direction: column; gap: 4px; font-size: 0.74rem; font-weight: 600; color: var(--ink-2); }
.triage-ai__lender select {
  min-height: var(--ctrl-h); padding: 0 var(--ctrl-px);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--fs-base); font-family: inherit; color: var(--ink); background: var(--surface);
}
.triage-ai__ask { margin: 0; }
.triage-ai__hint { margin: 0; }
/* The masthead's one-click button sits in the quick-actions decide row. */
.qa-decide .triage-ai__form { margin: 0; }
/* The Actions card is stretched to the masthead's height by .record-header.
   Its rows stay together at the top; the slack goes below them, never
   between the buttons and the decide row. */
.record-header > .qa-card { justify-content: flex-start; }
.record-header > .qa-card > .rail-card-title,
.record-header > .qa-card > .qa-grid,
.record-header > .qa-card > .qa-decide { flex: 0 0 auto; }
.record-header > .qa-card > .qa-decide { margin-top: var(--s3); flex-wrap: wrap; }

/* Ranked guesses: a short list of deals with a reason each, not a decision
   the system has made. */
.cand-list { list-style: none; margin: 0 0 var(--s2); padding: 0; display: grid; gap: var(--s2); }
.cand { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2) var(--s3); background: var(--surface); }
.cand__head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.cand__name { color: var(--ink); overflow-wrap: anywhere; }
.cand__id { font-size: 0.74rem; color: var(--mute); }
.cand__meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: 3px; }
.cand__lender { font-size: 0.78rem; color: var(--mute); }
.cand__why { margin: var(--s2) 0; color: var(--ink-2); font-size: 0.8rem; line-height: 1.45; }
.cand__actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }

/* Find the deal. The box is an ordinary form field; the results drop in
   under it as a list of buttons, the chip names what was picked. */
.deal-picker { position: relative; }
.deal-picker__results {
  list-style: none; margin: calc(-1 * var(--s2)) 0 0; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  max-height: 20rem; overflow-y: auto; background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.deal-picker__results li + li { border-top: 1px solid var(--line); }
.deal-picker__row {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: var(--s2) var(--s3); background: none; border: 0; cursor: pointer;
  font: inherit; color: var(--ink); line-height: 1.35;
}
.deal-picker__row:hover, .deal-picker__row:focus-visible { background: var(--surface-2); outline: none; }
.deal-picker__row:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--brand) 45%, transparent); }
.deal-picker__row strong { font-size: 0.84rem; }
.deal-picker__meta { color: var(--mute); font-size: 0.74rem; font-variant-numeric: var(--num); }
.deal-picker__lenders { color: var(--ink-2); font-size: 0.74rem; }
.deal-picker__sender { color: var(--ok-ink); font-weight: 700; }
.deal-picker__empty { padding: var(--s2) var(--s3); color: var(--mute); font-size: 0.8rem; }
.deal-picker__chosen {
  display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  border: 1px solid color-mix(in oklab, var(--ok) 35%, var(--line)); border-radius: var(--r-sm);
  background: var(--ok-soft); color: var(--ok-ink); font-size: 0.82rem;
}
.deal-picker__chosen-meta { color: var(--ok-ink); font-size: 0.74rem; opacity: 0.85; font-variant-numeric: var(--num); }
.deal-picker__chosen .link-btn { margin-left: auto; font-size: 0.74rem; }

/* "Also record the offer": folded under the link form so a decline or a
   question never scrolls past nine offer fields. Opens itself on an approval. */
.triage-fold { margin-top: var(--s3); border-top: 1px dashed var(--line); padding-top: var(--s2); }
.triage-fold__summary {
  cursor: pointer; list-style: none; user-select: none;
  font: 600 0.78rem/1.3 var(--font-sans); color: var(--ink-2);
  padding: var(--s1) 0;
}
.triage-fold__summary::-webkit-details-marker { display: none; }
.triage-fold__summary::before {
  content: "\25B8"; display: inline-block; margin-right: 6px; color: var(--mute);
}
@media (prefers-reduced-motion: no-preference) {
  .triage-fold__summary::before { transition: transform 160ms var(--ease); }
}
.triage-fold[open] .triage-fold__summary::before { transform: rotate(90deg); }
.triage-fold__body { margin-top: var(--s2); }
/* One field per line: the rail is 360px wide, and two columns of money
   boxes in it read as a spreadsheet. */
.triage-fold__body .grid-2 { grid-template-columns: 1fr; gap: var(--s2); }
.triage-fold__hint { margin: 0; }

/* The email itself: the lender's HTML in its sandboxed frame, the plain
   text under a disclosure, the files as chips. */
.mail-preview { display: flex; flex-direction: column; gap: var(--s2); }
.mail-preview__frame {
  display: block; width: 100%; height: 480px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.mail-preview__text {
  margin: 0; padding: var(--s3);
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-3); color: var(--ink);
  border-radius: var(--r-sm);
  max-height: 480px; overflow: auto;
  font-size: 0.82rem; line-height: 1.5; font-family: var(--font-sans);
}
.mail-preview .raw-toggle { margin-top: 0; }
.mail-preview__files { margin-top: 0; }
.cmail-file__icon svg { display: block; }

/* ---------- 10. Data table ---------- */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
  font-variant-numeric: var(--num);
}
.data-table thead th {
  text-align: left;
  padding: 0.45rem var(--cell-px);
  color: var(--mute);
  font-size: var(--fs-xxs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: calc(var(--top-offset) + var(--topbar-h)); z-index: 1;
  white-space: nowrap;
}
.data-table tbody td {
  padding: var(--cell-py) var(--cell-px);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  line-height: 1.35;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.08s var(--ease); }
/* Subtle hover — a 4% brand tint feels enterprise, not "checkbox row" */
.data-table tbody tr:hover {
  background: color-mix(in oklab, var(--brand) 4%, var(--surface));
}
.data-table .row-disabled { opacity: 0.55; }
.data-table .center { text-align: center; padding: var(--s10); color: var(--mute); }
.data-table .actions { text-align: right; white-space: nowrap; }
/* First column gets a touch more left padding — matches the panel
   internal rhythm so columns don't crowd the card edge. */
.data-table thead th:first-child,
.data-table tbody td:first-child { padding-left: var(--s3); }
.data-table thead th:last-child,
.data-table tbody td:last-child { padding-right: var(--s3); }
.data-table code { background: transparent; color: var(--mute); padding: 0; font-size: var(--fs-xs); }
.data-table a { color: var(--ink); font-weight: 600; }
.data-table a:hover { color: var(--brand); text-decoration: none; }
.data-table .sub { display: block; color: var(--mute); font-weight: 400; font-size: var(--fs-xs); margin-top: 1px; }

/* Numeric cells — tabular figures so columns align */
.data-table .num,
.data-table td.num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Optional striped variant */
.data-table--striped tbody tr:nth-child(even) { background: color-mix(in oklab, var(--surface-2) 50%, var(--surface)); }
.data-table--striped tbody tr:nth-child(even):hover { background: var(--surface-2); }

body.density-cozy .data-table tbody td { padding: 0.7rem var(--cell-px); }
body.density-compact .data-table tbody td { padding: 0.3rem var(--cell-px); font-size: var(--fs-xs); }

/* IDs/external refs in data-table cells should read as code, not prose.
   Templates that already add the class get the mono treatment automatically. */
.data-table .ext-id, .data-table code.id { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  font-size: var(--fs-sm);
  color: var(--mute);
  border-top: 1px solid var(--line);
}
.pagination a, .pagination .btn-secondary { padding: 0 var(--ctrl-px-sm); min-height: var(--ctrl-h-sm); font-size: var(--fs-sm); }

/* ---------- 11. Stats / dashboard ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s4);
  margin-top: 0;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
  position: relative;
}
a.stat-card:hover {
  border-color: color-mix(in oklab, var(--brand) 35%, var(--line));
  background: var(--surface-2);
  text-decoration: none;
}
.stat-card .stat-label {
  font-size: var(--fs-xxs);
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.stat-card .stat-value {
  font-size: 1.25rem;
  line-height: 1.1;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.025em;
  font-variant-numeric: var(--num);
}
.stat-card .stat-meta { font-size: var(--fs-xs); color: var(--mute); }

.stat-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s2); }
.stat-list li { display: flex; flex-direction: column; gap: 1px; padding: 0.5rem 0.7rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.stat-label { font-size: var(--fs-xxs); color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--ink); font-variant-numeric: var(--num); letter-spacing: -0.01em; }

.big-stat { font-size: 1.8rem; font-weight: 800; color: var(--brand); margin: 0; letter-spacing: -0.03em; font-variant-numeric: var(--num); }

/* Funnel — solid muted bars, no gradients */
.funnel { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s1); }
.funnel-stage {
  position: relative;
  padding: 0.35rem 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  min-height: 30px;
}
.funnel-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: color-mix(in oklch, var(--brand) 14%, transparent);
  transition: width 0.5s var(--ease);
}
.funnel-stage.funnel-funded .funnel-bar { background: color-mix(in oklch, var(--ok) 18%, transparent); }
.funnel-stage.funnel-underwriting .funnel-bar { background: color-mix(in oklch, var(--warn) 18%, transparent); }
.funnel-stage.funnel-lost .funnel-bar { background: color-mix(in oklch, var(--danger) 14%, transparent); }
.funnel-label {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 600;
}
.funnel-name { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); font-weight: 700; }
.funnel-numbers { color: var(--mute); font-size: 0.8rem; font-weight: 600; font-variant-numeric: var(--num); }

/* ---------- 12. Auth shell (login / forgot / change pwd) ---------- */

.auth-shell {
  flex: 1;
  display: grid;
  place-items: center;
  padding: var(--s8);
  background:
    radial-gradient(circle at 20% 0%, color-mix(in oklch, var(--brand) 7%, transparent), transparent 40%),
    radial-gradient(circle at 100% 100%, color-mix(in oklch, var(--brand) 5%, transparent), transparent 40%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s8);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-2);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: 0 0 var(--s5);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}
.auth-logo img { height: 24px; width: auto; display: block; }
.auth-sub { font-size: 0.86rem; font-weight: 500; color: var(--mute); margin: 0 0 var(--s4); text-transform: none; letter-spacing: 0; }
.portal-links { margin-top: var(--s5); font-size: 0.82rem; color: var(--mute); text-align: center; }
.portal-links a { font-weight: 600; }

/* ---------- 13. Landing (public portal picker) ---------- */

.landing { flex: 1; display: grid; place-items: center; padding: var(--s8); background: var(--bg); }
.landing-inner { max-width: 880px; width: 100%; text-align: center; }
.landing-logo { display: block; height: 36px; width: auto; margin: 0 auto var(--s3); }
.landing-sub { color: var(--mute); margin: 0 0 var(--s8); font-size: 1rem; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); }
.portal-card {
  display: block;
  padding: var(--s8) var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.portal-card:hover {
  text-decoration: none;
  background: var(--surface-2);
  border-color: color-mix(in oklab, var(--brand) 35%, var(--line));
}
.portal-card h2 { margin: 0 0 var(--s2); color: var(--ink); font-size: 1.1rem; font-weight: 700; }
.portal-card p { margin: 0; color: var(--mute); font-size: 0.86rem; }

/* ---------- 14. Notifications (notice / success / error) ---------- */

.notice, .success, .error {
  padding: 0.45rem 0.75rem;
  border-radius: var(--r);
  margin-bottom: var(--s3);
  font-size: var(--fs-sm);
  border: 1px solid;
  line-height: 1.4;
}
/* Leading glyph per tone — masked so it renders in the tone's ink color. */
.notice::before, .success::before, .error::before {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  background: currentColor;
  -webkit-mask: var(--notice-icon) center / contain no-repeat;
  mask: var(--notice-icon) center / contain no-repeat;
}
.notice  { background: var(--info-soft);   border-color: color-mix(in oklch, var(--info) 25%, transparent);   color: var(--info-ink);
  --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.success { background: var(--ok-soft);     border-color: color-mix(in oklch, var(--ok) 25%, transparent);     color: var(--ok-ink);
  --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.error   { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 25%, transparent); color: var(--danger-ink);
  --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E"); }

/* @fundivi-end */

/* @fundivi-begin 2079-2223 (16 Timeline, 17 Messages, 18 Documents/uploads, 19 Sensitive PII revealed) */
/* ---------- 16. Timeline (no border-stripes) ---------- */

.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.timeline-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px dashed var(--line);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item::before {
  content: "";
  width: 8px; height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--mute-soft);
}
.timeline-item.timeline-lead-created::before    { background: var(--brand); }
.timeline-item.timeline-status-changed::before  { background: var(--ok); }
.timeline-item.timeline-user-assigned::before   { background: var(--violet); }
.timeline-item.timeline-lender-routed::before   { background: var(--warn); }
.timeline-item.timeline-note::before            { background: var(--mute); }
.timeline-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  font-size: 0.82rem;
}
.timeline-meta strong { font-weight: 700; color: var(--ink); font-size: 0.78rem; }
.timeline-meta .muted { font-size: var(--fs-xs); flex-shrink: 0; }
.timeline-body {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--ink-2);
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ---------- 17. Messages ---------- */

.message-thread { list-style: none; padding: 0; margin: 0 0 var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.message-bubble {
  padding: 0.55rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  max-width: 90%;
}
.message-bubble.bubble-admin    { background: var(--brand-soft);   border-color: color-mix(in oklab, var(--brand) 18%, var(--line)); }
.message-bubble.bubble-lender   { background: var(--teal-soft);    border-color: color-mix(in oklab, var(--teal) 18%, var(--line)); }
.message-bubble.bubble-client   { background: var(--violet-soft);  border-color: color-mix(in oklab, var(--violet) 18%, var(--line)); align-self: flex-end; }
.message-bubble.bubble-partner  { background: var(--ok-soft);      border-color: color-mix(in oklab, var(--ok) 18%, var(--line)); }
.message-bubble.bubble-internal { background: var(--warn-soft);    border-color: color-mix(in oklab, var(--warn) 18%, var(--line)); }
/* Portal conversation (_portal-activity with selfPortal): chat-style me-vs-them.
   The viewer's own messages sit right; everyone else's sit left with a neutral
   fill, so a desk reply is not mistaken for the merchant's own client-audience message. */
.portal-activity__list .message-bubble.is-mine { align-self: flex-end; }
.portal-activity__list .message-bubble.is-them { align-self: flex-start; background: var(--surface-2); border-color: var(--line); }
.portal-activity__list .message-bubble.is-reply { max-width: 82%; }
.message-meta {
  display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center;
  font-size: 0.76rem; color: var(--mute); margin-bottom: var(--s2);
}
.message-meta strong { color: var(--ink); font-weight: 700; font-size: 0.82rem; }
.message-body { font-size: 0.82rem; color: var(--ink); white-space: pre-wrap; line-height: 1.5; }

.message-form {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.message-form textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit; font-size: 0.9rem;
  background: var(--surface); color: var(--ink);
  resize: vertical; min-height: 80px; line-height: 1.5;
}
.message-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.message-form-actions { display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap; }
.audience-toggle { display: flex; align-items: center; gap: var(--s2); font-size: 0.84rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.audience-toggle input { margin: 0; }
.message-form-actions .btn-primary { margin-left: auto; }

/* ---------- 18. Documents / uploads ---------- */

.upload-form {
  display: flex; gap: var(--s3); align-items: flex-end; flex-wrap: wrap;
  padding: var(--s4);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
}
.upload-field { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: var(--s2); }
.upload-field > span { font-size: 0.74rem; color: var(--mute); font-weight: 600; }
.upload-field input[type="file"] { padding: 0.3rem 0; font-size: 0.84rem; font-family: inherit; color: var(--ink-2); }

.section-head-action { margin-left: auto; }

/* Doc preview lightbox */
/* Above the side drawers (My Work 9100, quick compose 9200, Brain 9300) so the dimmed
   page is not interactive behind the viewer; below the confirm modals. */
.doc-preview { position: fixed; inset: 0; z-index: 9400; }
.doc-preview-backdrop { position: absolute; inset: 0; background: oklch(0% 0 0 / 0.65); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.doc-preview-dialog {
  position: absolute; inset: var(--s8);
  background: var(--surface);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.doc-preview-head {
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 0.86rem; color: var(--ink); flex-shrink: 0;
}
.doc-preview-head .link-btn { font-size: 1.1rem; font-weight: 700; color: var(--mute); }
.doc-preview-body {
  flex: 1;
  display: flex;
  /* `safe center` falls back to start when the content overflows, so the
     top of a zoomed canvas stays scrollable instead of being clipped
     above the viewport. */
  align-items: safe center;
  justify-content: safe center;
  background: var(--surface-3);
  overflow: auto;
}
.doc-preview-img { max-width: 100%; max-height: 100%; display: block; }
.doc-preview-iframe { width: 100%; height: 100%; border: 0; }

/* ---------- 19. Sensitive PII: revealed value ----------
   The vault panel itself is styled in section 34 (it is a .doc-panel). */

.revealed { display: inline-flex; align-items: center; gap: var(--s2); }
.revealed .muted { font-size: var(--fs-xs); }
.revealed.muted strong { color: var(--ink-2); background: var(--surface-2); }

/* @fundivi-end */

/* @fundivi-begin 2342-2359 (23 Audit / details) */
/* ---------- 23. Audit / details ---------- */

.audit-meta {
  margin: var(--s2) 0 0;
  padding: var(--s2) var(--s3);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 0.74rem;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  max-width: 480px;
  max-height: 200px;
  overflow: auto;
}
details > summary { cursor: pointer; font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
details > summary:hover { color: var(--ink); }

/* @fundivi-end */

/* @fundivi-begin 2367-2725 (25 Empty state, 26 Responsive, 26b List primitives) */
/* ---------- 25. Empty state ---------- */

.empty {
  padding: var(--s10) var(--s5);
  text-align: center;
  color: var(--mute);
}
/* Soft inbox glyph above the title so an empty screen reads as a designed
   state, not a rendering gap. */
.empty::before {
  content: "";
  display: block;
  width: 34px; height: 34px;
  margin: 0 auto var(--s3);
  background: var(--mute-soft);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.empty h3 { font-size: 1rem; color: var(--ink); margin-bottom: var(--s2); font-weight: 700; }
.empty p { font-size: 0.86rem; max-width: 440px; margin: 0 auto var(--s4); }

/* ---------- 26. Responsive ---------- */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
    box-shadow: var(--shadow-pop);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after {
    content: "";
    position: fixed; inset: 0;
    background: oklch(0% 0 0 / 0.4);
    z-index: 15;
  }
  .topbar-toggle { display: inline-grid; }
  /* The drawer is either open or shut here; there is no rail to collapse to. */
  .sidebar-collapse { display: none; }
  .app-main { padding: var(--s5) var(--s4); }
  .topbar { padding: 0 var(--s4); }
}
@media (min-width: 901px) {
  .topbar-toggle.is-mobile-only { display: none; }
}

/* ---------- 26b. List primitives (Phase 2) ---------- */

.list-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  margin: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-decoration: none;
  font-variant-numeric: var(--num);
}
.filter-chip:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
  text-decoration: none;
}
.filter-chip.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-color: color-mix(in oklab, var(--brand) 35%, var(--line));
}
.filter-chip .muted { color: inherit; opacity: 0.65; font-weight: 600; }

/* Sub-tab row (Leads → Abandoned). Inset and quieter than the tab row above
   it, so it reads as narrowing that tab rather than competing with it. */
.list-tabs--sub {
  padding-left: var(--s5);
  background: var(--surface-2);
}
.list-tabs--sub .filter-chip { font-size: 0.72rem; }

/* Applications list: the tab strip is two deliberate bands instead of one
   strip that wraps wherever the viewport happens to cut it. Pipeline stages
   on top; terminal outcomes and the derived views (Refi, All) underneath on
   the inset surface, so they read as secondary. */
.list-tabs--pipeline { padding: var(--s2) var(--s4); }
.list-tabs--views {
  padding: var(--s2) var(--s4);
  background: var(--surface-2);
}
.list-tabs--views .filter-chip { font-size: 0.72rem; padding-block: 0.15rem; }
.list-tabs__sep { width: 1px; height: 14px; background: var(--line-strong); margin: 0 var(--s1); flex: 0 0 auto; }

/* Chip counts: a quiet tabular number after the label, no separator glyph. */
.filter-chip__count {
  margin-left: 0.15rem;
  font-variant-numeric: var(--num);
  font-weight: 600;
  opacity: 0.55;
}
.filter-chip.active .filter-chip__count { opacity: 0.85; }

/* Applications toolbar: count + pager left, Filters + density right. The
   Filters dropdown anchors here now (it used to hang off the tab row). */
.list-toolbar--apps { justify-content: space-between; padding: var(--s2) var(--s4); }
.list-toolbar__count { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--mute); font-variant-numeric: var(--num); }
.list-toolbar__actions { display: flex; align-items: center; gap: var(--s2); }
.apps-filter-form { margin: 0; display: flex; }
.list-toolbar .lead-filter__dropdown { position: relative; }

/* Applications Filters panel: search band on top, a two-column control
   grid (three columns clipped the date inputs), footer with Reset + Apply. */
.apps-filter-form .lead-filter__dropdown-panel { width: min(600px, 92vw); }
.apps-filter-form .lead-filter__dropdown-panel > .lead-filter__row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3) var(--s4);
  padding: var(--s3) var(--s4) var(--s4);
}
.lead-filter__search-row {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.lead-filter__search { position: relative; }
.lead-filter__search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--mute); pointer-events: none;
}
.lead-filter__search input[type="search"] {
  width: 100%; min-width: 0; height: 36px;
  padding: 0 0.75rem 0 2.1rem;
  border: 1px solid transparent; border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink);
  font: 500 0.85rem/1 var(--font-sans);
  transition: box-shadow 140ms var(--ease);
}
.lead-filter__search input[type="search"]::placeholder { color: var(--mute-soft); }
.lead-filter__search input[type="search"]:hover { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--brand) 42%, var(--line-strong)); }
.lead-filter__search input[type="search"]:focus,
.lead-filter__search input[type="search"]:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--brand), 0 0 0 3px color-mix(in oklab, var(--brand) 16%, transparent);
}
.lead-filter__search input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.apps-filter-form .lead-filter__range-sep { font-size: 0.7rem; color: var(--mute-soft); padding: 0 1px; }
.apps-filter-form .lead-filter__select input[type="date"] { padding: 0 0.5rem; }
.apps-filter-form .lead-filter__dropdown-actions { padding: var(--s3) var(--s4); }

/* Pager-only band under a long table: no count text, that lives in the toolbar. */
.list-meta--pager-only { justify-content: flex-end; }

/* Sortable column headers: inherit the header type, show the direction
   glyph small, and hint on hover that the header is a control. */
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 0.2rem; }
.th-sort:hover { color: var(--ink); text-decoration: none; }
.th-sort__dir { font-size: 0.65em; opacity: 0.75; }

/* Applications KPI strip: four action tiles. */
.list-kpi-strip.list-kpi-strip--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .list-kpi-strip.list-kpi-strip--4 { grid-template-columns: repeat(2, 1fr); } }

/* Applications table cells. */
.apps-table .row-primary { font-weight: 600; color: var(--ink); text-decoration: none; }
.apps-table .row-primary:hover { color: var(--brand-ink); text-decoration: underline; }
.apps-table .row-id { font-family: var(--font-mono); font-size: 0.68rem; color: var(--mute); }
.apps-table .col-business { min-width: 210px; }
.apps-table .col-business .sub { white-space: nowrap; }
.stage-age { font-variant-numeric: var(--num); font-weight: 600; color: var(--ink-2); }
.stage-age--warn { color: var(--warn-ink); }
.stage-age--late { color: var(--danger-ink); }
.lender-counts { display: inline-flex; align-items: center; gap: 0.3rem; }
.lender-chip {
  display: inline-flex; align-items: center; gap: 2px;
  height: 18px; padding: 0 0.4rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; font-variant-numeric: var(--num);
}
.lender-chip--ok { background: var(--ok-soft); color: var(--ok-ink); }
.lender-chip--no { background: var(--danger-soft); color: var(--danger-ink); }

/* The peek eye shows on the hovered or focused row only; the hover card and
   the row click already cover the resting state. */
.apps-table .peek-trigger { opacity: 0; transition: opacity 120ms var(--ease); }
.apps-table tr:hover .peek-trigger,
.apps-table tr:focus-within .peek-trigger,
.apps-table tr.is-peek-active .peek-trigger,
.apps-table .peek-trigger:focus-visible { opacity: 1; }

/* Main tab items (Leads / Converted to Application) */
.list-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.list-tab:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.list-tab.active {
  background: var(--brand);
  color: var(--on-brand);
}
.list-tab.active .tab-badge {
  background: color-mix(in oklch, var(--on-brand) 25%, transparent);
  color: var(--on-brand);
}

/* Count badge inside tabs */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  padding: 0 0.3rem;
  height: 1.15rem;
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 999px;
  font-size: var(--fs-xxs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Status sub-tab bar inside a panel */
.status-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  overflow-x: auto;
}
.status-tab-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}
.status-tab-link:hover { color: var(--ink); text-decoration: none; border-bottom-color: var(--line-strong); }
.status-tab-link.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
.status-tab-link.active .tab-badge {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

/* Toolbar inside a flush panel: filter bar + actions */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: var(--surface);
}
.list-toolbar .filter-bar { flex: 1; min-width: 0; gap: var(--s2); }
.list-toolbar .filter-bar input[type="search"] { min-width: 200px; }

/* Leads list: multi-select filter row */
.lead-filter-bar { row-gap: var(--s2); }
.lead-filter-bar select { min-width: 9.5rem; flex: 0 0 auto; }
.list-toolbar .lead-filter-bar input[type="search"] { flex: 1 1 200px; min-width: 180px; }

.list-meta {
  padding: var(--s2) var(--s3);
  font-size: var(--fs-xs); color: var(--mute);
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-variant-numeric: var(--num);
}

.actions-row { display: inline-flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.actions-row .sep { color: var(--mute-soft); }

.nowrap { white-space: nowrap; }

/* Empty-state cell inside a table */
.data-table tbody tr.empty-row td {
  padding: var(--s10) var(--s5);
  text-align: center;
  color: var(--mute);
}
.data-table tbody tr.empty-row strong { color: var(--ink); display: block; margin-bottom: var(--s2); font-size: 0.95rem; }
.data-table tbody tr.empty-row p { font-size: 0.84rem; max-width: 460px; margin: 0 auto; }

/* Aggregate / metric bar (funded deals totals row) */
.metric-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s4);
}
.metric { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.metric-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mute); font-weight: 700; }
.metric-value { font-size: 1.15rem; font-weight: 700; color: var(--ink); font-variant-numeric: var(--num); letter-spacing: -0.01em; }

/* Misc tags used across list views */
.tag-active   { background: var(--ok-soft);    color: var(--ok-ink); }
.tag-inactive { background: var(--surface-3);  color: var(--ink-2); }
.tag-danger   { background: var(--danger-soft); color: var(--danger-ink); }
.tag-whale    { background: var(--violet-soft); color: var(--violet-ink); }
.tag-auto     { background: var(--info-soft);   color: var(--info-ink); }
.tag-manual   { background: var(--surface-3);   color: var(--ink-2); }

/* Inline toggle form — one-tap status flip from list rows. The button
   wears the same .tag pill styling, plus subtle affordances so it's
   obvious it's clickable. */
.inline-toggle-form { display: inline; margin: 0; padding: 0; }
.tag-toggle {
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  transition: filter 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.tag-toggle:hover  { filter: brightness(0.96); border-color: var(--line-strong); }
.tag-toggle:active { filter: brightness(0.92); }
.tag-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-soft, rgba(0, 100, 255, 0.25));
}

/* @fundivi-end */

/* @fundivi-begin 8562-8603 (Page-level tabs) */
/* ---------- Page-level tabs (used on configuration pages like /admin/automation) ---------- */

.page-tabs {
  display: flex;
  gap: 0;
  background: var(--surface-2);
  border-bottom: 2px solid var(--line-strong);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  margin: 0 0 var(--s4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.page-tab {
  appearance: none;
  background: none;
  border: none;
  padding: 0.45rem var(--s3);
  color: var(--mute);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
  display: inline-flex; align-items: center; gap: var(--s2);
}
.page-tab:hover { color: var(--ink); text-decoration: none; }
.page-tab.is-active { color: var(--ink); border-bottom-color: var(--brand); }
.page-tab__count {
  font-size: 0.72rem; font-weight: 600;
  background: var(--surface-2);
  color: var(--mute);
  padding: 0 0.4rem;
  height: 18px; line-height: 18px;
  border-radius: 999px;
  font-variant-numeric: var(--num);
}
.page-tab.is-active .page-tab__count { background: var(--brand-soft); color: var(--brand-ink); }

.page-body { display: flex; flex-direction: column; gap: var(--s3); }
/* @fundivi-end */

/* @fundivi-begin 5325-5716 (Customer portal - product shell) */
/* ============================================================
 * Customer portal — product shell
 *
 * Distinct from the admin chrome. Customer = SMB owner checking
 * on their application. No sidebar. Single column. Generous
 * whitespace. Status is the hero. Reuses OKLCH tokens.
 * ============================================================ */

.product-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.product-topbar {
  display: flex;
  align-items: center;
  gap: var(--s5);
  padding: var(--s4) var(--s6);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.product-brand { display: inline-flex; align-items: center; line-height: 0; flex-shrink: 0; }
.product-brand img { height: 22px; width: auto; display: block; }
[data-theme="dark"] .product-brand img { filter: brightness(0) invert(1); }

.product-nav {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: 1;
  margin-left: var(--s5);
  overflow: hidden;
}
.product-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.product-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.product-nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

/* When the tabs would overflow into a horizontal scroll, collapse them into
   a dropdown menu instead (toggled by .nav-collapsed via a small script). */
.product-nav-menu { position: relative; display: none; flex: 1; margin-left: var(--s5); }
.nav-collapsed .product-nav { display: none; }
.nav-collapsed .product-nav-menu { display: block; }
.product-nav-menu-btn {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
.product-nav-menu-btn:hover { background: var(--surface-2); }
.product-nav-menu-btn svg { opacity: 0.55; }
.product-nav-menu-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  min-width: 210px;
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md, 10px);
  box-shadow: var(--shadow-pop);
}
.product-nav-menu-list[hidden] { display: none; }
.product-nav-menu-list a {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 0.9rem; font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.product-nav-menu-list a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.product-nav-menu-list a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

.product-topbar-actions { display: inline-flex; align-items: center; gap: var(--s3); flex-shrink: 0; }
.product-user {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink); font-size: 0.78rem; font-weight: 600;
  text-decoration: none;
}
.product-user:hover { background: var(--surface-2); text-decoration: none; }
.product-user svg { width: 14px; height: 14px; color: var(--mute); flex-shrink: 0; }

.product-signout {
  background: none; border: 1px solid transparent;
  color: var(--mute); font-size: 0.82rem; font-weight: 500;
  padding: 0.4rem 0.7rem; border-radius: var(--r-sm);
  cursor: pointer; font-family: inherit;
}
.product-signout:hover { color: var(--danger-ink); background: var(--danger-soft); }

.product-main {
  flex: 1;
  padding: var(--s12) var(--s6) var(--s16);
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s12);
}

.product-page-head { display: flex; flex-direction: column; gap: var(--s2); }
.product-page-head h1 { font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem); line-height: 1.1; letter-spacing: -0.025em; font-weight: 800; margin: 0; }
.product-page-head .lede { font-size: 1.05rem; color: var(--mute); margin: 0; max-width: 65ch; line-height: 1.55; }

/* Status hero block */
.product-hero {
  padding: var(--s10) var(--s8);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  position: relative;
  overflow: hidden;
}
.product-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--brand);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.product-hero-eyebrow {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mute);
  margin: 0;
}
.product-hero-amount {
  font-size: clamp(2.5rem, 1.8rem + 3vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: var(--num);
  line-height: 1;
  margin: 0;
}
.product-hero-status {
  font-size: 1.1rem;
  color: var(--ink-2);
  margin: 0;
  font-weight: 500;
}
.product-hero-status .status-pill {
  font-size: 0.78rem; padding: 0.25rem 0.7rem;
}
.product-hero-meta {
  font-size: 0.86rem;
  color: var(--mute);
  margin: var(--s2) 0 0;
}
.product-hero-meta a { font-weight: 600; }

/* Big call-to-action banner (you have offers!) */
.product-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
  padding: var(--s5) var(--s6);
  background: var(--brand-soft);
  border: 1px solid color-mix(in oklab, var(--brand) 30%, var(--line));
  border-radius: var(--r-lg);
  flex-wrap: wrap;
}
.product-cta-text { font-size: 1rem; font-weight: 600; color: var(--brand-ink); }
.product-cta .btn-primary { padding: 0.6rem 1.1rem; font-size: 0.92rem; }

/* Editorial section: not a boxy card, just a thin top divider + label */
.product-section {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding-top: var(--s8);
  border-top: 1px solid var(--line);
}
.product-section:first-of-type { border-top: 0; padding-top: 0; }

.product-section-head { display: flex; flex-direction: column; gap: var(--s2); }
.product-section-head h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
.product-section-head .lede { font-size: 0.95rem; color: var(--mute); margin: 0; max-width: 65ch; }
.product-section-head .label {
  font-size: 0.7rem; font-weight: 700; color: var(--brand-ink);
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* Inline meta grid (replaces stat-grid for product context) */
.product-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s5) var(--s6);
}
.product-meta-item { display: flex; flex-direction: column; gap: var(--s1); }
.product-meta-label { font-size: 0.74rem; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; }
.product-meta-value { font-size: 1.15rem; font-weight: 700; color: var(--ink); font-variant-numeric: var(--num); letter-spacing: -0.005em; }

/* Offer card (premium feel — bigger, more breathing room than admin) */
.product-offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--s4);
}
.product-offer-card {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  position: relative;
}
.product-offer-card.urgent {
  border-color: color-mix(in oklab, var(--warn) 40%, var(--line));
  background: color-mix(in oklab, var(--warn-soft) 50%, var(--surface));
}
.product-offer-card-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; color: var(--mute); font-weight: 600;
}
.product-offer-card-head .countdown { color: var(--warn-ink); font-variant-numeric: var(--num); }
.product-offer-amount {
  font-size: 2rem; font-weight: 800;
  letter-spacing: -0.025em;
  font-variant-numeric: var(--num);
  color: var(--ink);
  margin: 0;
}
.product-offer-grid-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--s3) var(--s4);
}
.product-offer-grid-inline > div { display: flex; flex-direction: column; gap: 2px; }
.product-offer-grid-inline .label { font-size: 0.7rem; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.product-offer-grid-inline span:not(.label) { font-size: 0.95rem; font-weight: 700; color: var(--ink); font-variant-numeric: var(--num); }
.product-offer-notes { font-size: 0.86rem; color: var(--ink-2); line-height: 1.55; padding: var(--s3); background: var(--surface-2); border-radius: var(--r); }
.product-offer-card .btn-primary { width: 100%; padding: 0.75rem; font-size: 0.95rem; }
.product-offer-actions { display: flex; flex-direction: column; gap: var(--s2); }
.product-offer-actions form { margin: 0; }
.product-offer-actions .btn-secondary { width: 100%; padding: 0.6rem; font-size: 0.9rem; }

/* Document requests / upload */
.product-doc-requests {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s5);
  background: var(--warn-soft);
  border: 1px solid color-mix(in oklab, var(--warn) 30%, var(--line));
  border-radius: var(--r-lg);
}
.product-doc-requests h3 { font-size: 1.05rem; font-weight: 700; color: var(--warn-ink); margin: 0 0 var(--s2); }
.product-doc-requests ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.product-doc-requests li { font-size: 0.92rem; color: var(--ink); display: flex; gap: var(--s2); align-items: baseline; }
.product-doc-requests li::before { content: "•"; color: var(--warn-ink); font-weight: 700; }
.product-doc-requests .hint { color: var(--warn-ink); margin-top: var(--s3); font-size: 0.82rem; }

.product-upload {
  display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.product-upload .upload-field { flex: 1; min-width: 240px; }

/* Plain document list — no table chrome */
.product-doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.product-doc-list li {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.product-doc-list li:last-child { border-bottom: none; }
.product-doc-list .doc-name { flex: 1; min-width: 0; }
.product-doc-list .doc-name a { color: var(--ink); font-weight: 600; }
.product-doc-list .doc-meta { font-size: 0.78rem; color: var(--mute); font-variant-numeric: var(--num); flex-shrink: 0; white-space: nowrap; }

/* Message thread reused but slightly tweaked for product context */
.product-section .message-thread { gap: var(--s3); }

/* Timeline reused but no border-bottom dashed dividers in the product context */
.product-section .timeline { gap: var(--s4); }
.product-section .timeline-item { border-bottom: 0; padding: 0; }

/* Business card (My businesses page) */
.product-business-card {
  padding: var(--s6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.product-business-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.product-business-card-head h3 { font-size: 1.15rem; font-weight: 700; margin: 0; color: var(--ink); }
.product-business-card-head .meta { font-size: 0.78rem; color: var(--mute); margin-top: var(--s1); }

/* Comm-prefs checkbox group (richer for product feel) */
.product-pref {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
}
.product-pref input { margin-top: 0.2rem; flex-shrink: 0; }
.product-pref:hover { border-color: var(--line-strong); }
.product-pref:has(input:checked) { border-color: color-mix(in oklab, var(--brand) 35%, var(--line)); background: color-mix(in oklab, var(--brand-soft) 40%, var(--surface)); }
.product-pref-text { display: flex; flex-direction: column; gap: 2px; }
.product-pref-text strong { font-size: 0.95rem; color: var(--ink); font-weight: 700; }
.product-pref-text span { font-size: 0.82rem; color: var(--mute); }

/* Referral share block (code + link rows) */
.referral-share { display: flex; flex-direction: column; gap: var(--s3); max-width: 680px; }
.referral-share__row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.referral-share__tag {
  flex-shrink: 0; width: 48px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--mute);
}
.referral-share__code {
  font-size: 1.3rem; letter-spacing: 3px; font-weight: 700;
  padding: 0.3rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
}
.referral-share__link {
  flex: 1; min-width: 240px;
  padding: 0 var(--ctrl-px); min-height: var(--ctrl-h);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: 0.9rem; font-family: var(--font-mono, inherit); color: var(--ink-2);
  background: var(--surface);
}
.referral-share__link:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.referral-share .btn-primary,
.referral-share .btn-secondary { flex-shrink: 0; }

@media (max-width: 700px) {
  .product-topbar { padding: var(--s3) var(--s4); gap: var(--s3); }
  .product-nav { margin-left: var(--s2); gap: 0; }
  .product-nav a { padding: 0.35rem 0.5rem; font-size: 0.82rem; }
  .product-main { padding: var(--s6) var(--s4) var(--s10); gap: var(--s8); }
  .product-hero { padding: var(--s6) var(--s5); }
  .product-user span { display: none; }
}

/* @fundivi-end */

/* @fundivi-begin 5783-5791 (27 Reduced motion) */
/* ---------- 27. Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* @fundivi-end */

/* @fundivi-begin 17187-17660 (32 Chrome: ink sidebar and a quiet top bar) */
/* ---------- 32. Chrome: ink sidebar and a quiet top bar ----------
   The frame was the same pale tinted column every SaaS ships: small uppercase
   group labels, then a white bar of bordered controls beside it. This section
   gives it a point of view without adding anything to it.

   - The sidebar is Fundivi navy in BOTH themes (the brand hue, deep), so the
     work surface reads as one bright field against a dark frame and the frame
     reads as the brand.
   - It re-scopes the ink, line, surface and brand tokens its own rules already
     use, instead of rewriting those rules. Every sidebar rule that says
     var(--ink-2) now resolves to light-on-navy with no per-rule edit, and a
     future sidebar rule written against the normal tokens does the right thing.
   - Colour stays for meaning. The active item is a brand-tinted glass fill with
     the marker, counts are translucent chips, nothing is a pastel fill.
   - The top bar drops its borders: a soft search field, one grouped tool
     cluster, controls at 32px. The alert button keeps its violet: that is a
     decision about meaning, not decoration. */

.sidebar {
  --sidebar-bg: oklch(21% 0.05 var(--brand-h));
  --ink: oklch(97% 0.008 var(--brand-h));
  --ink-2: oklch(89% 0.014 var(--brand-h));
  --mute: oklch(76% 0.03 var(--brand-h));
  --mute-soft: oklch(70% 0.03 var(--brand-h));
  --line: oklch(100% 0 0 / 0.08);
  --line-strong: oklch(100% 0 0 / 0.16);
  --surface: oklch(100% 0 0 / 0.07);
  --surface-2: oklch(100% 0 0 / 0.1);
  --surface-3: oklch(100% 0 0 / 0.13);
  --brand: oklch(76% 0.15 var(--brand-h));
  --brand-soft: oklch(70% 0.15 var(--brand-h) / 0.22);
  --brand-ink: oklch(96% 0.025 var(--brand-h));
  --ring: 0 0 0 2px var(--sidebar-bg), 0 0 0 4px var(--brand);
  /* A faint brand glow behind the wordmark, then the navy. One gradient on the
     background itself, so there is no pseudo-element to stack against the nav. */
  background:
    radial-gradient(ellipse 130% 110px at 0 0, oklch(52% 0.17 var(--brand-h) / 0.34), transparent 72%),
    var(--sidebar-bg);
  border-right: 0;
}
[data-theme="dark"] .sidebar {
  --sidebar-bg: oklch(12% 0.03 var(--brand-h));
  border-right: 1px solid oklch(100% 0 0 / 0.06);
}

.sidebar-logo { height: 19px; filter: brightness(0) invert(1); }
/* The portal tag is a quiet outlined chip on the ink, not the light tag fill. */
.sidebar .sidebar-portal-tag {
  background: oklch(100% 0 0 / 0.07);
  color: oklch(88% 0.04 var(--brand-h));
  border: 1px solid oklch(100% 0 0 / 0.13);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* Group heads read as headings in sentence case, not a row of small caps: the
   hierarchy is brighter and heavier, not louder. */
.sidebar-group-head {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.sidebar-group-head:hover { background: var(--surface-2); }
/* Not the active row: hovering "you are here" must not wipe its tint. */
.sidebar-nav-item:not(.active):hover { background: var(--surface-2); }
.sidebar-nav-item.active .sidebar-item-icon,
.sidebar-group[open] > .sidebar-group-head:has(~ .sidebar-group-items .active) .sidebar-group-icon { color: var(--brand); }

.sidebar-user { background: oklch(100% 0 0 / 0.05); }
.sidebar-user:hover,
.sidebar-user-menu[open] > .sidebar-user { background: var(--surface-2); }

/* The account popover opens over the ink but is a normal light surface in light
   theme and a lifted navy in dark. It sits inside .sidebar, so it inherits the
   re-scoped tokens above and has to put its own back. */
.sidebar-user-pop {
  --surface: oklch(99% 0.004 var(--brand-h));
  --surface-2: oklch(95% 0.01 var(--brand-h));
  --surface-3: oklch(93% 0.012 var(--brand-h));
  --line: oklch(90% 0.014 var(--brand-h));
  --line-strong: oklch(84% 0.018 var(--brand-h));
  --ink: oklch(22% 0.03 var(--brand-h));
  --ink-2: oklch(32% 0.025 var(--brand-h));
  --mute: oklch(46% 0.02 var(--brand-h));
  --mute-soft: oklch(52% 0.018 var(--brand-h));
}
[data-theme="dark"] .sidebar-user-pop {
  --surface: oklch(24% 0.03 var(--brand-h));
  --surface-2: oklch(29% 0.032 var(--brand-h));
  --surface-3: oklch(33% 0.034 var(--brand-h));
  --line: oklch(34% 0.03 var(--brand-h));
  --line-strong: oklch(40% 0.03 var(--brand-h));
  --ink: oklch(96% 0.01 var(--brand-h));
  --ink-2: oklch(88% 0.014 var(--brand-h));
  --mute: oklch(74% 0.02 var(--brand-h));
  --mute-soft: oklch(68% 0.02 var(--brand-h));
}

/* The rail. Labels used to be CLIPPED by the 48px edge, not hidden, which left
   the first letter of every row sitting next to its icon ("M", "D", "P"...).
   Fade them out instead; the peek fades them back in. The icons do not move: the
   nav still keeps its full-width layout underneath. */
.sidebar-group-label-text,
.sidebar-nav-item > span { transition: opacity 0.12s var(--ease); }
/* Keeps the 0.18s rotate the base rule gives it: a new transition declaration
   replaces the old one, it does not add to it. */
.sidebar-group-chevron { transition: transform 0.18s var(--ease), opacity 0.12s var(--ease); }
@media (min-width: 901px) {
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-group-label-text,
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-nav-item > span,
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-group-chevron { opacity: 0; }
}

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
}
@media (min-width: 32.0625rem) {
  /* Roomier than the base padding, but only where the row has the width: the
     phone row barely fits (see the 32rem block above) and must keep its own. */
  .topbar { padding: 0 var(--s5); }

  /* One soft field with no border until you are in it. */
  .topbar-search input {
    height: 32px;
    padding: 0 3.9rem 0 2.2rem;
    border-color: transparent;
    border-radius: 10px;
    background: var(--surface-3);
    font-size: 0.8125rem;
  }
  .topbar-search input:hover { background: var(--line); }
  .topbar-search input:focus { border-color: var(--brand); background: var(--surface); }
  /* --mute-soft is 4.43:1 on --surface-3, under AA; --mute clears it. */
  .topbar-search input::placeholder { color: var(--mute); }
  .topbar-search svg { left: 0.75rem; width: 15px; height: 15px; }
  .topbar-search__shortcut {
    right: 0.45rem;
    padding: 2px 6px;
    border-radius: 6px;
    border-color: var(--line-strong);
    background: var(--surface);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  /* Controls share one height with the search so the row sits on a line. */
  .topbar .btn-primary.btn-sm {
    min-height: 32px;
    padding: 0 0.85rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 700;
  }
  .topbar .vs__trigger { height: 32px; border-radius: 10px; }
  .topbar .vs[data-tone="neutral"] .vs__trigger {
    border-color: transparent;
    background: transparent;
    font-weight: 600;
  }
  .topbar .vs[data-tone="neutral"] .vs__trigger:hover { background: var(--surface-3); }
  .topbar-alerts { height: 32px; padding: 0 0.85rem; border-radius: 10px; }
}

/* Voice agent, Text agent and Ask are one cluster: related tools in one soft
   capsule, so the right edge is two things (the cluster, then My Work) instead of
   four loose bordered boxes. */
.topbar-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--surface-3);
}
.topbar-tools .topbar-agent,
.topbar-tools .topbar-brain {
  height: 28px;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
}
.topbar-tools .topbar-agent:hover,
.topbar-tools .topbar-brain:hover { background: var(--surface); box-shadow: var(--shadow-1); }
.topbar-tools .topbar-agent:focus-visible,
.topbar-tools .topbar-brain:focus-visible { box-shadow: var(--ring); }
@media (min-width: 901px) {
  .topbar-tools .topbar-brain { padding: 0 var(--s3) 0 var(--s2); }
}

/* Card 1046: automated outreach on hold (views/admin/_outreach-holds-banner.ejs) */
.outreach-holds { border-left: 4px solid var(--warn); background: var(--warn-soft); color: var(--warn-ink); margin-bottom: var(--s3); }
.outreach-holds--ok { border-left-color: var(--ok, var(--warn)); }
.outreach-holds--error { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger-ink); }
.outreach-holds__text, .outreach-holds__title { margin: 0; }
.outreach-holds__list { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: var(--s2); }
.outreach-holds__item { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: space-between; }
.outreach-holds__reason { font-size: 0.9em; }
.outreach-holds__form { display: flex; gap: var(--s2); align-items: center; margin: 0; }
.outreach-holds__reason-input { min-width: 16rem; }
.outreach-holds__note { font-size: 0.9em; }
.outreach-holds__what { min-width: 0; }

/* Card 919: Other Communication compose section (Communication > Emails). */
.ocomm { border-top: 1px solid var(--border, #e5e7eb); margin-top: 8px; padding-bottom: 8px; }
.ocomm .cmail-list-head { display: flex; align-items: center; justify-content: space-between; }
.ocomm__open { font: inherit; font-size: 0.75rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border, #d1d5db); background: var(--surface-3, #f3f4f6); cursor: pointer; }
.ocomm__form { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px; }
.ocomm__form[hidden] { display: none; }
.ocomm__label { display: flex; flex-direction: column; gap: 3px; font-size: 0.75rem; color: var(--mute, #6b7280); }
.ocomm__vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.72rem; }
.ocomm__vars-title { color: var(--mute, #6b7280); }
.ocomm__var { font: inherit; font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border, #d1d5db); background: transparent; cursor: pointer; }
.ocomm__bar { display: flex; align-items: center; gap: 8px; }
.ocomm__status { font-size: 0.75rem; color: var(--mute, #6b7280); }

.ocomm__input { font: inherit; font-size: 0.85rem; padding: 6px 8px; border: 1px solid var(--border, #d1d5db); border-radius: 6px; background: var(--surface, #fff); color: inherit; }

/* AI Reachout teaser (partials/sidebar.ejs). Deliberately louder than the
   nav rows under it: it announces voice + text outreach before they launch. */
.sidebar-ai-reach {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  margin: 0 0 var(--s3);
  padding: 0.7rem var(--s3);
  border: 1px solid color-mix(in oklch, var(--brand) 45%, transparent);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, color-mix(in oklch, var(--brand) 22%, var(--surface)), color-mix(in oklch, var(--brand) 6%, var(--surface)));
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  position: relative;
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--brand) 40%, transparent);
  animation: sidebar-ai-pulse 2.8s ease-out infinite;
  transition: transform 0.12s var(--ease), border-color 0.12s var(--ease);
}
.sidebar-ai-reach:hover { transform: translateY(-1px); border-color: var(--brand); }
.sidebar-ai-reach:focus-visible { outline: none; box-shadow: var(--ring); }
.sidebar-ai-reach__icons { display: flex; flex-direction: column; gap: 3px; color: var(--brand-ink); flex-shrink: 0; }
.sidebar-ai-reach__icons svg { width: 17px; height: 17px; display: block; }
.sidebar-ai-reach__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-ai-reach__title { font-size: 0.95rem; font-weight: 700; line-height: 1.2; }
.sidebar-ai-reach__sub { font-size: 0.7rem; color: var(--mute); line-height: 1.3; }
.sidebar-ai-reach__badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
@keyframes sidebar-ai-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklch, var(--brand) 38%, transparent); }
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .sidebar-ai-reach { animation: none; } }
@media (min-width: 901px) {
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-ai-reach { justify-content: center; padding: 0.6rem 0; }
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-ai-reach__text,
  body.sidebar-collapsed:not(.sidebar-peek) .sidebar .sidebar-ai-reach__badge { display: none; }
}

/* Ask Sharie page (views/admin/assistant.ejs) */
.sa-wrap { max-width: 860px; margin: 0 auto; padding: var(--s4) 0 var(--s6); }
.sa-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.sa-avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, color-mix(in oklch, var(--brand) 85%, #fff), var(--brand)); color: #fff; }
.sa-avatar svg { width: 22px; height: 22px; }
.sa-title { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.sa-lede { margin: 2px 0 0; color: var(--mute); font-size: 0.88rem; }
.sa-chat { background: var(--surface); border: 1px solid var(--line, var(--surface-3)); border-radius: 16px;
  box-shadow: var(--shadow-1); display: flex; flex-direction: column; overflow: hidden; }
.sa-log { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); min-height: 340px; max-height: 58vh; overflow-y: auto; }
.sa-empty { margin: auto; text-align: center; padding: var(--s4) 0; }
.sa-empty__title { margin: 0 0 var(--s3); font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.sa-chips { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; }
.sa-chip { font: inherit; font-size: 0.82rem; padding: 0.45rem 0.85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--surface-3); background: var(--surface-2); color: var(--ink-2);
  transition: border-color 0.12s var(--ease), background 0.12s var(--ease); }
.sa-chip:hover { border-color: var(--brand); background: color-mix(in oklch, var(--brand) 8%, var(--surface)); color: var(--ink); }
.sa-msg { max-width: 85%; padding: 0.55rem 0.85rem; border-radius: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; font-size: 0.9rem; }
.sa-msg--user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.sa-msg--bot { align-self: flex-start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 4px; }
.sa-msg--typing { color: var(--mute); }
.sa-proposals { display: flex; flex-direction: column; gap: var(--s2); padding: 0 var(--s4); }
.sa-proposals:not(:empty) { padding-bottom: var(--s3); }
.sa-proposal { padding: 0.7rem 0.9rem; border: 1px solid var(--surface-3); border-radius: 12px; background: var(--surface-2); }
.sa-proposal .sa-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.sa-composer { display: flex; align-items: center; gap: var(--s2); margin: 0; padding: var(--s3) var(--s4); border-top: 1px solid var(--surface-3); background: var(--surface); }
.sa-composer input { flex: 1; height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--surface-3);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 0.92rem; }
.sa-composer input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); background: var(--surface); }
.sa-send { width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--brand); color: #fff; flex-shrink: 0; transition: opacity 0.12s var(--ease), transform 0.12s var(--ease); }
.sa-send:hover { transform: translateY(-1px); }
.sa-send:disabled { opacity: 0.5; cursor: default; transform: none; }
.sa-prefs { margin-top: var(--s4); padding: var(--s3) var(--s4); border: 1px solid var(--surface-3); border-radius: 12px; background: var(--surface); }
.sa-prefs > summary { cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); }

/* Filter rows that lay themselves out inline (ai-activity/cost.ejs and friends). */
.filters select,
.filters input[type="text"] { min-width: 9rem; }
@media (max-width: 600px) {
  .filters { flex-direction: column; align-items: stretch; }
}

/* Card 1074: AI Reachout pages (overview, inbox, text agent, turns, voice agent, voice session).
   One left-aligned settings form, one filter toolbar, one lane of hand-off cards and one table
   rhythm, shared by all seven views under src/views/admin/ai-reachout/. Prefixed ro- so nothing
   here leaks into the rest of the portal. The Reachouts card on the lead page keeps its own rule. */
.reachouts-card table { width: 100%; }

/* Page rhythm: one --s4 step between the blocks a page stacks. */
.ro-page > .panel,
.ro-page > .grid-2,
.ro-page > .ro-toolbar { margin-top: var(--s4); }
.ro-page .panel > p { margin: var(--s3) 0 0; }
.ro-page .panel > .section-head + p { margin-top: 0; }
.ro-page .panel > p + p { margin-top: var(--s2); }
.ro-page .panel .stat-card { box-shadow: none; }
.ro-page .section-head .hint a { font-weight: 600; }
.ro-page .section-head .link-btn { margin-left: auto; flex: none; font-size: var(--fs-sm); }
.ro-stat-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); min-height: 1.4rem; }
.ro-list { margin: var(--s2) 0 0; padding-left: 1.2em; }

/* Settings form: sections with an eyebrow title, one-row switches, two column fields, Save on the left. */
.ro-form { display: flex; flex-direction: column; gap: var(--s4); max-width: 720px; }
.ro-form .ro-section { display: flex; flex-direction: column; gap: var(--s3); }
.ro-form .ro-section + .ro-section { padding-top: var(--s4); border-top: 1px solid var(--line); }
.ro-form .ro-section__title {
  margin: 0;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--mute);
}
.ro-switch { display: flex; flex-direction: column; gap: 2px; }
.ro-switch .checkbox-row { padding: 0; }
.ro-switch .muted.small { margin: 0 0 0 calc(13px + var(--s2)); }
.ro-form .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.ro-form .form-row > label .hint { margin: 0; font-weight: 400; }
.ro-form .form-row > label .hint a { font-weight: 600; }
.ro-form input[type="number"] { max-width: 9rem; }
.ro-form textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
.ro-form .form-actions { margin-top: 0; }
.ro-inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s3) 0 0; }
.ro-inline-form input[type="text"] {
  flex: 1 1 200px; max-width: 320px;
  min-height: var(--ctrl-h); padding: 0 var(--ctrl-px);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-base); color: var(--ink); background: var(--surface);
}
.ro-inline-form input[type="text"]:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.ro-tech {
  margin: var(--s3) 0 0; padding-top: var(--s2);
  border-top: 1px dashed var(--line);
  font-size: var(--fs-xs); color: var(--mute); overflow-wrap: anywhere;
}
.ro-tech code { font-family: var(--font-mono); font-size: inherit; color: inherit; background: transparent; padding: 0; }

/* Filter toolbar: labels above the controls, one width, Filter and Clear on the right. */
.ro-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3);
  padding: var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.ro-toolbar__field {
  display: flex; flex-direction: column; gap: var(--s1);
  font-size: var(--fs-xxs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mute);
}
.ro-toolbar__field select,
.ro-toolbar__field input {
  width: 11rem; min-height: var(--ctrl-h); padding: 0 var(--ctrl-px-sm);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-sm); font-weight: 400; letter-spacing: 0; text-transform: none;
  color: var(--ink); background: var(--surface);
}
.ro-toolbar__field select:focus,
.ro-toolbar__field input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.ro-toolbar__actions { display: flex; align-items: center; gap: var(--s3); margin-left: auto; min-height: var(--ctrl-h); }

/* "Needs a person" lane: compact cards with a one-line Resume form. */
.ro-lane { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s3); }
.ro-lane__card {
  display: flex; flex-direction: column; gap: var(--s2); min-width: 0;
  padding: var(--s3);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.ro-lane__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); font-size: var(--fs-sm); }
.ro-lane__head a { color: var(--ink); font-weight: 600; }
.ro-lane__head a:hover { color: var(--brand); text-decoration: none; }
.ro-lane__meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-size: var(--fs-xs); color: var(--mute); }
.ro-lane__meta a { font-weight: 600; }
.ro-lane__reason { margin: 0; font-size: var(--fs-sm); color: var(--ink); }
.ro-lane__resume { display: flex; align-items: center; gap: var(--s2); margin: 0; }
.ro-lane__resume input[type="text"] {
  flex: 1; min-width: 0; min-height: var(--ctrl-h-sm); padding: 0 var(--ctrl-px-sm);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-sm); color: var(--ink); background: var(--surface);
}
.ro-lane__resume input[type="text"]:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

/* Tables: fixed column widths so merchant, state and the two "last" columns do not drift. */
.ro-table { table-layout: fixed; }
.ro-table td { overflow-wrap: anywhere; }
.ro-table col.ro-col-xs { width: 7%; }
.ro-table col.ro-col-sm { width: 11%; }
.ro-table col.ro-col-md { width: 14%; }
.ro-table col.ro-col-lg { width: 22%; }
.ro-table tbody th {
  text-align: left; vertical-align: middle;
  padding: var(--cell-py) var(--cell-px); padding-left: var(--s3);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink);
}
.ro-table tbody tr:last-child th { border-bottom: none; }
.ro-table .tag + .sub { margin-top: 3px; }
.ro-flush-head { padding: var(--s3) var(--s3) 0; }
.ro-clamp {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; white-space: normal; overflow-wrap: anywhere;
}
.ro-modes select {
  min-height: var(--ctrl-h-sm); padding: 0 var(--ctrl-px-sm);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-sm); color: var(--ink); background: var(--surface);
}
.ro-modes select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.ro-quote {
  margin: 0; padding: var(--s2) var(--s3);
  border-left: 3px solid var(--brand); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-2);
  font-size: var(--fs-sm); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Voice session transcript: a role column, the words, the latency. The role classes are also
   set by the page's polling script, so they are hooks as well as styles. */
.ro-transcript { list-style: none; margin: 0; padding: 0; }
.transcript-line {
  display: grid; grid-template-columns: 6rem minmax(0, 1fr) auto; gap: var(--s3); align-items: baseline;
  padding: var(--s2) 0; border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm); line-height: 1.45; overflow-wrap: anywhere;
}
.transcript-line:last-child { border-bottom: none; }
.transcript-line > .muted { font-size: var(--fs-xxs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.transcript-assistant > .muted { color: var(--brand); }
.transcript-merchant > .muted { color: var(--ink); }
.transcript-tool, .transcript-system { color: var(--mute); font-style: italic; }

@media (max-width: 700px) {
  .ro-form .form-row, .ro-lane { grid-template-columns: 1fr; }
  .ro-form input[type="number"] { max-width: none; }
  .ro-toolbar__field, .ro-toolbar__field select, .ro-toolbar__field input { width: 100%; }
  .ro-toolbar__actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .ro-inline-form input[type="text"] { max-width: none; }
  .ro-table { table-layout: auto; }
  .transcript-line { grid-template-columns: 1fr; gap: 2px; }
}

/* @fundivi-end */

/* @fundivi-begin 6515-6556 (Top bar alerts button) */
.topbar-alerts {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: var(--ctrl-h);
  padding: 0 var(--ctrl-px);
  background: var(--violet);
  color: var(--surface);
  border: 1px solid color-mix(in oklab, var(--violet) 70%, black 12%);
  border-radius: var(--r-md);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 120ms var(--ease), box-shadow 120ms var(--ease);
}
[data-theme="dark"] .topbar-alerts { color: var(--bg); }
.topbar-alerts:hover { filter: brightness(1.06); }
.topbar-alerts:active { filter: brightness(0.96); }
.topbar-alerts:focus-visible { outline: none; box-shadow: var(--ring); }
.topbar-alerts svg { width: 16px; height: 16px; flex: none; }
.topbar-alerts__label { line-height: 1; }
/* The button stays put; the COUNT is what changes. A control that only shows
   up when it has news is one nobody learns the location of. */
.topbar-alerts__count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--surface);
  color: var(--violet);
  font-size: var(--fs-xxs);
  font-weight: 700;
  font-variant-numeric: var(--num);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
[data-theme="dark"] .topbar-alerts__count { background: var(--bg); color: var(--violet); }
.topbar-alerts__count[hidden] { display: none; }
/* @fundivi-end */
