/* Family budget: tokens */
:root {
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f8f9fc; --line: #e3e7ef; --line-2: #eef1f6;
  --ink: #16203a; --ink-2: #5b6478; --ink-3: #8a93a6;
  --c-income: #1d9a5b; --c-expense: #e4572e; --c-savings: #2a78d6; --c-bills: #e59f00; --c-subs: #d5518e; --c-cards: #6a4cc2; --c-goals: #0fa3a3; --c-notes: #7a8699;
  --good-bg: #dff5e8; --good-ink: #146c3c; --bad-bg: #fde8e4; --bad-ink: #b3261e; --warn-bg: #fff3d6; --warn-ink: #8a5a00; --info-bg: #e7eef9; --info-ink: #2b4a7a;
  --radius: 14px; --radius-s: 9px;
  --shadow: 0 1px 2px rgba(22, 32, 58, .05), 0 10px 30px -18px rgba(22, 32, 58, .18);
  --sidebar: 236px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; font-feature-settings: 'tnum' 1, 'ss01' 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 .5em; }
a { color: var(--c-savings); }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
kbd { font-family: inherit; font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #fff; }
code, .mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .85em; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.pos { color: var(--good-ink); }
.neg { color: var(--bad-ink); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.icon { display: inline-flex; width: 18px; height: 18px; vertical-align: -4px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.icon.ok { color: var(--c-income); }

#splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--ink-2); z-index: 50; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
#sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; }
.brand b { display: block; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.brand small { color: var(--ink-3); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px; }
.nav-item .icon { color: var(--nav-color); width: 19px; height: 19px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: color-mix(in srgb, var(--nav-color) 13%, #fff); color: var(--ink); font-weight: 700; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); padding: 1px 7px; border-radius: 999px; }
.nav-count:empty { display: none; }
.nav-item.active .nav-count { background: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 4px; font-size: 12px; }
.main { min-width: 0; display: flex; flex-direction: column; }
#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 14px 32px; background: rgba(243, 245, 249, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
#page-title { font-size: 22px; padding-left: 14px; position: relative; }
#page-title::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 4px; border-radius: 3px; background: var(--page-color, var(--c-savings)); }
.alert-count { background: var(--c-expense); color: #fff; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.menu-btn { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#content { padding: 24px 32px 60px; width: 100%; display: flex; flex-direction: column; gap: 20px; }

@media (min-width: 1700px) {
  #content { padding: 28px 40px 60px; gap: 24px; }
  #topbar { padding: 14px 40px; }
  .kpi-row { gap: 20px; }
  .grid-2, .grid-main-side { gap: 24px; }
  .chart-host { height: 300px; }
  .chart-host.donut { height: 260px; }
  .donut-layout { grid-template-columns: 260px 1fr; }
}

/* Month picker */
.month-picker { display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.month-label { border: 0; background: transparent; font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 999px; cursor: pointer; min-width: 150px; }
.month-label:hover { background: var(--surface-2); }

/* Save pill */
.save-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.save-pill.ok { color: var(--good-ink); border-color: #bfe8cf; background: #f0faf4; }
.save-pill.saving { color: var(--info-ink); }
.save-pill.saving .icon { animation: spin 1s linear infinite; }
.save-pill.error { color: var(--bad-ink); border-color: #f3c1b8; background: #fff3f0; }
.save-pill.local { color: var(--warn-ink); border-color: #f1dca7; background: #fff9ea; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: #d3d9e4; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--c-savings); outline-offset: 2px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #24304f; }
.btn.danger { background: var(--c-expense); border-color: var(--c-expense); color: #fff; }
.btn.danger-ghost { color: var(--bad-ink); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.warn { background: var(--warn-bg); border-color: #f1dca7; color: var(--warn-ink); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad-ink); }
.icon-btn.on { color: var(--c-bills); }
.icon-btn svg { width: 18px; height: 18px; }
.link { border: 0; background: none; color: var(--c-savings); font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-row input[type=text] { flex: 1; min-width: min(260px, 100%); }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; display: flex; align-items: center; gap: 6px; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 16px 20px 20px; }
.card-head + .card-body { padding-top: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > *, .grid-main-side > *, .stack-cards > *, .card-grid > *, .goal-grid > *, .note-grid > * { min-width: 0; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.stack-cards { display: flex; flex-direction: column; gap: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; }

/* KPI tiles */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px 22px; box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--kpi); }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: #d3d9e4; }
.kpi-top { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.kpi-top .icon { color: var(--kpi); width: 16px; height: 16px; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-value .stack { font-size: 14px; font-weight: 600; margin-top: 2px; }
.kpi-sub { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* Hero */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 26px 30px; border-radius: 18px; border: 1px solid; }
.hero.green { background: #e8f7ee; border-color: #c4eccf; color: #0f4f2a; }
.hero.red { background: #fdeae5; border-color: #f6c8bc; color: #7a1d12; }
.hero h2 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 8px; }
.hero-month { font-weight: 700; font-size: 13.5px; opacity: .8; margin: 0; }
.hero-sub { margin: 0; font-size: 14px; opacity: .9; }
.hero-stats { display: flex; gap: 10px; flex: none; }
.stat { display: flex; flex-direction: column; gap: 2px; background: rgba(255, 255, 255, .75); border-radius: 12px; padding: 12px 16px; min-width: 130px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.stat-value { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat.income .stat-value { color: var(--good-ink); }
.stat.expense .stat-value { color: var(--bad-ink); }

/* Attention / due lists */
.attention { border-color: #f6c8bc; }
.attention .card-head h3 .icon { color: var(--c-expense); }
.reminder { border-color: #f1dca7; background: #fffdf5; }
.reminder .card-head h3 .icon { color: var(--c-bills); }
.reminder-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.reminder-row:first-child { border-top: 0; padding-top: 0; }
.reminder-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.due-list { display: flex; flex-direction: column; }
.due-row { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-2); }
.due-row:first-child { border-top: 0; }
.due-list.compact .due-row { grid-template-columns: 4px minmax(0, 1fr) auto auto; }
.due-list.compact .due-action { display: none; }
.due-bar { display: block; width: 4px; height: 34px; border-radius: 3px; }
.due-name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.due-sub { font-size: 12.5px; color: var(--ink-2); }
.due-when { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.due-date { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.due-amount { font-weight: 800; font-size: 15px; min-width: 90px; }
.due-row.status-overdue .due-amount { color: var(--bad-ink); }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--info-bg); color: var(--info-ink); vertical-align: middle; }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.tag .icon { width: 11px; height: 11px; }

/* Badges & chips */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.badge.overdue { background: var(--bad-bg); color: var(--bad-ink); }
.badge.today { background: #ffe3c7; color: #8a3b00; }
.badge.soon { background: var(--warn-bg); color: var(--warn-ink); }
.badge.upcoming { background: var(--info-bg); color: var(--info-ink); }
.badge.paid { background: var(--good-bg); color: var(--good-ink); }
.badge.muted { background: var(--line-2); color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 9px 2px 6px; white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.progress { height: 7px; background: var(--line-2); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.progress.tall { height: 11px; }
.progress-bar { height: 100%; border-radius: 999px; transition: width .4s ease; animation: grow-bar .9s cubic-bezier(.2,.7,.2,1) both; }
@keyframes grow-bar { from { width: 0; } }

/* Charts */
.chart-host { position: relative; height: 250px; }
.chart-host.donut { height: 220px; }
.donut-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: center; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-pct { color: var(--ink-3); font-size: 12px; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* Toolbar, search, inputs */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; height: 38px; min-width: 200px; }
.search .icon { color: var(--ink-3); width: 16px; height: 16px; }
.search input[type=search] { appearance: none; -webkit-appearance: none; border: 0; border-radius: 0; background: transparent; outline: 0; box-shadow: none; width: 100%; height: 100%; padding: 0 2px; min-width: 0; }
.search:focus-within { border-color: var(--c-savings); outline: 2px solid var(--c-savings); outline-offset: 2px; }
.search input[type=search]:focus-visible { outline: 0; box-shadow: none; }
.search input[type=search]::-webkit-search-decoration { -webkit-appearance: none; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; height: 38px; width: 100%; min-width: 0; }
textarea { height: auto; resize: vertical; }
input.invalid { border-color: var(--c-expense); }
select.inline-select { width: auto; padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6478' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg.on { background: var(--ink); color: #fff; }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); margin: 0; max-width: 640px; }
.hint .icon { width: 15px; height: 15px; color: var(--c-savings); margin-top: 2px; }

/* Quick add */
.quick-add { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); flex-wrap: wrap; border-left: 5px solid var(--c-expense); }
.quick-add.income { border-left-color: var(--c-income); }
.quick-label { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.quick-add input[type=date] { width: 140px; }
.quick-add input.grow { flex: 1 1 160px; }
.quick-add select { width: auto; max-width: 150px; }
.quick-add .amount-input { width: 110px; font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; margin: -4px -8px; padding: 4px 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line); padding-top: 12px; color: var(--ink-2); }
.table tfoot td b { color: var(--ink); }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 2px; align-items: center; }
.row-paid td { opacity: .6; }
.row-paid td .badge { opacity: 1; }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--c-expense); }

/* Empty states */
.empty { text-align: center; padding: 34px 20px; color: var(--ink-2); }
.empty h4 { color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 14px; font-size: 13.5px; }
.empty-icon { width: 36px; height: 36px; color: var(--ink-3); margin-bottom: 8px; }

/* Welcome */
.welcome { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 36px; box-shadow: var(--shadow); }
.welcome h2 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 10px; }
.welcome-text p { color: var(--ink-2); font-size: 15px; max-width: 520px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 20px; }
.welcome-actions .btn { flex: 1 1 auto; justify-content: center; }
.welcome-steps { display: flex; flex-direction: column; gap: 10px; }
.welcome-step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border-left: 4px solid var(--step); }
.welcome-step .step-n { width: 24px; height: 24px; border-radius: 50%; background: var(--step); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; flex: none; }
.welcome-step p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }

/* Goals */
.goal-list { display: flex; flex-direction: column; gap: 12px; }
.goal-row { cursor: pointer; }
.goal-row-top { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 20px; }
.goal-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-top: 5px solid var(--goal-color); display: flex; flex-direction: column; gap: 8px; }
.goal-card.done { background: #f3fbf6; }
.goal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.goal-head h3 { font-size: 17px; }
.goal-amounts { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.goal-amounts .muted { font-size: 14px; font-weight: 600; }
.goal-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.goal-facts b { color: var(--ink); }
.goal-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.goal-history { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.goal-history .row-actions { gap: 8px; }

/* Credit cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 20px; }
.credit-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; background: var(--card-color); color: #fff; }
.cc-top h3 { font-size: 18px; color: #fff; }
.cc-top .icon-btn { color: rgba(255, 255, 255, .85); }
.cc-top .icon-btn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.cc-bank { font-size: 12.5px; opacity: .85; font-variant-numeric: tabular-nums; }
.cc-balance { padding: 16px 20px 0; display: flex; flex-direction: column; }
.cc-balance b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.cc-limit { padding: 4px 20px 0; }
.cc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 14px 20px 0; }
.cc-fact { display: flex; flex-direction: column; font-size: 13.5px; font-weight: 600; }
.cc-notes { padding: 12px 20px 0; }
.cc-actions { display: flex; gap: 8px; padding: 16px 20px 20px; flex-wrap: wrap; }
.mini-cards { display: flex; flex-direction: column; gap: 10px; }
.mini-card { border: 1px solid var(--line); border-left: 5px solid var(--card-color); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.mini-card:hover { background: var(--surface-2); }
.mini-card-top { display: flex; justify-content: space-between; align-items: baseline; }
.mini-card-balance { font-size: 18px; font-weight: 800; }
.mini-card-due { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Budget list (expenses side panel) */
.budget-list { display: flex; flex-direction: column; gap: 12px; }
.budget-row { cursor: pointer; }
.budget-top { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }

/* Notes */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.note { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--note-color); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.note:hover { border-color: #d3d9e4; }
.note.pinned { background: #fffdf4; }
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.note-head h3 { font-size: 15.5px; }
.note-body { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-2); margin: 0; max-height: 220px; overflow: hidden; }
.note-foot { margin-top: auto; }

/* Settings */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.cat-list { display: flex; flex-direction: column; }
.cat-row { display: flex; align-items: center; gap: 14px; padding: 9px 0; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.cat-row:first-child { border-top: 0; }
.cat-name { flex: 1; }
.cat-budget { display: flex; align-items: center; gap: 8px; }
.cat-budget input { width: 110px; height: 34px; text-align: right; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 2px #fff; }
.swatch.on { border-color: var(--ink); }
.swatch.static { width: 14px; height: 14px; border-radius: 4px; box-shadow: none; cursor: default; flex: none; }
.file-box { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.file-box .icon { width: 22px; height: 22px; color: var(--c-savings); margin-top: 2px; }
.file-box.warn { background: var(--warn-bg); }
.file-box.warn .icon { color: var(--warn-ink); }
.danger-zone { border-color: #f3c1b8; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

ol.steps { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; }
ol.steps li { margin: 4px 0; }
input[type=password] { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; height: 38px; width: 100%; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(22, 32, 58, .45); display: grid; place-items: center; padding: 20px; z-index: 40; overflow-y: auto; animation: fade-in .15s ease-out; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 580px; box-shadow: 0 30px 80px -20px rgba(22, 32, 58, .5); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: rise-in .15s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { transform: translateY(8px); } to { transform: none; } }
.modal.small { max-width: 440px; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; align-items: center; padding: 14px 22px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.form-note { background: var(--info-bg); color: var(--info-ink); font-size: 12.5px; padding: 10px 12px; border-radius: 10px; margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.form-grid.static { gap: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; grid-column: 1 / -1; font-size: 13.5px; }
.field.half { grid-column: auto; }
.field-label { font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }
.field .req { color: var(--c-expense); font-weight: 700; }
.field.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 6px; flex-wrap: wrap; }
.field.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--ink); }
.form-section { grid-column: 1 / -1; font-weight: 700; font-size: 12.5px; color: var(--ink-3); border-bottom: 1px solid var(--line-2); padding-bottom: 4px; }
.form-html { grid-column: 1 / -1; }

/* Menus & toasts */
.menu-pop { position: absolute; z-index: 45; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px -12px rgba(22, 32, 58, .35); padding: 6px; min-width: 210px; max-height: 70vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-weight: 500; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.on { font-weight: 700; background: var(--surface-2); }
.menu-item .icon { color: var(--ink-2); }
.menu-item .dot { margin-left: auto; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { display: flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); opacity: 0; transform: translateY(8px); transition: all .2s; max-width: 380px; }
.toast.show { opacity: 1; transform: none; }
.toast.success .icon { color: #5fd38e; }
.toast.error { background: #b3261e; }

/* Motion: one quiet entrance per page, then the numbers and charts do the talking */
#content > * { animation: rise .42s cubic-bezier(.2,.7,.2,1) both; }
#content > *:nth-child(2) { animation-delay: .05s; }
#content > *:nth-child(3) { animation-delay: .1s; }
#content > *:nth-child(4) { animation-delay: .15s; }
#content > *:nth-child(5) { animation-delay: .2s; }
#content > *:nth-child(n+6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kpi-row .kpi { animation: rise .42s cubic-bezier(.2,.7,.2,1) both; }
.kpi-row .kpi:nth-child(2) { animation-delay: .07s; }
.kpi-row .kpi:nth-child(3) { animation-delay: .14s; }
.kpi-row .kpi:nth-child(4) { animation-delay: .21s; }

/* Warnings pulse so they catch the eye */
.badge.overdue { animation: pulse-red 1.8s ease-out infinite; }
.badge.today { animation: pulse-orange 1.8s ease-out infinite; }
.badge.soon { animation: pulse-amber 2.6s ease-out infinite; }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(179, 38, 30, .45); } 60% { box-shadow: 0 0 0 7px rgba(179, 38, 30, 0); } 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, 0); } }
@keyframes pulse-orange { 0% { box-shadow: 0 0 0 0 rgba(138, 59, 0, .4); } 60% { box-shadow: 0 0 0 7px rgba(138, 59, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(138, 59, 0, 0); } }
@keyframes pulse-amber { 0% { box-shadow: 0 0 0 0 rgba(229, 159, 0, .35); } 60% { box-shadow: 0 0 0 6px rgba(229, 159, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 159, 0, 0); } }
.alert-count { animation: pulse-red 1.8s ease-out infinite; }
.attention { animation: rise .42s cubic-bezier(.2,.7,.2,1) both, warn-border 2.4s ease-out .4s 1; }
@keyframes warn-border { 0% { border-color: #f6c8bc; box-shadow: var(--shadow); } 25% { border-color: var(--c-expense); box-shadow: 0 0 0 4px rgba(228, 87, 46, .18); } 100% { border-color: #f6c8bc; box-shadow: var(--shadow); } }
.attention .card-head h3 .icon, .reminder .card-head h3 .icon, .tag.warn .icon, .save-pill.error .icon, .file-box.warn .icon { animation: wiggle 2.4s ease-in-out infinite; transform-origin: 50% 20%; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-12deg); } 80% { transform: rotate(10deg); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(6deg); } 95% { transform: rotate(-3deg); } }
.due-row.status-overdue .due-bar, .row-overdue td:first-child { animation: blink-bar 1.8s ease-in-out infinite; }
@keyframes blink-bar { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.budget-row.over .progress-bar { animation: grow-bar .9s cubic-bezier(.2,.7,.2,1) both, blink-bar 2.2s ease-in-out .9s infinite; }
.save-pill.error { animation: pulse-red 1.8s ease-out infinite; }
.toast.error .icon { animation: wiggle 1.2s ease-in-out 1; }
.reminder { animation: rise .42s cubic-bezier(.2,.7,.2,1) both, warn-border-amber 2.4s ease-out .4s 1; }
@keyframes warn-border-amber { 0% { box-shadow: none; } 25% { box-shadow: 0 0 0 4px rgba(229, 159, 0, .22); } 100% { box-shadow: none; } }

/* Responsive */
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2, .grid-main-side { grid-template-columns: 1fr; } .welcome { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 30; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  body.nav-open #sidebar { transform: none; }
  .menu-btn { display: inline-grid; }
  #topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  #page-title { font-size: 18px; }
  .month-picker { order: 5; width: 100%; justify-content: center; }
  #content { padding: 16px 16px 40px; }
  .hero { flex-direction: column; align-items: stretch; padding: 20px; }
  .hero h2 { font-size: 24px; }
  .hero-stats { flex-wrap: wrap; }
  .stat { min-width: 0; flex: 1 1 30%; padding: 10px 12px; }
  .stat-value { font-size: 15px; }
  .kpi-row { grid-template-columns: 1fr; }
  .donut-layout { grid-template-columns: 1fr; }
  .due-row, .due-list.compact .due-row { grid-template-columns: 4px 1fr auto; gap: 10px; }
  .due-when { align-items: flex-end; }
  .cc-facts { grid-template-columns: 1fr 1fr; }
  .goal-head h3 { font-size: 16px; }
  .welcome { padding: 22px 18px; }
  .welcome h2 { font-size: 24px; }
  .legend li { grid-template-columns: 10px 1fr auto; }
  .legend-pct { display: none; }
  .month-label { min-width: 0; }
  .toolbar-left > *, .toolbar-right > * { max-width: 100%; }
  .search { min-width: 0; flex: 1 1 100%; }
  .card-head { padding: 14px 16px 0; }
  .card-body { padding: 12px 16px 16px; }
  .kpi-value { font-size: 23px; }
  .due-amount, .due-action { grid-column: 2 / -1; justify-self: end; }
  .form-grid { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  .quick-add select, .quick-add input[type=date], .quick-add .amount-input { flex: 1 1 45%; width: auto; max-width: none; }
  .table { font-size: 13px; }
  .save-pill span { display: none; }
}
@media (min-width: 600px) and (max-width: 820px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { flex-direction: row; align-items: center; }
  .hero-stats { flex-wrap: nowrap; }
  .stat-value { font-size: 17px; }
  .due-row, .due-list.compact .due-row { grid-template-columns: 4px minmax(0, 1fr) auto auto; }
  .due-amount { grid-column: auto; }
  .due-action { grid-column: 2 / -1; justify-self: end; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field.half { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Print */
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body { background: #fff; color: #000; font-size: 12px; }
  .print-doc { padding: 0; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 14px; }
  .print-head h1 { font-size: 20px; }
  .print-head p { margin: 2px 0 0; color: #444; }
  .print-meta { text-align: right; font-size: 11px; color: #444; }
  .print-doc h2 { font-size: 14px; margin: 18px 0 6px; border-bottom: 1px solid #999; padding-bottom: 3px; }
  .print-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; page-break-inside: auto; }
  .print-table th { text-align: left; font-size: 11px; color: #444; border-bottom: 1px solid #000; padding: 4px 6px; }
  .print-table td { padding: 5px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
  .print-table tfoot td { font-weight: 700; border-top: 1px solid #000; border-bottom: 0; }
  .print-table .num { text-align: right; white-space: nowrap; }
  .print-table small { color: #555; }
  .box { display: inline-block; width: 12px; height: 12px; border: 1.5px solid #000; border-radius: 3px; }
  .box.checked { background: #000; }
  .st-overdue { color: #b3261e; font-weight: 700; }
  .st-today { font-weight: 700; }
  .st-paid { color: #146c3c; }
  .print-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .print-box { border: 1px solid #999; border-radius: 6px; padding: 6px 10px; min-width: 110px; display: flex; flex-direction: column; }
  .print-box span { font-size: 10px; color: #444; }
  .print-box b { font-size: 14px; }
  .print-box.good b { color: #146c3c; }
  .print-box.bad b { color: #b3261e; }
  @page { margin: 14mm; }
}

/* The menu control works on desktop and as a drawer on smaller screens. */
.menu-btn{display:inline-grid;position:relative;z-index:31}
@media(min-width:821px){body.nav-collapsed .app{grid-template-columns:0 minmax(0,1fr)}body.nav-collapsed #sidebar{visibility:hidden;overflow:hidden;padding:0;border:0}}
@media(max-width:820px){body.nav-open #menu-btn{position:fixed;left:270px;top:12px;background:var(--surface);box-shadow:0 2px 12px #0002}#sidebar{overflow-y:auto}}
.family-name-list{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}.family-name-chip{display:inline-flex;align-items:center;gap:12px;background:#edf3f0;border:1px solid #d8e5de;border-radius:7px;padding:7px 10px;color:#315747;font-size:14px}.family-name-chip button{border:0;background:none;color:#647b70;cursor:pointer;font-size:19px;line-height:1;padding:0 2px}.family-name-add{display:flex;gap:10px;align-items:center}.family-name-add input{flex:1}.family-name-add button{white-space:nowrap}.family-invite-shortcut{display:inline-block;font-size:14px;margin-top:13px;color:#285d4c}.family-name-editor+small{display:block;margin-top:10px}
.family-access-panel>.search{max-width:440px;margin:8px 0 14px}.family-access-person{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:13px 0;border-bottom:1px solid var(--line)}.family-access-person>div{flex:1;min-width:160px}.family-access-person strong{display:block;font-size:14px}.family-access-person small{display:block;color:var(--ink-2);font-size:13px;overflow-wrap:anywhere;margin-top:4px}.family-access-person>span{font-size:12px;padding:5px 8px;border-radius:5px}.access-ready{color:#276043;background:#eaf5ee}.access-needed{color:#815c24;background:#fff4dd}
