/* Dompetku — ledger/editorial fintech UI
   Prinsip: netral, kontras tinggi, aksen hemat, angka mudah dipindai. */

:root {
  color-scheme: light;
  --bg: #f3f2ec;
  --surface: #fffefa;
  --surface-2: #eae9e1;
  --ink: #111310;
  --ink-2: #3b3e37;
  --muted: #64675e;
  --line: #dbd9cf;
  --line-strong: #c6c3b6;
  --accent: #d8f45f;
  --accent-ink: #10120c;
  --accent-soft: #eef8bf;
  --pos: #0b6b46;
  --neg: #b23a2b;
  --transfer: #5f6258;
  --hero: #111310;
  --hero-ink: #f7f7f0;
  --hero-muted: #a2a69a;
  --hero-line: rgba(255, 255, 255, .13);
  --on-dark-pos: #8fe3b4;
  --on-dark-neg: #ff9d8f;
  --primary: var(--ink);
  --primary-ink: var(--bg);
  --shadow: 0 1px 0 rgba(17, 19, 16, .04);
  --r: 14px;
  --r-lg: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0f0c;
    --surface: #151813;
    --surface-2: #1e221b;
    --ink: #f3f4ec;
    --ink-2: #c9ccc2;
    --muted: #9a9e92;
    --line: #2a2e26;
    --line-strong: #3b4036;
    --accent: #d8f45f;
    --accent-ink: #0e100b;
    --accent-soft: #28301a;
    --pos: #7ee0ab;
    --neg: #ff9e90;
    --transfer: #9a9e92;
    --hero: #1a1e17;
    --hero-ink: #f3f4ec;
    --hero-muted: #9ba08f;
    --hero-line: rgba(255, 255, 255, .12);
    --shadow: none;
    --primary: var(--accent);
    --primary-ink: var(--accent-ink);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.sheet-open { overflow: hidden; }
::selection { background: var(--accent); color: var(--accent-ink); }
:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
strong { font-weight: 600; }

/* ---------- layout ---------- */

.app { min-height: 100dvh; }
.shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(104px + var(--safe-bottom));
}
main { min-height: 40dvh; }
.foot { display: none; }

.rail {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-bottom));
}
.brand, .rail-foot { display: none; }
.brand-mark {
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--ink);
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}
@media (prefers-color-scheme: dark) {
  .brand-mark { background: var(--accent); }
  .brand-mark::after { background: var(--accent-ink); }
}
.brand-name {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.04em;
}
.brand-dot { color: var(--pos); }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background: var(--bg);
}
.auth-card {
  width: min(100%, 404px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 30px; }
.auth-copy .eyebrow { margin-bottom: 9px; }
.auth-copy h1 {
  font-size: clamp(25px, 7vw, 32px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -.045em;
}
.auth-copy p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}
.auth-form { display: grid; gap: 12px; margin-top: 22px; }
.auth-form .primary { margin-top: 2px; }
.login-error {
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--neg) 24%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--neg) 8%, var(--surface));
  color: var(--neg);
  font-size: 11px;
  line-height: 1.45;
}
.auth-foot {
  margin-top: 24px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  padding: 3px 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.nav .ic {
  display: grid;
  place-items: center;
  width: 36px;
  height: 26px;
  border-radius: 999px;
  transition: background-color .16s ease, color .16s ease;
}
.nav .ic svg { width: 21px; height: 21px; }
.nav .label {
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: .005em;
  white-space: nowrap;
}
.nav button.active { color: var(--ink); font-weight: 600; }
.nav button.active .ic { background: var(--accent); color: var(--accent-ink); }
.nav button:active .ic { transform: scale(.94); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 0 12px;
  background: var(--bg);
}
.titles { min-width: 0; }
.topbar h1 {
  font-size: 26px;
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -.045em;
}
.page-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#btn-add {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 13px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
#btn-add svg { width: 15px; height: 15px; }
#btn-add:active { transform: scale(.97); }
#btn-add:disabled { opacity: .5; cursor: default; }

/* ---------- hero / home ---------- */

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.home-grid > *, .content-grid > * { min-width: 0; }
.hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--hero);
  border-radius: var(--r-lg);
  background: var(--hero);
  color: var(--hero-ink);
}
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.hero .eyebrow { color: var(--hero-muted); }
.hero-num {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 14px 0 8px;
  max-width: 100%;
  font-size: clamp(34px, 10.4vw, 58px);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums lining-nums;
}
.hero-num .cur {
  color: var(--hero-muted);
  font-size: .38em;
  font-weight: 600;
  letter-spacing: 0;
}
.hero-note { color: var(--hero-muted); font-size: 11.5px; }
.hero-side {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hero-line);
}
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat span { color: var(--hero-muted); font-size: 9.5px; }
.stat strong {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat.net strong { color: var(--accent); }
.hero .net-pos { color: var(--accent); }
.hero .net-neg { color: var(--on-dark-neg); }
.hero .pos { color: var(--on-dark-pos); }
.hero .neg { color: var(--on-dark-neg); }

.month-switch {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 1px;
  min-height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.month-switch button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.month-switch button:hover { background: var(--surface-2); color: var(--ink); }
.month-switch button:active { transform: scale(.94); }
.month-switch svg { width: 15px; height: 15px; }
.month-label {
  min-width: 84px;
  padding: 0 4px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-align: center;
  white-space: nowrap;
}
.hero .month-switch {
  border-color: var(--hero-line);
  background: rgba(255, 255, 255, .07);
}
.hero .month-switch button { color: var(--hero-muted); }
.hero .month-switch button:hover { background: rgba(255, 255, 255, .12); color: var(--hero-ink); }
.hero .month-label { color: var(--hero-ink); font-size: 10.5px; min-width: 80px; }

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.015em;
}
.panel-link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.panel-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.wallet-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.wallet-scroll::-webkit-scrollbar { display: none; }
.wallet-scroll > .empty { flex: 1 0 100%; }
.wallet-card {
  flex: 0 0 142px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color .15s ease, background-color .15s ease;
}
.wallet-card:hover { border-color: var(--line-strong); background: var(--surface); }
.wallet-top { display: flex; align-items: center; gap: 6px; width: 100%; }
.wallet-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--c, var(--muted));
}
.wallet-type {
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.wallet-name {
  width: 100%;
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wallet-card strong {
  margin-top: auto;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wallet-page { display: grid; gap: 12px; max-width: 920px; }
.wallet-total {
  padding: 20px;
  border: 1px solid var(--hero);
  border-radius: var(--r-lg);
  background: var(--hero);
  color: var(--hero-ink);
}
.wallet-total-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wallet-total .eyebrow { color: var(--hero-muted); }
.wallet-total-num {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 13px 0 6px;
  font-size: clamp(31px, 9.4vw, 50px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
}
.wallet-total-num .cur {
  color: var(--hero-muted);
  font-size: .38em;
  letter-spacing: 0;
}
.wallet-total-note { color: var(--hero-muted); font-size: 11px; }
.wallet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.wallet-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  min-height: 116px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.wallet-tile:hover { border-color: var(--line-strong); background: var(--bg); }
.wallet-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.wallet-tile-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c, var(--muted)) 17%, var(--surface));
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
}
.wallet-tile-name {
  overflow: hidden;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wallet-tile-bal {
  margin-top: auto;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wallet-share {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.wallet-share i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--c, var(--line-strong));
  opacity: .75;
}
.mini-seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-2);
}
.mini-seg button {
  padding: 5px 9px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
}
.mini-seg button.active { background: var(--surface); color: var(--ink); }

.spend-bar {
  display: flex;
  gap: 2px;
  height: 9px;
  margin: 2px 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.spend-bar i { display: block; height: 100%; min-width: 2px; }
.spend-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.spend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.spend-name {
  overflow: hidden;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spend-pct { margin-left: 5px; color: var(--muted); font-size: 10.5px; }
.spend-val {
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.spend-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.spend-total strong { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }

.tx-list { display: flex; flex-direction: column; margin: 0 -6px; }
.tx {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 50px;
  padding: 8px 6px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.tx:hover { background: var(--surface-2); }
.tx-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--line-strong));
}
.tx-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tx-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-amt {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-amt.income { color: var(--pos); }
.tx-amt.expense { color: var(--ink); }
.tx-amt.transfer { color: var(--transfer); }

/* ---------- transaction view ---------- */

.tx-page { max-width: 880px; }
.view-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.tool-note {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.ledger-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}
.summary-cell { padding: 10px 12px; background: var(--surface); min-width: 0; }
.summary-cell span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.summary-cell strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.day { margin-top: 16px; }
.day:first-of-type { margin-top: 0; }
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 7px;
  color: var(--muted);
  font-size: 10.5px;
}
.day-head strong { color: var(--ink); font-size: 11px; font-weight: 600; }
.day-list {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.day-net { font-variant-numeric: tabular-nums; }
.tx-more-wrap { display: flex; justify-content: center; padding: 18px 0 6px; }
.tx-more { min-width: 190px; }
.tx-end {
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 10.5px;
  text-align: center;
}

/* ---------- wallets / settings ---------- */

.content-grid { display: grid; gap: 12px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.025em;
}
.list { display: flex; flex-direction: column; gap: 1px; }
.row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 54px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--surface-2); }
.row-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--c, var(--muted)) 17%, var(--surface));
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: -.02em;
}
.row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.row-main strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-main small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta {
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-chevron { flex: none; width: 15px; height: 15px; color: var(--line-strong); }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag.income { background: color-mix(in srgb, var(--pos) 13%, var(--surface)); color: var(--pos); }
.tag.expense { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); color: var(--neg); }
.tag.transfer { background: color-mix(in srgb, var(--transfer) 13%, var(--surface)); color: var(--transfer); }

.settings-page { display: grid; gap: 12px; }
.setting-block { display: flex; flex-direction: column; gap: 12px; }
.account-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px 2px 13px;
  border-bottom: 1px solid var(--line);
}
.account-line span { color: var(--muted); font-size: 10.5px; }
.account-line strong { font-size: 12.5px; font-weight: 600; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}
.switch-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-copy strong { font-size: 12.5px; font-weight: 500; }
.switch-copy small { color: var(--muted); font-size: 10.5px; line-height: 1.4; }
.switch { position: relative; display: block; flex: none; width: 42px; height: 25px; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color .18s ease;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform .18s ease, background-color .18s ease;
}
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { background: var(--accent); transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }
.divider { height: 1px; background: var(--line); }
.hint { color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.hint code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-2);
  font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.group-label {
  padding: 9px 8px 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.group-label:first-child { padding-top: 2px; }
.facts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 0;
  font-size: 11.5px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; text-align: right; }

/* ---------- buttons / forms ---------- */

.primary, .secondary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: opacity .14s ease, background-color .14s ease, transform .12s ease;
}
.primary { border: 0; background: var(--primary); color: var(--primary-ink); }
.primary:hover { opacity: .88; }
.primary:active, .secondary:active, .danger:active { transform: scale(.98); }
.primary:disabled { opacity: .55; cursor: progress; }
.secondary { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.secondary:hover { background: var(--surface-2); }
.danger {
  border: 1px solid color-mix(in srgb, var(--neg) 30%, var(--line));
  background: transparent;
  color: var(--neg);
}
.danger:hover { background: color-mix(in srgb, var(--neg) 8%, transparent); }
.danger.armed { border-color: var(--neg); background: color-mix(in srgb, var(--neg) 12%, transparent); }
.ghost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.ghost:hover { background: var(--surface-2); color: var(--ink); }
.full { width: 100%; }
.ghost.full {
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin-top: 4px;
  border: 1px dashed var(--line);
  font-size: 11px;
}
.ghost.full svg { width: 14px; height: 14px; flex: none; }
.small { font-size: 11px; }
.muted { color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select, textarea {
  width: 100%;
  min-height: 43px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
input:focus, select:focus, textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 48%, transparent);
}
select {
  appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-repeat: no-repeat;
  background-size: 5px 5px;
}
input[type="color"] { height: 44px; padding: 4px; cursor: pointer; }
.amount-input {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  padding: 12px;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.seg label { position: relative; min-width: 0; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: block;
  padding: 9px 4px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}
.seg label:has(input:checked) span { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 1px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}
.empty-title { color: var(--ink); font-size: 13px; font-weight: 600; }
.empty-text { max-width: 32ch; font-size: 11.5px; line-height: 1.5; }
.empty .secondary { margin-top: 8px; }
.empty-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
}
.empty-mark svg { width: 17px; height: 17px; }

/* ---------- AI ---------- */

.ai-page { display: flex; flex-direction: column; gap: 12px; min-height: calc(100dvh - 190px); }
.ai-intro { padding: 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ai-intro h2 {
  margin: 8px 0 6px;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -.04em;
}
.ai-intro p { max-width: 54ch; color: var(--muted); font-size: 12px; line-height: 1.55; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 13px; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 10.5px;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); background: var(--surface-2); }
.section-note {
  margin: 0 2px 8px;
  color: var(--muted);
  font-size: 10.5px;
}
.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.mode-switch button {
  min-height: 36px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.mode-switch button.active { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.mode-switch button:disabled { opacity: .55; cursor: default; }
.ai-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}
.ai-result { display: grid; gap: 9px; }
.ai-result, #ai-out { scroll-margin-top: 84px; }
.ai-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}
.ai-result-head strong { font-size: 11px; font-weight: 600; }
.ai-result-head .ghost { padding: 5px 7px; }
.ai-list { display: grid; gap: 9px; }
.ai-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ai-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-amount {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.ai-desc { margin-top: 8px; color: var(--ink-2); font-size: 11.5px; line-height: 1.55; }
.ai-desc b { font-weight: 600; color: var(--ink); }
.ai-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 11px; flex-wrap: wrap; }
.ai-actions .primary { min-height: 36px; padding: 8px 11px; font-size: 11px; }
.ai-actions .ghost { padding: 7px 8px; }
.warn { margin-top: 5px; color: var(--neg); font-size: 10.5px; }
.ask-empty {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.prompt-grid { display: grid; gap: 6px; }
.prompt {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.prompt:hover { border-color: var(--line-strong); background: var(--surface-2); }
.chat { display: flex; flex-direction: column; gap: 9px; }
.bubble {
  max-width: 88%;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  line-height: 1.55;
}
.bubble.user {
  align-self: flex-end;
  border-radius: 15px 15px 4px 15px;
  background: var(--primary);
  color: var(--primary-ink);
}
.bubble.bot {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 15px 15px 15px 4px;
  background: var(--surface);
}
.bubble.bot.error { border-color: color-mix(in srgb, var(--neg) 38%, var(--line)); }
.bubble-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.bubble p { margin: 0; white-space: pre-wrap; }
.typing-dots { display: inline-flex; gap: 3px; margin-top: 7px; }
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
.chat-tools { display: flex; justify-content: flex-end; margin-top: -3px; }
.chat-tools .ghost { padding: 4px 6px; font-size: 10.5px; }
@keyframes typing {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.composer {
  position: sticky;
  z-index: 6;
  bottom: calc(76px + var(--safe-bottom));
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(17, 19, 16, .09);
}
.composer textarea {
  min-height: 42px;
  max-height: 132px;
  padding: 10px 8px;
  border: 0;
  background: transparent;
  font-size: 14px;
  resize: none;
}
.composer textarea:focus { box-shadow: none; }
.composer-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: var(--primary);
  color: var(--primary-ink);
  cursor: pointer;
}
.composer-send svg { width: 18px; height: 18px; }
.composer-send:disabled { opacity: .55; cursor: progress; }
.composer-send .spinner { width: 16px; height: 16px; border-color: color-mix(in srgb, var(--bg) 35%, transparent); border-top-color: var(--bg); }

/* ---------- sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 10, 7, .48);
  animation: fade-in .16s ease both;
}
.sheet {
  position: fixed;
  z-index: 61;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -24px 70px rgba(0, 0, 0, .22);
  animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1) both;
}
.sheet-handle {
  flex: none;
  width: 34px;
  height: 4px;
  margin: 9px auto 0;
  border-radius: 999px;
  background: var(--line-strong);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: none;
  padding: 12px 18px 10px;
}
.sheet-head h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.035em;
}
.sheet-head p { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }
.sheet form { display: flex; flex-direction: column; min-height: 0; }
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 13px;
  overflow: auto;
  padding: 3px 18px 16px;
  overscroll-behavior: contain;
}
.sheet-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 11px 18px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet-actions .primary { flex: 1; }
.sheet-actions .danger { flex: none; }
.sheet-note { color: var(--muted); font-size: 10.5px; line-height: 1.45; }

/* ---------- states / motion ---------- */

.progress {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform-origin: 0 50%;
  animation: progress 1.1s ease-in-out infinite;
}
.skeleton {
  border-radius: 12px;
  background: var(--surface-2);
  animation: pulse 1.25s ease-in-out infinite;
}
.skel-hero { height: 190px; border-radius: var(--r-lg); }
.skel-panel { height: 128px; }
.skel-tall { height: 260px; }
.skel-tools { width: 170px; height: 34px; margin-bottom: 14px; border-radius: 999px; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  animation: toast-in .18s ease both;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(26px); opacity: .6; } }
@keyframes toast-in { from { transform: translate(-50%, 6px); opacity: 0; } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress {
  0% { transform: scaleX(.05); opacity: .5; }
  55% { transform: scaleX(.72); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

/* ---------- responsive ---------- */

@media (max-width: 899px) {
  body[data-view='ai'] .toast { bottom: calc(152px + var(--safe-bottom)); }
}

@media (max-width: 399px) {
  #btn-add { width: 40px; padding: 0; border-radius: 50%; }
  #btn-add span { display: none; }
  .hero { padding: 17px; }
  .month-label { min-width: 76px; }
  .hero .month-label { min-width: 72px; }
  .hero-side { gap: 6px; }
  .stat strong { font-size: 11px; }
  .stat span { font-size: 9px; }
  .wallet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 600px) {
  .home-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hero { grid-column: 1 / -1; }
  .wallets-panel { grid-column: 1 / -1; }
  .spend-panel { grid-column: 1; }
  .recent-panel { grid-column: 2; }
  .content-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .wallet-card { flex-basis: 158px; }
  .wallet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .prompt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
  }
  .rail {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 26px;
    height: 100dvh;
    padding: 28px 18px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--bg);
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 2px 8px;
  }
  .nav { display: flex; flex-direction: column; gap: 3px; }
  .nav button {
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 10px;
  }
  .nav .ic { width: 22px; height: 22px; background: none !important; color: inherit; }
  .nav .ic svg { width: 20px; height: 20px; }
  .nav .label { font-size: 12.5px; font-weight: 500; }
  .nav button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
  .nav button.active .ic { color: var(--accent-ink); }
  .rail-foot {
    display: block;
    margin-top: auto;
    padding: 0 8px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
  }
  .shell {
    max-width: none;
    padding: 0 40px 40px;
  }
  .topbar {
    position: static;
    padding: 38px 0 22px;
    background: none;
  }
  .topbar h1 { font-size: 36px; }
  .page-sub { font-size: 12.5px; }
  .home-grid { grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: 14px; }
  .hero { grid-column: 1 / -1; display: grid; grid-template-columns: 1.2fr .8fr; gap: 32px; align-items: end; padding: 26px 28px; }
  .hero-side {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 0;
    padding-top: 0;
    padding-left: 26px;
    border-top: 0;
    border-left: 1px solid var(--hero-line);
  }
  .stat strong { font-size: 14px; }
  .hero-num { font-size: clamp(42px, 5.6vw, 64px); }
  .wallets-panel { grid-column: 1 / -1; }
  .spend-panel { grid-column: 1; }
  .recent-panel { grid-column: 2; }
  .wallet-card { flex: 1 0 0; }
  .wallet-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .panel { padding: 18px; }
  .foot {
    display: block;
    margin-top: 34px;
    color: var(--muted);
    font-size: 9.5px;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .toast { bottom: 28px; }
  .composer { position: static; margin-top: auto; }
  .ai-page { max-width: 720px; }
  .settings-page { max-width: 640px; }
  .sheet {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: min(500px, calc(100vw - 40px));
    max-height: 84dvh;
    border-radius: 18px;
    transform: translate(-50%, -50%);
    animation: modal-in .2s cubic-bezier(.2, .8, .2, 1) both;
  }
  .sheet-handle { display: none; }
  .sheet-head { padding-top: 20px; }
  .sheet-actions { padding-bottom: 16px; }
  @keyframes modal-in {
    from { opacity: 0; transform: translate(-50%, -48%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
  }
}

@media (min-width: 1180px) {
  .shell { padding-right: 56px; padding-left: 44px; }
  .home-grid { grid-template-columns: minmax(0, 1.18fr) minmax(0, .82fr); gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
