/* =============================================================================
   CaseLens — "Ink & Evidence" Design System
   Vanilla CSS. Calm enterprise precision with a legal-document soul.
   Tokens → Base → Layout (app shell) → Components → Views → Responsive
   ========================================================================== */

/* ----------------------------------------------------------------------------
   1. TOKENS
---------------------------------------------------------------------------- */
:root {
  /* Ink / authority */
  --ink: #1E3A8A;
  --ink-deep: #172554;
  --ink-deeper: #0F1B3D;
  --ink-interactive: #2563EB;
  --ink-soft: #DBE4F5;
  --ink-tint: #EEF3FC;

  /* Accent (trust gold) + evidence highlight */
  --accent: #B45309;
  --accent-soft: #FDF3E7;
  --highlight: #F59E0B;
  --highlight-glow: rgba(245, 158, 11, .28);

  /* Surfaces */
  --canvas: #FAFAF8;          /* warm paper */
  --canvas-2: #F4F4F0;
  --surface: #FFFFFF;
  --surface-sunken: #F7F8FB;

  /* Text */
  --text: #0F172A;
  --text-muted: #475569;
  --text-subtle: #64748B;
  --text-faint: #94A3B8;
  --text-on-ink: #EAF0FB;
  --text-on-ink-muted: #9DB0D6;

  /* Lines */
  --border: #E6E8EC;
  --border-2: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-ink: rgba(255,255,255,.10);

  /* Status — triage R/A/G (always paired with icon + label) */
  --pass: #15803D;  --pass-bg: #DCFCE7;  --pass-line: #86EFAC;
  --warn: #B45309;  --warn-bg: #FEF3C7;  --warn-line: #FCD34D;
  --fail: #B91C1C;  --fail-bg: #FEE2E2;  --fail-line: #FCA5A5;
  --info: #1E40AF;  --info-bg: #E0E9FB;  --info-line: #BFD3F6;

  /* Typography */
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 8px 24px rgba(15,23,42,.10);
  --shadow-xl: 0 24px 56px rgba(15,23,42,.18);
  --ring: 0 0 0 3px rgba(37,99,235,.30);

  /* Motion (emil: professional dashboard = crisp & fast) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --t-press: 120ms;
  --t-hover: 160ms;
  --t-pop: 180ms;
  --t-drawer: 260ms;

  /* Dimensions */
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --maxw: 1320px;
}

/* ----------------------------------------------------------------------------
   2. BASE
---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* faint paper grain for atmosphere (very low opacity) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); line-height: 1.25; }
p { margin: 0; }
a { color: var(--ink-interactive); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0; padding: 0; list-style: none; }

button, input, select, textarea { font: inherit; color: inherit; }

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

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

::selection { background: var(--highlight-glow); }

/* Scrollbars (webkit) */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #D2D7DF; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #B6BECB; background-clip: content-box; }

/* Typography helpers */
.serif { font-family: var(--font-serif); }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.display { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.015em; }
.eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-subtle);
}
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.faint { color: var(--text-faint); }
.t-sm { font-size: 13px; }
.t-xs { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ----------------------------------------------------------------------------
   3. APP SHELL
---------------------------------------------------------------------------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app.is-auth { display: block; }     /* landing/login shows no shell */

/* Sidebar */
.sidebar {
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(37,99,235,.18), transparent 60%),
    linear-gradient(180deg, var(--ink-deep), var(--ink-deeper));
  color: var(--text-on-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border-ink);
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #2D5BD6, #1E3A8A);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 6px 14px rgba(8,18,48,.5);
}
.brand-mark svg { width: 19px; height: 19px; color: #fff; }
.brand-name { font-family: var(--font-serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; color: #fff; }
.brand-name b { color: var(--highlight); font-weight: 600; }
.brand-sub { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-on-ink-muted); margin-top: 1px; }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-on-ink-muted); padding: 14px 12px 6px; opacity: .8;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--text-on-ink-muted); cursor: pointer;
  font-size: 14px; font-weight: 500;
  transition: background var(--t-hover) var(--ease-out), color var(--t-hover) var(--ease-out);
  border: 1px solid transparent;
  text-decoration: none;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(37,99,235,.30), rgba(37,99,235,.10));
  color: #fff;
  border-color: rgba(120,160,255,.30);
  box-shadow: inset 2px 0 0 var(--highlight);
}
.nav-item .nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: rgba(245,158,11,.18); color: var(--highlight);
  padding: 1px 7px; border-radius: 999px;
}
.sidebar-foot { margin-top: auto; padding: 14px; }
.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 11px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border-ink);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600; color: #fff;
  background: linear-gradient(145deg, #4F46E5, #2563EB);
}
.userchip .nm { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.userchip .rl { font-size: 11px; color: var(--text-on-ink-muted); }

/* Topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: rgba(250,250,248,.85);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-subtle); min-width: 0; }
.crumbs .sep { color: var(--text-faint); }
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs .crumb-case { color: var(--ink); font-weight: 600; }

.searchbox {
  margin-left: 8px; flex: 1; max-width: 360px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-pill);
  padding: 7px 14px; color: var(--text-subtle);
  transition: box-shadow var(--t-hover) var(--ease-out), border-color var(--t-hover) var(--ease-out);
}
.searchbox:focus-within { border-color: var(--ink-interactive); box-shadow: var(--ring); }
.searchbox svg { width: 16px; height: 16px; flex: none; }
.searchbox input { border: 0; background: transparent; outline: none; width: 100%; font-size: 13.5px; color: var(--text); }
.searchbox kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 6px; background: var(--surface-sunken);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  display: grid; place-items: center; position: relative;
  transition: background var(--t-hover) var(--ease-out), color var(--t-hover) var(--ease-out), border-color var(--t-hover) var(--ease-out), transform var(--t-press) var(--ease-out);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.96); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }

/* Content area */
.content { padding: 26px 24px 64px; max-width: var(--maxw); width: 100%; margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; animation: viewIn 320ms var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .ttl { font-family: var(--font-serif); font-size: 27px; font-weight: 600; letter-spacing: -.015em; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 3px; }
.page-head .spacer { flex: 1; }

/* ----------------------------------------------------------------------------
   4. COMPONENTS
---------------------------------------------------------------------------- */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; line-height: 1;
  padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--surface-sunken); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-hover) var(--ease-out), border-color var(--t-hover) var(--ease-out), box-shadow var(--t-hover) var(--ease-out), transform var(--t-press) var(--ease-out), color var(--t-hover) var(--ease-out);
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #1B347C; }
.btn-accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-accent:hover { background: #9C480A; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--ink-interactive); color: var(--ink); }
.btn-sm { padding: 7px 11px; font-size: 13px; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-pass { background: var(--pass); color: #fff; }
.btn-pass:hover { background: #126C34; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .sub { font-size: 12.5px; color: var(--text-subtle); }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8{margin-top:8px}.mt-12{margin-top:12px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}
.flex1 { flex: 1; }

/* KPI / stat cards */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-hover) var(--ease-out), transform var(--t-hover) var(--ease-out);
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi::after { content:""; position:absolute; right:-30px; top:-30px; width:120px; height:120px; border-radius:50%; background: radial-gradient(circle, var(--ink-tint), transparent 70%); opacity:.7; }
.kpi .kpi-ico { width: 36px; height: 36px; border-radius: 10px; display:grid; place-items:center; background: var(--ink-tint); color: var(--ink); margin-bottom: 12px; }
.kpi .kpi-ico svg { width: 19px; height: 19px; }
.kpi .kpi-ico.amber { background: var(--warn-bg); color: var(--accent); }
.kpi .kpi-ico.green { background: var(--pass-bg); color: var(--pass); }
.kpi .kpi-label { font-size: 12.5px; color: var(--text-subtle); font-weight: 500; }
.kpi .kpi-val { font-family: var(--font-serif); font-size: 32px; font-weight: 600; letter-spacing: -.02em; line-height: 1.05; margin-top: 3px; }
.kpi .kpi-val small { font-size: 16px; color: var(--text-subtle); font-family: var(--font-sans); font-weight: 500; }
.kpi .kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; margin-top: 8px; }
.kpi .kpi-delta svg { width: 14px; height: 14px; }
.kpi .kpi-delta.up { color: var(--pass); }
.kpi .kpi-delta.down { color: var(--fail); }
.kpi .kpi-delta .vs { color: var(--text-faint); font-weight: 500; }
.spark { margin-top: 10px; height: 34px; width: 100%; }

/* Status pills (icon + label, never colour-only) */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 9px 4px 7px; border-radius: var(--r-pill);
  border: 1px solid transparent;
}
.pill svg { width: 13px; height: 13px; }
.pill-pass { background: var(--pass-bg); color: var(--pass); border-color: var(--pass-line); }
.pill-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill-fail { background: var(--fail-bg); color: var(--fail); border-color: var(--fail-line); }
.pill-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.pill-neutral { background: var(--surface-sunken); color: var(--text-muted); border-color: var(--border-2); }
.pill-ghost { background: transparent; color: var(--text-subtle); border-color: var(--border-2); }

/* dot status (for tables) */
.sdot { display:inline-flex; align-items:center; gap:7px; font-size:13px; font-weight:500; }
.sdot::before { content:""; width:8px; height:8px; border-radius:50%; background: var(--text-faint); }
.sdot.pass::before { background: var(--pass); }
.sdot.warn::before { background: var(--warn); }
.sdot.fail::before { background: var(--fail); }
.sdot.info::before { background: var(--ink-interactive); }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; padding: 3px 8px; border-radius: 7px;
  background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border-2);
}
.chip svg { width: 12px; height: 12px; }
.chip-source { background: var(--accent-soft); color: var(--accent); border-color: #F2D9B8; cursor: pointer; font-family: var(--font-mono); font-size: 11px; }
.chip-source:hover { background: #FBE9D2; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.tbl thead th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-subtle); font-weight: 600; padding: 11px 16px;
  background: var(--surface-sunken); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background var(--t-hover) var(--ease-out); cursor: pointer; }
.tbl tbody tr:hover { background: var(--ink-tint); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .nm { font-weight: 600; color: var(--text); }
.tbl .ref { font-family: var(--font-mono); font-size: 12px; color: var(--text-subtle); }
.tbl-progress { width: 90px; }

/* progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--border-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ink-interactive); transition: width 600ms var(--ease-out); }
.bar.amber > i { background: var(--highlight); }
.bar.green > i { background: var(--pass); }

/* confidence meter */
.conf { display: inline-flex; align-items: center; gap: 7px; }
.conf-track { width: 46px; height: 5px; border-radius: 999px; background: var(--border-2); overflow: hidden; }
.conf-track > i { display: block; height: 100%; border-radius: 999px; }
.conf-val { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; }
.conf.high > .conf-track > i { background: var(--pass); width: var(--c, 98%); }
.conf.high .conf-val { color: var(--pass); }
.conf.med > .conf-track > i { background: var(--highlight); width: var(--c, 82%); }
.conf.med .conf-val { color: var(--accent); }
.conf.low > .conf-track > i { background: var(--fail); width: var(--c, 55%); }
.conf.low .conf-val { color: var(--fail); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; color: var(--text);
  transition: border-color var(--t-hover) var(--ease-out), box-shadow var(--t-hover) var(--ease-out);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink-interactive); box-shadow: var(--ring); }
.input.mono { font-family: var(--font-mono); }
.input.filled { background: var(--pass-bg); border-color: var(--pass-line); }
.input.flagged { background: var(--warn-bg); border-color: var(--warn-line); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field-hint { font-size: 11.5px; color: var(--text-subtle); }
.field-prov { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-subtle); }

/* segmented / tabs */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--r-md); }
.tab {
  padding: 7px 14px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text-subtle);
  cursor: pointer; border: 0; background: transparent;
  transition: background var(--t-hover) var(--ease-out), color var(--t-hover) var(--ease-out);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

/* avatars in content */
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; color: #fff; background: linear-gradient(145deg, #475569, #334155); flex: none; }
.av.a { background: linear-gradient(145deg, #4F46E5, #2563EB); }
.av.b { background: linear-gradient(145deg, #0D9488, #0F766E); }
.av.c { background: linear-gradient(145deg, #B45309, #92400E); }
.av-sm { width: 26px; height: 26px; font-size: 10.5px; }

/* Toast */
.toast-host { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: flex-start; gap: 11px; width: 340px;
  background: var(--ink-deep); color: #fff; border-radius: var(--r-md);
  padding: 13px 15px; box-shadow: var(--shadow-xl);
  transition: transform var(--t-drawer) var(--ease-out), opacity var(--t-drawer) var(--ease-out);
}
@starting-style { .toast { transform: translateY(14px); opacity: 0; } }
.toast.out { transform: translateY(14px); opacity: 0; }
.toast .t-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: rgba(255,255,255,.12); }
.toast .t-ico svg { width: 17px; height: 17px; }
.toast.ok .t-ico { background: rgba(34,197,94,.2); color: #86EFAC; }
.toast .t-title { font-weight: 600; font-size: 13.5px; }
.toast .t-msg { font-size: 12.5px; color: var(--text-on-ink-muted); margin-top: 2px; }

/* Modal / drawer */
.scrim { position: fixed; inset: 0; background: rgba(8,15,35,.42); z-index: 70; opacity: 0; pointer-events: none; transition: opacity var(--t-drawer) var(--ease-out); backdrop-filter: blur(2px); }
.scrim.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; z-index: 80; left: 50%; top: 50%;
  width: min(520px, calc(100vw - 32px));
  transform: translate(-50%, -48%) scale(.96); opacity: 0; pointer-events: none;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  transition: transform var(--t-drawer) var(--ease-out), opacity var(--t-drawer) var(--ease-out);
}
.modal.show { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.modal-head { padding: 20px 22px 0; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 16px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* Skeleton */
.skel { background: linear-gradient(90deg, #EEF0F3 25%, #F6F7F9 37%, #EEF0F3 63%); background-size: 400% 100%; border-radius: 6px; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; color: var(--text-subtle); }
.empty .e-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-sunken); display: grid; place-items: center; margin: 0 auto 14px; color: var(--text-faint); }

/* Divider */
.hr { height: 1px; background: var(--border); border: 0; margin: 18px 0; }

/* Stagger reveal helper */
.stagger > * { opacity: 0; transform: translateY(8px); animation: fadeUp 360ms var(--ease-out) forwards; }
.stagger > *:nth-child(1){animation-delay:30ms}.stagger > *:nth-child(2){animation-delay:80ms}
.stagger > *:nth-child(3){animation-delay:130ms}.stagger > *:nth-child(4){animation-delay:180ms}
.stagger > *:nth-child(5){animation-delay:230ms}.stagger > *:nth-child(6){animation-delay:280ms}
@keyframes fadeUp { to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------------------
   5. SIGNATURE — Document viewer + source-linking ("evidence")
---------------------------------------------------------------------------- */
.evidence { display: grid; grid-template-columns: 1.05fr 1fr; gap: 0; }
.evidence-doc {
  background: var(--surface-sunken); border-right: 1px solid var(--border);
  padding: 22px; position: relative; min-height: 520px;
}
.evidence-panel { padding: 4px; }
.doc-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.doc-tab { font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 8px; cursor: pointer; color: var(--text-subtle); border: 1px solid transparent; }
.doc-tab.is-active { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--shadow-xs); }

/* The paper */
.paper {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-md); padding: 26px 28px; position: relative;
  max-width: 460px; margin: 0 auto; font-size: 13px; color: #1c2433;
}
.paper.passport { background: linear-gradient(160deg,#f3f1e9,#eceadf); border-color:#d9d4c2; }
.paper .doc-kicker { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-faint); }
.paper h4 { font-family: var(--font-serif); font-size: 16px; margin: 2px 0 14px; }
.paper .pp-photo { width: 64px; height: 80px; border-radius: 4px; background: linear-gradient(160deg,#c9cdd6,#aeb4c0); float: right; border: 1px solid rgba(0,0,0,.1); }
.paper dl { display: grid; grid-template-columns: 120px 1fr; gap: 7px 10px; margin: 0; }
.paper dt { color: var(--text-subtle); font-size: 11.5px; }
.paper dd { margin: 0; font-weight: 500; }
.paper .mrz { margin-top: 16px; padding-top: 12px; border-top: 1px dashed #c7c1ad; font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; color: #3a4256; word-break: break-all; }
.paper .stmt-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--border-2); font-size: 12px; }
.paper .stmt-row .amt { font-family: var(--font-mono); }

/* highlightable regions */
.region {
  background: transparent; color: inherit; border-radius: 4px; padding: 0 2px;
  box-shadow: 0 0 0 0 transparent; transition: background var(--t-pop) var(--ease-out), box-shadow var(--t-pop) var(--ease-out);
  cursor: pointer; scroll-margin: 40px;
}
.region:hover { background: rgba(245,158,11,.16); }
.region.lit {
  background: var(--highlight-glow);
  box-shadow: 0 0 0 2px var(--highlight), 0 4px 14px var(--highlight-glow);
}
.scanline { position: absolute; left: 22px; right: 22px; height: 38px; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(37,99,235,.18), transparent);
  border-top: 1px solid rgba(37,99,235,.5); border-bottom: 1px solid rgba(37,99,235,.5);
  opacity: 0; }
.is-scanning .scanline { opacity: 1; animation: scan 1.5s var(--ease-in-out); }
@keyframes scan { 0%{ top: 40px; } 100%{ top: calc(100% - 70px); } }

/* extracted field rows */
.xfield {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  margin-bottom: 8px; background: var(--surface);
  transition: border-color var(--t-hover) var(--ease-out), box-shadow var(--t-hover) var(--ease-out), background var(--t-hover) var(--ease-out);
  cursor: pointer;
}
.xfield:hover { border-color: var(--ink-soft); box-shadow: var(--shadow-sm); }
.xfield.active { border-color: var(--highlight); box-shadow: 0 0 0 1px var(--highlight); background: #FFFDF8; }
.xfield .xk { font-size: 11.5px; color: var(--text-subtle); font-weight: 500; }
.xfield .xv { font-family: var(--font-mono); font-size: 13.5px; font-weight: 500; color: var(--text); grid-column: 1; }
.xfield .xmeta { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

/* audit timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--border-2); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.tl-item.ok::before { border-color: var(--pass); background: var(--pass); box-shadow: 0 0 0 3px var(--pass-bg); }
.tl-item.act::before { border-color: var(--ink-interactive); background: var(--ink-interactive); box-shadow: 0 0 0 3px var(--ink-tint); }
.tl-item .tl-t { font-size: 13.5px; font-weight: 600; }
.tl-item .tl-m { font-size: 12.5px; color: var(--text-muted); }
.tl-item .tl-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

/* checklist */
.check { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; background: var(--surface); transition: box-shadow var(--t-hover) var(--ease-out); }
.check:hover { box-shadow: var(--shadow-sm); }
.check .ck-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.check .ck-ico svg { width: 16px; height: 16px; }
.check.ok .ck-ico { background: var(--pass-bg); color: var(--pass); }
.check.warn .ck-ico { background: var(--warn-bg); color: var(--warn); }
.check.fail .ck-ico { background: var(--fail-bg); color: var(--fail); }
.check.pending .ck-ico { background: var(--surface-sunken); color: var(--text-faint); }
.check .ck-name { font-weight: 600; font-size: 14px; }
.check .ck-sub { font-size: 12px; color: var(--text-subtle); }
.check.warn { border-color: var(--warn-line); background: linear-gradient(0deg, var(--warn-bg), transparent 60%); }
.check.warn.resolved { border-color: var(--pass-line); background: linear-gradient(0deg, var(--pass-bg), transparent 60%); transition: background 500ms var(--ease-out), border-color 500ms var(--ease-out); }

/* score ring */
.ring { --p: 0; width: 124px; height: 124px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--rc, var(--ink-interactive)) calc(var(--p) * 1%), var(--border-2) 0); }
.ring::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface); }
.ring .ring-in { position: relative; text-align: center; }
.ring .ring-in b { font-family: var(--font-serif); font-size: 30px; }
.ring .ring-in span { display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-subtle); }

/* letter editor */
.letter {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-sm);
  padding: 40px 46px; font-family: var(--font-serif); font-size: 14px; line-height: 1.85; color: #20262f; max-width: 640px;
}
.letter p { margin-bottom: 14px; }
.letter .lh { display: flex; justify-content: space-between; margin-bottom: 26px; align-items: flex-start; }
.letter .fact { background: var(--accent-soft); border-bottom: 1px solid #E7C79B; padding: 0 2px; border-radius: 3px; }

/* trust badges */
.badge-trust { display: flex; align-items: center; gap: 11px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.badge-trust .bt-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--pass-bg); color: var(--pass); display: grid; place-items: center; flex: none; }
.badge-trust .bt-ico svg { width: 20px; height: 20px; }
.badge-trust .bt-t { font-weight: 600; font-size: 13.5px; }
.badge-trust .bt-s { font-size: 12px; color: var(--text-subtle); }

/* callout */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--info-line); background: var(--info-bg); }
.callout svg { width: 18px; height: 18px; color: var(--info); flex: none; margin-top: 1px; }
.callout.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.callout.warn svg { color: var(--accent); }
.callout .co-t { font-weight: 600; font-size: 13.5px; }
.callout .co-m { font-size: 12.5px; color: var(--text-muted); }

/* demo flow bar */
.flowbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  display: none; align-items: center; gap: 10px; padding: 8px 8px 8px 16px;
  background: var(--ink-deep); color: #fff; border-radius: var(--r-pill); box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-ink);
}
.flowbar .fl-step { font-size: 12px; color: var(--text-on-ink-muted); font-family: var(--font-mono); }
.flowbar .fl-step b { color: #fff; }
.flowbar .fl-title { font-size: 13px; font-weight: 600; margin-right: 4px; }

/* ----------------------------------------------------------------------------
   6. LANDING / LOGIN (Enterprise Gateway)
---------------------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; position: relative; z-index: 1; }
.auth-hero {
  background:
    radial-gradient(130% 80% at 0% 0%, rgba(37,99,235,.30), transparent 55%),
    radial-gradient(90% 70% at 100% 100%, rgba(180,83,9,.20), transparent 60%),
    linear-gradient(160deg, var(--ink-deep), var(--ink-deeper));
  color: #fff; padding: 46px 54px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-hero::after { content:""; position:absolute; inset:0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M0 39.5H40M39.5 0V40' stroke='%23ffffff' stroke-opacity='0.05'/%3E%3C/svg%3E"); }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .h-tag { display: inline-flex; align-items: center; gap: 7px; align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--highlight); background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); padding: 5px 12px; border-radius: 999px; }
.auth-hero h1 { font-family: var(--font-serif); font-size: 42px; line-height: 1.1; letter-spacing: -.02em; margin: 26px 0 16px; max-width: 14ch; }
.auth-hero h1 { color: #fff; }
.auth-hero .lede { font-size: 16px; color: var(--text-on-ink); max-width: 42ch; line-height: 1.6; }
.auth-hero .as b { color: #fff; }
.auth-card .brand-name { color: var(--ink-deep); }
.auth-card .brand-name b { color: var(--accent); }
.auth-card h2 { color: var(--text); }
.auth-stats { display: flex; gap: 30px; margin-top: 36px; }
.auth-stats .as b { font-family: var(--font-serif); font-size: 30px; display: block; }
.auth-stats .as span { font-size: 12px; color: var(--text-on-ink-muted); }
.auth-logos { margin-top: auto; }
.auth-logos .lbl { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-on-ink-muted); margin-bottom: 12px; }
.auth-logos .row { flex-wrap: wrap; gap: 10px 18px; }
.auth-logos .firm { font-family: var(--font-serif); font-size: 14.5px; color: rgba(255,255,255,.75); white-space: nowrap; }

.auth-form { background: var(--surface); display: flex; flex-direction: column; justify-content: center; padding: 46px 54px; }
.auth-card { width: 100%; max-width: 360px; margin: 0 auto; }
.auth-card .a-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.auth-card h2 { font-family: var(--font-serif); font-size: 24px; }
.auth-card .a-sub { color: var(--text-muted); margin: 4px 0 26px; font-size: 14px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-faint); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ----------------------------------------------------------------------------
   7. RESPONSIVE
---------------------------------------------------------------------------- */
.menu-btn { display: none; }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 256px; transform: translateX(-100%); transition: transform var(--t-drawer) var(--ease-drawer); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-xl); }
  .menu-btn { display: grid; }
  .evidence { grid-template-columns: 1fr; }
  .evidence-doc { border-right: 0; border-bottom: 1px solid var(--border); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 80px; }
  .topbar { padding: 0 14px; }
  .searchbox { display: none; }
  .page-head .ttl { font-size: 22px; }
  .split-2 { grid-template-columns: 1fr !important; }
  .flowbar { left: 12px; right: 12px; transform: none; bottom: 12px; }
  .crumbs { display: none; }
  .topbar-actions .pill { display: none; }
  .page-head .spacer { display: none; }
}

/* split helper used by several views */
.split-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; }
.split-doc { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .split-doc { grid-template-columns: 1fr; } }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .view.is-active, .stagger > * { opacity: 1 !important; transform: none !important; }
}

/* print */
@media print { .sidebar, .topbar, .flowbar, .toast-host { display: none !important; } .app { display: block; } }

/* utility */
.hidden { display: none !important; }
.clickable { cursor: pointer; }

/* Icons (inline SVG sprite, line style) */
.ic { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; width: 18px; height: 18px; vertical-align: middle; flex: none; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }
.ic-xl { width: 28px; height: 28px; }
svg.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
