/* ==========================================================================
   DeFIN UI — shared design system for static UI mockups
   ==========================================================================
   Scope     : Policy Console + Servicer Operations mockup set (screens 01–10).
   Theming   : class-based dark mode — `.dark` on <html> (matches the real
               app's Tailwind v4 `@custom-variant dark (&:is(.dark *))`).
               Every color flows through a CSS custom property; toggling the
               class reskins the entire page. assets/theme.js owns the toggle.
   Tokens    : the neutral OKLCH tokens below are copied VERBATIM from the
               production design system (Tailwind v4 / shadcn). Do not edit
               them. The semantic status palette (success / warning / info +
               subtle variants) is additive and intentionally low-chroma.
   Usage     : every screen links this file and composes the classes below.
               Screen-specific CSS may extend in a local <style> block but
               must never redefine tokens.
   Fonts     : system stack only — the mockups must render from file:// with
               zero network requests.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */

:root {
  /* ---- production tokens (verbatim — do not alter) ---- */
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);

  /* ---- semantic status palette (additive; restrained chroma) ----
     Solid color = dots, icons, meters. `-foreground` = text ON the solid.
     `-subtle` = tinted badge/row background. `-subtle-foreground` = text ON
     the tint. Status color never appears without an accompanying label. */
  --success: oklch(0.55 0.12 152);
  --success-foreground: oklch(0.985 0 0);
  --success-subtle: oklch(0.962 0.032 152);
  --success-subtle-foreground: oklch(0.4 0.1 152);
  --warning: oklch(0.66 0.13 75);
  --warning-foreground: oklch(0.24 0.06 75);
  --warning-subtle: oklch(0.965 0.042 85);
  --warning-subtle-foreground: oklch(0.44 0.1 72);
  --info: oklch(0.55 0.12 250);
  --info-foreground: oklch(0.985 0 0);
  --info-subtle: oklch(0.955 0.028 250);
  --info-subtle-foreground: oklch(0.42 0.11 252);
  --destructive-foreground: oklch(0.985 0 0);
  --destructive-subtle: oklch(0.962 0.026 27);
  --destructive-subtle-foreground: oklch(0.46 0.17 27);

  /* ---- chart tokens (dataviz: recessive grid, one data hue + neutrals) ---- */
  --chart-ink: oklch(0.3 0 0);            /* primary series / bars           */
  --chart-accent: oklch(0.55 0.12 250);   /* single accent hue (info blue)   */
  --chart-muted: oklch(0.85 0 0);         /* comparison / track fills        */
  --chart-grid: oklch(0.94 0 0);          /* gridlines — recessive           */
  --chart-area: oklch(0.55 0.12 250 / 10%); /* area fill under accent lines  */

  /* ---- surfaces & chrome ---- */
  --sidebar: oklch(0.985 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --topbar: oklch(1 0 0 / 88%);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 5%);
  --shadow-md: 0 2px 8px oklch(0 0 0 / 7%);

  /* ---- derived radii (shadcn convention) ---- */
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  /* ---- type ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono",
    Menlo, Consolas, monospace;

  color-scheme: light;
}

.dark {
  /* ---- production tokens (verbatim — do not alter) ---- */
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);

  /* ---- semantic status palette — dark variants (not an auto-invert) ---- */
  --success: oklch(0.7 0.12 152);
  --success-foreground: oklch(0.17 0.04 152);
  --success-subtle: oklch(0.26 0.045 152);
  --success-subtle-foreground: oklch(0.8 0.1 152);
  --warning: oklch(0.75 0.13 80);
  --warning-foreground: oklch(0.2 0.05 80);
  --warning-subtle: oklch(0.27 0.05 80);
  --warning-subtle-foreground: oklch(0.84 0.1 80);
  --info: oklch(0.7 0.11 250);
  --info-foreground: oklch(0.17 0.04 250);
  --info-subtle: oklch(0.26 0.045 252);
  --info-subtle-foreground: oklch(0.8 0.09 250);
  --destructive-foreground: oklch(0.985 0 0);
  --destructive-subtle: oklch(0.27 0.06 25);
  --destructive-subtle-foreground: oklch(0.8 0.1 22);

  /* ---- chart tokens ---- */
  --chart-ink: oklch(0.82 0 0);
  --chart-accent: oklch(0.7 0.11 250);
  --chart-muted: oklch(0.38 0 0);
  --chart-grid: oklch(0.28 0 0);
  --chart-area: oklch(0.7 0.11 250 / 14%);

  /* ---- surfaces & chrome ---- */
  --sidebar: oklch(0.185 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --topbar: oklch(0.145 0 0 / 85%);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 35%);
  --shadow-md: 0 2px 8px oklch(0 0 0 / 40%);

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

h1, h2, h3, h4, p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY UTILITIES
   -------------------------------------------------------------------------- */

/* Page-level H1 in the main column */
.page-title { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.page-subtitle { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }

/* Section heading between card groups */
.section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted-foreground);
}

/* Small uppercase eyebrow label (KPI labels, column groups) */
.eyebrow {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted-foreground);
}

.text-muted { color: var(--muted-foreground); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }

/* Identifiers (da_id, vault_id, policy versions, reason codes) */
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }

/* Anything numeric that columns-up: amounts, counts, timestamps */
.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   4. APP SHELL
   --------------------------------------------------------------------------
   Canonical skeleton (reuse verbatim on every screen):

   <div class="app">
     <aside class="sidebar"> … </aside>
     <div class="app-body">
       <header class="topbar"> … </header>
       <main class="main"> … </main>
     </div>
   </div>
   -------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.app-body { display: flex; flex-direction: column; min-width: 0; }

.main {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  padding: 24px 28px 48px;
  margin: 0 auto;
  min-width: 0;
}

/* Narrow viewports: sidebar collapses to an icon rail (no clipping) */
@media (max-width: 960px) {
  .app { grid-template-columns: 60px minmax(0, 1fr); }
  .sidebar .brand-name,
  .sidebar .app-label,
  .sidebar .nav-section-title,
  .sidebar .nav-item > span,
  .sidebar .nav-item .nav-badge,
  .sidebar .sidebar-footer { display: none; }
  .sidebar { padding: 14px 10px; align-items: center; }
  .sidebar-brand { padding: 0 0 14px; justify-content: center; }
  .nav-item { justify-content: center; padding: 8px; }
  .main { padding: 18px 16px 40px; }
}

/* --------------------------------------------------------------------------
   5. SIDEBAR
   -------------------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
}

/* Brand lockup: mark + wordmark + app label */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 16px;
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; letter-spacing: -0.02em;
  text-decoration: none; color: var(--foreground);
}

.brand-mark {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--primary);
  color: var(--primary-foreground);
}
.brand-mark svg { width: 12px; height: 12px; }

/* Which application this shell is: "Policy Console" / "Servicer Operations" */
.app-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-foreground);
  padding-left: 30px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 18px; flex: 1; }

.nav-section { display: flex; flex-direction: column; gap: 1px; }

.nav-section-title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted-foreground);
  padding: 0 8px 5px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--accent); color: var(--accent-foreground); }
.nav-item.active {
  background: var(--accent);
  color: var(--foreground);
  font-weight: 600;
}

.nav-icon { width: 16px; height: 16px; flex: none; }

/* Optional right-aligned count on a nav item (e.g. Exceptions 4) */
.nav-badge {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.nav-badge.danger { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); }

/* FI / environment context pinned at the bottom of the rail */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--sidebar-border);
}
.fi-context { display: flex; flex-direction: column; gap: 2px; }
.fi-context .fi-name { font-size: 12px; font-weight: 600; }
.fi-context .fi-meta { font-size: 11px; color: var(--muted-foreground); }

/* --------------------------------------------------------------------------
   6. TOPBAR
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 24px;
  background: var(--topbar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Breadcrumbs (topbar or in-page) */
.breadcrumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted-foreground);
  white-space: nowrap; overflow: hidden;
}
.breadcrumbs a { text-decoration: none; color: var(--muted-foreground); }
.breadcrumbs a:hover { color: var(--foreground); }
.breadcrumbs .crumb-sep { color: var(--border); user-select: none; }
.breadcrumbs .current { color: var(--foreground); font-weight: 600; }

/* Global search */
.search {
  display: flex; align-items: center; gap: 7px;
  width: 240px; height: 32px;
  padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--muted-foreground);
}
.search svg { width: 14px; height: 14px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 12.5px; color: var(--foreground);
}
.search input::placeholder { color: var(--muted-foreground); }
.search kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 5px; border: 1px solid var(--border);
  border-radius: 4px; color: var(--muted-foreground); background: var(--muted);
}
@media (max-width: 1100px) { .search { width: 160px; } .search kbd { display: none; } }

/* Context switcher (FI / vault / source platform) */
.context-switcher {
  display: flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap;
}
.context-switcher:hover { background: var(--accent); }
.context-switcher .ctx-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted-foreground);
}
.context-switcher .chev { width: 12px; height: 12px; color: var(--muted-foreground); }
@media (max-width: 1100px) { .context-switcher .ctx-label { display: none; } }

/* Square icon buttons (bell, theme toggle) */
.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: var(--muted-foreground);
  transition: background 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: var(--accent); color: var(--foreground); }
.icon-btn svg { width: 16px; height: 16px; }

/* Alert bell count */
.bell-count {
  position: absolute; top: -3px; right: -3px;
  min-width: 15px; height: 15px; padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--destructive);
  color: var(--destructive-foreground);
  font-size: 9.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--background);
  box-sizing: content-box;
}

/* Theme toggle: sun shown in light (click → dark), moon shown in dark */
.theme-toggle .icon-moon { display: none; }
.dark .theme-toggle .icon-moon { display: block; }
.dark .theme-toggle .icon-sun { display: none; }

/* User avatar (initials) + optional name/role block */
.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.user-menu { display: flex; align-items: center; gap: 9px; padding-left: 6px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta .user-name { font-size: 12px; font-weight: 600; }
.user-meta .user-role { font-size: 10.5px; color: var(--muted-foreground); }
@media (max-width: 1220px) { .user-meta { display: none; } }

/* --------------------------------------------------------------------------
   7. CARDS / PANELS
   -------------------------------------------------------------------------- */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 0;
}
.card-header.bordered { padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.card-title { font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em; }
.card-desc { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }

/* Right-hand actions inside a card header */
.card-toolbar { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.card-body { padding: 14px 16px 16px; min-width: 0; }
.card-body.flush { padding: 0; }        /* for full-bleed tables */

.card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted-foreground);
  display: flex; align-items: center; gap: 8px;
  /* Let trailing chips (e.g. a right-aligned reason code) drop to their
     own line rather than clip at the card edge on narrow footers. */
  flex-wrap: wrap; row-gap: 6px;
}

/* --------------------------------------------------------------------------
   8. KPI / STAT TILES  (dataviz stat-tile guidance: label → value → context)
   -------------------------------------------------------------------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 14px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}

.kpi-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted-foreground);
  display: flex; align-items: center; gap: 6px;
}

.kpi-value {
  font-size: 26px; font-weight: 650; letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-value .kpi-unit { font-size: 14px; font-weight: 500; color: var(--muted-foreground); }

/* Context line under the value: delta, split, or note */
.kpi-delta {
  font-size: 12px; color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.kpi-delta .up { color: var(--success-subtle-foreground); font-weight: 600; }
.kpi-delta .down { color: var(--destructive-subtle-foreground); font-weight: 600; }
.kpi-delta .flat { color: var(--muted-foreground); font-weight: 600; }

/* Inline sparkline slot — an <svg class="spark"> sized by the container */
.kpi-spark { margin-top: 6px; height: 28px; }
.kpi-spark svg { width: 100%; height: 100%; overflow: visible; }

/* Sparkline strokes/fills (use these classes on SVG shapes) */
.spark-line { fill: none; stroke: var(--chart-accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark-line.neutral { stroke: var(--chart-ink); }
.spark-area { fill: var(--chart-area); stroke: none; }
.spark-dot { fill: var(--chart-accent); }
.spark-dot.neutral { fill: var(--chart-ink); }

/* --------------------------------------------------------------------------
   9. BADGES & STATUS DOTS
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--secondary); color: var(--secondary-foreground);
  border: 1px solid transparent;
}
.badge--success { background: var(--success-subtle); color: var(--success-subtle-foreground); }
.badge--warning { background: var(--warning-subtle); color: var(--warning-subtle-foreground); }
.badge--danger  { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); }
.badge--info    { background: var(--info-subtle); color: var(--info-subtle-foreground); }
.badge--neutral { background: var(--secondary); color: var(--secondary-foreground); }
.badge--outline { background: transparent; border-color: var(--border); color: var(--muted-foreground); }

/* Colored dot + label for health / lifecycle states.
   Always paired with text — never color alone. */
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.status-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 999px; flex: none;
  background: var(--muted-foreground);
}
.status-dot.ok::before      { background: var(--success); }
.status-dot.warn::before    { background: var(--warning); }
.status-dot.danger::before  { background: var(--destructive); }
.status-dot.info::before    { background: var(--info); }
.status-dot.neutral::before { background: var(--muted-foreground); }
.status-dot.pending::before { background: transparent; border: 1.5px solid var(--muted-foreground); width: 6px; height: 6px; }

/* "SEEDED DEMO DATA" marker — required on every mockup screen */
.demo-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 10px;
  border-radius: 999px;
  border: 1px dashed var(--warning);
  background: var(--warning-subtle);
  color: var(--warning-subtle-foreground);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; white-space: nowrap;
}
.demo-pill::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--warning); }

/* --------------------------------------------------------------------------
   10. TABLES
   -------------------------------------------------------------------------- */

/* Wrap every .table in .table-wrap: it owns horizontal overflow and the
   sticky-header scroll context. Combine with .card-body.flush inside cards. */
.table-wrap { overflow: auto; max-width: 100%; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--card);
  text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted-foreground);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: var(--muted); }
.table.zebra tbody tr:nth-child(even) { background: color-mix(in oklab, var(--muted) 55%, transparent); }
.table.zebra tbody tr:hover { background: var(--muted); }

/* Right-aligned numerics — amounts, counts, rates */
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sortable header affordance */
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--foreground); }
.table th.sortable::after { content: "↕"; margin-left: 5px; opacity: 0.45; font-size: 10px; }
.table th.sorted-asc::after { content: "↑"; opacity: 1; }
.table th.sorted-desc::after { content: "↓"; opacity: 1; }

/* Cell truncation — give the cell a width and let content ellipsize */
.cell-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Primary entity name inside a row */
.table .cell-strong { font-weight: 600; color: var(--foreground); }
.table .cell-sub { font-size: 11px; color: var(--muted-foreground); margin-top: 1px; }

/* --------------------------------------------------------------------------
   11. BUTTONS  (mirrors the shadcn button feel)
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 13px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 88%, var(--background)); }

.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 80%, var(--muted-foreground) 8%); }

.btn-outline { background: var(--background); border-color: var(--input); color: var(--foreground); }
.btn-outline:hover { background: var(--accent); }

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); }

.btn-danger { background: var(--destructive); color: var(--destructive-foreground); }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { height: 26px; padding: 0 10px; font-size: 11.5px; border-radius: var(--radius-sm); }
.btn-lg { height: 38px; padding: 0 18px; font-size: 13.5px; }

.btn:disabled, .btn.disabled {
  opacity: 0.5; pointer-events: none; cursor: not-allowed;
}

/* Square icon-only button */
.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 26px; }

/* --------------------------------------------------------------------------
   12. TABS
   -------------------------------------------------------------------------- */

.tabs {
  display: flex; align-items: flex-end; gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 8px 13px 9px;
  font-size: 12.5px; font-weight: 500;
  color: var(--muted-foreground);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none; white-space: nowrap;
  transition: color 0.12s ease;
}
.tab:hover { color: var(--foreground); }
.tab.active { color: var(--foreground); font-weight: 600; border-bottom-color: var(--primary); }
.tab .tab-count {
  margin-left: 6px; font-size: 10.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 999px;
  background: var(--secondary); color: var(--secondary-foreground);
}

/* Segmented pill alternative (filters, view switches) */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--muted);
  border-radius: var(--radius-md);
}
.seg .seg-item {
  padding: 4px 11px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; color: var(--muted-foreground);
  text-decoration: none;
}
.seg .seg-item.active { background: var(--background); color: var(--foreground); font-weight: 600; box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   13. PROGRESS BARS / METERS
   -------------------------------------------------------------------------- */

.progress {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--muted);
}
.progress .progress-bar {
  height: 100%; border-radius: 999px;
  background: var(--primary);
  transition: width 0.3s ease;
}
.progress .progress-bar.success { background: var(--success); }
.progress .progress-bar.warning { background: var(--warning); }
.progress .progress-bar.danger  { background: var(--destructive); }
.progress .progress-bar.info    { background: var(--info); }

/* Labeled meter row: label — bar — value */
.meter { display: grid; grid-template-columns: minmax(90px, auto) 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.meter .meter-label { color: var(--muted-foreground); white-space: nowrap; }
.meter .meter-value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* --------------------------------------------------------------------------
   14. CHECKLISTS  (setup gates, readiness items)
   -------------------------------------------------------------------------- */

.checklist { display: flex; flex-direction: column; }
.check-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.check-item:last-child { border-bottom: 0; }

.check-mark {
  width: 17px; height: 17px; flex: none; margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
}
.check-item.done .check-mark { background: var(--success); color: var(--success-foreground); }
.check-item.todo .check-mark { background: transparent; border: 1.5px solid var(--border); color: transparent; }
.check-item.blocked .check-mark { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); }
.check-item.done .check-text { color: var(--muted-foreground); }
.check-item .check-text { flex: 1; min-width: 0; }
.check-item .check-note { font-size: 11px; color: var(--muted-foreground); margin-top: 1px; }
.check-item.blocked .check-note { color: var(--destructive-subtle-foreground); }

/* --------------------------------------------------------------------------
   15. TIMELINE / STEPPER  (vertical staged workflow)
   -------------------------------------------------------------------------- */

.stepper { display: flex; flex-direction: column; }

.step {
  position: relative;
  display: flex; gap: 12px;
  padding-bottom: 18px;
}
.step:last-child { padding-bottom: 0; }

/* Connector line between nodes */
.step::before {
  content: ""; position: absolute;
  left: 9px; top: 22px; bottom: 2px;
  width: 2px; border-radius: 1px;
  background: var(--border);
}
.step:last-child::before { display: none; }
.step.done::before { background: var(--success); }

.step-node {
  width: 20px; height: 20px; flex: none; z-index: 1;
  display: grid; place-items: center;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  background: var(--muted); color: var(--muted-foreground);
  border: 2px solid var(--background);
  box-shadow: 0 0 0 1.5px var(--border);
}
.step.done .step-node { background: var(--success); color: var(--success-foreground); box-shadow: 0 0 0 1.5px var(--success); }
.step.current .step-node { background: var(--primary); color: var(--primary-foreground); box-shadow: 0 0 0 1.5px var(--primary); }
.step.blocked .step-node { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); box-shadow: 0 0 0 1.5px var(--destructive); }
.step.pending .step-node { background: var(--background); box-shadow: 0 0 0 1.5px var(--border); }

.step-body { flex: 1; min-width: 0; padding-top: 1px; }
.step-title { font-size: 12.5px; font-weight: 600; }
.step.pending .step-title { color: var(--muted-foreground); font-weight: 500; }
.step-meta { font-size: 11.5px; color: var(--muted-foreground); margin-top: 1px; }

/* --------------------------------------------------------------------------
   16. FORM CONTROLS
   -------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field .label { font-size: 12px; font-weight: 600; }
.field .label .req { color: var(--destructive); margin-left: 2px; }
.field .hint { font-size: 11px; color: var(--muted-foreground); }
.field .error-text { font-size: 11px; color: var(--destructive-subtle-foreground); font-weight: 500; }

.input, .select, .textarea {
  height: 32px; padding: 0 10px;
  font: inherit; font-size: 12.5px;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  width: 100%;
}
.textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--ring); }
.input:disabled, .select:disabled, .input[readonly] { background: var(--muted); color: var(--muted-foreground); cursor: not-allowed; }
.input.invalid, .select.invalid { border-color: var(--destructive); }

.select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

/* Multi-select chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  background: var(--secondary); color: var(--secondary-foreground);
  border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 500;
}
.chip .chip-x { color: var(--muted-foreground); font-size: 13px; line-height: 1; cursor: pointer; }
.chip .chip-x:hover { color: var(--foreground); }

/* Toggle switch (pure CSS; input is the state) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 32px; height: 18px; flex: none;
  border-radius: 999px;
  background: var(--input);
  transition: background 0.15s ease;
  position: relative;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 999px;
  background: var(--background);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Read-only key→value display (detail panes) */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 18px; font-size: 12.5px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   17. STATE BLOCKS  (empty / loading / stale / access-denied / error)
   -------------------------------------------------------------------------- */

.state-block {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  padding: 36px 20px;
  color: var(--muted-foreground);
}
.state-block .state-icon {
  width: 34px; height: 34px; margin-bottom: 4px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--muted);
}
.state-block .state-icon svg { width: 16px; height: 16px; }
.state-block .state-title { font-size: 13px; font-weight: 600; color: var(--foreground); }
.state-block .state-desc { font-size: 12px; max-width: 340px; }
.state-block.error .state-icon { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); }
.state-block.denied .state-icon { background: var(--warning-subtle); color: var(--warning-subtle-foreground); }

/* Loading: skeleton shimmer bars */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--muted) 25%, color-mix(in oklab, var(--muted) 60%, var(--background)) 50%, var(--muted) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s ease-in-out infinite;
  min-height: 12px;
}
@keyframes skeleton-wave { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Small inline spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--muted-foreground);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Stale-data notice strip (attach above/below a panel body) */
.stale-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  font-size: 11.5px; font-weight: 500;
  background: var(--warning-subtle); color: var(--warning-subtle-foreground);
  border-top: 1px solid var(--border);
}

/* Full-width contextual banner (info / warning / danger) */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 12.5px;
  background: var(--muted);
}
.banner svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.banner.info { background: var(--info-subtle); color: var(--info-subtle-foreground); border-color: color-mix(in oklab, var(--info) 30%, transparent); }
.banner.warning { background: var(--warning-subtle); color: var(--warning-subtle-foreground); border-color: color-mix(in oklab, var(--warning) 35%, transparent); }
.banner.danger { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); border-color: color-mix(in oklab, var(--destructive) 30%, transparent); }
.banner .banner-title { font-weight: 650; }

/* --------------------------------------------------------------------------
   18. SIMPLE CHARTS  (inline SVG/CSS only — no libraries; legible both themes)
   -------------------------------------------------------------------------- */

/* Generic chart frame: use with inline <svg>; gridlines get .chart-gridline */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart-gridline { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis-label { fill: var(--muted-foreground); font-size: 10px; font-family: var(--font-sans); }
.chart-value-label { fill: var(--foreground); font-size: 10.5px; font-weight: 600; font-family: var(--font-sans); }

/* Horizontal bar list: label — track — value (counts, splits, reasons) */
.bar-row { display: grid; grid-template-columns: minmax(110px, auto) 1fr auto; align-items: center; gap: 10px; font-size: 12px; padding: 5px 0; }
.bar-row .bar-label { color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { height: 8px; border-radius: 3px; background: var(--muted); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 3px; background: var(--chart-ink); }
.bar-row .bar-fill.accent { background: var(--chart-accent); }
.bar-row .bar-fill.success { background: var(--success); }
.bar-row .bar-fill.warning { background: var(--warning); }
.bar-row .bar-fill.danger { background: var(--destructive); }
.bar-row .bar-value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Split bar (e.g. accepted vs rejected) with a 2px surface gap between fills */
.split-bar { display: flex; height: 8px; border-radius: 3px; overflow: hidden; gap: 2px; background: transparent; }
.split-bar > span { height: 100%; }
.split-bar .seg-success { background: var(--success); border-radius: 3px 0 0 3px; }
.split-bar .seg-danger { background: var(--destructive); border-radius: 0 3px 3px 0; }
.split-bar .seg-muted { background: var(--chart-muted); }

/* Donut / gauge: build with two SVG circles; classes color the strokes */
.donut-track { fill: none; stroke: var(--muted); }
.donut-value { fill: none; stroke: var(--chart-accent); stroke-linecap: round; }
.donut-value.success { stroke: var(--success); }
.donut-value.warning { stroke: var(--warning); }
.donut-center { fill: var(--foreground); font-weight: 650; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.donut-sub { fill: var(--muted-foreground); font-size: 9px; font-family: var(--font-sans); }

/* Legend (required when ≥ 2 series share a plot) */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 11.5px; color: var(--muted-foreground); }
.legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.legend .swatch.ink { background: var(--chart-ink); }
.legend .swatch.accent { background: var(--chart-accent); }
.legend .swatch.muted-fill { background: var(--chart-muted); }
.legend .swatch.success { background: var(--success); }
.legend .swatch.warning { background: var(--warning); }
.legend .swatch.danger { background: var(--destructive); }

/* --------------------------------------------------------------------------
   19. FEED / ACTIVITY LIST  (eligibility outcomes, audit trail)
   -------------------------------------------------------------------------- */

.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item .feed-body { flex: 1; min-width: 0; }
.feed-item .feed-meta { font-size: 11px; color: var(--muted-foreground); margin-top: 1px; display: flex; gap: 8px; flex-wrap: wrap; }
.feed-item .feed-time { margin-left: auto; flex: none; font-size: 11px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Machine-readable reason code chip (mono, quiet) */
.reason-code {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  padding: 1px 6px; border-radius: 4px;
  background: var(--muted); color: var(--muted-foreground);
  border: 1px solid var(--border);
  /* Stay on one line when there's room; break mid-token rather than
     spilling out of a narrow cell/panel instead of overflowing it. */
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.reason-code.danger { background: var(--destructive-subtle); color: var(--destructive-subtle-foreground); border-color: transparent; }
.reason-code.warning { background: var(--warning-subtle); color: var(--warning-subtle-foreground); border-color: transparent; }

/* --------------------------------------------------------------------------
   20. LAYOUT UTILITIES
   -------------------------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
/* 2/1 asymmetric split — main panel + rail */
.grid-main-rail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-rail { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Page header block at the top of .main */
.page-header { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header .page-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Context strip: quiet horizontal band for environment / integration status */
.context-strip {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--muted) 45%, transparent);
  font-size: 12px; color: var(--muted-foreground);
}
.context-strip .strip-title { font-weight: 650; color: var(--foreground); display: flex; align-items: center; gap: 7px; }
