/* =========================================================
   Khata — styles. Mobile-first, calm slate-blue + clay palette.
   ========================================================= */
:root {
  --bg: #f1f1ee;
  --surface: #fbfbf9;
  --surface-2: #eae9e4;
  --border: #dedcd5;
  --text: #2a2d33;
  --muted: #6a6f78;
  --accent: #4f6a8f;
  --accent-ink: #f6f7f9;
  --accent-soft: #e1e7ef;
  --clay: #a8705a;
  --clay-soft: #f1e4dc;
  --income: #4d7a5a;
  --income-soft: #dfeae1;
  --expense: #a35d4f;
  --expense-soft: #f3e1dc;
  --warn: #a07a3c;
  --chart-grid: rgba(50, 55, 65, 0.08);
  --shadow: 0 1px 2px rgba(30, 35, 45, 0.04), 0 6px 18px rgba(30, 35, 45, 0.05);
  --shadow-lg: 0 10px 40px rgba(20, 25, 35, 0.18);
  --radius: 16px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --surface: #1b1e24; --surface-2: #23272f; --border: #2e333c;
    --text: #d6d9de; --muted: #8d939d;
    --accent: #8fa7c9; --accent-ink: #12161d; --accent-soft: #252e3b;
    --clay: #cf9a83; --clay-soft: #362922;
    --income: #8fbf9a; --income-soft: #213029; --expense: #d39484; --expense-soft: #382624; --warn: #cfa86a;
    --chart-grid: rgba(220, 225, 235, 0.07);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b; --surface: #1b1e24; --surface-2: #23272f; --border: #2e333c;
  --text: #d6d9de; --muted: #8d939d;
  --accent: #8fa7c9; --accent-ink: #12161d; --accent-soft: #252e3b;
  --clay: #cf9a83; --clay-soft: #362922;
  --income: #8fbf9a; --income-soft: #213029; --expense: #d39484; --expense-soft: #382624; --warn: #cfa86a;
  --chart-grid: rgba(220, 225, 235, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: .95rem; }
p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pos { color: var(--income); }
.neg { color: var(--expense); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.brand-mark svg { width: 17px; height: 17px; }
.topnav { display: none; gap: 4px; }
.topnav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .92rem; }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.plain { border-color: transparent; background: transparent; }

/* ---------- bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tabbar-h); max-width: 560px; margin: 0 auto; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 550; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 31;
  width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.fab svg { width: 26px; height: 26px; }
body.focus .tabbar, body.focus .fab, body.bare .tabbar, body.bare .fab, body.bare .topnav { display: none; }
main { padding: 18px 0 calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom)); min-height: 70vh; }
body.focus main { padding-bottom: 120px; }
@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .fab { bottom: 28px; right: max(28px, calc((100vw - 980px) / 2 - 40px)); }
  main { padding-bottom: 80px; }
}

/* ---------- page header & month nav ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.month-nav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.month-nav button { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.month-nav button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.month-nav button:disabled { opacity: .35; cursor: default; }
.month-nav span { min-width: 120px; text-align: center; font-weight: 600; font-size: .92rem; }
.month-nav svg { width: 16px; height: 16px; }
.back-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.back-head h1 { font-size: 1.2rem; margin-right: auto; }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-title h2 { font-size: .8rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.card-title a { font-size: .85rem; text-decoration: none; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.section-label { font-size: .78rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; margin: 22px 4px 8px; }

/* ---------- summary ---------- */
.hero-stat .label { font-size: .85rem; color: var(--muted); }
.hero-stat .value { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.hero-stat .hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.mini { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.mini .label { display: block; font-size: .75rem; color: var(--muted); }
.mini .value { display: block; font-weight: 650; font-variant-numeric: tabular-nums; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chart-box { position: relative; height: 220px; }
.chart-box.round { height: 200px; }
.chart-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .85rem; text-align: center; }

/* category bars */
.cat-bars { display: grid; gap: 10px; margin-top: 14px; }
.cat-bar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: .9rem; text-decoration: none; color: inherit; }
.cat-bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar .track { grid-column: 2 / 4; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: -4px; }
.cat-bar .fill { height: 100%; border-radius: 99px; }
.cat-bar .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.cat-bar .pct { color: var(--muted); font-size: .8rem; font-weight: 500; margin-left: 4px; }

/* ---------- avatars ---------- */
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center;
  font-weight: 700; font-size: .95rem; color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
}
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: .78rem; }
.avatar svg { width: 18px; height: 18px; }

/* ---------- lists ---------- */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%;
  text-align: left; border: 0; background: transparent; color: inherit; text-decoration: none; cursor: pointer;
}
.row + .row { border-top: 1px solid var(--border); }
.row:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.row .main { flex: 1; min-width: 0; }
.row .title, .row .meta, .set-row .title, .set-row .meta { display: block; }
.row .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.row .amount small { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.amount.income { color: var(--income); }
.amount.transfer { color: var(--muted); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 4px 8px; font-size: .82rem; color: var(--muted); font-weight: 600; }
.day-head .num { font-weight: 550; }
.tag { display: inline-block; font-size: .72rem; padding: 0 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }

/* ---------- forms ---------- */
.field { display: block; }
.field + .field, .field + .row-fields, .row-fields + .field, .row-fields + .row-fields { margin-top: 16px; }
.field > .label, .label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; font-weight: 550; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 11px 12px; font: inherit; font-size: 1rem; outline: none; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); background: var(--surface); }
select.input {
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d939d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.input-affix { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 0 12px; }
.input-affix:focus-within { border-color: var(--accent); background: var(--surface); }
.input-affix .input { border: 0; background: transparent; padding-left: 0; padding-right: 0; }
.input-affix span { color: var(--muted); }
.help { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.error { font-size: .85rem; color: var(--expense); margin-top: 8px; min-height: 1.2em; }

/* amount entry */
.amount-box { display: flex; align-items: center; gap: 6px; padding: 6px 4px 8px; border-bottom: 2px solid var(--border); }
.amount-box:focus-within { border-color: var(--accent); }
.amount-box .cur { font-size: 1.8rem; color: var(--muted); font-weight: 600; }
.amount-box input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); outline: none;
  font: inherit; font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; padding: 0;
}
.amount-box.expense input { color: var(--text); }
.amount-box.income input { color: var(--income); }
.ops { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.ops button { width: 40px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--muted); }
.ops .result { margin-left: auto; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* segmented & chips */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 13px; }
.seg button, .seg label { flex: 1; position: relative; border: 0; background: transparent; cursor: pointer; padding: 8px 6px; border-radius: 10px; font-size: .9rem; font-weight: 550; color: var(--muted); text-align: center; }
.seg label input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg [aria-pressed="true"], .seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.type [data-type="expense"][aria-pressed="true"] { color: var(--expense); }
.seg.type [data-type="income"][aria-pressed="true"] { color: var(--income); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer; font-size: .88rem; color: var(--text);
}
.chip.text { padding: 6px 12px; }
.chip .dot { width: 22px; height: 22px; border-radius: 8px; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.add { color: var(--accent); border-style: dashed; padding: 6px 12px; }
.chip .x { margin-left: 2px; opacity: .6; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 32px; height: 32px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; background: var(--c); }
.swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--expense); border-color: color-mix(in srgb, var(--expense) 40%, var(--border)); }
.btn.danger.solid { background: var(--expense); color: var(--surface); border-color: var(--expense); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions > .btn { flex: 1; }
.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.sticky-actions .actions { max-width: 640px; margin: 0 auto; }
.form-wrap { max-width: 640px; margin: 0 auto; }

/* ---------- banners & empty states ---------- */
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--clay-soft); border-left: 3px solid var(--clay); font-size: .9rem; margin-bottom: 14px; }
.banner .grow { flex: 1; }
.banner.info { background: var(--accent-soft); border-left-color: var(--accent); }
.empty { text-align: center; padding: 34px 18px; }
.empty .art { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .art svg { width: 30px; height: 30px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 36ch; margin: 0 auto 18px; font-size: .95rem; }

/* filters */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 0 12px; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 16px; height: 16px; color: var(--muted); flex: 0 0 auto; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; padding: 10px 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.totals-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
.badge-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 700; }

/* settings */
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.set-row .main { flex: 1; min-width: 0; }
.set-row .title { font-weight: 550; }
.set-row .meta { font-size: .82rem; color: var(--muted); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- welcome ---------- */
.welcome { max-width: 560px; margin: 0 auto; }
.welcome .hero { padding: 18px 0 8px; }
.welcome .hero h1 { font-size: 1.9rem; }
.welcome .hero p { color: var(--muted); margin-top: 8px; }
.points { display: grid; gap: 10px; margin: 18px 0 8px; }
.point { display: flex; gap: 12px; align-items: flex-start; }
.point .avatar { width: 34px; height: 34px; }
.point b { display: block; font-weight: 600; }
.point span { font-size: .88rem; color: var(--muted); }

/* ---------- sheet (bottom sheet on mobile, dialog on desktop) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 18, 24, 0.42); opacity: 0; transition: opacity .2s ease; }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .24s ease; box-shadow: var(--shadow-lg);
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 99px; background: var(--border); margin: 4px auto 12px; }
.sheet.open { transform: none; }
.sheet-backdrop.open { opacity: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 1.1rem; }
.sheet .actions { margin-top: 20px; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(480px, 92vw); border-radius: 20px; transform: translate(-50%, -46%); opacity: 0; transition: transform .2s ease, opacity .2s ease; padding-top: 18px; }
  .sheet::before { display: none; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
}

/* ---------- toast ---------- */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 86px + env(safe-area-inset-bottom)); z-index: 60; display: grid; justify-items: center; pointer-events: none; padding: 0 16px; }
body.focus .toast-root { bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .toast-root { bottom: 28px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 460px; width: max-content;
  background: var(--text); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: .92rem; transform: translateY(10px); opacity: 0; transition: all .2s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast button { border: 0; background: color-mix(in srgb, var(--bg) 14%, transparent); color: inherit; font-weight: 700; cursor: pointer; padding: 6px 12px; border-radius: 9px; }
.toast:not(:has(button)) { padding-right: 16px; }

.fatal { max-width: 520px; margin: 60px auto; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- installable app ---------- */
.offline-pill { font-size: .75rem; font-weight: 650; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); padding: 3px 10px; border-radius: 99px; }
.steps { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 10px; }
.steps svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
#pwa-banner .icon-btn { width: 32px; height: 32px; }
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); } }

/* ---------- buckets & budgets ---------- */
.bucket-grid { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .bucket-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bucket-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.bucket-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.bucket-card.archived { opacity: .7; }
.bucket-top { display: flex; align-items: center; gap: 12px; }
.bucket-top .main { flex: 1; min-width: 0; }
.bucket-top .title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bucket-top .meta { display: block; font-size: .8rem; color: var(--muted); }
.bucket-top .amount { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bucket-top .amount small { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.budget { margin-top: 12px; }
.budget .meter { margin-top: 0; }
.budget .meter > div { background: var(--income); }
.budget.warn .meter > div { background: var(--warn); }
.budget.over .meter > div { background: var(--expense); }
.budget-text { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.budget.warn .budget-text > span:first-child { color: var(--warn); font-weight: 600; }
.budget.over .budget-text > span:first-child { color: var(--expense); font-weight: 600; }
.hero-stat .budget { margin-top: 10px; }
.mini-buckets { display: grid; gap: 4px; }
.mini-bucket { display: block; padding: 8px 4px; text-decoration: none; color: inherit; border-radius: 10px; }
.mini-bucket + .mini-bucket { border-top: 1px solid var(--border); border-radius: 0; }
.mini-bucket .budget { margin-top: 6px; }
.mb-top { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.mb-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-bar { height: 6px; border-radius: 99px; background: var(--clay); opacity: .85; overflow: hidden; margin-top: 12px; }
.split-bar span { display: block; height: 100%; background: var(--accent); }
.mini .value.clay { color: var(--clay); }
.seg.scope { margin: 14px 0; max-width: 360px; }

/* ---------- bulk select ---------- */
.list-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 4px 0; min-height: 36px; }
.row.selectable input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; margin: 0; }
.row.selectable:has(input:checked) { background: var(--accent-soft); }
.select-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.select-bar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.select-bar .grow { flex: 1; font-weight: 600; font-size: .92rem; }
body.selecting .tabbar, body.selecting .fab { display: none; }
.share-preview { white-space: pre-wrap; font: inherit; font-size: .9rem; background: var(--surface-2); padding: 12px 14px; border-radius: 12px; margin: 0; }

/* ---------- print / PDF: calm, light, easy on ink ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 16mm 14mm; }
  body.printing { background: #fff !important; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  .topbar, .tabbar, .fab, .sticky-actions { display: none !important; }
}
.pr { --ink: #2f343b; --soft: #7b818a; --line: #e4e1da; --paper: #fdfcf9; --slate: #5d7697; --clay: #b07a63; --sage: #5f8a6a;
  color: var(--ink); font-family: var(--font); font-size: 10.5pt; line-height: 1.45; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pr-head { border-bottom: 2px solid var(--slate); padding-bottom: 10px; margin-bottom: 14px; }
.pr-brand { color: var(--slate); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 8.5pt; }
.pr h1 { font-size: 18pt; font-weight: 650; margin: 2px 0 0; }
.pr h3 { font-size: 8.5pt; text-transform: uppercase; letter-spacing: .07em; color: var(--soft); font-weight: 650; margin: 0 0 6px; }
.pr-muted { color: var(--soft); }
.pr-stats { display: flex; gap: 10px; margin-bottom: 16px; }
.pr-stats div { flex: 1; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pr-stats span { display: block; font-size: 8pt; color: var(--soft); }
.pr-stats b { font-size: 13pt; font-variant-numeric: tabular-nums; font-weight: 650; }
.pr-split { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 14px; break-inside: avoid; }
.pr-split > .pr-block { flex: 1; }
.pr-chartbox { flex: 0 0 auto; }
.pr-chart { width: 120px; height: 120px; }
.pr-block { margin-bottom: 14px; }
.pr-table { width: 100%; border-collapse: collapse; }
.pr-table td, .pr-table th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.pr-table th { font-size: 8pt; color: var(--soft); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--slate); }
.pr-table tr { break-inside: avoid; }
.pr-table tfoot td { font-weight: 650; border-top: 1px solid var(--slate); border-bottom: 0; }
.pr-entries tbody tr:nth-child(even) td { background: var(--paper); }
.pr-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-nowrap { white-space: nowrap; }
.pr-debit { color: var(--clay); }
.pr-credit { color: var(--sage); }
.pr-dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.pr-foot { margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--soft); font-size: 8pt; text-align: center; }
