/* Penny Pages · Notion x retro. Tokens first, components after. */

:root {
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --pixel: 'Press Start 2P', 'Space Mono', monospace;
  --sidebar-w: 244px;
}

/* ── light / dark base tokens ── */
[data-mode="light"] {
  color-scheme: light;
  --bg: #f5f4ef; --grid: rgba(31, 31, 29, .045);
  --surface: #ffffff; --surface-2: #f1f0ea;
  --text: #1f1f1d; --dim: #6d6c65; --line: #e2e0d6;
  --ink: #1f1f1d; --shadow: #1f1f1d;
  --income: #2e8b3d; --income-bg: #dff3d9;
  --expense: #cf3d3d; --expense-bg: #fbdcdc;
  --hero: #1c1c1b; --hero-text: #f5f4ef;
  --bar2: #26261f;
}
[data-mode="dark"] {
  color-scheme: dark;
  --bg: #121211; --grid: rgba(255, 255, 255, .035);
  --surface: #1c1c1a; --surface-2: #262624;
  --text: #f0efe8; --dim: #9c9b92; --line: #34342f;
  --ink: #4b4b45; --shadow: color-mix(in srgb, var(--accent) 30%, #000);
  --income: #86dc8f; --income-bg: #1f3a22;
  --expense: #ff8d85; --expense-bg: #4a2220;
  --hero: #0b0b0a; --hero-text: #f0efe8;
  --bar2: #8b8a80;
}

/* ── palettes × modes (4 × 2 = 8 combinations) ── */
[data-palette="lime"][data-mode="light"] {
  --accent: #d8ee7c; --accent-soft: #ecf6bc; --accent-on: #1c1c1b; --accent-strong: #5f7a0f;
  --c1: #2f3b0d; --c2: #5d7716; --c3: #86a626; --c4: #b2d03e; --c5: #d6ea7a; --c6: #eef6c0; --c7: #4a4a45; --c8: #a8a79d;
}
[data-palette="lime"][data-mode="dark"] {
  --accent: #d8ee7c; --accent-soft: #2c3410; --accent-on: #1c1c1b; --accent-strong: #cde66a;
  --c1: #d8ee7c; --c2: #b2d03e; --c3: #86a626; --c4: #5d7716; --c5: #3f5210; --c6: #e9f5b5; --c7: #8a8a82; --c8: #5a5a53;
}
[data-palette="tangerine"][data-mode="light"] {
  --accent: #ffb04a; --accent-soft: #ffe5c2; --accent-on: #1f1408; --accent-strong: #b84f00;
  --c1: #7a2e00; --c2: #b84f00; --c3: #e8791a; --c4: #ffb04a; --c5: #ffd08a; --c6: #ffeccd; --c7: #4a4a45; --c8: #a8a79d;
}
[data-palette="tangerine"][data-mode="dark"] {
  --accent: #ffb04a; --accent-soft: #3a2812; --accent-on: #1f1408; --accent-strong: #ffc27a;
  --c1: #ffb04a; --c2: #e8791a; --c3: #b84f00; --c4: #7a3a0a; --c5: #ffd08a; --c6: #ffeccd; --c7: #8a8a82; --c8: #5a5a53;
}
[data-palette="bubblegum"][data-mode="light"] {
  --accent: #ff9fcf; --accent-soft: #ffdcee; --accent-on: #2a0f1e; --accent-strong: #b82b78;
  --c1: #6e1346; --c2: #b82b78; --c3: #e85aa3; --c4: #ff9fcf; --c5: #ffc9e4; --c6: #7c5cff; --c7: #4a4a45; --c8: #a8a79d;
}
[data-palette="bubblegum"][data-mode="dark"] {
  --accent: #ff9fcf; --accent-soft: #3a1730; --accent-on: #2a0f1e; --accent-strong: #ffb3da;
  --c1: #ff9fcf; --c2: #e85aa3; --c3: #b82b78; --c4: #7c5cff; --c5: #a893ff; --c6: #ffc9e4; --c7: #8a8a82; --c8: #5a5a53;
}
[data-palette="ocean"][data-mode="light"] {
  --accent: #74e3d2; --accent-soft: #cdf6ee; --accent-on: #06201c; --accent-strong: #0a7a6d;
  --c1: #064a43; --c2: #0a7a6d; --c3: #1fb5a3; --c4: #74e3d2; --c5: #b4f1e7; --c6: #3b6cff; --c7: #4a4a45; --c8: #a8a79d;
}
[data-palette="ocean"][data-mode="dark"] {
  --accent: #74e3d2; --accent-soft: #10312c; --accent-on: #06201c; --accent-strong: #8ef0e0;
  --c1: #74e3d2; --c2: #1fb5a3; --c3: #0a7a6d; --c4: #3b6cff; --c5: #7a9cff; --c6: #b4f1e7; --c7: #8a8a82; --c8: #5a5a53;
}

/* ── reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); font-weight: 700; }
b, strong { font-weight: 800; }
small { font-size: 12px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1.5px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .7; margin-left: 6px; }
.grow { flex: 1; }
.muted { color: var(--dim); }
.num { font-family: var(--mono); font-weight: 700; letter-spacing: -.02em; }
.mt { margin-top: 14px; }
.mob-only { display: none !important; }

/* ── layout ── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 16px 12px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border-right: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; }
.logo {
  width: 34px; height: 34px; display: grid; place-items: center; flex: none;
  font-family: var(--pixel); font-size: 14px; color: var(--accent-on); background: var(--accent);
  border: 2px solid var(--ink); border-radius: 9px; box-shadow: 2px 2px 0 var(--shadow);
}
.brand-name { font-family: var(--pixel); font-size: 10px; line-height: 1.5; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--dim); text-decoration: none; font-weight: 700;
}
.nav a:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.nav a.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1.5px var(--ink); }
.nav svg, .tabbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-family: var(--mono); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumb { font-size: 13px; color: var(--dim); display: flex; gap: 8px; align-items: center; }
.crumb b { color: var(--text); }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; font-size: 17px;
  text-decoration: none; color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.page { max-width: 1080px; margin: 0 auto; padding: 0 20px 120px; }

/* ── Notion-style page header with pixel cover ── */
.pagehead { margin: 16px 0 18px; }
.cover {
  height: 96px; border: 2px solid var(--ink); border-radius: 14px;
  background:
    conic-gradient(var(--accent) 25%, transparent 0 50%, var(--accent) 0 75%, transparent 0) 0 0 / 20px 20px,
    var(--accent-soft);
}
.head-inner { display: flex; align-items: flex-start; gap: 14px; margin: -30px 14px 0; flex-wrap: wrap; }
.page-icon {
  width: 68px; height: 68px; display: grid; place-items: center; font-size: 36px; flex: none;
  background: var(--surface); border: 2px solid var(--ink); border-radius: 16px; box-shadow: 3px 3px 0 var(--shadow);
}
.head-text { flex: 1; min-width: 180px; padding-top: 36px; }
.head-text h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
.head-text p { color: var(--dim); font-size: 14px; margin-top: 2px; }
.head-actions { padding-top: 36px; display: flex; gap: 8px; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px;
  font-weight: 800; font-size: 14px; color: var(--text); background: var(--surface);
  border: 2px solid var(--ink); border-radius: 10px; box-shadow: 3px 3px 0 var(--shadow);
  transition: transform .08s, box-shadow .08s; text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-on); }
.btn.light { background: #f5f4ef; color: #1c1c1b; border-color: #f5f4ef; box-shadow: none; }
.btn.danger { background: var(--expense-bg); color: var(--expense); }
.btn.xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; box-shadow: 2px 2px 0 var(--shadow); }
.btn.block { width: 100%; }

/* ── segmented control / chips ── */
.seg { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; max-width: 100%; overflow-x: auto; }
.seg button { padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--dim); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1.5px var(--ink); }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .field { width: auto; min-width: 140px; }
.toolbar .search { flex: 1; min-width: 200px; }
.pills { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pills button { padding: 6px 12px; border-radius: 999px; font-weight: 700; color: var(--dim); white-space: nowrap; }
.pills button.on { background: var(--hero); color: var(--accent); }
.year-nav { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-weight: 700; }

/* ── form fields ── */
.field {
  width: 100%; padding: 9px 12px; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 10px; outline: 0; min-width: 0;
}
.field:focus { border-color: var(--ink); box-shadow: 2px 2px 0 var(--shadow); }
.field:disabled { opacity: .5; }
textarea.field { resize: vertical; min-height: 70px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; }
.search:focus-within { border-color: var(--ink); box-shadow: 2px 2px 0 var(--shadow); }
.bare { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 10px 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.inline-form .field { flex: 1; min-width: 120px; }

/* ── cards, windows, tiles ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.win { background: var(--surface); border: 2px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--shadow); overflow: hidden; min-width: 0; }
.win-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2);
  border-bottom: 2px solid var(--ink); font-family: var(--mono); font-size: 12px;
}
.dots { display: flex; gap: 5px; flex: none; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--accent); }
.dots i:nth-child(2) { background: var(--surface); }
.dots i:nth-child(3) { background: var(--accent-soft); }
.win-title { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-bar .seg { padding: 2px; border-radius: 9px; }
.win-bar .seg button { padding: 3px 9px; font-size: 12px; font-family: var(--mono); }
.win-body { padding: 14px; }
.win-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.chart { position: relative; height: 260px; }
.chart.sm { height: 220px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles.t3 { grid-template-columns: repeat(3, 1fr); }
.tile {
  display: flex; gap: 10px; align-items: center; padding: 12px; min-width: 0;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
}
.tile small { display: block; color: var(--dim); font-weight: 600; }
.tile b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 800; border: 1.5px solid var(--ink); }
.tile.in .tile-ico { background: var(--income-bg); color: var(--income); }
.tile.out .tile-ico { background: var(--expense-bg); color: var(--expense); }
.tile.sv .tile-ico { background: var(--accent); color: var(--accent-on); }
.tile.big { display: block; padding: 14px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--shadow); }
.tile.big b { font-size: 18px; margin-top: 2px; }
.tile.big small:last-child { margin-top: 2px; color: inherit; opacity: .7; }
.tile.dark { background: var(--hero); color: var(--hero-text); }
.tile.dark small { color: var(--hero-text); opacity: .75; }
.tile.lime { background: var(--accent); color: var(--accent-on); }
.tile.lime small { color: var(--accent-on); opacity: .75; }
.tile.soft { background: var(--accent-soft); }
.hl { grid-template-columns: repeat(2, 1fr); }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.callout-ico { font-size: 20px; line-height: 1.2; }

/* ── balance hero ── */
.hero {
  position: relative; overflow: hidden; padding: 18px; background: var(--hero); color: var(--hero-text);
  border: 2px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--shadow);
}
.hero::after {
  content: ''; position: absolute; right: -24px; bottom: -24px; width: 220px; height: 150px; opacity: .17; transform: rotate(-8deg); pointer-events: none;
  background: conic-gradient(var(--accent) 25%, transparent 0 50%, var(--accent) 0 75%, transparent 0) 0 0 / 14px 14px;
}
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }
.hero-label { margin-top: 18px; opacity: .75; font-size: 14px; }
.hero-amt { font-size: clamp(30px, 6vw, 44px); line-height: 1.15; color: var(--accent); }
.hero-foot { margin-top: 6px; font-size: 12px; opacity: .6; font-family: var(--mono); }

/* ── lists & rows ── */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.ico {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; font-size: 20px;
  background: var(--accent-soft); border-radius: 10px; border: 1px solid var(--line);
}
.ico.sm { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main b, .c-name b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small, .c-sub { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-family: var(--mono); font-weight: 700; white-space: nowrap; font-size: 14px; }
.amt.in { color: var(--income); } .amt.out { color: var(--expense); } .amt.sv { color: var(--accent-strong); }
.empty { padding: 28px 16px; text-align: center; color: var(--dim); }

.db-head, .db-row {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr) 176px 110px;
  gap: 12px; align-items: center; padding: 9px 14px;
}
.db-head { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--dim); border-bottom: 1px solid var(--line); }
.db-row { width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.db-row:hover { background: var(--surface-2); }
.c-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.c-name > span { min-width: 0; display: flex; flex-direction: column; }
.c-sub { display: none; font-size: 12px; }
.c-acc, .c-date { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-amt { text-align: right; }
.tag { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 9px; border-radius: 6px; background: var(--accent-soft); font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.summary .tag.in { background: var(--income-bg); color: var(--income); }
.summary .tag.out { background: var(--expense-bg); color: var(--expense); }
.more { display: block; margin: 14px auto; }

/* ── charts: donut, legend, svg ── */
.donut-wrap { position: relative; height: 230px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; padding: 0 70px; }
.donut-center .ico { margin: 0 auto 4px; }
.donut-center b { font-size: 13px; }
.donut-center small { color: var(--dim); }
.legend { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend .dot { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--ink); flex: none; }
.legend .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .pc { width: 44px; text-align: right; color: var(--dim); font-family: var(--mono); font-size: 12px; }
.cd-svg, .hm-svg { display: block; max-width: 100%; height: auto; }
.cd-scroll .cd-svg { max-width: none; height: 260px; }
.svg-t { font: 10px var(--mono); fill: var(--dim); }
.cd-grid { stroke: var(--line); stroke-dasharray: 3 4; }
.cd-wick { stroke: var(--ink); stroke-width: 1.5; }
[data-mode="dark"] .cd-wick { stroke: var(--dim); }
.cd-body { stroke: var(--ink); stroke-width: 1.5; rx: 2; }
.cd.up .cd-body { fill: var(--accent); }
.cd.down .cd-body { fill: var(--bar2); }
.cd:hover .cd-body, .cd.sel .cd-body { stroke-width: 2.5; }
.cd-hit { fill: transparent; cursor: pointer; }
.cd-info { margin-top: 8px; font: 12px var(--mono); color: var(--dim); min-height: 18px; }
.hm-svg rect { stroke: var(--line); stroke-width: 1; rx: 3; }
.hm-svg .l0 { fill: var(--surface-2); }
.hm-svg .l1 { fill: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.hm-svg .l2 { fill: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.hm-svg .l3 { fill: color-mix(in srgb, var(--accent) 80%, var(--surface)); }
.hm-svg .l4 { fill: var(--accent); stroke: var(--ink); }
.hm-legend { display: flex; align-items: center; gap: 4px; font: 11px var(--mono); color: var(--dim); margin-top: 6px; justify-content: flex-end; }
.hm-legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }
.hm-legend .l0 { background: var(--surface-2); }
.hm-legend .l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.hm-legend .l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.hm-legend .l3 { background: color-mix(in srgb, var(--accent) 80%, var(--surface)); }
.hm-legend .l4 { background: var(--accent); border-color: var(--ink); }
.top-item { padding: 8px 0; }
.top-item .tp { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.top-item .tp b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── budget ── */
.gauge-wrap { position: relative; width: 190px; height: 190px; margin: 4px auto 12px; }
.gauge { width: 100%; height: 100%; }
.g-track { fill: none; stroke: var(--surface-2); stroke-width: 16; }
.g-bar { fill: none; stroke: var(--text); stroke-width: 16; }
.g-bar.over { stroke: var(--expense); }
.g-bar.warn { stroke: var(--accent-strong); }
.gauge-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge-center b { font-size: 20px; font-family: var(--mono); }
.gauge-center .st { font-weight: 800; font-size: 13px; color: var(--accent-strong); }
.gauge-center .st.over { color: var(--expense); }
.gauge-center .st.none { color: var(--dim); }
.brow { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.brow:last-child { border-bottom: 0; }
.brow-top { display: flex; align-items: center; gap: 10px; }
.brow-top .neg { color: var(--expense); }
.brow-meta { display: flex; justify-content: space-between; margin: 8px 0 4px; font: 12px var(--mono); color: var(--dim); }
.bar { height: 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--text); }
.bar.over i { background: var(--expense); }

/* ── settings ── */
.sec { font-size: 17px; font-weight: 800; margin: 24px 0 10px; display: flex; align-items: center; gap: 8px; }
.combos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.combo { text-align: left; padding: 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.combo.on { border-color: var(--ink); box-shadow: 3px 3px 0 var(--shadow); }
.combo-prev { display: block; padding: 8px; border-radius: 8px; background: var(--p-bg); border: 1px solid color-mix(in srgb, var(--p-text) 20%, transparent); margin-bottom: 8px; }
.combo-prev i { display: block; height: 10px; border-radius: 3px; margin-bottom: 5px; background: var(--p-surface); border: 1px solid color-mix(in srgb, var(--p-text) 25%, transparent); }
.combo-prev i:first-child { background: var(--p-accent); width: 55%; }
.combo-prev i:last-child { margin-bottom: 0; width: 80%; }
.combo b { display: block; font-size: 13px; }
.combo small { color: var(--dim); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; font-size: 13px; }
.chip button { width: 20px; height: 20px; border-radius: 50%; color: var(--dim); }
.chip button:hover { background: var(--expense-bg); color: var(--expense); }
.acct { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.acct:last-child { border-bottom: 0; }

/* ── overlays / sheets ── */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10, 10, 8, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .15s;
}
.overlay.out { opacity: 0; transition: opacity .15s; }
.sheet {
  width: 100%; max-width: 520px; max-height: min(92vh, 880px); overflow-y: auto; padding: 18px;
  background: var(--surface); border: 2px solid var(--ink); border-radius: 18px; box-shadow: 6px 6px 0 var(--shadow); animation: pop .18s;
}
.sheet.pick-sheet { max-width: 460px; }
.sheet-grip { display: none; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 18px; font-weight: 800; }
.sheet-foot { display: flex; gap: 10px; margin-top: 16px; }
.amount-field { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; padding: 12px 14px; background: var(--surface-2); border: 2px solid var(--ink); border-radius: 14px; }
.amount-field .cur { font: 700 24px var(--mono); color: var(--dim); }
.amount-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 700 34px var(--mono); letter-spacing: -.03em; }
.title-input { width: 100%; border: 0; outline: 0; background: none; padding: 10px 2px; font-size: 19px; font-weight: 800; border-bottom: 1px dashed var(--line); }
.title-input::placeholder, .amount-field input::placeholder { color: var(--dim); opacity: .6; }
.props { margin-top: 8px; }
.prop { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: center; padding: 5px 0; }
.prop.top { align-items: start; }
.prop.check { grid-template-columns: auto 1fr; cursor: pointer; font-size: 14px; color: var(--dim); font-weight: 600; }
.prop.check input { width: 17px; height: 17px; accent-color: var(--accent-strong); }
.pk { color: var(--dim); font-size: 13px; font-weight: 600; }
.pick { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; }
.pick:hover { border-color: var(--ink); }
.cat-list { max-height: 44vh; overflow-y: auto; margin-top: 8px; }
.cat-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 9px 8px; border-radius: 10px; }
.cat-item:hover, .cat-item.on { background: var(--surface-2); }
.cat-item b { flex: 1; }
.chk { color: var(--accent-strong); font-weight: 800; }

/* ── toast, splash, tabbar ── */
#toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 9px 14px; font-weight: 700; background: var(--hero); color: var(--hero-text); border: 2px solid var(--ink); border-radius: 10px; box-shadow: 3px 3px 0 var(--shadow); animation: rise .2s; max-width: 90vw; }
.toast.err { background: var(--expense-bg); color: var(--expense); }
.splash { min-height: 70vh; display: grid; place-content: center; gap: 14px; text-align: center; }
.splash b { font-family: var(--pixel); font-size: clamp(16px, 4vw, 26px); color: var(--accent-strong); line-height: 1.5; }
.splash b::after { content: '▮'; animation: blink 1s steps(2) infinite; margin-left: 4px; }
.splash p { color: var(--dim); max-width: 420px; }
.tabbar { display: none; }
.fab {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: -30px;
  background: var(--hero); color: var(--accent); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--shadow);
}
.fab svg { width: 28px; height: 28px; stroke-width: 3; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes blink { 50% { opacity: 0; } }

/* ── responsive ── */
@media (min-width: 761px) {
  .tiles.t4 { grid-template-columns: repeat(4, 1fr); }
  .hl { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1100px) and (min-width: 821px) {
  :root { --sidebar-w: 74px; }
  .brand-name, .nav-label, .side-foot, .sidebar .btn kbd { display: none; }
  .sidebar { align-items: center; }
  .sidebar .btn { padding: 9px 0; width: 46px; font-size: 0; }
  .sidebar .btn::before { content: '＋'; font-size: 18px; }
  .nav a { justify-content: center; padding: 10px; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mob-only { display: inline-grid !important; }
  .crumb-brand, .crumb .sep { display: inline; }
  .topbar { padding: 8px 14px; }
  .page { padding: 0 14px 130px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; align-items: flex-end; justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 2px solid var(--ink);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--dim); text-decoration: none; font-size: 11px; font-weight: 700; }
  .tabbar a.on { color: var(--text); }
  .tabbar a.on svg { stroke: var(--accent-strong); }
  .tabbar .fab { margin: -30px 6px 0; }
  #toast-root { bottom: 96px; }
}
@media (max-width: 760px) {
  .db-head { display: none; }
  .db-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0; }
  .db-row .c-cat, .db-row .c-acc, .db-row .c-date { display: none; }
  .c-sub { display: block; }
  .head-text h1 { font-size: 25px; }
  .cover { height: 72px; }
  .head-inner { margin: -24px 8px 0; gap: 10px; }
  .page-icon { width: 56px; height: 56px; font-size: 30px; border-radius: 14px; }
  .head-text, .head-actions { padding-top: 30px; }
  .tile.big b { font-size: 16px; }
}
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  .sheet { max-width: none !important; border-radius: 20px 20px 0 0; border-bottom: 0; max-height: 94vh; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: rise .22s; box-shadow: none; }
  .sheet-grip { display: block; }
  .prop { grid-template-columns: 1fr; gap: 4px; }
  .prop.check { grid-template-columns: auto 1fr; }
  .tiles.t3 .tile { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; }
  .tiles.t3 .tile b { font-size: 13px; }
  .chart { height: 230px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
