:root {
  --bg: #F2F8FD;
  --surface: #FFFFFF;
  --surface-2: #F4F8FC;
  --ink: #1C2A3B;
  --muted: #637289;
  --line: #DBE6F2;
  --accent: #7CC7F0;          /* baby blue: her favorite */
  --accent-ink: #0E2A45;
  --accent-text: #2B78B8;
  --accent-soft: #DDF0FC;
  --lav: #B9A3EC;             /* light purple */
  --lav-soft: #EEE8FC;
  --pink: #F3A9C8;            /* pink */
  --pink-soft: #FDE8F1;
  --good: #2C7A57;
  --good-soft: #DDF2E6;
  --warn: #9A6410;
  --warn-soft: #FCEFD6;
  --bad: #B4304A;
  --bad-soft: #FCE1E7;
  --shadow: 0 1px 0 rgba(28, 42, 59, .04), 0 10px 26px -14px rgba(43, 120, 184, .28);
  --radius: 18px;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1520;
    --surface: #16202E;
    --surface-2: #1C2838;
    --ink: #EAF2FB;
    --muted: #98A7BB;
    --line: #283649;
    --accent: #8FD3F7;
    --accent-ink: #0A1D2F;
    --accent-text: #8FD3F7;
    --accent-soft: #15324A;
    --lav: #B9A6EE;
    --lav-soft: #2A2342;
    --pink: #F2A7C6;
    --pink-soft: #3A1F2D;
    --good: #6CCB9C;
    --good-soft: #17322A;
    --warn: #E9B95C;
    --warn-soft: #382C14;
    --bad: #F38FA5;
    --bad-soft: #3B1B24;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 30px -16px rgba(0, 0, 0, .75);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 var(--sans);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 0;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
.num { font-family: var(--serif); font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout */
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
header.top { display: flex; align-items: flex-end; justify-content: space-between; padding: 18px 2px 12px; gap: 12px; }
header.top h1 { font: 600 30px/1.05 var(--serif); margin: 0; letter-spacing: -.02em; }
header.top .date { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 22px; line-height: 1; flex: none; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid var(--line);
}
nav.tabs button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button[aria-current="page"] { color: var(--accent-text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 10px; }
.section-title h2 { font: 600 19px var(--serif); margin: 0; }
.section-title .link { background: none; border: 0; color: var(--accent-text); font-weight: 600; font-size: 14px; padding: 0; }

/* ---------- hero */
.hero { padding: 20px 18px 8px; background:
  radial-gradient(90% 80% at 100% 0%, var(--pink-soft) 0%, transparent 60%),
  radial-gradient(110% 90% at 0% 0%, var(--accent-soft) 0%, transparent 65%),
  radial-gradient(80% 70% at 60% 100%, var(--lav-soft) 0%, transparent 70%), var(--surface); }
.hero .label { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hero .big { font-size: 52px; font-weight: 600; line-height: 1; margin: 6px 0 4px; }
.hero .sub { color: var(--muted); font-size: 15px; margin-bottom: 10px; }
.hero.clear .big { color: var(--good); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 2px; }
.stat .v.good { color: var(--good); }
.stat .v.bad { color: var(--bad); }

/* ---------- bill rows */
.rows { display: grid; }
.row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: color-mix(in srgb, var(--c, #888) 16%, transparent); }
.row .nm { font-weight: 600; line-height: 1.2; }
.row .meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row .amt { text-align: right; font-size: 18px; font-weight: 600; }
.row .amt small { display: block; font: 600 12px var(--sans); color: var(--muted); }
.row.tap { cursor: pointer; }
.row .actions { grid-column: 2 / -1; display: flex; gap: 8px; margin-top: -2px; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 14px; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.good { background: var(--good); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; padding: 14px; font-size: 16px; border-radius: 14px; }
.btn:disabled { opacity: .5; }

.day-group { margin-bottom: 4px; }
.day-label { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 2px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }
.empty .em { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- progress */
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--lav)); border-radius: 999px; transition: width .4s ease; }
.cat-bars { display: grid; gap: 10px; margin-top: 14px; }
.cat-bar { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.cat-bar .track { grid-column: 2 / 3; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.cat-bar .track i { display: block; height: 100%; border-radius: 99px; }

/* ---------- chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font: 600 22px var(--serif); margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); padding-bottom: 4px; }
.cal button.d { aspect-ratio: 1 / 1.05; border: 1px solid transparent; background: var(--surface); border-radius: 12px; padding: 5px 2px 3px; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; font-size: 14px; font-weight: 600; }
.cal button.d.out { visibility: hidden; }
.cal button.d.today { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.cal button.d.sel { background: var(--accent); color: var(--accent-ink); }
.cal button.d .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; align-content: center; max-width: 30px; }
.cal button.d .dots i { width: 6px; height: 6px; border-radius: 50%; }
.cal button.d .dots i.paid { opacity: .35; }
.cal button.d .tot { font: 600 9.5px var(--sans); color: var(--muted); }
.cal button.d.sel .tot { color: inherit; opacity: .7; }

/* ---------- goals */
.goal { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; }
.goal .ring { width: 52px; height: 52px; }
.goal h3 { margin: 0; font: 600 18px var(--serif); }
.goal .line2 { font-size: 14px; color: var(--muted); margin-top: 2px; }
.goal .acts { grid-column: 1 / -1; display: flex; gap: 8px; }
.goal-mini { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.goal-mini:first-child { border-top: 0; }
.goal-mini .bar { grid-column: 1 / -1; height: 8px; }

/* ---------- forms + sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 14, 10, .42); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet-bg.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .9, .25, 1);
  max-width: 560px; margin: 0 auto;
}
.sheet.on { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font: 600 24px var(--serif); margin: 4px 0 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 700; color: var(--muted); }
.field .hint { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea, input[inputmode] {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 13px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; min-height: 48px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.money-in { position: relative; }
.money-in::before { content: '$'; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.money-in input { padding-left: 26px; font-family: var(--serif); font-size: 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 9px 4px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.switch-row:first-child { border-top: 0; }
.switch-row .t { font-weight: 600; }
.switch-row .d { font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 20px; font-weight: 700; }
.stepper output { min-width: 110px; text-align: center; font-weight: 700; }
.sheet .foot { display: grid; gap: 10px; margin-top: 8px; }

/* ---------- login */
.login { min-height: 88dvh; display: grid; align-content: center; justify-items: center; text-align: center; gap: 14px; padding: 20px; }
.login .mark { width: 86px; height: 86px; border-radius: 26px; background: linear-gradient(135deg, var(--accent) 0%, var(--lav) 60%, var(--pink) 100%); color: var(--accent-ink); display: grid; place-items: center; font: 600 44px var(--serif); box-shadow: var(--shadow); }
.login h1 { font: 600 32px/1.1 var(--serif); margin: 6px 0 0; }
.login p { color: var(--muted); max-width: 320px; margin: 0; }
.login form { width: 100%; max-width: 320px; display: grid; gap: 10px; margin-top: 8px; }
.login input { text-align: center; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; }

/* ---------- misc */
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; opacity: 0; transition: .25s; z-index: 60; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast { pointer-events: none; }
.toast.on button { pointer-events: auto; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 800; padding: 0; }
.banner { border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--lav-soft); color: var(--ink); }
.banner b { color: inherit; }
.acct { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.acct:first-child { border-top: 0; }
.acct .bal { font-size: 18px; font-weight: 600; text-align: right; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent-text); animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-plain { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.list-plain li { margin: 4px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
