/* =========================================================================
   AKEFIN — Web Dashboard Styles
   ========================================================================= */

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-step) var(--grid-step);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  overflow: hidden;
}

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

.ak-app {
  display: flex; flex-direction: column;
  height: 100%;
}

/* =========================================================================
   HEADER
   ========================================================================= */
.ak-header {
  display: flex; align-items: center; gap: 16px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-translucent);
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 20;
}
.ak-logo {
  display: flex; align-items: center; gap: 8px;
  color: var(--fg-strong);
  padding-right: 16px;
  border-right: 1px solid var(--rule);
  height: 100%;
  margin-right: 0;
}
.ak-logo svg { display: block; }
.ak-wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* Entity scope switcher */
.scope-switcher { position: relative; }
.scope-trigger {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  height: 32px;
  padding: 0 10px 0 0;
  color: var(--fg);
  position: relative;
}
.scope-trigger:hover { background: color-mix(in srgb, var(--paper) 96%, black 4%); }
.scope-stripe {
  display: block;
  width: 4px;
  height: 24px;
  border-radius: 1px;
  margin: 0 8px 0 4px;
}
.scope-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
}
.scope-name {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-strong);
  white-space: nowrap;
}
.scope-trigger { white-space: nowrap; }
.scope-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 220px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  z-index: 50;
}
.scope-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 8px 8px 4px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  color: var(--fg);
  border-radius: var(--r-sm);
}
.scope-item:hover { background: var(--btn-ghost-hover); }
.scope-item.active { color: var(--fg-strong); font-weight: 500; }
.scope-item svg { margin-left: auto; color: var(--conf-rules); }

/* Search */
.ak-search {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 480px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  height: 32px;
  padding: 0 10px;
}
.ak-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg);
}
.ak-search input::placeholder { color: var(--fg-subtle); }
.ak-search-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-subtle);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 2px 5px;
  border-radius: 2px;
}

.ak-status {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin-left: auto;
}
.ak-status .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
}

/* =========================================================================
   BODY · sidebar + main
   ========================================================================= */
.ak-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* SIDEBAR */
.ak-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  padding: 16px 8px;
  gap: 2px;
}
.ak-sb-section {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  padding: 6px 10px 4px;
  text-transform: uppercase;
}
.ak-sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--fg);
  border-radius: var(--r-sm);
  text-align: left;
  font-size: 13px;
}
.ak-sb-item:hover { background: var(--btn-ghost-hover); }
.ak-sb-item.active {
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--fg-strong);
  font-weight: 500;
}
.ak-sb-item .ak-sb-label { flex: 1; }
.ak-sb-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 1px 6px;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
}
.ak-sb-item.active .ak-sb-count {
  color: var(--fg-strong);
}
.ak-sb-foot {
  padding: 12px 10px;
  border-top: 1px solid var(--rule);
  display: flex; flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.ak-sb-foot-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px;
}
.ak-sb-foot-row .lbl {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  font-size: 10px;
}
.ak-sb-foot-row .val {
  font-family: var(--font-mono);
  color: var(--fg);
}

/* MAIN */
.ak-main {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* =========================================================================
   REVIEW SCREEN
   ========================================================================= */
.review-screen {
  display: flex;
  flex: 1;
  min-height: 0;
}

.review-pane {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--rule);
}

/* Queue head */
.rq-head {
  display: flex; align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--rule);
  gap: 16px;
}
.rq-tabs { display: flex; gap: 18px; }
.rq-tab {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 8px;
}
.rq-tab.active { color: var(--fg-strong); border-bottom-color: var(--fg-strong); }
.rq-tab .rq-count {
  font-family: var(--font-mono);
  background: var(--bg-deep);
  padding: 1px 6px;
  font-size: 10px;
  color: var(--fg-muted);
  border-radius: 2px;
}
.rq-tab.active .rq-count { color: var(--fg); background: var(--paper); border: 1px solid var(--rule); }

.rq-controls { display: flex; gap: 10px; margin-left: auto; align-items: center; }
.rq-ctrl {
  display: flex; align-items: center; gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--fg);
}
.rq-ctrl:hover { background: var(--btn-ghost-hover); }
.rq-sort {
  display: flex; align-items: center; gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg);
}
.rq-sort select {
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  letter-spacing: inherit;
}

/* Queue list */
.rq-list-head, .tx-row {
  display: grid;
  grid-template-columns: 80px 1fr 160px 110px 100px 84px;
  gap: 14px;
  align-items: center;
  padding: 0 20px;
}
.rq-list-head {
  height: 32px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  background: var(--bg-deep);
}
.rq-list { flex: 1; overflow-y: auto; }
.tx-row {
  height: 44px;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
  font-family: inherit;
  color: var(--fg);
  border-left: 2px solid transparent;
  border-right: none;
  border-top: none;
  width: 100%;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.tx-row:hover { background: rgba(20,18,12,0.025); }
.tx-row.selected {
  background: var(--paper);
  border-left-color: var(--fg-strong);
}
.tx-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.tx-payee {
  display: flex; flex-direction: column;
  min-width: 0;
}
.tx-payee .ko {
  font-family: var(--font-sans-kr);
  font-size: 13px;
  color: var(--fg-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tx-payee-note {
  font-size: 11px;
  color: var(--fg-subtle);
}
.tx-amount-cell { text-align: right; }

.rq-foot {
  display: flex; justify-content: space-between;
  padding: 8px 20px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--fg-subtle);
  text-transform: uppercase;
}

/* =========================================================================
   ATOMS — chip / badge / tier / amount / btn
   ========================================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip.rules { background: var(--conf-rules-bg); color: var(--conf-rules); }
.chip.high  { background: var(--conf-high-bg);  color: var(--conf-high); }
.chip.mid   { background: var(--conf-mid-bg);   color: var(--conf-mid); }
.chip.low   { background: var(--conf-low-bg);   color: var(--conf-low); }
.chip .star { font-size: 10px; line-height: 1; }

.entity-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px;
  padding: 0 8px 0 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.entity-badge::before {
  content: "";
  width: 3px; height: 13px;
  border-radius: 1px;
}
.entity-badge.personal { background: var(--entity-personal-bg); color: var(--entity-personal); }
.entity-badge.personal::before { background: var(--entity-personal); }
.entity-badge.tfox     { background: var(--entity-9tfox-bg); color: var(--entity-9tfox); }
.entity-badge.tfox::before     { background: var(--entity-9tfox); }
.entity-badge.finacode { background: var(--entity-finacode-bg); color: var(--entity-finacode); }
.entity-badge.finacode::before { background: var(--entity-finacode); }

.tier {
  display: inline-flex; align-items: center;
  height: 18px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: var(--r-sm);
}
.tier.rules     { color: var(--conf-rules); }
.tier.llm       { color: var(--conf-high); }
.tier.agent     { color: var(--conf-mid); }
.tier.unmatched { color: var(--conf-low); }

.amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 500;
  white-space: nowrap;
  color: var(--fg);
}
.amount.pos { color: var(--conf-rules); }
.amount.neg { color: var(--fg-strong); }
.amount .ccy { color: var(--fg-subtle); font-weight: 400; }
.amount.muted { color: var(--fg-subtle); font-weight: 400; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  color: var(--fg);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--btn-ghost-hover); }
.btn:active { transform: scale(0.99); box-shadow: var(--shadow-inset-press); }
.btn.primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-color: var(--btn-bg);
}
.btn.primary:hover { background: var(--btn-bg-hover); }
.btn.bracket { border: none; padding: 0; background: transparent; height: auto; }
.btn.bracket:hover { background: transparent; color: var(--fg-strong); }

/* =========================================================================
   INSPECTOR
   ========================================================================= */
.inspector {
  width: 420px;
  flex-shrink: 0;
  background: var(--paper);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.inspector.empty { background: transparent; }
.ins-empty {
  margin: auto;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  color: var(--fg-subtle);
  font-size: 13px;
}
.ins-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}
.ins-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin-bottom: 10px;
}
.ins-eyebrow > span:first-child { margin-right: auto; }
.ins-more {
  background: none; border: none; padding: 0;
  color: var(--fg-muted);
}
.ins-payee {
  font-family: var(--font-sans-kr);
  font-size: 18px;
  font-weight: 500;
  color: var(--fg-strong);
  line-height: 1.3;
  margin-bottom: 2px;
}
.ins-payee-note {
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 12px;
}
.ins-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-top: 8px;
}
.ins-meta { display: flex; flex-direction: column; gap: 4px; }
.ins-meta .lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
}
.ins-meta .val {
  font-size: 13px;
  color: var(--fg);
}
.ins-meta .val.mono { font-family: var(--font-mono); }

.ins-suggestion {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  color: var(--fg-on-ink);
}
.ins-arrow { color: var(--conf-rules); font-weight: 600; }
.ins-acct { word-break: break-all; }
.ins-tier-line {
  margin-top: 8px;
  font-size: 11px;
  color: var(--fg-muted);
  line-height: 1.5;
}
.ins-tier-line .tier { vertical-align: -2px; margin-right: 4px; }

/* Account picker */
.acct-picker { position: relative; }
.acct-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--fg);
}
.acct-trigger:hover { border-color: var(--fg-muted); }
.acct-picker.open .acct-trigger {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent);
}
.acct-path {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
}
.acct-path .branch { color: var(--fg-muted); }
.acct-path .leaf   { color: var(--fg-strong); font-weight: 500; }
.acct-path .sep    { color: var(--fg-faint); margin: 0 1px; }
.acct-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  max-height: 300px;
  overflow-y: auto;
  z-index: 60;
}
.acct-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
}
.acct-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
}
.acct-section { padding: 4px; }
.acct-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  padding: 6px 8px 4px;
}
.acct-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  border-radius: var(--r-sm);
}
.acct-item:hover { background: var(--btn-ghost-hover); }
.acct-item.new { color: var(--fg-muted); }
.mru-mark {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  background: var(--bg-deep);
  padding: 1px 5px;
  border-radius: 2px;
}

/* Ledger preview */
.ledger-preview {
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-on-ink);
}
.lp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px dashed var(--rule-ink);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}
.lp-head .lp-payee { color: var(--fg-on-ink); }
.lp-head .lp-conf  { margin-left: auto; }
.lp-body { padding: 10px 12px; }
.lp-leg {
  display: grid;
  grid-template-columns: 1fr 100px 40px;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.lp-acct { color: var(--fg-on-ink); }
.lp-amt  { text-align: right; }
.lp-amt:not([data-pos="false"]) { color: var(--fg-on-ink); }
.lp-ccy  { color: var(--fg-on-ink-muted); }
.lp-foot {
  padding: 6px 12px;
  border-top: 1px solid var(--rule-ink);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--conf-rules);
}
.lp-fx-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 0 4px 16px;
  font-size: 10.5px;
  color: var(--fg-on-ink-muted);
  border-left: 1px dashed var(--rule-ink);
  margin: 2px 0 2px 8px;
  font-variant-numeric: tabular-nums;
}
.lp-fx-arrow { color: var(--conf-mid); font-size: 12px; }
.lp-fx-text { line-height: 1.3; }
.lp-fx-rate { color: var(--conf-mid); font-weight: 500; }
.lp-fx-meta { color: var(--fg-on-ink-muted); }
.ledger-empty {
  padding: 16px;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--surface);
  border: 1px dashed var(--rule-ink);
  border-radius: var(--r-sm);
  text-align: center;
}

/* Inspector actions */
.ins-actions {
  display: flex; gap: 8px; align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  background: var(--bg-deep);
  margin-top: auto;
  position: sticky;
  bottom: 0;
}
.ins-actions .btn { height: 36px; }
.ins-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 2px 6px;
  border-radius: 2px;
  margin-left: auto;
}

/* =========================================================================
   SCREEN — RULES
   ========================================================================= */
.rules-screen, .ledger-screen, .import-screen {
  padding: 24px;
  overflow-y: auto;
  height: 100%;
}
.screen-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.screen-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 32px;
  color: var(--fg-strong);
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.screen-sub {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 6px;
}
.screen-actions { display: flex; gap: 10px; }

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.rule-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex; flex-direction: column;
  gap: 12px;
}
.rule-head {
  display: flex; align-items: flex-start; gap: 12px;
}
.rule-pattern {
  display: flex; align-items: baseline; gap: 6px;
  flex-wrap: wrap;
}
.pattern-prefix {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.rule-pattern code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  padding: 2px 6px;
  border-radius: 2px;
}
.rule-occ {
  display: flex; flex-direction: column;
  align-items: flex-end;
  margin-left: auto;
  white-space: nowrap;
}
.rule-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
  line-height: 1;
}
.rule-occ-lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  margin-top: 2px;
}
.rule-map {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-on-ink);
}
.rule-map .ko { font-family: var(--font-sans-kr); }
.rule-target { color: var(--fg-strong); }
.rule-examples {
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}
.rule-ex-label {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  margin-bottom: 4px;
}
.rule-ex {
  color: var(--fg);
  padding: 2px 0;
}
.rule-actions {
  display: flex; align-items: center; gap: 10px;
  padding-top: 4px;
  border-top: 1px dashed var(--rule);
  padding-top: 12px;
}
.rule-promote {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--fg);
}
.rule-promote input { accent-color: var(--fg-strong); }

/* =========================================================================
   SCREEN — LEDGER
   ========================================================================= */
.ledger-entity {
  margin-bottom: 28px;
}
.ledger-entity-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.stripe { width: 4px; height: 18px; border-radius: 1px; }
.ledger-entity-name {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-strong);
}
.ledger-entity-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-left: auto;
  letter-spacing: 0.04em;
}
.tree {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.tree-head, .tree-node {
  display: grid;
  grid-template-columns: 32px 24px 1fr 2fr 160px;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
}
.tree-head {
  height: 28px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
}
.tree-node {
  height: 36px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12.5px;
  cursor: default;
}
.tree-node.branch { color: var(--fg-strong); font-weight: 500; cursor: pointer; }
.tree-node.branch:hover { background: var(--btn-ghost-hover); }
.tree-node.leaf { color: var(--fg); }
.tree-chevron .dot {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--fg-faint);
  margin-left: 4px;
}
.tree-path { font-weight: inherit; }
.tree-full { color: var(--fg-subtle); font-size: 11px; }
.tree-amount { text-align: right; }

/* =========================================================================
   SCREEN — IMPORT
   ========================================================================= */
.import-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 4px;
}
.stat-num {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
  line-height: 1;
}
.stat-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
}

.import-list {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  margin-top: 20px;
}
.import-list-head, .import-row {
  display: grid;
  grid-template-columns: 140px 1fr 110px 80px 220px 80px;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
}
.import-list-head {
  height: 32px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--rule);
}
.import-row {
  height: 56px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.import-row:last-child { border-bottom: none; }
.import-row .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.import-row .right { text-align: right; }
.import-bar {
  display: flex;
  height: 8px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.import-bar-cell { display: flex; flex-direction: column; gap: 4px; }
.import-counts {
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--fg-subtle);
  letter-spacing: 0.04em;
}

/* =========================================================================
   TERMINAL FRAME (re-used across screens)
   ========================================================================= */
.term-frame {
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  color: var(--fg-on-ink);
  margin-bottom: 20px;
}
.term-frame-title {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--rule-ink);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-on-ink-muted);
}
.term-frame-title .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-left: auto;
}
.term-frame-body {
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.term-frame-body .m { color: var(--fg-on-ink-muted); }

/* =========================================================================
   TOAST
   ========================================================================= */
.ak-toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--fg-strong);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: var(--shadow-pop);
  z-index: 100;
  animation: toast-in var(--dur-slow) var(--ease);
}
@keyframes toast-in {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

/* Scrollbar (subtle) */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--rule-strong); }

/* =========================================================================
   HEADER · NEW BITS
   ========================================================================= */
.ak-search.ak-search-btn {
  background: var(--paper);
  border: 1px solid var(--rule);
  cursor: pointer;
  text-align: left;
}
.ak-search.ak-search-btn:hover { background: color-mix(in srgb, var(--paper) 96%, black 4%); }
.ak-search-placeholder {
  flex: 1;
  font-size: 13px;
  color: var(--fg-subtle);
}
.ak-header-actions {
  display: flex; gap: 8px;
}
.ak-header-btn {
  display: flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bg);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  white-space: nowrap;
}
.ak-header-btn:hover { background: var(--btn-bg-hover); }

/* =========================================================================
   REVIEW QUEUE · FILTER controls
   ========================================================================= */
.rq-ctrl.active {
  background: var(--paper);
  border-color: var(--fg-strong);
  color: var(--fg-strong);
}
.rq-ctrl-dot {
  display: inline-block;
  background: var(--fg-strong);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  width: 14px; height: 14px;
  border-radius: 50%;
  line-height: 14px;
  text-align: center;
  margin-left: 4px;
  letter-spacing: 0;
}

/* =========================================================================
   FILTER PANEL
   ========================================================================= */
.filter-panel {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--rule);
  padding: 14px 20px;
  display: flex; flex-direction: column; gap: 12px;
  animation: filter-slide 180ms var(--ease);
}
@keyframes filter-slide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.filter-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 16px;
}
.filter-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
  text-transform: uppercase;
}
.filter-options {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.filter-pill {
  display: inline-flex; align-items: center;
  height: 24px;
  padding: 0 10px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--fg);
}
.filter-pill:hover { border-color: var(--fg-muted); }
.filter-pill.active {
  background: var(--fg-strong);
  color: var(--bg);
  border-color: var(--fg-strong);
}
.filter-pill.tier-rules.active     { background: var(--conf-rules); border-color: var(--conf-rules); }
.filter-pill.tier-llm.active       { background: var(--conf-high);  border-color: var(--conf-high); }
.filter-pill.tier-agent.active     { background: var(--conf-mid);   border-color: var(--conf-mid); }
.filter-pill.tier-unmatched.active { background: var(--conf-low);   border-color: var(--conf-low); }

.filter-custom-dates {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 6px;
}
.filter-date {
  height: 24px;
  padding: 0 8px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
}

.filter-slider-wrap {
  display: flex; align-items: center; gap: 12px;
  max-width: 320px;
}
.filter-slider {
  flex: 1;
  appearance: none;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
}
.filter-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 14px;
  background: var(--fg-strong);
  border: 2px solid var(--paper);
  border-radius: 50%;
  cursor: pointer;
}
.filter-conf-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

.filter-foot {
  display: flex; align-items: center; gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--rule);
}
.filter-active-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

/* Empty state */
.rq-empty {
  padding: 60px 20px;
  text-align: center;
}
.rq-empty-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--fg-muted);
  margin-bottom: 6px;
}
.rq-empty-sub {
  font-size: 12px;
  color: var(--fg-subtle);
}

/* =========================================================================
   COMMAND PALETTE
   ========================================================================= */
.cp-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 18, 12, 0.32);
  z-index: 200;
  display: flex; justify-content: center;
  padding-top: 100px;
  animation: cp-fade 140ms var(--ease);
}
@keyframes cp-fade { from { opacity: 0; } to { opacity: 1; } }
.cp-panel {
  width: 560px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: cp-pop 140ms var(--ease);
}
@keyframes cp-pop {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.cp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.cp-head input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--fg);
}
.cp-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-subtle);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 2px 6px;
  border-radius: 2px;
}
.cp-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.cp-group { margin-bottom: 4px; }
.cp-group-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
  padding: 8px 12px 4px;
}
.cp-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg);
  border-radius: var(--r-sm);
}
.cp-item.active { background: var(--surface); }
.cp-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  flex-shrink: 0;
}
.cp-item.active .cp-icon { background: var(--paper); color: var(--fg-strong); }
.cp-label { flex: 1; }
.cp-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-subtle);
  background: var(--bg-deep);
  padding: 2px 6px;
  border-radius: 2px;
}
.cp-item.active .cp-hint { color: var(--fg); }
.cp-empty {
  padding: 30px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-muted);
  font-style: italic;
}
.cp-foot {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
}
.cp-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0px 4px;
  border-radius: 2px;
  margin-right: 4px;
}

/* =========================================================================
   MODAL (CSV import)
   ========================================================================= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 18, 12, 0.32);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: cp-fade 140ms var(--ease);
}
.modal {
  width: 560px;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: cp-pop 220ms var(--ease);
}
.modal-head {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
}
.modal-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  color: var(--fg-strong);
  margin-top: 4px;
  letter-spacing: -0.005em;
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--btn-ghost-hover); color: var(--fg); }
.modal-body {
  padding: 18px 24px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 18px;
}
.modal-foot {
  display: flex; gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--rule);
  background: var(--bg-deep);
}

.form-field { display: flex; flex-direction: column; gap: 8px; }
.form-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  text-transform: uppercase;
}
.form-lbl-note {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--fg-subtle);
  text-transform: none;
  margin-left: 8px;
}
.form-help {
  font-size: 11px;
  color: var(--fg-muted);
  font-style: italic;
}

.file-drop {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 16px;
  background: var(--bg);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--r-sm);
}
.file-drop-text { flex: 1; font-size: 13px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-drop-text .mono { font-family: var(--font-mono); color: var(--fg-strong); }
.file-pick {
  background: none; border: none; padding: 0;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  font: inherit;
}
.file-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-subtle);
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.pw-input {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  padding-right: 8px;
}
.pw-input:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent);
}
.pw-input input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  background: transparent;
  border: none; outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--fg);
}
.pw-toggle {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  background: transparent;
  border: none;
  color: var(--fg-muted);
}
.pw-toggle:hover { color: var(--fg-strong); }

.entity-radio {
  display: flex; gap: 8px;
}
.entity-radio-item {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
}
.entity-radio-item input { display: none; }
.entity-radio-item .stripe { width: 4px; height: 16px; border-radius: 1px; }
.entity-radio-item.active {
  border-color: var(--fg-strong);
  background: var(--paper);
}
.entity-radio-item:hover { background: var(--paper); }
