:root {
  --bg: #eeece6;
  --card: #fbfaf7;
  --ink: #1d2421;
  --muted: #6b716d;
  --line: #dbd8cf;
  --chip: #e4e1d8;
  --accent: #2f5d8a;
  --accent-deep: #234870;
  --gold: #b9862a;
  --ok: #2f7d52;
  --soon: #b8800f;
  --over: #bf3a2b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 25, 22, .05), 0 6px 18px rgba(20, 25, 22, .06);
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131715; --card: #1c211f; --ink: #ebefe9; --muted: #98a19b; --line: #2d3431;
    --chip: #252c29; --accent: #6b9fd4; --accent-deep: #4f84ba; --gold: #d8a74a;
    --ok: #5fb07f; --soon: #e1a93c; --over: #ea6a58; --shadow: 0 1px 2px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 Inter, system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
#app { max-width: 880px; margin: 0 auto; padding: 0 16px calc(48px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .01em; }
h2 { font-size: 26px; line-height: 1.1; }
h3 { font-size: 20px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono, .amt { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.amt { white-space: nowrap; font-weight: 600; }
.neg { color: var(--over); }
.pos { color: var(--ok); }
.err { color: var(--over); min-height: 1.2em; margin: 4px 0 0; font-size: 14px; }
.err:empty { min-height: 0; margin: 0; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.eyebrow { font: 600 11px/1 Inter, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 10px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand h1 { font-size: 32px; text-transform: uppercase; letter-spacing: .04em; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); position: relative; flex: none; overflow: hidden; }
.mark::before, .mark::after { content: ''; position: absolute; left: 7px; right: 7px; height: 3.5px; border-radius: 2px; background: var(--gold); }
.mark::before { top: 10px; }
.mark::after { top: 17px; right: 13px; background: var(--bg); }
.top-right { display: flex; align-items: center; gap: 8px; }
.status { font-size: 12px; color: var(--muted); }

.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.monthbar h2 { font-size: 30px; text-transform: uppercase; letter-spacing: .03em; }
.monthbar .mid { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; text-align: center; }

.tabs { display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 999px; margin: 0 0 18px; position: sticky; top: 8px; z-index: 5; }
.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font: 600 14px Inter, sans-serif; padding: 9px 6px; border-radius: 999px; white-space: nowrap; }
.tabs a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }

/* building blocks */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card > h3 + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-head h3 { font-size: 22px; text-transform: uppercase; letter-spacing: .03em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px Inter, sans-serif; padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent-deep); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--over); }
.btn.block { display: flex; width: 100%; }
.btn.big { padding: 14px; font-size: 16px; }
.icon { border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; flex: none; }
.icon:hover { background: var(--chip); }

.lbl { display: block; font: 600 12px Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
input, textarea, select { width: 100%; font: 16px Inter, sans-serif; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }

.pill { font: 600 11px/1 Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; padding: 5px 8px; border-radius: 999px; white-space: nowrap; background: var(--chip); color: var(--muted); }
.pill.open { background: color-mix(in srgb, var(--soon) 18%, transparent); color: var(--soon); }
.pill.closed { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.warn { background: var(--over); color: #fff; }

/* the hero number */
.hero { border-top: 5px solid var(--accent); }
.hero.closed { border-top-color: var(--gold); }
.big-num { font: 600 40px/1.05 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin: 2px 0 12px; }
.big-num.neg { color: var(--over); }
.calc { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; }
.calc .amt { text-align: right; font-weight: 500; }
.calc .total { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; }
.calc .total.amt { font-weight: 700; }

/* phase stepper */
.phases { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.phase { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); text-decoration: none; color: inherit; }
.phase b { display: block; font: 700 18px/1.1 var(--display); text-transform: uppercase; letter-spacing: .03em; }
.phase.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.phase.done b::after { content: ' ✓'; color: var(--ok); }

/* line lists */
.lines { padding: 2px 16px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .main { min-width: 0; flex: 1; }
.line .title { font-weight: 600; overflow-wrap: anywhere; }
.line .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.line.check { justify-content: flex-start; cursor: pointer; }
.line.check.done .title { color: var(--muted); text-decoration: line-through; }
.line button.rowbtn { all: unset; display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; cursor: pointer; }
.empty { padding: 14px 0; color: var(--muted); font-size: 14px; }

/* transfer card */
.transfer { border-left: 5px solid var(--gold); }
.transfer.clear { border-left-color: var(--ok); }
.transfer .move { font: 700 22px/1.2 var(--display); }

/* buckets */
.bgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.bgrid .card { margin: 0; cursor: pointer; }
.bucket h3 { font-size: 22px; text-transform: uppercase; }
.bucket .bal { font: 600 26px/1.1 var(--mono); margin: 6px 0 2px; }
.bar { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.low span { background: var(--soon); }
.bar.neg span { background: var(--over); }

.kind { font: 600 10px/1 Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; padding: 4px 6px; border-radius: 6px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.kind.income { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.kind.bucket { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.kind.goal { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.kind.transfer, .kind.ignore { opacity: .7; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.filters button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 11px; font: 500 13px Inter, sans-serif; color: var(--ink); cursor: pointer; white-space: nowrap; }
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.history { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px 14px; align-items: center; font-size: 14px; }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100% - 24px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 14, 12, .45); }
dialog form { padding: 18px; }
dialog h3 { margin-bottom: 12px; font-size: 24px; }
dialog .actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px); }
.toast.bad { background: var(--over); color: #fff; }

/* login */
.login-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { justify-content: center; margin-bottom: 18px; }

@media print {
  .tabs, .top-right, .btn, .icon, .filters { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .big-num { font-size: 34px; }
  .monthbar h2 { font-size: 26px; }
  .brand h1 { font-size: 28px; }
}

/* money additions */
.mark.bank::before { top: 8px; height: 3px; left: 6px; right: 6px; }
.mark.bank::after { top: 13px; left: 8px; right: auto; width: 3px; height: 9px; background: var(--gold); box-shadow: 6px 0 0 var(--gold), 12px 0 0 var(--gold); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ok); flex: none; }
.status-dot.login_required, .status-dot.error { background: var(--over); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-head h3 { font-size: 22px; text-transform: uppercase; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 140px; }
.secret { font: 600 14px/1.4 var(--mono); background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
.notice { border-left: 5px solid var(--soon); }
.notice.bad { border-left-color: var(--over); }
.raw { font: 12px/1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.center-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.narrow { width: 100%; max-width: 380px; }

/* privacy mode: blur every dollar amount for screenshots */
body.private .amt, body.private .big-num, body.private .bal, body.private .calc .amt,
body.private input[inputmode="decimal"], body.private .money-x {
  filter: blur(7px); user-select: none; -webkit-user-select: none;
}
body.private .big-num, body.private .bal { transition: filter .15s; }
#privacy[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
@media print { body.private .amt, body.private .big-num, body.private .bal { filter: blur(7px) !important; } }

/* header fits on phones: wrap if needed, drop the email, tighten buttons */
.top { flex-wrap: wrap; row-gap: 8px; }
.top-right { flex-wrap: wrap; justify-content: flex-end; min-width: 0; margin-left: auto; }
@media (max-width: 600px) {
  #who { display: none; }
  .brand h1 { font-size: 26px; }
  .top-right { gap: 6px; }
  .top-right .btn.small { padding: 6px 9px; }
}
