/* Life — design system. One accent (violet), one typeface (Inter), quiet surfaces,
   data colors from the validated palette (income blue, spending orange). */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --glow: rgba(91, 79, 230, .10);
  --sidebar: rgba(255, 255, 255, .55);
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --surface-3: #eaeaee;
  --line: rgba(15, 15, 30, .07);
  --line-2: rgba(15, 15, 30, .12);
  --ink: #0b0b10;
  --ink-2: #55555f;
  --muted: #8a8a94;
  --accent: #5b4fe6;
  --accent-2: #8a7dff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(91, 79, 230, .09);
  --accent-text: #4b3fd8;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s2-soft: rgba(235, 104, 52, .11);
  --ord-1: #86b6ef;
  --ord-2: #3987e5;
  --ord-3: #184f95;
  --track: rgba(91, 79, 230, .10);
  --in: #0f7a46;
  --in-soft: rgba(15, 122, 70, .09);
  --warning: #fab219;
  --critical: #d03b3b;
  --crit-text: #b4232c;
  --crit-soft: rgba(208, 59, 59, .09);
  --grid: rgba(15, 15, 30, .07);
  --shadow: 0 1px 2px rgba(16, 16, 40, .04), 0 2px 8px -2px rgba(16, 16, 40, .05);
  --shadow-lg: 0 24px 60px -20px rgba(16, 16, 40, .28), 0 2px 8px rgba(16, 16, 40, .06);
  --highlight: none;
  --r: 20px;
  --r-sm: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #07070a;
    --glow: rgba(124, 108, 255, .16);
    --sidebar: rgba(14, 14, 19, .6);
    --surface: #111116;
    --surface-2: #18181f;
    --surface-3: #22222b;
    --line: rgba(255, 255, 255, .065);
    --line-2: rgba(255, 255, 255, .11);
    --ink: #f4f4f6;
    --ink-2: #a3a3ad;
    --muted: #6f6f7a;
    --accent: #8b7fff;
    --accent-2: #b3a9ff;
    --accent-ink: #0d0a24;
    --accent-soft: rgba(139, 127, 255, .13);
    --accent-text: #aea4ff;
    --s1: #3987e5;
    --s2: #d95926;
    --s2-soft: rgba(217, 89, 38, .15);
    --ord-1: #1c5cab;
    --ord-2: #3987e5;
    --ord-3: #9ec5f4;
    --track: rgba(139, 127, 255, .14);
    --in: #3ddc97;
    --in-soft: rgba(61, 220, 151, .1);
    --crit-text: #ff7b7b;
    --crit-soft: rgba(255, 90, 90, .12);
    --grid: rgba(255, 255, 255, .06);
    --shadow: 0 1px 0 rgba(255, 255, 255, .025) inset, 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
    --highlight: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 40%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07070a; --glow: rgba(124, 108, 255, .16); --sidebar: rgba(14, 14, 19, .6);
  --surface: #111116; --surface-2: #18181f; --surface-3: #22222b;
  --line: rgba(255, 255, 255, .065); --line-2: rgba(255, 255, 255, .11);
  --ink: #f4f4f6; --ink-2: #a3a3ad; --muted: #6f6f7a;
  --accent: #8b7fff; --accent-2: #b3a9ff; --accent-ink: #0d0a24; --accent-soft: rgba(139, 127, 255, .13); --accent-text: #aea4ff;
  --s1: #3987e5; --s2: #d95926; --s2-soft: rgba(217, 89, 38, .15);
  --ord-1: #1c5cab; --ord-2: #3987e5; --ord-3: #9ec5f4; --track: rgba(139, 127, 255, .14);
  --in: #3ddc97; --in-soft: rgba(61, 220, 151, .1); --crit-text: #ff7b7b; --crit-soft: rgba(255, 90, 90, .12);
  --grid: rgba(255, 255, 255, .06);
  --shadow: 0 1px 0 rgba(255, 255, 255, .025) inset, 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
  --highlight: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 40%);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(900px 420px at 78% -120px, var(--glow), transparent 70%), var(--bg);
  background-attachment: fixed;
  font: 450 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.num, .tab { font-variant-numeric: tabular-nums; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px 16px; border-right: 1px solid var(--line); background: var(--sidebar);
  backdrop-filter: blur(20px);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; color: var(--ink); font-weight: 680; font-size: 17px; letter-spacing: -0.02em; }
.logo-mark { width: 30px; height: 30px; filter: drop-shadow(0 6px 14px rgba(91, 79, 230, .35)); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 520; transition: background .15s, color .15s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.side-nav a[aria-current="page"] .i { color: var(--accent); }
.side-spacer { flex: 1; }
.side-me { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--line); min-height: 58px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 650; font-size: 13px;
}
.me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me-text b { font-weight: 600; font-size: 13px; }
.me-text small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { width: 100%; max-width: 1260px; margin: 0 auto; padding: 30px 40px 72px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 30px; line-height: 1.15; font-weight: 680; letter-spacing: -0.03em; margin: 0; }
.page-sub { color: var(--ink-2); margin: 6px 0 0; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tabbar { display: none; }

/* ---------- Grid ---------- */
.row { display: grid; gap: 20px; margin-bottom: 20px; }
.row-2 { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.row-2e { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- Cards ---------- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px 24px; box-shadow: var(--shadow); min-width: 0;
}
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--highlight); pointer-events: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 24px; }
.card-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 620; letter-spacing: -0.01em; margin: 0; }
.card-title .i { width: 17px; height: 17px; color: var(--muted); }
.card-meta { color: var(--muted); font-size: 13px; }
.card-sub { color: var(--ink-2); font-size: 13px; margin: -10px 0 14px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

/* ---------- Buttons and controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 560; font-size: 13.5px; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .i { width: 16px; height: 16px; }
.btn-primary {
  border: 0; color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 8px 20px -8px var(--accent);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent-2), var(--accent)); filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn-danger { color: var(--crit-text); }
kbd { font: 600 10.5px/1 "Inter", system-ui; padding: 3px 5px; border-radius: 5px; background: rgba(255, 255, 255, .2); color: inherit; opacity: .85; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2);
  display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 560; font-size: 13px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.month-pill {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.month-pill .label { min-width: 128px; text-align: center; font-weight: 600; font-size: 13.5px; }
.month-pill .icon-btn { width: 30px; height: 30px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button {
  border: 0; background: transparent; color: var(--ink-2); padding: 5px 11px; border-radius: 8px; font-weight: 560; font-size: 12.5px;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.input, .field input, .field select, .field textarea {
  width: 100%; min-width: 0; height: 40px; padding: 0 12px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .field input::placeholder { color: var(--muted); }
.input:focus, .field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-box { position: relative; }
.search-box .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search-box .input { padding-left: 33px; height: 34px; width: 200px; font-size: 13px; }

/* ---------- Figures ---------- */
.figure { font-weight: 680; letter-spacing: -0.035em; display: inline-flex; align-items: baseline; gap: .18em; }
.figure .cur { font-size: .42em; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.hero-figure { font-size: 50px; line-height: 1.05; }
.stat-label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -0.025em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.delta .i { width: 14px; height: 14px; }
.delta.up { color: var(--in); background: var(--in-soft); }
.delta.down { color: var(--crit-text); background: var(--crit-soft); }
.chip-icon {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip-icon .i { width: 17px; height: 17px; }
.chip-icon.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.chip-icon.out { background: var(--s2-soft); color: var(--s2); border-color: transparent; }
.chip-icon.in { background: var(--in-soft); color: var(--in); border-color: transparent; }
.chip-icon.sm { width: 30px; height: 30px; border-radius: 9px; }
.chip-icon.sm .i { width: 15px; height: 15px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 560; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill.warn { background: rgba(250, 178, 25, .14); color: #a46c00; border-color: transparent; }
:root:not([data-theme="light"]) .pill.warn { color: #f6c453; }
.pill.crit { background: var(--crit-soft); color: var(--crit-text); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge { width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; flex: none; }
.badge.warning { background: var(--warning); color: #0b0b0b; }
.badge.critical { background: var(--critical); color: #fff; }

/* ---------- Charts ---------- */
.chart { position: relative; min-height: 60px; }
.chart-svg { display: block; width: 100%; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .base, .chart-svg .zero { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-svg .tick.sel { fill: var(--ink); font-weight: 650; }
.chart-svg .marker { stroke: var(--surface); stroke-width: 2; }
.chart-svg .cross { stroke: var(--line-2); stroke-width: 1; }
.chart-svg .hit { cursor: crosshair; }
.chart-svg .band { fill: var(--surface-2); opacity: 0; transition: opacity .15s; }
.chart-svg .col-group { cursor: pointer; outline: none; }
.chart-svg .col-group:hover .band, .chart-svg .col-group:focus .band { opacity: 1; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .amount { font-weight: 620; white-space: nowrap; text-align: right; }
.amount.in { color: var(--in); }
.amount.move { color: var(--ink-2); font-weight: 520; }
.empty-note { color: var(--ink-2); margin: 0; font-size: 13.5px; }

/* ---------- Money: hero ---------- */
.hero-card { padding: 26px 28px 18px; overflow: hidden; }
.hero-card::after {
  content: ""; position: absolute; right: -120px; top: -160px; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent); pointer-events: none;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.hero-line { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; }
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 18px -28px -18px; border-top: 1px solid var(--line); }
.hero-stats > div { padding: 14px 28px 16px; border-left: 1px solid var(--line); min-width: 0; }
.hero-stats > div:first-child { border-left: 0; }

.month-card .big { font-size: 34px; }
.meter { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.warning > span { background: var(--warning); }
.meter.critical > span { background: var(--critical); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.flow { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.flow-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; }
.flow-row .bar { height: 10px; border-radius: 0 5px 5px 0; }

/* ---------- Money: where it goes ---------- */
.where { display: flex; flex-direction: column; gap: 4px; }
.where-row {
  display: grid; grid-template-columns: 36px minmax(0, 170px) minmax(0, 1fr) auto; gap: 14px; align-items: center;
  border: 0; background: none; padding: 7px 8px; margin: 0 -8px; text-align: left; border-radius: 12px; transition: background .15s;
  width: calc(100% + 16px);
}
.where-row:hover, .where-row.active { background: var(--surface-2); }
.where-name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where-name small { display: block; color: var(--muted); font-size: 12px; font-weight: 450; }
.where-bar { height: 8px; display: block; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.where-bar > span { display: block; height: 100%; background: var(--s2); border-radius: 0 99px 99px 0; }
.where-val { font-weight: 620; text-align: right; min-width: 96px; white-space: nowrap; }
.where-val small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }

/* ---------- Money: coming up ---------- */
.plan { align-items: center; }
.plan-main { border: 0; background: none; padding: 0; text-align: left; min-width: 0; color: inherit; }
.plan-main:hover .title { color: var(--accent-text); }
.plan .when { font-weight: 600; color: var(--ink-2); }
.plan.late .when { color: var(--crit-text); }
.plan-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.plan-done { height: 26px; padding: 0 9px; font-size: 12px; }
.plan-done .i { width: 13px; height: 13px; }
.hero-stats .stat-value { font-size: 20px; }
.plan-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.plan-foot b { color: var(--ink); }

/* ---------- Money: accounts ---------- */
.acct-group + .acct-group { margin-top: 18px; }
.acct-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.acct-head .total { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.acct-edit { border: 0; background: none; padding: 0; font-weight: 620; color: var(--ink); border-bottom: 1px dashed transparent; }
.acct-edit:hover { border-bottom-color: var(--line-2); }
.debt-meter { height: 5px; border-radius: 99px; background: var(--surface-3); margin-top: 7px; max-width: 220px; overflow: hidden; }
.debt-meter > span { display: block; height: 100%; background: var(--in); border-radius: 99px; }
.inline-edit { width: 110px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--accent); background: var(--surface); text-align: right; box-shadow: 0 0 0 4px var(--accent-soft); }
.add-acct { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr) auto; gap: 8px; margin-top: 16px; }
.add-acct .input, .add-acct select { height: 36px; font-size: 13px; }
.add-acct select { padding: 0 10px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface-2); }

/* ---------- Money: budget ---------- */
.budget-row { padding: 12px 0; border-top: 1px solid var(--line); }
.budget-row:first-child { border-top: 0; padding-top: 0; }
.budget-top { display: flex; align-items: center; gap: 10px; }
.budget-top .grow { flex: 1; min-width: 0; font-weight: 560; }
.budget-nums { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.budget-nums b { color: var(--ink); font-weight: 620; }
.budget-row .meter { margin-top: 9px; height: 6px; }
.budget-status { font-size: 12px; color: var(--ink-2); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.budget-status.critical { color: var(--crit-text); font-weight: 560; }
.bud { border: 0; background: none; padding: 0 1px; color: var(--ink-2); border-bottom: 1px dashed transparent; }
.bud:hover { color: var(--ink); border-bottom-color: var(--line-2); }
.bud.set { color: var(--accent-text); font-weight: 560; }

/* ---------- Money: transactions ---------- */
.tx-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-group + .day-group { margin-top: 10px; }
.day-head { display: flex; justify-content: space-between; padding: 8px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); }
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.tx:hover, .tx:focus-visible { background: var(--surface-2); }
.tx.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.tx .grow { flex: 1; min-width: 0; }
.tx .title { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .amount { font-weight: 620; white-space: nowrap; }
.to-check { font-size: 10.5px; font-weight: 650; color: #6b4700; background: #fbd36b; border-radius: 5px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }
.chip-filter { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; font-weight: 600; }
.chip-filter button { border: 0; background: none; color: inherit; padding: 0 3px; display: grid; place-items: center; }
.chip-filter .i { width: 14px; height: 14px; }

/* ---------- Today ---------- */
.greet { font-size: 30px; }
.next-card {
  padding: 26px 28px; overflow: hidden;
  background: radial-gradient(600px 220px at 0% 0%, var(--accent-soft), transparent 70%), var(--surface);
}
.next-card .eyebrow { color: var(--accent-text); display: flex; align-items: center; gap: 8px; }
.next-card .eyebrow .i { width: 15px; height: 15px; }
.next-card .md { font-size: 19px; line-height: 1.5; font-weight: 520; letter-spacing: -0.015em; margin-top: 12px; max-width: 900px; }
.next-card .md p:last-child { margin-bottom: 0; }
.next-card .md code { font-size: 15px; }
.next-meta { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12.5px; margin-top: 16px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 16px 18px; }
.stat-card .chip-icon { width: 32px; height: 32px; border-radius: 10px; margin-bottom: 12px; }
.stat-card .chip-icon .i { width: 16px; height: 16px; }
.mini-meter { height: 4px; border-radius: 99px; background: var(--track); margin-top: 10px; overflow: hidden; }
.mini-meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.standard { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 16px; }
.std-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px 7px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 540; font-size: 13px; transition: all .15s;
}
.std-chip .tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; }
.std-chip .tick .i { width: 12px; height: 12px; stroke-width: 3; opacity: 0; }
.std-chip:hover { border-color: var(--accent); color: var(--ink); }
.std-chip.done { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.std-chip.done .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.std-chip.done .tick .i { opacity: 1; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; padding-top: 0; }
.box {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); flex: none; margin-top: 1px; padding: 0;
  background: transparent; display: grid; place-items: center; color: var(--accent-ink); transition: all .15s;
}
.box .i { width: 13px; height: 13px; stroke-width: 3; opacity: 0; }
.box:hover { border-color: var(--accent); }
.box.done { background: var(--accent); border-color: var(--accent); }
.box.done .i { opacity: 1; }
.checks li.done .text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.tracks { display: grid; gap: 14px; }
.track-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 44px; gap: 14px; align-items: center; }
.track-name { font-weight: 560; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-name:hover { color: var(--accent-text); }
.track-bar { display: flex; gap: 2px; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.track-bar > span { height: 100%; min-width: 4px; }
.track-count { text-align: right; color: var(--ink-2); font-size: 12.5px; }
.track-current { grid-column: 2 / 4; color: var(--muted); font-size: 12px; margin-top: -8px; }
.quick { display: flex; gap: 8px; margin-top: 14px; }
.quick .input { height: 36px; font-size: 13px; }
.mission-quote { font-size: 17px; line-height: 1.55; font-weight: 520; margin: 0 0 14px; padding-left: 14px; border-left: 3px solid var(--accent); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 9px 16px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; white-space: nowrap; }

/* ---------- Markdown ---------- */
.md { overflow-wrap: anywhere; line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: 26px; letter-spacing: -0.03em; margin: 0 0 16px; line-height: 1.2; }
.md h2 { font-size: 18px; letter-spacing: -0.02em; margin: 30px 0 10px; }
.md h3 { font-size: 15px; margin: 22px 0 8px; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--muted); }
.md blockquote { margin: 0 0 14px; padding: 4px 0 4px 16px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.md code { font: 500 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.md pre { background: var(--surface-2); padding: 14px 16px; border-radius: 12px; overflow-x: auto; border: 1px solid var(--line); }
.md pre code { background: none; border: 0; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.md table { border-collapse: separate; border-spacing: 0; margin: 0 0 16px; display: block; overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; }
.md th, .md td { padding: 8px 12px; text-align: left; vertical-align: top; font-size: 13px; border-bottom: 1px solid var(--line); }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--surface-2); font-weight: 620; }
.md a { text-decoration: underline; text-decoration-color: var(--accent-soft); text-underline-offset: 3px; }
.md input[type="checkbox"] { accent-color: var(--accent); margin: 0 6px 0 0; }

/* ---------- Files ---------- */
.files { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.file-nav { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 14px 12px; }
.file-group { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 14px 10px 6px; }
.file-group:first-child { margin-top: 4px; }
.file-nav a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.file-nav a .i { width: 15px; height: 15px; color: var(--muted); }
.file-nav a:hover { background: var(--surface-2); color: var(--ink); }
.file-nav a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.file-nav a[aria-current="true"] .i { color: var(--accent-text); }
.doc { padding: 34px 44px 40px; }
.doc .md { max-width: 760px; font-size: 15px; }
.doc-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.doc-path { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.doc-actions { display: flex; align-items: center; gap: 8px; }
.editor {
  width: 100%; min-height: 480px; resize: vertical; padding: 18px 20px; border-radius: 14px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
  font: 13.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2;
}
.editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.file-select { display: none; margin-bottom: 14px; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; border-radius: 22px; padding: 0; width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(5, 5, 12, .5); backdrop-filter: blur(4px); }
.dlg { padding: 24px; display: grid; gap: 16px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.seg3 { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.seg3 label { text-align: center; padding: 8px 0; border-radius: 10px; font-weight: 560; color: var(--ink-2); cursor: pointer; font-size: 13.5px; }
.seg3 input { position: absolute; opacity: 0; pointer-events: none; }
.seg3 label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg3 label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 560; }
.amount-field input { height: 58px; font-size: 30px; font-weight: 680; letter-spacing: -0.03em; padding: 0 16px; }
.amount-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.amount-row:has(#max-field[hidden]) { grid-template-columns: 1fr; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-field { display: flex; gap: 9px; align-items: center; font-size: 13.5px; color: var(--ink-2); }
.check-field input { accent-color: var(--accent); width: 16px; height: 16px; }
.error { color: var(--crit-text); font-size: 13px; margin: 0; }
.dlg-foot { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
.dlg-foot .spacer { flex: 1; }

/* ---------- Tooltip, toast, offline ---------- */
#tooltip {
  position: fixed; z-index: 50; pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  padding: 10px 12px; font-size: 12.5px; min-width: 150px;
}
#tooltip.show { opacity: 1; transform: none; }
.tt-title { color: var(--ink-2); margin-bottom: 4px; font-size: 12px; }
.tt-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.tt-row b { font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 650; }
.tt-row span { color: var(--ink-2); }
.tt-row .key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tt-foot { border-top: 1px solid var(--line); margin-top: 7px; padding-top: 6px; color: var(--ink-2); }
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); opacity: 0; transition: .25s cubic-bezier(.2, .9, .3, 1.2);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 560; font-size: 13.5px;
  pointer-events: none; max-width: calc(100vw - 32px); z-index: 60; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#offline { display: none; position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--critical); color: #fff; padding: 8px 16px; border-radius: 12px; font-weight: 560; font-size: 13px; }
body.is-offline #offline { display: block; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); padding: 34px; display: grid; gap: 16px; }
.login .logo-mark { width: 44px; height: 44px; }
.login h1 { font-size: 24px; letter-spacing: -0.03em; margin: 6px 0 0; }
.login p { color: var(--ink-2); margin: -8px 0 6px; }

/* ---------- Load-in ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ---------- Narrower screens ---------- */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .row-2, .row-2e { grid-template-columns: 1fr; }
  .files { grid-template-columns: 1fr; }
  .file-nav { display: none; }
  .file-select { display: block; }
  .tabbar {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40;
    justify-content: space-around; align-items: center; padding: 8px 6px; border-radius: 22px;
    background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  }
  .tabbar a, .tabbar .tab-link {
    display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10.5px; font-weight: 600;
    border: 0; background: none; padding: 4px 8px; min-width: 56px;
  }
  .tabbar a .i, .tabbar .tab-link .i { width: 21px; height: 21px; }
  .tabbar a[aria-current="page"] { color: var(--accent-text); }
  .tab-add {
    width: 48px; height: 48px; border-radius: 16px; border: 0; display: grid; place-items: center; color: #fff;
    background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: 0 10px 24px -8px var(--accent);
  }
  .tab-add .i { width: 22px; height: 22px; stroke-width: 2.2; }
}
@media (max-width: 720px) {
  .page-title, .greet { font-size: 25px; }
  .hero-figure { font-size: 40px; }
  .hero-card { padding: 22px 20px 16px; }
  .hero-stats { grid-template-columns: 1fr 1fr; margin: 16px -20px -16px; }
  .hero-stats > div { padding: 12px 20px 14px; }
  .hero-stats > div:nth-child(3) { border-left: 0; }
  .hero-stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .card { padding: 18px; border-radius: 18px; }
  .next-card { padding: 20px; }
  .next-card .md { font-size: 17px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-grid .stat-card:last-child { grid-column: 1 / -1; }
  .where-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .where-row .where-bar { grid-column: 2 / 4; grid-row: 2; }
  .add-acct { grid-template-columns: 1fr 1fr; }
  .search-box .input { width: 150px; }
  .doc { padding: 22px 18px; }
  .page-actions .btn-label, .page-actions kbd { display: none; }
}
