/* ═══════════════════════════════════════════════════════════════════
   Kharcha — design system
   Concept: a modern bahi-khata. Paper, ink, one vermilion accent.
   Type: Fraunces (display) + Inter (body, tabular numbers).
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* paper & ink (light) */
  --bg: oklch(0.975 0.008 80);
  --bg-deep: oklch(0.955 0.01 80);
  --surface: oklch(0.992 0.004 80);
  --surface-2: oklch(0.965 0.008 80);
  --ink: oklch(0.17 0.015 55);
  --ink-2: oklch(0.36 0.015 55);
  --ink-3: oklch(0.52 0.015 55);
  --ink-4: oklch(0.66 0.012 55);
  --line: oklch(0.17 0.015 55 / 0.09);
  --line-strong: oklch(0.17 0.015 55 / 0.18);

  /* accents — exactly two */
  --accent: oklch(0.58 0.19 32);           /* vermilion / sindoor */
  --accent-ink: oklch(0.99 0.004 80);
  --accent-soft: oklch(0.58 0.19 32 / 0.10);
  --income: oklch(0.58 0.13 152);          /* moss green */
  --income-soft: oklch(0.58 0.13 152 / 0.12);
  --warn: oklch(0.72 0.14 78);
  --warn-soft: oklch(0.72 0.14 78 / 0.16);

  /* legacy aliases used by components */
  --text: var(--ink); --text-2: var(--ink-2); --muted: var(--ink-3); --border: var(--line);
  --primary: var(--accent); --primary-soft: var(--accent-soft); --success: var(--income); --success-soft: var(--income-soft);
  --danger: var(--accent); --danger-soft: var(--accent-soft); --surface-3: var(--surface-2);

  --shadow: 0 1px 0 oklch(0.17 0.015 55 / 0.04), 0 18px 40px -28px oklch(0.17 0.015 55 / 0.35);
  --shadow-lg: 0 40px 90px -40px oklch(0.17 0.015 55 / 0.5);

  --r-xs: 6px; --r-sm: 10px; --r: 14px; --r-lg: 20px;
  --sidebar-w: 236px;
  --gutter: clamp(16px, 3vw, 40px);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --d-micro: 150ms; --d-sm: 250ms; --d-md: 400ms; --d-lg: 650ms;

  --t-display: clamp(3.2rem, 7vw + 1rem, 7rem);
  --t-h1: clamp(1.9rem, 2.2vw + 1rem, 2.6rem);
  --t-h2: clamp(1.25rem, 1vw + 0.8rem, 1.6rem);
  --t-body: 0.95rem;
  --t-label: 0.7rem;
}
html[data-theme="dark"] {
  --bg: oklch(0.17 0.012 60);
  --bg-deep: oklch(0.15 0.012 60);
  --surface: oklch(0.205 0.012 60);
  --surface-2: oklch(0.245 0.012 60);
  --ink: oklch(0.95 0.008 80);
  --ink-2: oklch(0.80 0.01 80);
  --ink-3: oklch(0.64 0.012 80);
  --ink-4: oklch(0.50 0.012 80);
  --line: oklch(0.95 0.008 80 / 0.09);
  --line-strong: oklch(0.95 0.008 80 / 0.18);
  --accent: oklch(0.70 0.15 32);
  --accent-ink: oklch(0.15 0.012 60);
  --accent-soft: oklch(0.70 0.15 32 / 0.14);
  --income: oklch(0.72 0.12 152);
  --income-soft: oklch(0.72 0.12 152 / 0.14);
  --warn: oklch(0.80 0.12 80);
  --warn-soft: oklch(0.80 0.12 80 / 0.16);
  --shadow: 0 1px 0 oklch(1 0 0 / 0.03), 0 20px 50px -30px oklch(0 0 0 / 0.8);
  --shadow-lg: 0 40px 90px -40px oklch(0 0 0 / 0.9);
}

/* ───────────── base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font-body); font-size: var(--t-body); line-height: 1.55; letter-spacing: -0.011em;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color var(--d-md) var(--ease-out), color var(--d-md) var(--ease-out);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; letter-spacing: inherit; }
input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: var(--t-h2); line-height: 1.15; }
h3 { font-size: 1.05rem; line-height: 1.25; }
.serif { font-family: var(--font-display); font-weight: 500; font-variation-settings: 'opsz' 72; letter-spacing: -0.015em; }
.serif i, .serif em { font-style: italic; font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow, .label {
  font-size: var(--t-label); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); line-height: 1.2;
}
.hint { font-size: 0.8rem; color: var(--ink-3); letter-spacing: -0.005em; }
.hint a, .link { color: var(--accent); font-weight: 600; }
code { font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace; font-size: 0.8em; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); }
kbd { font: 600 10px/1 var(--font-body); padding: 3px 5px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--ink-3); letter-spacing: 0.04em; }
i[data-icon], .icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-icon] svg, .icon svg { width: 100%; height: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ───────────── shell ───────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 28px 20px 22px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 20px;
  color: var(--accent-ink); background: var(--ink);
}
.brand-text { display: flex; flex-direction: column; font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1; letter-spacing: -0.02em; gap: 5px; }
.brand-text small { font-family: var(--font-body); font-weight: 500; font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.1em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.nav a {
  display: grid; grid-template-columns: 30px 1fr; align-items: center;
  padding: 14px 6px; border-bottom: 1px solid var(--line);
  color: var(--ink-3); font-weight: 500; font-size: 0.95rem;
  transition: color var(--d-sm) var(--ease-out), padding-left var(--d-md) var(--ease-out);
}
.nav a .nav-idx { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-4); transition: color var(--d-sm); }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); font-weight: 600; padding-left: 10px; }
.nav a.active .nav-idx { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sync-pill {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: transparent;
  font-size: 0.78rem; font-weight: 500; color: var(--ink-2); text-align: left;
  transition: border-color var(--d-sm), background var(--d-sm);
}
.sync-pill:hover { border-color: var(--line-strong); background: var(--surface); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); flex: none; }
[data-status="connected"] .sync-dot { background: var(--income); box-shadow: 0 0 0 4px var(--income-soft); }
[data-status="syncing"] .sync-dot, [data-status="connecting"] .sync-dot { background: var(--accent); animation: pulse 1s infinite; }
[data-status="error"] .sync-dot, [data-status="reconnect"] .sync-dot { background: var(--warn); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.user-chip .u-name { font-size: 0.8rem; font-weight: 600; line-height: 1.2; }
.user-chip .u-mail { font-size: 0.7rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px var(--gutter) 14px;
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.page-title { font-family: var(--font-display); font-weight: 500; font-size: var(--t-h1); line-height: 1; letter-spacing: -0.025em; font-variation-settings: 'opsz' 72; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.month-nav { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.month-nav .btn-icon { width: 34px; height: 34px; border-radius: 0; }
.month-label { border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: transparent; padding: 0 12px; height: 34px; font-weight: 600; font-size: 0.85rem; min-width: 150px; letter-spacing: -0.01em; }
.month-label:hover { background: var(--surface-2); }
.view { padding: 8px var(--gutter) 120px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ───────────── buttons & inputs ───────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); font-weight: 600; font-size: 0.85rem; letter-spacing: -0.005em;
  background: var(--surface); color: var(--ink); white-space: nowrap; overflow: hidden; isolation: isolate;
  transition: transform var(--d-micro) var(--ease-out), border-color var(--d-sm), background var(--d-sm), color var(--d-sm);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--accent); transform: scaleX(0); transform-origin: right; transition: transform var(--d-md) var(--ease-out); }
.btn-primary:hover::before { transform: scaleX(1); transform-origin: left; }
.btn-primary:hover { color: var(--accent-ink); border-color: var(--accent); }
.btn-primary kbd { border-color: oklch(1 0 0 / 0.25); color: inherit; opacity: .7; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-3); }
.btn-soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-soft:hover { background: var(--accent); color: var(--accent-ink); }
.btn-danger { background: transparent; color: var(--accent); border-color: var(--accent-soft); }
.btn-danger:hover { background: var(--accent); color: var(--accent-ink); }
.btn-sm { padding: 7px 12px; font-size: 0.78rem; }
.btn-icon { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-xs); border: 0; background: transparent; color: var(--ink-3); transition: background var(--d-sm), color var(--d-sm); }
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-theme { width: 36px; height: 36px; padding: 0; justify-content: center; }
.btn-theme span { display: none; }

.input, .select, textarea.input {
  width: 100%; padding: 10px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); outline: none;
  transition: border-color var(--d-sm), box-shadow var(--d-sm);
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--ink-4); }
.select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.field { display: flex; flex-direction: column; gap: 7px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-sm); background: var(--surface-2); gap: 2px; border: 1px solid var(--line); }
.seg-btn { padding: 7px 13px; border-radius: 7px; border: 0; background: transparent; font-weight: 600; font-size: 0.8rem; color: var(--ink-3); transition: background var(--d-sm), color var(--d-sm); }
.seg-btn.active { background: var(--ink); color: var(--bg); }
.search { position: relative; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }
.search .input { padding-left: 38px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); transition: all var(--d-sm) var(--ease-out); }
.chip:hover { border-color: var(--ink); }
.chip.active { border-color: var(--ink); background: var(--ink); color: var(--bg); }

/* ───────────── surfaces ───────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(18px, 2.2vw, 26px); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head .sub { font-size: 0.8rem; color: var(--ink-3); margin-top: 3px; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line-strong); margin-bottom: 4px; }
.section-head h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1.1fr .9fr; }

/* ───────────── hero (statement) ───────────── */
.hero { padding: clamp(18px, 4vw, 48px) 0 clamp(16px, 2.5vw, 28px); border-bottom: 1px solid var(--line-strong); }
.hero .eyebrow { margin-bottom: 14px; display: flex; gap: 14px; align-items: center; }
.hero .eyebrow .sep { width: 24px; height: 1px; background: var(--line-strong); }
.hide-sm { display: inline-flex; align-items: center; gap: 14px; }
.hero-amount {
  font-family: var(--font-display); font-weight: 400; font-variation-settings: 'opsz' 144;
  font-size: var(--t-display); line-height: 0.92; letter-spacing: -0.035em; font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.hero-amount .cur { font-size: 0.5em; vertical-align: 0.5em; margin-right: 0.08em; color: var(--ink-3); font-weight: 300; }
.hero-line { margin-top: 16px; font-size: clamp(1rem, 1.1vw + 0.5rem, 1.25rem); color: var(--ink-2); max-width: 60ch; text-wrap: pretty; }
.hero-line b { color: var(--ink); font-weight: 600; }
.hero-line .up { color: var(--accent); } .hero-line .down { color: var(--income); }
.hero-track { margin-top: 26px; display: grid; gap: 8px; }
.hero-track .track { position: relative; height: 3px; background: var(--line-strong); border-radius: 2px; overflow: visible; }
.hero-track .track > span { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: var(--ink); transition: width 1.2s var(--ease-out); border-radius: 2px; }
.hero-track .track.warn > span { background: var(--warn); }
.hero-track .track.over > span { background: var(--accent); }
.hero-track .track .mark { position: absolute; top: -5px; width: 1px; height: 13px; background: var(--ink-3); }
.hero-track .track .mark::after { content: attr(data-l); position: absolute; top: 15px; left: 50%; transform: translateX(-50%); font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); white-space: nowrap; }
.hero-track .meta { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--ink-3); margin-top: 14px; }
.hero-track .meta b { color: var(--ink); }

/* ───────────── bento ───────────── */
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-top: 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(18px, 2.2vw, 26px); min-width: 0; animation: rise var(--d-lg) var(--ease-out) both; }
.tile:nth-child(1) { animation-delay: 60ms; } .tile:nth-child(2) { animation-delay: 120ms; } .tile:nth-child(3) { animation-delay: 180ms; } .tile:nth-child(4) { animation-delay: 240ms; }
.tile-7 { grid-column: span 7; } .tile-5 { grid-column: span 5; } .tile-12 { grid-column: span 12; } .tile-4 { grid-column: span 4; }
.tile-ink { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tile-ink .eyebrow, .tile-ink .hint { color: oklch(from var(--bg) l c h / 0.6); }
.tile-ink .kpi { border-color: oklch(from var(--bg) l c h / 0.14); }
.kpi-list { display: flex; flex-direction: column; }
.kpi { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.kpi:first-child { padding-top: 0; } .kpi:last-child { border-bottom: 0; padding-bottom: 0; }
.kpi .k { font-size: 0.8rem; color: var(--ink-3); }
.tile-ink .kpi .k { color: oklch(from var(--bg) l c h / 0.6); }
.kpi .v { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi .v.income { color: var(--income); }
.kpi .v small { font-family: var(--font-body); font-size: 0.72rem; color: var(--ink-3); margin-left: 6px; font-weight: 500; letter-spacing: 0; }
.tile-ink .kpi .v small { color: oklch(from var(--bg) l c h / 0.6); }

/* donut */
.donut-wrap { display: flex; align-items: center; gap: 26px; }
.donut { width: 176px; height: 176px; flex: none; }
.donut-seg { transition: stroke-dasharray 1s var(--ease-out); }
.donut-center { position: relative; }
.donut-center .dc { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center .dc b { font-family: var(--font-display); font-weight: 500; font-size: 1.45rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut-center .dc small { display: block; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-top: 2px; }
.legend { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.legend-item { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; font-size: 0.85rem; padding: 7px 0; border-bottom: 1px solid var(--line); }
.legend-item:last-child { border-bottom: 0; }
.legend-item .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.legend-item .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-item .pct { color: var(--ink-4); font-size: 0.72rem; margin-left: 8px; font-variant-numeric: tabular-nums; }

/* bars */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 14px; height: var(--h, 170px); align-items: end; padding-top: 10px; border-bottom: 1px solid var(--line-strong); }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 5px; }
.bar { width: 40%; max-width: 30px; border-radius: 3px 3px 0 0; background: var(--ink); transform-origin: bottom; animation: growBar var(--d-lg) var(--ease-out) both; position: relative; }
.bar.income { background: transparent; border: 1.5px solid var(--income); border-bottom: 0; }
.bar-col.current .bar { background: var(--accent); }
.bar-label { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; margin-bottom: -22px; padding-top: 6px; }
.bar-col.current .bar-label { color: var(--accent); }
.bars-foot { height: 20px; }
.bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: 0.68rem; font-weight: 600; padding: 4px 8px; border-radius: 5px; white-space: nowrap; z-index: 2; }
.bar-legend { display: flex; gap: 16px; font-size: 0.72rem; color: var(--ink-3); margin-top: 26px; }
.bar-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--ink); }
.bar-legend span.inc::before { background: transparent; border: 1.5px solid var(--income); }

/* ───────────── ledger (transactions) ───────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 18px; }
.toolbar .search { flex: 1; min-width: 220px; }
.toolbar .select { width: auto; min-width: 170px; }
.ledger-summary { display: flex; justify-content: space-between; align-items: baseline; padding: 0 0 10px; border-bottom: 1px solid var(--line-strong); }
.ledger-summary .n { font-size: 0.8rem; color: var(--ink-3); }
.ledger-summary .t { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tx-group { margin-top: 22px; }
.tx-date { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 8px; }
.tx-date span { font-size: var(--t-label); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.tx-date b { font-size: 0.8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 500; }
.tx-list { display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.tx {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 14px;
  padding: 12px 6px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: transparent; text-align: left; width: 100%;
  transition: background var(--d-sm) var(--ease-out), padding-left var(--d-md) var(--ease-out);
  animation: rise var(--d-md) var(--ease-out) both;
}
.tx:hover { background: var(--surface); padding-left: 12px; }
.tx-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; }
.tx-body { min-width: 0; }
.tx-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.tx-sub { font-size: 0.76rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; margin-top: 1px; }
.tx-sub .dotsep::before { content: '·'; margin-right: 6px; }
.tx-amt { font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; font-size: 0.95rem; }
.tx-amt.income { color: var(--income); } .tx-amt.income::before { content: '+'; }
.tx-list.compact .tx { padding: 10px 6px; }

/* ───────────── budgets ───────────── */
.budget-row { display: grid; grid-template-columns: 40px 1fr 130px; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.budget-row:last-child { border-bottom: 0; }
.budget-row .b-name { font-weight: 600; font-size: 0.92rem; }
.budget-row .b-meta { font-size: 0.76rem; color: var(--ink-3); margin: 2px 0 8px; display: flex; justify-content: space-between; gap: 10px; }
.budget-row .b-meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.budget-row .input { text-align: right; padding: 8px 10px; font-variant-numeric: tabular-nums; }
.budget-row.over .b-meta b { color: var(--accent); }
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 2px; background: var(--ink); width: 0; transition: width 1s var(--ease-out); }
.progress.warn > span { background: var(--warn); } .progress.over > span { background: var(--accent); } .progress.ok > span { background: var(--income); }
.progress-lg { height: 6px; }
.cat-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .c-name { font-weight: 600; font-size: 0.9rem; }
.cat-row .c-sub { font-size: 0.74rem; color: var(--ink-3); }
.cat-row .actions { display: flex; gap: 2px; }

/* planner */
.planner { position: relative; overflow: hidden; }
.planner::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--income)); }
.planner-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: end; margin-bottom: 22px; }
.planner-head h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.4rem, 1.6vw + 0.6rem, 2rem); margin-top: 8px; }
.planner-head p { margin-top: 6px; max-width: 52ch; }
.planner-base { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 18px; align-items: end; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.amount-wrap { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 4px 12px; background: var(--surface); transition: border-color var(--d-sm), box-shadow var(--d-sm); }
.amount-wrap:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.amount-wrap .cur { font-family: var(--font-display); font-size: 1.4rem; color: var(--ink-3); font-weight: 400; }
.amount-wrap input { border: 0; background: transparent; outline: none; font-family: var(--font-display); font-weight: 500; font-size: 2rem; width: 100%; letter-spacing: -0.02em; padding: 2px 0; font-variant-numeric: tabular-nums; }
.amount-wrap.lg input { font-size: 2.6rem; } .amount-wrap.lg .cur { font-size: 1.8rem; }
.amount-wrap input::-webkit-outer-spin-button, .amount-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.amount-wrap input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.alloc-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--line); margin-top: 22px; }
.alloc-bar span { display: block; height: 100%; transition: width var(--d-md) var(--ease-out); }
.alloc-meta { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--ink-3); margin-top: 10px; }
.alloc-meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.alloc-meta.over b { color: var(--accent); }
.alloc-rows { margin-top: 14px; }
.alloc-row { display: grid; grid-template-columns: 34px minmax(110px, 1.2fr) 2fr 84px 110px; gap: 14px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.alloc-row:last-child { border-bottom: 0; }
.alloc-row .tx-ico { width: 34px; height: 34px; border-radius: 8px; font-size: 16px; }
.alloc-row .a-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-row.zero .a-name { color: var(--ink-3); font-weight: 500; }
.alloc-row .a-pct { display: flex; align-items: center; gap: 4px; }
.alloc-row .a-pct input { width: 56px; padding: 6px 8px; text-align: right; }
.alloc-row .a-pct span { color: var(--ink-3); font-size: 0.8rem; }
.alloc-row .a-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.alloc-row.zero .a-amt { color: var(--ink-4); font-weight: 500; }
input[type=range] { width: 100%; height: 22px; margin: 0; background: transparent; accent-color: var(--ink); cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: var(--line-strong); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); margin-top: -6.5px; transition: transform var(--d-micro); }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type=range]::-moz-range-track { height: 3px; background: var(--line-strong); border-radius: 2px; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); }
.planner-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* category chooser */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.cat-chip { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: var(--r-sm); border: 1px solid var(--line); background: transparent; font-size: 0.72rem; font-weight: 600; color: var(--ink-2); transition: border-color var(--d-sm), background var(--d-sm), transform var(--d-micro) var(--ease-out); }
.cat-chip:hover { border-color: var(--ink-3); }
.cat-chip.active { border-color: var(--ink); background: var(--surface-2); color: var(--ink); }
.cat-chip .em { font-size: 18px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; }
.cat-chip span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform var(--d-micro) var(--ease-back); }
.color-dot.active { border-color: var(--ink); transform: scale(1.15); }

/* empty */
.empty { text-align: center; padding: clamp(40px, 8vw, 80px) 20px; color: var(--ink-3); }
.empty .em { font-size: 40px; margin-bottom: 12px; }
.empty h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.6rem; color: var(--ink); margin-bottom: 8px; }
.empty .btn { margin-top: 18px; }

/* settings */
.settings-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; margin-top: 8px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .s-title { font-weight: 600; font-size: 0.9rem; }
.setting-row .s-desc { font-size: 0.76rem; color: var(--ink-3); margin-top: 2px; }
.setting-row .select { width: 180px; }
.status-line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 0.85rem; }
details.steps { margin-top: 14px; border-top: 1px solid var(--line); }
details.steps summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-size: 0.85rem; list-style: none; display: flex; justify-content: space-between; }
details.steps summary::after { content: '+'; color: var(--ink-3); } details[open].steps summary::after { content: '–'; }
details.steps ol { margin: 0 0 14px; padding-left: 20px; font-size: 0.85rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 8px; }
.danger-zone { border-color: var(--accent-soft); }
.danger-zone h2 { color: var(--accent); }

/* ───────────── modal ───────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: oklch(0.17 0.015 55 / 0.45); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; animation: fadeIn var(--d-sm) var(--ease-out); }
html[data-theme="dark"] .modal-backdrop { background: oklch(0 0 0 / 0.6); }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: popIn var(--d-md) var(--ease-out); }
.modal.sm { width: min(430px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-head h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; }
.modal-body { padding: 18px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }
.modal-foot .left { margin-right: auto; }
.modal-backdrop.closing { animation: fadeOut 180ms var(--ease-out) forwards; }
.modal-backdrop.closing .modal { animation: popOut 180ms var(--ease-out) forwards; }

/* ───────────── toast ───────────── */
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: var(--r-sm); background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.82rem; box-shadow: var(--shadow-lg); animation: toastIn var(--d-md) var(--ease-out); pointer-events: auto; }
.toast.success { background: var(--income); color: oklch(0.99 0 0); }
.toast.error { background: var(--accent); color: var(--accent-ink); }
.toast.out { animation: toastOut var(--d-sm) var(--ease-out) forwards; }

.bottomnav { display: none; }

/* ───────────── motion ───────────── */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes popOut { to { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
@keyframes growBar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.view > * { animation: rise var(--d-lg) var(--ease-out) both; }
.view > *:nth-child(2) { animation-delay: 80ms; } .view > *:nth-child(3) { animation-delay: 160ms; } .view > *:nth-child(4) { animation-delay: 240ms; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  html { scroll-behavior: auto; }
}

/* ───────────── responsive ───────────── */
@media (max-width: 1100px) {
  .tile-7, .tile-5 { grid-column: span 12; }
  .tile-4 { grid-column: span 6; }
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 14px 16px 10px; }
  .view { padding: 4px 16px 120px; }
  .month-label { min-width: 0; font-size: 0.78rem; padding: 0 8px; }
  .btn-primary[data-action="new-tx"] { display: none; }
  .tile-4 { grid-column: span 12; }
  .budget-row { grid-template-columns: 40px 1fr; }
  .budget-row .input { grid-column: 2; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut-center { margin: 0 auto; }
  .planner-head, .planner-base { grid-template-columns: 1fr; }
  .alloc-row { grid-template-columns: 34px 1fr 84px; grid-template-areas: 'ico name pct' 'ico range amt'; row-gap: 6px; }
  .alloc-row .tx-ico { grid-area: ico; } .alloc-row .a-name { grid-area: name; } .alloc-row input[type=range] { grid-area: range; }
  .alloc-row .a-pct { grid-area: pct; justify-content: flex-end; } .alloc-row .a-amt { grid-area: amt; }
  .bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: grid; grid-template-columns: 1fr 1fr 72px 1fr 1fr; align-items: center;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in oklch, var(--bg) 88%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; font-size: 0.65rem; font-weight: 600; letter-spacing: 0.04em; color: var(--ink-4); }
  .bottomnav a.active { color: var(--ink); }
  .fab { width: 54px; height: 54px; border-radius: 16px; border: 0; margin: -26px auto 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; box-shadow: var(--shadow-lg); }
  .fab i { width: 24px; height: 24px; }
  .hero-track .meta { flex-direction: column; gap: 4px; }
}
@media (max-width: 480px) {
  .row2 { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi .v { font-size: 1.25rem; }
  .toolbar .seg { width: 100%; } .toolbar .seg-btn { flex: 1; }
}

/* small-screen refinements */
@media (max-width: 860px) {
  .hero .eyebrow { flex-wrap: wrap; gap: 8px 10px; }
  .hero .eyebrow .sep { width: 12px; }
  .hide-sm { display: none; }
  .hero-line { font-size: 1rem; }
}

/* ───────────── category budget progress (Overview + form) ───────────── */
.cb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.cb-row { display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: center; padding: 13px 4px; border-bottom: 1px solid var(--line); border-radius: 0; transition: background var(--d-sm) var(--ease-out), padding-left var(--d-md) var(--ease-out); }
.cb-row:hover { background: var(--surface-2); padding-left: 10px; }
.cb-main { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.cb-top, .cb-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.cb-name { font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pct { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.06em; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--ink-3); }
.cb-state { font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--income); }
.cb-row.warn .cb-state { color: var(--warn); }
.cb-row.over .cb-state { color: var(--accent); }
.cb-row.full .cb-state { color: var(--ink-2); }
.progress.full > span { background: var(--ink-2); }
.cb-meta { font-size: 0.74rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cb-meta b { color: var(--ink); font-weight: 600; }
.cb-row .progress { position: relative; overflow: visible; }
.cb-row .progress > span { border-radius: 2px; }
.cb-pace { position: absolute; top: -3px; width: 1.5px; height: 10px; background: var(--ink-3); border-radius: 1px; }
.cb-flag { color: var(--warn); font-weight: 600; }
.cb-empty { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.f-budget { margin-top: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; animation: rise var(--d-md) var(--ease-out); }
.f-budget .fb-top { display: flex; justify-content: space-between; font-size: 0.74rem; font-weight: 600; color: var(--ink-3); letter-spacing: 0.01em; }
.f-budget .fb-text { font-size: 0.82rem; color: var(--ink-2); }
.f-budget .fb-text b { color: var(--ink); font-variant-numeric: tabular-nums; }
.f-budget .progress { position: relative; height: 6px; }
.f-budget .progress > span:first-child { background: var(--ink-3); }
.f-budget .fb-add { position: absolute; top: 0; height: 100%; background: var(--income); border-radius: 0 3px 3px 0; transition: width var(--d-sm) var(--ease-out); }
.f-budget.warn .fb-add { background: var(--warn); }
.f-budget.over { border-color: var(--accent-soft); background: var(--accent-soft); }
.f-budget.over .fb-add { background: var(--accent); }
.f-budget.over .fb-text b { color: var(--accent); }
@media (max-width: 860px) { .cb-grid { grid-template-columns: 1fr; } }
