/* ============================================================
   Vellum — Documents in, data out.
   Design system  ·  "Warm paper + saffron highlighter" aesthetic
   Concept: an AI that reads and highlights documents.
   Fonts: Fraunces (display/wordmark) · Instrument Sans (UI)
          IBM Plex Mono (data)
   NOTE: the --scan* variables are the SAFFRON brand accent
   (name kept from v1 so all component CSS keeps working).
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Neutrals (light) — warm paper / ink */
  --paper:        #faf6ef;
  --surface:      #fffdf9;
  --surface-2:    #f7f2ea;
  --surface-3:    #f0e9dd;
  --line:         #e7ddcd;
  --line-strong:  #dccdb6;

  --ink:          #2a2320;
  --ink-2:        #574c44;
  --ink-3:        #857767;
  --ink-4:        #b0a291;

  /* Brand — saffron highlighter */
  --scan:         #f2a516;
  --scan-strong:  #d9880b;
  --scan-soft:    #fdeecb;
  --scan-glow:    rgba(242, 165, 22, 0.34);
  --ink-deep:     #241d18;   /* warm espresso for sidebar / hero fields */

  /* Semantic */
  --ok:           #5e8c6a;   /* verified sage */
  --ok-soft:      #e0ebdf;
  --warn:         #c98a1e;   /* ochre */
  --warn-soft:    #f8ebcf;
  --danger:       #d9603b;   /* clay */
  --danger-soft:  #f8e0d5;
  --info:         #8a6a8f;   /* muted plum */
  --info-soft:    #efe4ef;

  /* Elevation — warm-tinted shadows */
  --shadow-xs: 0 1px 2px rgba(58,42,24,.06);
  --shadow-sm: 0 1px 3px rgba(58,42,24,.09), 0 1px 2px rgba(58,42,24,.05);
  --shadow-md: 0 4px 16px rgba(58,42,24,.10), 0 2px 4px rgba(58,42,24,.06);
  --shadow-lg: 0 18px 44px rgba(58,42,24,.16), 0 6px 14px rgba(58,42,24,.08);
  --shadow-scan: 0 0 0 1px var(--scan), 0 8px 30px var(--scan-glow);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  /* Type */
  --font-display: "Fraunces", "Instrument Sans", Georgia, serif;
  --font-body:    "Instrument Sans", system-ui, -apple-system, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  /* Spacing rhythm */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Layout */
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
}

/* ---------- Dark theme — warm espresso, not black ---------- */
:root[data-theme="dark"] {
  --paper:        #1b1611;
  --surface:      #241d18;
  --surface-2:    #1f1914;
  --surface-3:    #2e251d;
  --line:         #3a2f25;
  --line-strong:  #4a3c2f;

  --ink:          #f5ede1;
  --ink-2:        #d6c8b6;
  --ink-3:        #a4937f;
  --ink-4:        #71614f;

  --scan:         #f7b53d;   /* warmer saffron pops on espresso */
  --scan-strong:  #f2a516;
  --scan-soft:    #3d2f14;
  --scan-glow:    rgba(247, 181, 61, 0.34);
  --ink-deep:     #14100c;

  --ok:           #7aa889;
  --ok-soft:      #223226;
  --warn:         #dba13a;
  --warn-soft:    #3a2c12;
  --danger:       #e5734f;
  --danger-soft:  #3a1f15;
  --info:         #b18fb5;
  --info-soft:    #2f2231;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.5), 0 2px 4px rgba(0,0,0,.3);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.6), 0 6px 14px rgba(0,0,0,.4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  transition: background .35s var(--ease), color .35s var(--ease);
}
h1,h2,h3,h4,h5 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; line-height: 1.12; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--scan-glow); color: var(--ink); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   App shell
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--ink-deep);
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column;
  padding: var(--sp-5) var(--sp-4);
  z-index: 40;
}
:root[data-theme="dark"] .sidebar { background: #060a11; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px var(--sp-6); }
.brand__mark { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--scan) 0%, var(--scan-strong) 100%);
  box-shadow: 0 4px 14px var(--scan-glow); }
.brand__mark svg { width: 20px; height: 20px; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: #fff; letter-spacing: -.02em; }
.brand__name b { color: var(--scan); }
.brand__tag { display:block; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.42); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.34); padding: var(--sp-4) 10px var(--sp-2); }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px;
  color: rgba(255,255,255,.66); font-weight: 500; font-size: 13.5px;
  position: relative; transition: background .18s var(--ease), color .18s var(--ease);
}
.nav__item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item.is-active { background: rgba(11,181,196,.14); color: #fff; }
.nav__item.is-active::before { content:""; position: absolute; left: -4px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 3px; background: var(--scan); box-shadow: 0 0 10px var(--scan); }
.nav__item.is-active svg { opacity: 1; color: var(--scan); }
.nav__badge { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; background: var(--scan); color: #3a2708; padding: 1px 7px; border-radius: var(--r-full); }
.nav__badge--warn { background: var(--warn); color: #3a2600; }

.sidebar__foot { margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid rgba(255,255,255,.07); }
.userchip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; transition: background .18s; }
.userchip:hover { background: rgba(255,255,255,.06); }
.userchip__av { width: 32px; height: 32px; border-radius: 9px; flex: none; background: linear-gradient(135deg,#3b7ff5,#8b5cf6); display: grid; place-items: center; color:#fff; font-weight: 700; font-size: 13px; }
.userchip__meta { min-width: 0; display: block; }
.userchip__name { display: block; color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip__role { display: block; color: rgba(255,255,255,.45); font-size: 11px; line-height: 1.2; }

/* ---------- Main + topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-8);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.topbar__crumbs b { color: var(--ink); font-weight: 600; }
.topbar__crumbs svg { width: 14px; height: 14px; opacity: .5; }
.topbar__spacer { flex: 1; }

.searchbox { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-full); padding: 7px 14px; width: 260px; color: var(--ink-3); transition: border-color .18s, box-shadow .18s; }
.searchbox:focus-within { border-color: var(--scan); box-shadow: 0 0 0 3px var(--scan-glow); }
.searchbox svg { width: 15px; height: 15px; flex: none; }
.searchbox input { border: none; outline: none; background: none; flex: 1; font-size: 13px; }
.searchbox kbd { font-family: var(--font-mono); font-size: 10px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink-4); }

.iconbtn { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); transition: all .18s var(--ease); position: relative; }
.iconbtn:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn__dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

/* ---------- Topbar dropdowns: search + notifications ---------- */
.searchwrap { position: relative; }
.notifwrap { position: relative; }
.search-results, .notif-panel {
  position: absolute; top: calc(100% + 10px); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  z-index: 60; overflow: hidden; animation: pop .16s var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.search-results { left: 0; width: 340px; padding: 6px; }
.search-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm); }
.search-item:hover { background: var(--surface-2); }
.search-item__ico { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-3); }
.search-item__ico svg { width: 16px; height: 16px; }
.search-item__t { display: block; font-size: 13px; font-weight: 600; }
.search-item__s { display: block; font-size: 11.5px; color: var(--ink-3); font-family: var(--font-mono); }

.notif-panel { right: 0; width: 340px; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background .14s; }
.notif-item:hover { background: var(--surface-2); }
.notif-item__ico { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.notif-item__ico svg { width: 15px; height: 15px; }
.notif-item__txt { font-size: 13px; min-width: 0; }
.notif-item__time { color: var(--ink-4); font-size: 11px; font-family: var(--font-mono); margin-top: 2px; }
.notif-panel__foot { display: block; text-align: center; padding: 11px; font-size: 12.5px; font-weight: 600; color: var(--scan-strong); }
.notif-panel__foot:hover { background: var(--surface-2); }

/* ---------- Page canvas ---------- */
.page { padding: var(--sp-8); max-width: 1440px; width: 100%; margin: 0 auto; }
.page--flush { padding: 0; max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head .sub { color: var(--ink-3); font-size: 14px; margin-top: 5px; }
.page-head__actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   Buttons
   ============================================================ */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--r-sm); font-weight: 600; font-size: 13.5px; transition: all .16s var(--ease); border: 1px solid transparent; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: linear-gradient(180deg, var(--scan) 0%, var(--scan-strong) 100%); color: #3a2708; box-shadow: 0 2px 10px var(--scan-glow), inset 0 1px 0 rgba(255,255,255,.35); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--scan-glow), inset 0 1px 0 rgba(255,255,255,.3); }
.btn--primary:active { transform: translateY(0); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); box-shadow: var(--shadow-xs); }
.btn--ghost:hover { border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn--dark { background: var(--ink); color: var(--paper); }
.btn--dark:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ============================================================
   Cards & surfaces
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.card__head h3 { font-size: 15px; }
.card__head .card__sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.stat { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat::after { content:""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--scan), transparent); opacity: .0; transition: opacity .2s; }
.stat:hover::after { opacity: 1; }
.stat__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.stat__ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--scan-soft); color: var(--scan-strong); }
.stat__ico svg { width: 20px; height: 20px; }
.stat__ico--ok { background: var(--ok-soft); color: var(--ok); }
.stat__ico--warn { background: var(--warn-soft); color: var(--warn); }
.stat__ico--info { background: var(--info-soft); color: var(--info); }
.stat__delta { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: var(--r-full); display: inline-flex; align-items: center; gap: 3px; }
.stat__delta--up { background: var(--ok-soft); color: var(--ok); }
.stat__delta--down { background: var(--danger-soft); color: var(--danger); }
.stat__val { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.stat__val small { font-size: 16px; color: var(--ink-3); font-weight: 600; }
.stat__label { color: var(--ink-3); font-size: 13px; margin-top: 6px; }

/* ============================================================
   Pills / chips / meters
   ============================================================ */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-full); font-family: var(--font-mono); letter-spacing: .01em; white-space: nowrap; }
.pill::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--danger { background: var(--danger-soft); color: var(--danger); }
.pill--info { background: var(--info-soft); color: var(--info); }
.pill--scan { background: var(--scan-soft); color: var(--scan-strong); }
.pill--muted { background: var(--surface-3); color: var(--ink-3); }
.pill--dot-pulse::before { animation: pulse-dot 1.4s var(--ease) infinite; }
@keyframes pulse-dot { 0%,100%{ box-shadow: 0 0 0 0 currentColor; opacity:1 } 50%{ box-shadow: 0 0 0 4px transparent; opacity:.5 } }

.tag { font-family: var(--font-mono); font-size: 11px; padding: 2px 7px; border-radius: 5px; background: var(--surface-3); color: var(--ink-3); border: 1px solid var(--line); }

/* Confidence meter */
.conf { display: flex; align-items: center; gap: 8px; }
.conf__bar { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; min-width: 46px; }
.conf__fill { height: 100%; border-radius: 6px; width: 0; transition: width 1s var(--ease-out); }
.conf__fill--hi { background: linear-gradient(90deg, var(--ok), #2fd18e); }
.conf__fill--mid { background: linear-gradient(90deg, var(--warn), #f0b24a); }
.conf__fill--lo { background: linear-gradient(90deg, var(--danger), #f07b77); }
.conf__val { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; min-width: 34px; text-align: right; }
.conf__val--hi { color: var(--ok); }
.conf__val--mid { color: var(--warn); }
.conf__val--lo { color: var(--danger); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th { text-align: left; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; padding: 12px var(--sp-5); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody td { padding: 14px var(--sp-5); border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background .14s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-strong { font-weight: 600; color: var(--ink); }
.td-sub { color: var(--ink-3); font-size: 12px; }
.doc-cell { display: flex; align-items: center; gap: 11px; }
.doc-thumb { width: 34px; height: 42px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-3); flex: none; display: grid; place-items: center; color: var(--ink-4); position: relative; overflow: hidden; }
.doc-thumb svg { width: 16px; height: 16px; }
.doc-thumb::before { content:""; position: absolute; inset: 5px 5px auto; height: 2px; background: var(--ink-4); opacity: .25; box-shadow: 0 5px 0 var(--ink-4), 0 10px 0 var(--ink-4), 0 15px 0 var(--ink-4); }

/* ============================================================
   Forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.input, .select { width: 100%; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); font-size: 13.5px; transition: border-color .16s, box-shadow .16s; }
.input:focus, .select:focus { outline: none; border-color: var(--scan); box-shadow: 0 0 0 3px var(--scan-glow); }
.input--mono { font-family: var(--font-mono); }

/* Toggle switch */
.switch { position: relative; width: 42px; height: 24px; border-radius: var(--r-full); background: var(--line-strong); transition: background .2s var(--ease); flex: none; cursor: pointer; }
.switch::after { content:""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .22s var(--ease); }
.switch.is-on { background: var(--scan); }
.switch.is-on::after { transform: translateX(18px); }

/* Range */
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px; background: var(--surface-3); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--scan); cursor: pointer; box-shadow: 0 2px 8px var(--scan-glow); border: 3px solid var(--surface); }

/* ============================================================
   Scanner motif — scan line
   ============================================================ */
.scanline { position: absolute; left: 0; right: 0; height: 44px; pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--scan-glow) 60%, transparent);
  border-top: 1.5px solid var(--scan); box-shadow: 0 0 24px var(--scan-glow); opacity: 0; }
.is-scanning .scanline { animation: scan-sweep 1.7s var(--ease) infinite; opacity: 1; }
@keyframes scan-sweep { 0% { top: -44px; } 100% { top: 100%; } }

/* Grain overlay for hero backdrops */
.grain::before {
  content:""; position: absolute; inset: 0; pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
}

/* ============================================================
   Activity / log feed
   ============================================================ */
.feed { display: flex; flex-direction: column; }
.feed__item { display: flex; gap: 12px; padding: 12px var(--sp-5); border-bottom: 1px solid var(--line); }
.feed__item:last-child { border-bottom: none; }
.feed__ico { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.feed__ico svg { width: 15px; height: 15px; }
.feed__txt { font-size: 13px; min-width: 0; }
.feed__txt b { font-weight: 600; }
.feed__time { color: var(--ink-4); font-size: 11.5px; font-family: var(--font-mono); margin-top: 2px; }

/* Log terminal (autofill) */
.logbox { background: var(--ink-deep); border-radius: var(--r-md); padding: var(--sp-4); font-family: var(--font-mono); font-size: 12px; height: 100%; overflow-y: auto; color: rgba(255,255,255,.85); }
.log-line { display: flex; gap: 9px; padding: 3px 0; opacity: 0; transform: translateY(4px); animation: log-in .3s var(--ease-out) forwards; }
@keyframes log-in { to { opacity: 1; transform: none; } }
.log-line__t { color: rgba(255,255,255,.4); flex: none; }
.log-line__m { color: rgba(255,255,255,.82); }
.log-line--ok .log-line__m { color: #4fe0a5; }
.log-line--scan .log-line__m { color: var(--scan); }
.log-line--warn .log-line__m { color: #f5c46b; }

/* ============================================================
   Extract & Review (hero 1)
   ============================================================ */
.extract-grid { display: grid; grid-template-columns: 1fr 440px; gap: var(--sp-5); align-items: start; }
.docstage-wrap { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); }
.docstage { position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md); }
.docstage__inner { position: relative; }
.docstage__inner img { width: 100%; display: block; }
.boxlayer { position: absolute; inset: 0; transition: opacity .3s var(--ease); }
.obox { position: absolute; border: 1.5px solid var(--scan); border-radius: 4px; background: rgba(11,181,196,.06); cursor: pointer; transition: all .16s var(--ease); }
.obox__tag { position: absolute; top: -22px; left: -1px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: #fff; background: var(--scan-strong); padding: 2px 6px; border-radius: 4px; white-space: nowrap; opacity: 0; transform: translateY(3px); transition: all .16s var(--ease); pointer-events: none; box-shadow: var(--shadow-sm); }
.obox--mid { border-color: var(--warn); background: rgba(224,149,27,.07); }
.obox--mid .obox__tag { background: var(--warn); }
.obox--lo { border-color: var(--danger); background: rgba(224,82,77,.08); border-style: dashed; }
.obox--lo .obox__tag { background: var(--danger); }
.obox:hover, .obox.is-linked { background: rgba(11,181,196,.16); box-shadow: 0 0 0 3px var(--scan-glow); z-index: 5; }
.obox--mid:hover, .obox--mid.is-linked { background: rgba(224,149,27,.18); box-shadow: 0 0 0 3px rgba(224,149,27,.28); }
.obox--lo:hover, .obox--lo.is-linked { background: rgba(224,82,77,.2); box-shadow: 0 0 0 3px rgba(224,82,77,.28); }
.obox:hover .obox__tag, .obox.is-linked .obox__tag { opacity: 1; transform: none; }

.field-panel { display: flex; flex-direction: column; gap: var(--sp-4); }
.fgroup { }
.fgroup__title { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; padding: 4px 2px 10px; }
.frow { padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid transparent; transition: background .14s, border-color .14s; margin-bottom: 4px; }
.frow.is-linked { background: var(--surface-2); border-color: var(--scan); }
.frow__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.frow__head label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; }
.frow__head .conf { width: 96px; flex: none; }
.frow input { background: var(--surface-2); }
.frow.is-linked input { border-color: var(--scan); }

.litems { display: flex; flex-direction: column; gap: 6px; }
.litem { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.litem__desc { font-size: 12.5px; font-weight: 500; margin-bottom: 5px; }
.litem__meta { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--ink-3); }
.litem__meta b { color: var(--ink); margin-left: auto; }

/* ============================================================
   Auto-Fill / Screen Reading (hero 2)
   ============================================================ */
.mock-window { border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); background: var(--surface); position: relative; }
.mock-window__bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-3); border-bottom: 1px solid var(--line); }
.mock-window__dots { display: flex; gap: 6px; }
.mock-window__dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.mock-window__url { flex: 1; text-align: center; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.mock-window__body { padding: var(--sp-6); position: relative; }
.mock-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4) var(--sp-5); }
.mfield { display: flex; flex-direction: column; gap: 5px; position: relative; }
.mfield--full { grid-column: 1 / -1; }
.mfield label { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.mfield__input { min-height: 40px; border: 1.5px solid var(--line-strong); border-radius: 8px; padding: 9px 12px; font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); color: var(--ink); display: flex; align-items: center; transition: border-color .2s, box-shadow .2s, background .2s; }
.mfield.is-target .mfield__input { border-color: var(--scan); box-shadow: 0 0 0 3px var(--scan-glow); background: var(--surface); }
.mfield.is-done .mfield__input { border-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface)); }
.mfield.is-reading label { color: var(--scan-strong); }
.mfield__caret { display: inline-block; width: 2px; height: 16px; background: var(--scan); margin-left: 1px; animation: blink 1s steps(1) infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: 0; } }
.mfield__check { position: absolute; right: 10px; bottom: 11px; color: var(--ok); opacity: 0; transform: scale(.6); transition: all .25s var(--ease-out); }
.mfield.is-done .mfield__check { opacity: 1; transform: scale(1); }
.mfield__check svg { width: 16px; height: 16px; }

/* the robot cursor */
.bot-cursor { position: absolute; width: 34px; height: 34px; z-index: 20; pointer-events: none; transition: transform .55s var(--ease); filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); opacity: 0; }
.bot-cursor.is-live { opacity: 1; }
.bot-cursor__scan { position: absolute; inset: -6px; border: 2px solid var(--scan); border-radius: 8px; opacity: 0; }
.bot-cursor.is-reading .bot-cursor__scan { animation: bot-read .8s var(--ease) infinite; }
@keyframes bot-read { 0%,100% { opacity: .2; transform: scale(1); } 50% { opacity: .9; transform: scale(1.08); } }

.rpa-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.speed { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.speed input { width: 96px; }

/* ============================================================
   Ingest / dropzone
   ============================================================ */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--r-lg); padding: var(--sp-12) var(--sp-6); text-align: center; background: var(--surface-2); transition: all .2s var(--ease); cursor: pointer; position: relative; overflow: hidden; }
.dropzone:hover, .dropzone.is-drag { border-color: var(--scan); background: var(--scan-soft); }
.dropzone__ico { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto var(--sp-4); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--scan-strong); box-shadow: var(--shadow-sm); }
.dropzone__ico svg { width: 30px; height: 30px; }
.dropzone h3 { font-size: 18px; margin-bottom: 6px; }
.source-card { display: flex; align-items: center; gap: 12px; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); transition: all .18s var(--ease); cursor: pointer; }
.source-card:hover { border-color: var(--scan); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.source-card__ico { width: 42px; height: 42px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.source-card__ico svg { width: 20px; height: 20px; }

/* ============================================================
   Mapping
   ============================================================ */
.map-cols { display: grid; grid-template-columns: 1fr 60px 1fr; gap: 0; align-items: start; }
.map-col__head { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; margin-bottom: var(--sp-3); padding: 0 4px; }
.map-node { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); margin-bottom: 10px; height: 52px; box-shadow: var(--shadow-xs); }
.map-node__label { font-size: 13px; font-weight: 600; }
.map-node__val { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-left: auto; }
.map-node__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--scan); flex: none; box-shadow: 0 0 0 3px var(--scan-glow); }
.map-mid { position: relative; align-self: stretch; }
.map-connectors { position: absolute; inset: 0; }

/* ============================================================
   Approvals — kanban
   ============================================================ */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.kcol__head { display: flex; align-items: center; gap: 9px; padding: 4px 6px 14px; font-weight: 600; font-size: 13.5px; }
.kcol__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.kcol__count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); padding: 1px 8px; border-radius: var(--r-full); }
.appr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow-xs); margin-bottom: 12px; transition: transform .16s var(--ease), box-shadow .16s var(--ease); cursor: grab; }
.appr:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.appr:last-child { margin-bottom: 0; }
.appr__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.appr__id { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.appr__amt { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.appr__vendor { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.appr__rule { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-family: var(--font-mono); color: var(--ink-3); background: var(--surface-3); padding: 3px 8px; border-radius: var(--r-full); }
.appr__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.appr__who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.appr__av { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-size: 10.5px; font-weight: 700; background: linear-gradient(135deg, var(--info), var(--ink-3)); }
.appr__actions { display: flex; gap: 6px; }
.appr-btn { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); transition: all .14s; }
.appr-btn svg { width: 15px; height: 15px; }
.appr-btn--ok:hover { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.appr-btn--no:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ============================================================
   Document detail — audit timeline
   ============================================================ */
.timeline { position: relative; padding-left: 8px; }
.tl-item { position: relative; padding: 0 0 26px 34px; }
.tl-item::before { content:""; position: absolute; left: 10px; top: 22px; bottom: -4px; width: 2px; background: var(--line-strong); }
.tl-item:last-child::before { display: none; }
.tl-dot { position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--scan); z-index: 1; }
.tl-dot svg { width: 10px; height: 10px; color: var(--scan-strong); }
.tl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.tl-head b { font-size: 13.5px; }
.tl-time { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); margin-left: auto; }
.tl-detail { font-size: 13px; color: var(--ink-2); }
.tl-who { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ============================================================
   Templates — document-type cards
   ============================================================ */
.dtype-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.dtype { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.dtype:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.dtype--draft { opacity: .7; border-style: dashed; }
.dtype__top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.dtype__ico { width: 46px; height: 56px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-3); position: relative; overflow: hidden; flex: none; }
.dtype__ico::before { content:""; position: absolute; inset: 8px 8px auto; height: 2px; background: var(--ink-4); opacity: .3; box-shadow: 0 6px 0 var(--ink-4), 0 12px 0 var(--ink-4), 0 18px 0 var(--ink-4), 0 24px 0 var(--ink-4); }
.dtype__ico::after { content:""; position: absolute; left: 8px; top: 20px; width: 22px; height: 4px; border-radius: 2px; background: var(--scan); opacity: .5; }
.dtype h3 { font-size: 17px; margin-bottom: 6px; }
.dtype p { font-size: 13px; color: var(--ink-2); line-height: 1.5; min-height: 40px; }
.dtype__stats { display: flex; gap: 18px; margin: 14px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dtype__stat { }
.dtype__stat b { display: block; font-family: var(--font-mono); font-size: 15px; font-weight: 600; }
.dtype__stat small { font-size: 11px; color: var(--ink-3); }

/* ============================================================
   Utilities
   ============================================================ */
.grid { display: grid; gap: var(--sp-4); }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-main { grid-template-columns: 1fr 340px; }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }
.center { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--font-mono); }
.tiny { font-size: 11.5px; }
.text-scan { color: var(--scan-strong); }
.divider { height: 1px; background: var(--line); margin: var(--sp-5) 0; }

/* ---------- Reveal-on-load orchestration ---------- */
.reveal { opacity: 0; transform: translateY(14px); animation: reveal .6s var(--ease-out) forwards; }
@keyframes reveal { to { opacity: 1; transform: none; } }
.reveal[style*="--d"] { animation-delay: var(--d); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--ink-3); }
.empty svg { width: 44px; height: 44px; color: var(--ink-4); margin: 0 auto var(--sp-4); }

/* ---------- Segmented control / tabs ---------- */
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { padding: 6px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); transition: all .16s; }
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--sp-6); }
.tabs button { padding: 11px 16px; font-weight: 600; font-size: 13.5px; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .16s, border-color .16s; }
.tabs button:hover { color: var(--ink); }
.tabs button.is-active { color: var(--scan-strong); border-bottom-color: var(--scan); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  :root { --sidebar-w: 76px; }
  .brand__name, .brand__tag, .nav__label, .nav__item span, .nav__badge, .userchip__meta { display: none; }
  .brand { justify-content: center; padding: 4px 0 var(--sp-6); }
  .nav__item { justify-content: center; padding: 11px; }
  .userchip { justify-content: center; }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .searchbox { display: none; }
  .page { padding: var(--sp-5); }
  .topbar { padding: 0 var(--sp-5); }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
}
