/* ==========================================================================
   Appel Money — shared design system + app shell (v20).
   --------------------------------------------------------------------------
   Every view inherits these components. Themes (themes.css) supply ONLY
   color tokens; no component here may hard-code a color — always use a
   var(--token). Non-color tokens (type scale, radii, fonts) live in :root
   below so all 10 themes inherit them.

   COMPONENT CONTRACT (for wave-2 view builders — class names are the API):
     Layout   : .view-head (+ .view-icon tile, .view-head-text, .view-sub,
                .view-actions), .toolbar (+ .spacer), .grid, .stats, .cols,
                .email-layout > .email-main + .email-rail
     Type     : .t-display .t-section .t-card-title .t-body .t-small .t-meta
                .lead .note .mono .ref .num .neg
     Cards    : .card (+ .k label, .v value, .s sub-line),
                .stat-card (+ .stat-ic, .stat-tx, .k, .v, .s)  [preferred]
     Tables   : table inside .table-wrap (auto-wrapped by JS observer);
                th small-caps; td.num right-aligned tabular; tr.clickable
     Status   : .pill + p-* (p-pass/p-fail/p-unknown, p-proposed…,
                p-needs_review, p-quarantined, p-info, …)
     Actions  : .btn (primary) / .btn.secondary / .btn.ghost / .btn.danger,
                .btn.sm .btn.lg, grouped in .btnrow
     Tabs     : .tabs > .btn (+ .btn.ghost for inactive) + .tab-count badge
     Forms    : form.form > label > input/select; .field block; .inline-input
     Feedback : .alert(.info/.good/.warn/.bad), .empty-state, .modal in
                .modal-backdrop, .toast(.err), .progress, .rule2, .chain
     Misc     : .filters, .intel-list, .badge, .chip, .kv, .divider
   ========================================================================== */

/* ---- non-color design tokens (shared by all themes) ---- */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs-display: 29px;   /* page titles (.view-head h2) */
  --fs-section: 16px;   /* h3 section heads */
  --fs-card-title: 14px;
  --fs-body: 13.5px;
  --fs-small: 12.5px;
  --fs-meta: 11px;      /* small caps labels, table headers */

  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; }
input, select, textarea { font: inherit; color: var(--ink); }
img, svg { vertical-align: middle; }

/* ---- type scale: one coherent scale, no ad-hoc sizes ----
   Views should reach for these utilities instead of inline font-size. */
.t-display { font-size: var(--fs-display); font-weight: 750; letter-spacing: -0.015em; line-height: 1.2; }
.t-section { font-size: var(--fs-section); font-weight: 700; letter-spacing: -0.005em; }
.t-card-title { font-size: var(--fs-card-title); font-weight: 650; }
.t-body { font-size: var(--fs-body); }
.t-small { font-size: var(--fs-small); }
.t-meta {
  font-size: var(--fs-meta);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lead { font-size: 14.5px; color: var(--ink-muted); max-width: 78ch; }
.note { font-size: var(--fs-small); color: var(--ink-muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
/* tabular numerals for every money figure */
.num, .card .v, .stat-card .v, .t-display {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
/* short human-readable reference code (presentation only — see shortRef()) */
.ref {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--ink-muted);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

h3 { margin: 26px 0 12px; font-size: var(--fs-section); font-weight: 700; letter-spacing: -0.005em; }
h3:first-child { margin-top: 0; }

/* ---- simulation banner (kept from v13; restyled) ---- */
.sim-banner {
  background: var(--sim);
  color: #fff;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 12px;
  font-weight: 700;
  position: relative;
  z-index: 60;
}
.sim-banner .ver-warn {
  background: #ffd60a;
  color: #3a2b00;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ---- app frame ---- */
.app { display: flex; min-height: calc(100vh - 30px); }

/* ---- sidebar (dark per approved mockup) ---- */
.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: calc(100vh - 30px);
  border-right: 1px solid var(--line-soft);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-mark { color: var(--accent); display: flex; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-text strong {
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--sidebar-ink);
  white-space: nowrap;
}
.brand-text span {
  font-size: 11.5px;
  color: var(--sidebar-ink-dim);
  white-space: nowrap;
}
#nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item, .nav-group-head {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--sidebar-ink-dim);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.nav-item svg, .nav-group-head svg { flex: 0 0 auto; opacity: 0.85; }
.nav-item:hover, .nav-group-head:hover {
  background: var(--sidebar-active);
  color: var(--sidebar-ink);
}
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-ink);
  font-weight: 650;
}
/* the group holding the active view is tinted (mockup's highlighted group) */
.nav-group.active-parent > .nav-group-head {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.nav-item .nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--sim-soft);
  color: var(--sim);
  padding: 2px 7px;
  border-radius: 999px;
}
.nav-group { display: flex; flex-direction: column; }
.nav-group-head .chev { margin-left: auto; transition: transform 0.15s; }
.nav-group.open .nav-group-head .chev { transform: rotate(180deg); }
.nav-children {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 4px 18px;
  border-left: 1px solid var(--line-soft);
  margin: 2px 0 2px 20px;
}
.nav-group.open .nav-children { display: flex; }
.nav-children .nav-item { font-size: 13px; padding: 8px 12px; }
.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.synth-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn);
  padding: 3px 9px;
  border-radius: var(--radius-xs);
}
.foot-note { font-size: 11px; color: var(--sidebar-ink-dim); line-height: 1.5; }

/* ---- main column + topbar ---- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.menu-btn { display: none; }
.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 200px;
  max-width: 420px;
  flex: 0 1 420px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 13.5px;
}
.search-trigger:hover { border-color: var(--accent); }
.search-trigger .search-ph { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger kbd {
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--ink-muted);
  font-family: inherit;
  flex: 0 0 auto;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-clock {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  text-align: right;
  padding: 2px 8px;
  border-left: 1px solid var(--line-soft);
}
.topbar-clock strong { font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.topbar-clock span { font-size: 11.5px; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.drop-wrap { position: relative; }
.theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-dots { display: inline-flex; }
.theme-dots i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  margin-left: -5px;
  display: inline-block;
}
.theme-dots i:first-child { margin-left: 0; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 250px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 70;
  max-height: 70vh;
  overflow-y: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  font-size: 13.5px;
  text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.active { background: var(--accent-soft); }
.menu-item .theme-dots { margin-right: 2px; }
.menu-item small { display: block; color: var(--ink-muted); font-size: 11.5px; }
.menu-item .check { margin-left: auto; color: var(--accent); font-weight: 700; }
.menu-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 8px 10px 4px;
}
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notif-menu { min-width: 320px; }
.notif-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.notif-row:hover { background: var(--surface-2); }
.notif-row strong { display: block; font-size: 13px; }
.notif-row span { font-size: 12px; color: var(--ink-muted); }
.notif-empty { padding: 14px; color: var(--ink-muted); font-size: 13px; text-align: center; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink-on-accent);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 12.5px; white-space: nowrap; }
.user-meta em { font-style: normal; font-size: 11px; color: var(--ink-muted); }

/* ---- view ---- */
#view {
  padding: 26px 30px 60px;
  max-width: 1460px;
  width: 100%;
  margin: 0 auto;
}

/* ---- view header: icon tile + title + subtitle, every view inherits it ----
   Signature: viewHead(title, sub, actions, iconName?) — icon is optional and
   maps to ICON_PATHS (e.g. "email", "bills"). */
.view-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 2px 0 18px;
}
.view-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 46px;
  border: 1px solid var(--line-soft);
}
.view-head-text { min-width: 0; }
.view-head h2 {
  margin: 0;
  font-size: var(--fs-display);
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.view-sub { margin: 6px 0 0; color: var(--ink-muted); font-size: 13.5px; max-width: 78ch; line-height: 1.55; }
.view-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: auto; align-items: center; flex-wrap: wrap; }

/* ---- toolbar: action row between header and content (mockup pattern) ---- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.toolbar .spacer { flex: 1 1 auto; }

/* ---- cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  min-width: 0;
}
.card .k {
  font-size: var(--fs-meta);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 650;
}
.card .v {
  font-size: 25px;
  font-weight: 750;
  margin: 6px 0 2px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.card .s { font-size: 12.5px; color: var(--ink-muted); line-height: 1.5; }
.card.flat { box-shadow: none; }

/* ---- stat cards: the mockup's KPI component (PREFERRED for new stat UI) ----
   Markup:
     <div class="stat-card">
       <span class="stat-ic" style="background:var(--info-soft);color:var(--info)">svg</span>
       <div class="stat-tx"><div class="k">Label</div><div class="v">12</div><div class="s">sub-line</div></div>
     </div>
   Grid them inside .stats. Legacy markup (.stats > .card > .stat-ic + .k + .v)
   keeps working and is styled identically. */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  min-width: 0;
}
.stat-card .stat-tx { min-width: 0; flex: 1; }
.stat-card .k, .stats .card .k {
  font-size: var(--fs-meta);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 650;
}
.stat-card .v, .stats .card .v {
  font-size: 23px;
  font-weight: 750;
  margin: 6px 0 2px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.stat-card .s, .stats .card .s { font-size: 12px; color: var(--ink-muted); line-height: 1.5; }
.stat-ic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
}
.stats .card .stat-ic { margin-bottom: 10px; }

/* ---- tables: one style app-wide ----
   Wrap is automatic (JS MutationObserver); headers are small-caps,
   rows highlight on hover, numerics right-align in tabular figures. */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line-soft); }
.table-wrap table { border: none; border-radius: 0; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  background: var(--bg-soft);
  font-size: var(--fs-meta);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 700;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); font-weight: 600; }

/* ---- pills / status badges: one vocabulary, color = meaning ----
   p-pass/p-settled/p-paid/p-confirmed = good · p-fail/p-failed/p-missed/
   p-quarantined = bad · p-open/p-needs_review/p-unmatched = warn ·
   p-info/p-matched = info · p-scheduled/p-dismissed/p-unknown = neutral */
.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.6;
}
.p-proposed { background: var(--warn-soft); color: var(--warn); }
.p-authorized { background: var(--accent-soft); color: var(--accent); }
.p-submitted { background: var(--sim-soft); color: var(--sim); }
.p-settled, .p-paid, .p-confirmed, .p-pass { background: var(--good-soft); color: var(--good); }
.p-returned, .p-reversed, .p-resolved, .p-info, .p-matched { background: var(--info-soft); color: var(--info); }
.p-failed, .p-fail, .p-missed, .p-quarantined { background: var(--bad-soft); color: var(--bad); }
.p-revoked, .p-expired, .p-scheduled, .p-dismissed, .p-unprocessed, .p-unknown { background: var(--surface-2); color: var(--ink-muted); }
.p-open, .p-needs_review, .p-unmatched { background: var(--warn-soft); color: var(--warn); }
.p-candidate { background: var(--sim-soft); color: var(--sim); }
/* count badge (tab counts, mockup pattern) */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  margin-left: 7px;
  font-variant-numeric: tabular-nums;
}
/* generic non-status chip (e.g. intermediary annotation "via PayPal") */
.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ---- buttons: one hierarchy ----
   .btn            primary action (accent)
   .btn.secondary   outlined, neutral emphasis
   .btn.ghost       borderless text button
   .btn.danger      destructive (bad)
   .btn.sm / .btn.lg sizing. Never nest .btn inside .btnrow-less anchors. */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 17px;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  background: var(--accent);
  color: var(--ink-on-accent);
  transition: filter 0.12s, transform 0.05s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; transform: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--accent); filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid transparent; }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 12px 22px; font-size: 14.5px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; align-items: center; }

/* ---- tabs: segmented control per the approved mockup ----
   Markup (existing): <div class="tabs"><button class="btn" data-…>Active</button>
   <button class="btn ghost" data-…>Inactive</button></div>
   Use <span class="tab-count">n</span> inside for count badges. */
.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 4px 0 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 5px;
  max-width: 100%;
}
.tabs .btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  box-shadow: none;
}
.tabs .btn:hover { filter: none; }
.tabs .btn.ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: transparent;
}
.tabs .btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.tabs .btn:active { transform: none; }

/* ---- forms: one control style ----
   form.form > label > input/select (existing); .field for ad-hoc blocks. */
form.form {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 12px;
  max-width: 600px;
}
form.form label, .field { font-size: 12.5px; color: var(--ink-muted); display: grid; gap: 5px; font-weight: 600; }
form.form input, form.form select, form.form textarea,
.inline-input,
.filters select, .filters input {
  padding: 9px 12px;
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 100%;
  background: var(--input-bg);
  color: var(--ink);
}
form.form input:focus, form.form select:focus, form.form textarea:focus,
.inline-input:focus, .filters select:focus, .filters input:focus,
.search-trigger:focus-visible, .btn:focus-visible, .nav-item:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
form.form input::placeholder, .inline-input::placeholder { color: var(--ink-faint); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }

/* ---- alerts: inline feedback, color = meaning ---- */
.alert {
  border: 1px solid;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin: 0 0 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.55;
}
.alert strong { color: var(--ink); }
.alert.info { background: var(--info-soft); border-color: var(--info); }
.alert.good { background: var(--good-soft); border-color: var(--good); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn); }
.alert.bad  { background: var(--bad-soft);  border-color: var(--bad); }

/* ---- empty states: one pattern for "nothing here yet" ----
   Markup:
     <div class="empty-state"><span class="empty-ic">svg</span>
       <h4>Title</h4><p>What this means / what to do next.</p>
       <button class="btn">Action</button></div> */
.empty-state { text-align: center; padding: 38px 20px; color: var(--ink-muted); }
.empty-state .empty-ic {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.empty-state h4 { margin: 0 0 6px; color: var(--ink); font-size: 15px; font-weight: 700; }
.empty-state p { margin: 0 auto 14px; font-size: 13px; max-width: 46ch; line-height: 1.6; }

/* ---- modal dialog ----
   Markup:
     <div class="modal-backdrop"><div class="modal" role="dialog">
       <div class="modal-head"><h3>Title</h3><button class="icon-btn" data-close>×</button></div>
       <div class="modal-body">…</div>
       <div class="modal-foot"><button class="btn ghost">Cancel</button><button class="btn">Confirm</button></div>
     </div></div> */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: min(560px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.modal-head h3 { margin: 0; }
.modal-body { padding: 14px 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 18px 18px;
  flex-wrap: wrap;
}

/* ---- key/value detail rows ---- */
.kv { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-muted); font-size: var(--fs-meta); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; padding-top: 2px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.divider { border: none; border-top: 1px solid var(--line-soft); margin: 18px 0; }

/* ---- misc components ---- */
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }
.rule2 {
  border-left: 4px solid var(--sim);
  background: var(--sim-soft);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.55;
}
.rule2 strong { color: var(--ink); }
.chain {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
  background: var(--surface);
  display: grid;
  gap: 8px;
  font-size: 13.5px;
}
.chain .k { font-size: var(--fs-meta); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 700; }
pre.audit, .audit {
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line-soft);
  padding: 14px;
  border-radius: 12px;
  font-size: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
}
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cols > * { min-width: 0; }

/* ---- email intake layout (kept hooks; wave-2 may restyle freely) ---- */
.email-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.email-layout > * { min-width: 0; }
.email-main { min-width: 0; }
.email-rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
}
.filters label { font-size: 12px; color: var(--ink-muted); display: grid; gap: 4px; font-weight: 600; min-width: 150px; flex: 1 1 150px; }
.intel-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.intel-list li { display: flex; gap: 10px; font-size: 13px; color: var(--ink-muted); line-height: 1.5; }
.intel-list li strong { color: var(--ink); display: block; font-size: 13px; }
.intel-ic {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---- toast ---- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 13.5px;
  max-width: 92vw;
  z-index: 100;
  box-shadow: var(--shadow);
  line-height: 1.5;
}
.toast.err { background: var(--bad); border-color: var(--bad); color: #fff; }
.hidden { display: none !important; }

/* ---- command palette ---- */
.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  display: flex;
  justify-content: center;
  padding-top: 14vh;
}
.palette {
  width: min(560px, 92vw);
  height: fit-content;
  max-height: 66vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette input {
  padding: 14px 18px;
  font-size: 15px;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
}
.palette input:focus { outline: none; }
#paletteList { overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 9px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}
.palette-item:hover, .palette-item.sel { background: var(--surface-2); }
.palette-item .theme-dots { margin-left: auto; }
.palette-kind {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.palette-item .theme-dots + .palette-kind { margin-left: 8px; }

/* ---- responsive: shell degrades gracefully at narrow widths ----
   < 1024px the sidebar becomes a drawer (opened via .menu-btn + .scrim);
   tables never break layout — they scroll inside .table-wrap. */
.scrim { display: none; }
@media (max-width: 1100px) {
  .email-layout { grid-template-columns: minmax(0, 1fr); }
  .email-rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 30px;
    height: calc(100vh - 30px);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.on {
    display: block;
    position: fixed;
    inset: 30px 0 0 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }
  .menu-btn { display: inline-flex; }
  .search-trigger { min-width: 0; flex-basis: 200px; }
  .search-trigger .search-ph, .search-trigger kbd { display: none; }
  .user-meta { display: none; }
}
@media (max-width: 900px) {
  .topbar-clock { display: none; }
}
@media (max-width: 760px) {
  #view { padding: 18px 14px 50px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .view-head { flex-wrap: wrap; }
  .view-actions { margin-left: 0; width: 100%; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .theme-btn #themeName { display: none; }
  th, td { padding: 8px 10px; }
  .stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .toolbar { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* === v20 patch: home-accounts === */
/* ============================================================================
 * Appel Money v20 — Home + Accounts patch CSS (appended to shell.css)
 * ============================================================================
 * Single addition: styling for the "Manage accounts" disclosure on the
 * Accounts view. Everything else comes from the design-system classes.
 * Colors only via var(--token); no hard-coded hex.
 * ========================================================================== */

details.ha-manage {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 20px;
  background: var(--bg-soft);
}

details.ha-manage > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

details.ha-manage > summary::-webkit-details-marker {
  display: none;
}

details.ha-manage > summary::before {
  content: "\25B8"; /* ▸ collapsed */
  color: var(--ink-muted);
}

details.ha-manage[open] > summary::before {
  content: "\25BE"; /* ▾ open */
}

/* === v20 patch: bills-cashflow === */
/* =====================================================================
 * Appel Money v20 — Bills + Cash Flow patch CSS (appended to shell.css)
 * Tokens only (var(--token)); no hard-coded colors. Layout for the bill
 * timeline, compact management table, snapshot header, and insights list.
 * ===================================================================== */

/* Bill timeline (Upcoming timeline card) */
.bc-timeline { display: flex; flex-direction: column; gap: 8px; }
.bc-tl-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.bc-tl-date { min-width: 46px; text-align: center; flex: none; }
.bc-tl-day { display: block; font-size: 20px; font-weight: 700; line-height: 1.15; }
.bc-tl-body { flex: 1 1 auto; min-width: 0; }
.bc-tl-amt { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; flex: none; }

/* Denser bill management table */
table.bc-dense th, table.bc-dense td { padding: 6px 10px; }

/* Financial snapshot header rows (title + period control / insight + CTA) */
.bc-snapshot-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

/* Bill insights list */
.bc-insights { margin: 0; padding-left: 20px; }
.bc-insights li { margin-bottom: 6px; }

/* Snapshot stat grid spacing + active-forecast card head */
.bc-stats-pad { margin-top: 14px; }
.bc-snapshot-head h3 { margin: 0; }

/* === v20 patch: paycheck-forecast === */
/* v20 patch — build items 6 & 7 (Before Next Paycheck + Forecast).
 * Presentation only. All colors come from theme tokens; no hard-coded
 * values, no per-theme overrides (theme_qa stays green). */

/* Horizontal stacked proportional bar (paycheck allocation, forecast mix). */
.pf-allocbar {
  display: flex;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.pf-allocbar > div {
  height: 100%;
  min-width: 2px;
}
.pf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 10px;
}
.pf-legend .sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 7px;
}

/* Honest SVG charts: fluid width, fixed aspect via viewBox; never overflow. */
.pf-chart {
  display: block;
  width: 100%;
  max-width: 860px;
  height: auto;
}

/* === v20 patch: credit-movement === */
/* Appel Money v20 — Credit + Money Movement patch styles.
 * Presentation only: token colors (var(--…)) — no hard-coded values, no data
 * or state. The lifecycle stepper is the one component with no design-system
 * equivalent; everything else in the patch uses shell.css classes. */
.cm-steps {
  list-style: none;
  display: flex;
  margin: 14px 0 4px;
  padding: 0;
}
.cm-steps li {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  padding-top: 20px;
  font-size: 12px;
  color: var(--ink-muted);
}
.cm-steps li::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--line);
}
.cm-steps li::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 15px;
  right: 4px;
  height: 2px;
  background: var(--line-soft);
}
.cm-steps li:last-child::after {
  display: none;
}
.cm-steps li.done::before {
  background: var(--good);
  border-color: var(--good);
}
.cm-steps li.done::after {
  background: var(--good);
}
.cm-steps li.current::before {
  background: var(--info);
  border-color: var(--info);
  box-shadow: 0 0 0 4px var(--info-soft);
}
.cm-steps li.current {
  color: var(--ink);
}
.cm-step-t {
  display: block;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
}
.cm-step-s {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
/* Narrow screens: the stepper stacks vertically (theme_qa asserts no
   horizontal overflow at 390px). */
@media (max-width: 560px) {
  .cm-steps {
    flex-direction: column;
    gap: 10px;
  }
  .cm-steps li {
    padding-top: 0;
    padding-left: 24px;
  }
  .cm-steps li::before {
    top: 2px;
  }
  .cm-steps li::after {
    display: none;
  }
}

/* === v20 patch: email-intake === */
/* ============================================================================
 * Appel Money v20 — Email Intake + Automation patch CSS (append to shell.css)
 * ============================================================================
 * View-layer additions only. Colors come from var(--token) — no hard-coded
 * hex. Everything else is DESIGN_SYSTEM.md components.
 * ========================================================================== */

/* Vertical card stacks (review queue, suggestions, sources list) */
.ei-list { display: grid; gap: 10px; }

/* Small vertical rhythm inside cards */
.ei-mv { margin: 6px 0; }

/* Connected-sources tile grid (bottom panel + sources tab use .card) */
.ei-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 10px; }

/* Recent Activity timeline (data-backed from /api/email-intake/audit) */
.ei-activity { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.ei-activity li { display: flex; gap: 10px; align-items: flex-start; }
.ei-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.ei-activity .t { font-size: 13px; font-weight: 600; color: var(--ink); }
.ei-activity .s { font-size: 12px; color: var(--ink-muted); }
.ei-activity .ago { margin-left: auto; font-size: 11px; color: var(--ink-muted); white-space: nowrap; }
