/* ============================================================
   Ledger design-system layer  (quick 260529-vxn)
   Light default + dark via Tailwind class-based dark mode (html.dark).
   Token source of truth: server/static/_mockup_system.html :root /
   [data-theme=dark]. Here the dark block is scoped to html.dark so it
   matches the live app's `<html class="dark">` toggle (NOT [data-theme]).

   ADDITIVE only: this complements Tailwind utilities (it must not fight
   layout). It carries (a) CSS tokens, (b) the global system-font + 16px
   base + tabular-nums body rule, and (c) a small set of opt-in helper
   component classes (.ls-* / cell-input / tbtn / badge) actually used
   by the markup. Bulk table/badge polish is done via Tailwind class
   sweeps in app.js / journal.js.
   ============================================================ */

/* ---------- design tokens ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* light theme (default) */
  --bg:        #eef1f5;
  --surface:   #ffffff;
  --surface-2: #f7f9fb;
  --line:      #e2e6ec;
  --line-soft: #eef1f5;
  --txt:       #1f2937;
  --txt-soft:  #4b5563;
  --label:     #6b7280;
  --accent:    #4f46e5;
  --accent-bg: rgba(79,70,229,0.10);
  --up:        #15915b;
  --up-bg:     rgba(21,145,91,0.12);
  --down:      #d12d2d;
  --down-bg:   rgba(209,45,45,0.12);
  --warn:      #c2740a;
  --warn-bg:   rgba(194,116,10,0.12);
  --shadow:    0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-lg: 0 8px 24px rgba(16,24,40,0.12);
}

/* dark tokens — scoped to the live app's class-based toggle */
html.dark {
  --bg:        #0d0f11;
  --surface:   #16191d;
  --surface-2: #1b1f24;
  --line:      #262b31;
  --line-soft: #1f242a;
  --txt:       #d7dbe0;
  --txt-soft:  #aeb4bd;
  --label:     #7c848f;
  --accent:    #e8b931;
  --accent-bg: rgba(232,185,49,0.13);
  --up:        #34c270;
  --up-bg:     rgba(52,194,112,0.14);
  --down:      #f0564a;
  --down-bg:   rgba(240,86,74,0.14);
  --warn:      #f0a93b;
  --warn-bg:   rgba(240,169,59,0.14);
  --shadow:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ---------- global type base ---------- */
html { font-size: 16px; }
/* Global small-text bump (2026-05-30) lives in index.html: text-xs is
   remapped in tailwind.config.fontSize; text-[11px] (arbitrary value) is
   overridden in a post-CDN <style>. Kept there to win the cascade against
   the runtime-injected Tailwind utilities. */
body {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;          /* aligned figures w/o monospace */
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================================================
   ACTIVE polish layer (2026-05-30) — matches algotrade.
   Attaches to the LIVE inline-Tailwind markup (not the dead opt-in
   helpers below). Per corrected memory: "crisp" = algotrade polish
   (soft shadows, larger KPI numbers, consistent focus rings, section
   separation), NOT flat/dense/stripped.
   ============================================================ */

/* D7 — soft card elevation. algotrade cards are white panels with a
   drop-shadow; our live cards are `rounded-lg border border-line ...`.
   Scope to bordered rounded-lg panels in the main content so pills/
   badges (which use plain `rounded`) are unaffected. */
main .rounded-lg.border { box-shadow: var(--shadow); }

/* D6 — consistent focus ring on every form control (algotrade gives
   every input a 3px ring; ours was inconsistent). */
main input:focus,
main select:focus,
main textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* D11 — larger headline KPI numbers for at-a-glance scanning
   (algotrade hero metrics are text-2xl/3xl; ours capped at 16px).
   Applied via `kpi-value` class added to the KPI number spans. */
.kpi-value { font-size: 22px !important; line-height: 1.15; font-weight: 600; }

/* D8 — section-header separation. algotrade underlines section headers
   (h2 border-bottom). Our section labels carry a `data-sec-head` hook. */
[data-sec-head] {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

/* ---------- opt-in component helpers (algotrade legibility) ---------- */
/* Tables that opt into the design-system look via class="ls-table".
   Tailwind-classed tables in app.js are swept separately; these rules
   only bite where .ls-table is explicitly applied. */
.ls-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.ls-table thead th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--label);
  padding: 12px 15px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--surface);
}
.ls-table thead th.r, .ls-table tbody td.r { text-align: right; }
.ls-table thead th.c, .ls-table tbody td.c { text-align: center; }
.ls-table tbody td { padding: 14px 15px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.ls-table tbody tr:last-child td { border-bottom: 0; }

/* badges (uppercase, rounded ~5px, 11px) */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.b-accent { background: var(--accent-bg); color: var(--accent); }
.b-up     { background: var(--up-bg); color: var(--up); }
.b-down   { background: var(--down-bg); color: var(--down); }
.b-warn   { background: var(--warn-bg); color: var(--warn); }
.b-soft   { background: var(--surface-2); color: var(--label); border: 1px solid var(--line); }
.b-dash   { background: none; color: var(--label); border: 1px dashed var(--line); }

/* editable cell input look */
.cell-input {
  width: 84px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--txt); font: inherit; font-size: 14px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* small table buttons */
.tbtn {
  padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--txt-soft); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tbtn:hover { border-color: var(--accent); color: var(--accent); }
.tbtn.danger { color: var(--down); }
.tbtn.danger:hover { border-color: var(--down); background: var(--down-bg); }
.tbtn.go { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

/* section header inside holdings */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.sec-head .title { display: flex; align-items: center; gap: 9px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--txt-soft); }
.sec-head .title .d { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* conditional banner */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 9px;
  font-size: 13px; margin-bottom: 18px; border: 1px solid var(--down); background: var(--down-bg);
}

/* segmented switcher */
.switcher { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; margin-bottom: 18px; }
.switcher button { border: 0; background: none; padding: 7px 16px; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--label); }
.switcher button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* KPI block */
.kpi .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--label); }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.15; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--label); margin-top: 3px; }
