/* =====================================================================
   Kobo — money app
   Paper-and-ink palette, single deep-green accent, fintech-grade density.
   Motion: transform/opacity only, custom easing, reduced-motion aware.
   ===================================================================== */

:root {
  --paper:       #F4F1EA;
  --paper-2:     #EDE8DE;
  --card:        #FFFEFB;
  --ink:         #14161A;
  --ink-2:       #4C5057;
  --ink-3:       #64686F;   /* 5.5:1 on card — AA for small text */
  --line:        #E4DFD4;
  --line-2:      #EFEBE2;

  --green:       #15513F;
  --green-2:     #1C6750;
  --green-deep:  #0E3A2D;
  --green-soft:  #E4EEE8;
  --green-tint:  #F1F6F3;

  --danger:      #8B3527;
  --danger-soft: #F7E8E3;
  --gold:        #8A6A21;
  --gold-soft:   #F5EEDC;

  --r-xxl: 28px;
  --r-xl:  22px;
  --r-lg:  18px;
  --r-md:  14px;
  --r-sm:  10px;

  --sh-1: 0 1px 2px rgba(20,22,26,.04), 0 6px 18px -12px rgba(20,22,26,.20);
  --sh-2: 0 2px 6px rgba(20,22,26,.05), 0 18px 40px -24px rgba(20,22,26,.34);
  --sh-hero: 0 10px 30px -14px rgba(14,58,45,.55), 0 2px 6px rgba(14,58,45,.16);

  --e: cubic-bezier(0.32, 0.72, 0, 1);
  --t1: 200ms var(--e);
  --t2: 420ms var(--e);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 84px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  overscroll-behavior-y: none;
  background-image: radial-gradient(120% 46% at 50% -6%, #FCFAF5 0%, rgba(252,250,245,0) 60%);
}
body.is-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; font-family: 'Sora', system-ui, sans-serif; font-weight: 600; letter-spacing: -0.022em; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
svg { display: block; }

.num, .balance-amount, .allow-v, .mini-v, .sum-v, .txn-amt, .amt-big, .kv-v, .heat-i, .people-amt, .p-amt {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ─────────────────────────── shell ─────────────────────────── */
.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 16px calc(var(--nav-h) + 26px + var(--safe-b));
}

.appbar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: calc(16px + var(--safe-t)) 0 14px;
}
.avatar {
  position: relative;
  width: 42px; height: 42px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--green-2), var(--green-deep));
  color: #EFEDE5;
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--line);
}
.avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.avatar-fallback { position: relative; }
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--sh-hero);
}
.appbar-text { flex: 1; min-width: 0; }
.appbar-greet { margin: 0; font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
.appbar-name {
  margin: 0;
  font-family: 'Sora', sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ghost-btn {
  position: relative;
  width: 44px; height: 44px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  transition: transform var(--t1), color var(--t1), border-color var(--t1);
}
.ghost-btn svg { width: 18px; height: 18px; }
.ghost-btn:active { transform: scale(.94); }
.ghost-btn.is-spinning svg { animation: spin 850ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-pip {
  position: absolute; top: 8px; right: 9px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--danger);
  opacity: 0;
  transition: opacity var(--t1);
}
.sync-pip.is-on { opacity: 1; }

/* ─────────────────────────── views ─────────────────────────── */
.view { display: none; }
.view.is-active { display: block; animation: viewIn var(--t2) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─────────────────────────── balance card ─────────────────────────── */
.balance-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xxl);
  padding: 20px 20px 16px;
  background:
    radial-gradient(78% 120% at 92% -18%, rgba(255,255,255,.17) 0%, rgba(255,255,255,0) 58%),
    linear-gradient(148deg, #1B6249 0%, var(--green) 42%, var(--green-deep) 100%);
  color: #F2F0E8;
  box-shadow: var(--sh-hero);
}
.balance-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.balance-label {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(242,240,232,.72);
  font-weight: 500;
}
.balance-label .dot { opacity: .5; margin: 0 2px; }
.balance-amount {
  margin: 0;
  font-family: 'Sora', sans-serif;
  font-size: clamp(29px, 8.6vw, 35px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.08;
  transition: filter var(--t2);
}
.balance-at { margin: 5px 0 0; font-size: 11.5px; color: rgba(242,240,232,.62); }
.eye {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(255,255,255,.11);
  color: rgba(242,240,232,.9);
  transition: transform var(--t1), background var(--t1);
}
.eye svg { width: 17px; height: 17px; }
.eye:active { transform: scale(.92); }
.is-private .balance-amount, .is-private .allow-v, .is-private .sum-v,
.is-private .mini-v, .is-private .txn-amt, .is-private .amt-big { filter: blur(7px); }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  gap: 8px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid rgba(255,255,255,.13);
}
.qa {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 7px 4px;
  border-radius: var(--r-md);
  color: rgba(242,240,232,.92);
  font-size: 11.5px;
  font-weight: 500;
  transition: background var(--t1), transform var(--t1);
}
.qa:active { background: rgba(255,255,255,.1); transform: scale(.97); }
.qa-ic {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(255,255,255,.13);
}
.qa-ic svg { width: 16px; height: 16px; }

/* ─────────────────────────── allowance dial ─────────────────────────── */
.allowance {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 12px;
  padding: 15px 16px;
  border-radius: var(--r-xl);
  background: var(--card);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-1);
}
.allow-ring { position: relative; width: 62px; height: 62px; flex: none; }
.allow-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.allow-track { fill: none; stroke: var(--line-2); stroke-width: 7; }
.allow-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 214;
  stroke-dashoffset: 214;
  transition: stroke-dashoffset 900ms var(--e), stroke 300ms var(--e);
}
.allow-fill.is-over { stroke: var(--danger); }
.allow-ring span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: 'Sora', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-2);
}
.allow-text { min-width: 0; }
.allow-k { margin: 0; font-size: 11px; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); }
.allow-v {
  margin: 1px 0 0;
  font-family: 'Sora', sans-serif;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.035em;
}
.allow-s { margin: 0; font-size: 11.5px; color: var(--ink-3); }

/* ─────────────────────────── mini stats ─────────────────────────── */
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.mini {
  padding: 13px 14px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line-2);
}
.mini-k { margin: 0; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.mini-v {
  margin: 3px 0 0;
  font-family: 'Sora', sans-serif;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.mini-s { margin: 1px 0 0; font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-v.is-negative { color: var(--danger); }

.note {
  margin: 12px 2px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.note strong { font-weight: 600; color: var(--ink); }

/* ─────────────────────────── headers ─────────────────────────── */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 2px 10px;
}
.list-head--top { margin-top: 6px; }
.list-head h2 { font-size: 14.5px; font-weight: 600; }
.text-btn {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--green);
  padding: 14px 6px;
  margin: -14px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.section-label {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 20px 2px 9px;
}
.section-label h3 { font-size: 13.5px; }
.muted { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  transition: transform var(--t1);
}
.pill-btn svg { width: 11px; height: 11px; opacity: .5; }
.pill-btn:active { transform: scale(.96); }

/* ─────────────────────────── transaction rows ─────────────────────────── */
.txns { display: grid; gap: 2px; }
.txns > li { min-width: 0; }
.txn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 10px 10px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--t1), transform var(--t1);
}
.txn:active { background: var(--paper-2); transform: scale(.992); }
.txn-av {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 13px;
  display: grid; place-items: center;
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: var(--paper-2);
  color: var(--ink-2);
}
.txn-av--in { background: var(--green-soft); color: var(--green); }
.txn-av--out { background: #F1EDE4; color: #6C5A34; }
.txn-av--food { background: var(--gold-soft); color: var(--gold); }
.txn-av--charge { background: var(--danger-soft); color: var(--danger); }
.txn-av--mute { background: var(--paper-2); color: var(--ink-3); }
.txn-body { flex: 1; min-width: 0; }
.txn-name {
  display: block;
  font-size: 13.8px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.txn-meta {
  display: block;
  margin-top: 1px;
  font-size: 11.2px;
  color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.txn-amt {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.025em;
  white-space: nowrap;
  text-align: right;
}
.txn-amt--in { color: var(--green); }
.txn-amt--mute { color: var(--ink-3); font-weight: 500; }
.txn-right { display: grid; justify-items: end; gap: 2px; flex: none; }
.txn-tag {
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 10px 5px;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  position: sticky;
  top: calc(56px + var(--safe-t));
  background: linear-gradient(var(--paper) 76%, rgba(244,241,234,0));
  z-index: 2;
}
.day-head b { font-weight: 600; color: var(--ink-2); letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.txns--flat .txn { background: var(--card); border: 1px solid var(--line-2); margin-bottom: 5px; padding: 11px 12px; }

.empty {
  padding: 34px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.6;
}
.empty svg { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--line); }

/* ─────────────────────────── cards ─────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  padding: 16px;
  box-shadow: var(--sh-1);
}
.card + .card { margin-top: 10px; }
.card--list { padding: 6px 0; }
.card--quiet { background: var(--green-tint); border-color: #DFE8E2; box-shadow: none; }

.sum-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sum-k { margin: 0; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.sum-v {
  margin: 2px 0 0;
  font-family: 'Sora', sans-serif;
  font-size: clamp(14px, 4.4vw, 16.5px);
  font-weight: 600;
  letter-spacing: -0.035em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sum-v--in { color: var(--green); }
.sum-v.is-negative { color: var(--danger); }

.gauge { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; margin-top: 15px; }
.gauge-fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-2), var(--green));
  transition: width 900ms var(--e), background 300ms var(--e);
}
.gauge-fill.is-over { background: linear-gradient(90deg, #A2453A, var(--danger)); }
.gauge-note { margin: 9px 0 0; font-size: 11.8px; color: var(--ink-2); line-height: 1.5; }

/* ─────────────────────────── categories ─────────────────────────── */
.cats { display: grid; gap: 1px; }
.cats > li { min-width: 0; }
.cat { padding: 10px 16px; }
.cat-top { display: flex; align-items: center; gap: 10px; }
.cat-ic {
  width: 28px; height: 28px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--paper-2);
  color: var(--ink-2);
  font-family: 'Sora', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
}
.cat-name { flex: 1; min-width: 0; font-size: 13.2px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-amt { font-size: 12.8px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cat-bar { height: 3px; border-radius: 999px; background: var(--line-2); margin: 7px 0 0 38px; overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: 999px; background: var(--green); opacity: .8; transition: width 900ms var(--e); }
.cat:nth-child(2) .cat-bar i { opacity: .66; }
.cat:nth-child(3) .cat-bar i { opacity: .52; }
.cat:nth-child(n+4) .cat-bar i { opacity: .38; }

/* ─────────────────────────── heat calendar ─────────────────────────── */
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.heat-i {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--line-2);
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 500;
  color: rgba(20,22,26,.42);
  transition: transform var(--t1);
}
.heat-i.is-empty { background: #F2EEE6; color: rgba(20,22,26,.28); }
.heat-i.l1 { background: #D8E6DE; color: #2B5C48; }
.heat-i.l2 { background: #B4D1C3; color: #1E4C3B; }
.heat-i.l3 { background: #7FB09A; color: #0F3A2B; }
.heat-i.l4 { background: #3F7F66; color: #F2F0E8; }
.heat-i.over { background: var(--danger); color: #FBEDE9; }
.hint { margin: 12px 0 0; font-size: 11.8px; line-height: 1.55; color: var(--ink-3); }
.hint--center { text-align: center; margin: 14px 0 0; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv-k { margin: 0; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.kv-v { margin: 3px 0 0; font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 600; letter-spacing: -0.03em; }

/* ─────────────────────────── settings row ─────────────────────────── */
.row-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  margin-top: 12px;
  padding: 13px 14px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line-2);
  text-align: left;
  transition: transform var(--t1), background var(--t1);
}
.row-btn:active { transform: scale(.99); background: var(--paper); }
.row-ic {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--paper-2);
  color: var(--ink-2);
}
.row-ic svg { width: 17px; height: 17px; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 13.5px; font-weight: 500; }
.row-sub { display: block; font-size: 11.2px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-chev { color: var(--ink-3); font-size: 18px; line-height: 1; }

/* ─────────────────────────── people ─────────────────────────── */
.people { display: grid; }
.people > li { min-width: 0; }
.person {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 11px 16px;
  text-align: left;
  transition: background var(--t1);
}
.person:active { background: var(--paper); }
.person + .person { border-top: 1px solid var(--line-2); }
.p-av {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--paper-2);
  color: var(--ink-2);
  font-family: 'Sora', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
}
.p-main { flex: 1; min-width: 0; }
.p-name { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-meta { display: block; font-size: 11.2px; color: var(--ink-3); }
.p-right { display: grid; justify-items: end; gap: 4px; flex: none; }
.p-amt { font-family: 'Sora', sans-serif; font-size: 13.5px; font-weight: 600; letter-spacing: -0.02em; }
.p-bar { width: 54px; height: 3px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.p-bar i { display: block; height: 100%; background: var(--green); opacity: .65; border-radius: 999px; }

/* ─────────────────────────── search + filters ─────────────────────────── */
.search { position: relative; }
.search svg {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--ink-3);
}
.search input {
  width: 100%;
  padding: 13px 14px 13px 42px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t1), box-shadow var(--t1);
}
.search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(21,81,63,.1); }
.search input::placeholder { color: var(--ink-3); }

.filters { display: flex; gap: 7px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all var(--t1);
}
.fchip.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.fchip:active { transform: scale(.96); }

/* ─────────────────────────── tabbar ─────────────────────────── */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  width: min(432px, calc(100% - 26px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 8px;
  border-radius: 24px;
  background: rgba(255,254,251,.9);
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
  backdrop-filter: saturate(160%) blur(16px);
}
[data-theme="dark"] .tabbar {
  background: rgba(33,30,25,.92);
  border-color: var(--line);
}
.tab-ind {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 0;
  width: 0;
  border-radius: 16px;
  background: var(--green-soft);
  opacity: 0;
  transition: transform 320ms var(--e), width 320ms var(--e), opacity 200ms var(--e);
  will-change: transform, width;
}
.tab {
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  border-radius: 16px;
  color: var(--ink-3);
  transition: color var(--t1), transform var(--t1);
}
.tab svg { width: 21px; height: 21px; transition: transform 320ms var(--e); }
.tab span { font-size: 10.5px; font-weight: 500; letter-spacing: .02em; transition: font-weight 200ms; }
.tab.is-active { color: var(--green); }
.tab.is-active svg { transform: translateY(-1px) scale(1.1); fill: currentColor; fill-opacity: .16; }
.tab.is-active span { font-weight: 700; }
.tab:active { transform: scale(.94); }
[data-theme="dark"] .tab.is-active { color: var(--green-2); }
[data-theme="dark"] .tab-ind { background: var(--green-soft); }
.fab {
  flex: none;
  width: 46px; height: 46px;
  margin-left: 3px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--green-2), var(--green-deep));
  color: #F2F0E8;
  box-shadow: 0 8px 20px -8px rgba(14,58,45,.85);
  transition: transform var(--t1);
}
.fab svg { width: 21px; height: 21px; }
.fab:active { transform: scale(.9); }

/* ─────────────────────────── scrim + sheets ─────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(14,20,18,.38);
  opacity: 0;
  transition: opacity var(--t2);
}
.scrim.is-open { opacity: 1; }

.sheet {
  position: fixed;
  z-index: 50;
  left: 50%; bottom: 0;
  width: min(460px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 20px calc(24px + var(--safe-b));
  border-radius: 26px 26px 0 0;
  background: var(--card);
  box-shadow: 0 -22px 50px -24px rgba(14,20,18,.45);
  transform: translate(-50%, 100%);
  transition: transform var(--t2);
  will-change: transform;
}
.sheet.is-open { transform: translate(-50%, 0); }
.sheet.is-dragging { transition: none; }
.grip {
  width: 40px; height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 8px auto 16px;
  touch-action: none;
}
.sheet-title { font-size: 17px; }
.sheet-sub { margin: 5px 0 18px; font-size: 12.5px; color: var(--ink-3); }

/* ─────────────────────────── forms ─────────────────────────── */
.form { display: grid; gap: 13px; }
.form label { display: grid; gap: 7px; font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.form label em { font-style: normal; text-transform: none; letter-spacing: 0; opacity: .7; }
.form input, .form select {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  outline: none;
  transition: border-color var(--t1), box-shadow var(--t1), background var(--t1);
}
.form input:focus, .form select:focus { border-color: var(--green); background: var(--card); box-shadow: 0 0 0 3px rgba(21,81,63,.1); }

.amount-field span { font-size: 10.5px; letter-spacing: .12em; }
.amount-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--paper);
  transition: border-color var(--t1), background var(--t1), box-shadow var(--t1);
}
.amount-input:focus-within { border-color: var(--green); background: var(--card); box-shadow: 0 0 0 3px rgba(21,81,63,.1); }
.amount-input > span { font-family: 'Sora', sans-serif; font-size: 20px; font-weight: 500; color: var(--ink-3); }
.amount-input input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px 0 !important;
  font-family: 'Sora', sans-serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.seg { display: flex; gap: 5px; padding: 4px; border-radius: var(--r-md); background: var(--paper-2); }
.seg button {
  flex: 1;
  min-height: 38px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  transition: background var(--t1), color var(--t1);
}
.seg button.is-on { background: var(--card); color: var(--ink); box-shadow: var(--sh-1); }

.btn {
  padding: 15px;
  border-radius: var(--r-md);
  font-family: 'Sora', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform var(--t1), background var(--t1);
}
.btn--primary { background: linear-gradient(150deg, var(--green-2), var(--green-deep)); color: #F2F0E8; box-shadow: var(--sh-hero); }
.btn--primary:active { transform: scale(.985); }
.btn--ghost { background: var(--paper-2); color: var(--ink-2); margin-top: 10px; width: 100%; }

.info-box {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--paper);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
}
.info-box b { color: var(--ink); font-weight: 600; }
.info-box .warn { color: var(--danger); }
.info-box code { font-size: 11px; background: var(--paper-2); padding: 1px 4px; border-radius: 4px; }

.months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.months button {
  min-height: 46px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all var(--t1);
}
.months button.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ─────────────────────────── edit sheet ─────────────────────────── */
.amt-big { font-family: 'Sora', sans-serif; font-size: 30px; font-weight: 600; letter-spacing: -0.04em; margin: 0; }
.amt-sub { margin: 3px 0 20px; font-size: 12px; color: var(--ink-3); }
.block { margin-bottom: 18px; }
.block-label { display: block; font-size: 10.5px; font-weight: 500; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all var(--t1);
}
.chip.is-on { background: var(--green-soft); border-color: #C9DCD1; color: var(--green); }
.chip:active { transform: scale(.96); }
.save-row { display: flex; gap: 8px; margin-top: 4px; }
.save-row .btn { flex: 1; }

/* ─────────────────────────── audit ─────────────────────────── */
.card--audit { border: 1.5px solid #E8C8C4; background: #FBF1EF; }
.card--audit .audit-item { padding: 12px 0; border-top: 1px solid #EED9D5; }
.card--audit .audit-item:first-of-type { border-top: 0; padding-top: 4px; }
.audit-amt { font-size: 20px; font-weight: 700; color: var(--danger); letter-spacing: -0.02em; }
.audit-where { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.audit-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.audit-chips .chip { font-size: 12.5px; min-height: 32px; padding: 7px 11px; }
.audit-why { margin-top: 8px; width: 100%; border: 1px solid #E4D5D2; border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 14px; background: #fff; color: var(--ink); }
.audit-why:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fee-btn { margin-top: 10px; width: 100%; border: 1.5px solid var(--ink); border-radius: 12px; padding: 11px 14px; font: inherit; font-weight: 600; font-size: 14px; background: var(--ink); color: var(--paper); }
.fee-btn:active { transform: scale(.98); }
.chip--danger { background: #F7E4E1; border-color: #E8C8C4; color: #A33B2E; }

/* ─────────────────────────── gate ─────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 24px;
  background: var(--paper);
}
.gate-inner { width: min(292px, 100%); text-align: center; }
.gate-mark { width: 52px; height: 52px; margin: 0 auto 18px; }
.gate-mark svg { width: 52px; height: 52px; border-radius: 16px; box-shadow: var(--sh-hero); }
.gate-title { font-size: 21px; margin-bottom: 6px; }
.gate-sub { margin: 0 0 24px; font-size: 12.5px; color: var(--ink-3); }
.gate-dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 26px; }
.gate-dots i {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  transition: background var(--t1), border-color var(--t1), transform var(--t1);
}
.gate-dots i.is-on { background: var(--green); border-color: var(--green); transform: scale(1.12); }
.gate-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gate-pad button {
  aspect-ratio: 1;
  border-radius: 17px;
  background: var(--card);
  border: 1px solid var(--line-2);
  font-family: 'Sora', sans-serif;
  font-size: 19px;
  font-weight: 500;
  display: grid; place-items: center;
  box-shadow: var(--sh-1);
  transition: transform var(--t1), background var(--t1);
}
.gate-pad button svg { width: 20px; height: 20px; color: var(--ink-2); }
.gate-pad button:active { transform: scale(.94); background: var(--paper-2); }
.gate-ok { background: linear-gradient(150deg, var(--green-2), var(--green-deep)) !important; color: #F2F0E8 !important; border-color: transparent !important; box-shadow: var(--sh-hero) !important; }
.gate-error { min-height: 18px; margin: 14px 0 0; font-size: 12.5px; color: var(--danger); }

/* ─────────────────────────── toast ─────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 12px);
  z-index: 70;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t1), transform var(--t1);
  max-width: 84vw;
  text-align: center;
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }

/* ─────────────────────────── skeleton ─────────────────────────── */
.skel {
  display: inline-block;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(255,255,255,.16) 0%, rgba(255,255,255,.3) 50%, rgba(255,255,255,.16) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skel--num { width: 148px; height: 30px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─────────────────────────── desktop ─────────────────────────── */
@media (min-width: 700px) {
  body { background: #E7E2D7; }
  .app {
    background: var(--paper);
    border-radius: 0;
    box-shadow: 0 0 0 1px rgba(20,22,26,.05), 0 40px 90px -50px rgba(20,22,26,.45);
  }
  .tabbar { bottom: 24px; }
}

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

/* ─────────────────────────── wallet strip ─────────────────────────── */
.wallet-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: rgba(242, 240, 232, .92);
  font-size: 12px;
  width: fit-content;
  max-width: 100%;
}
.ws-dot {
  width: 6px; height: 6px;
  flex: none;
  border-radius: 50%;
  background: #7FD6B4;
  box-shadow: 0 0 0 3px rgba(127, 214, 180, .2);
}
.ws-label { color: rgba(242, 240, 232, .72); }
.ws-amount {
  font-family: 'Sora', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────── charts ─────────────────────────── */
.chart { width: 100%; height: 108px; margin-bottom: 6px; }
.chart--bars { height: 132px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis-label { fill: var(--ink-3); font-size: 8px; font-family: 'Outfit', sans-serif; }
.chart .target-line { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 4 3; opacity: .75; }
.chart .area { fill: url(#spendGrad); }
.chart .line { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--card); stroke: var(--green); stroke-width: 1.8; }
.chart .bar-in { fill: var(--green); opacity: .85; }
.chart .bar-out { fill: #C9A98A; opacity: .9; }
.chart .bar-out.is-over { fill: var(--danger); }
.chart .m-label { fill: var(--ink-3); font-size: 8.5px; font-family: 'Outfit', sans-serif; text-anchor: middle; }

.legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--ink-3);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.lg--in { background: var(--green); }
.lg--out { background: #C9A98A; }

/* ─────────────────────────── background texture ─────────────────────────── */
.bg-texture {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--paper) url('/img/bg-texture.jpg') center / cover no-repeat;
  opacity: .5;
  pointer-events: none;
}

/* ─────────────────────────── motion ─────────────────────────── */
/* entrance states are applied by JS right before animating; if JS or Motion
   is unavailable the elements simply stay visible (progressive enhancement) */
.anim-pending { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .anim-pending { opacity: 1 !important; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ─────────────────────────── dark theme ─────────────────────────── */
/* warm charcoal, never pure black; cream ink; greens brightened for contrast */
[data-theme="dark"] {
  --paper:       #161411;
  --paper-2:     #1D1A16;
  --card:        #211E19;
  --ink:         #F0EDE4;
  --ink-2:       #B8B3A6;
  --ink-3:       #A19C90;   /* 5.6:1 on card */
  --line:        #37332C;
  --line-2:      #2B2822;

  --green:       #3AA47E;
  --green-2:     #46B78E;
  --green-deep:  #123B2E;
  --green-soft:  #1E332A;
  --green-tint:  #1A2C24;

  --danger:      #E8897A;
  --danger-soft: #3A241F;
  --gold:        #D2AC55;
  --gold-soft:   #332B18;

  --sh-1: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px -12px rgba(0,0,0,.5);
  --sh-2: 0 2px 6px rgba(0,0,0,.35), 0 18px 40px -24px rgba(0,0,0,.6);
  --sh-hero: 0 10px 30px -14px rgba(0,0,0,.7), 0 2px 6px rgba(0,0,0,.4);
}

/* dark variants for rules that hardcode light tints */
[data-theme="dark"] .card--audit { border-color: #4A2C25; background: #2A1F1B; }
[data-theme="dark"] .card--audit .audit-item { border-top-color: #3A2A25; }
[data-theme="dark"] .audit-why { background: #1B1815; border-color: #3A2A25; color: var(--ink); }
[data-theme="dark"] .chip--danger { background: #3A241F; border-color: #4A2C25; color: #E8897A; }
[data-theme="dark"] .bg-texture { opacity: .16; }
[data-theme="dark"] .avatar { background: var(--green-soft); color: var(--green-2); }
[data-theme="dark"] .skel { background: linear-gradient(90deg, #2B2822 25%, #35312B 50%, #2B2822 75%); }

/* dark heat calendar: same ramp, dimmed to sit in the dark palette */
[data-theme="dark"] .heat-i.is-empty { background: #262320; color: rgba(240,237,228,.3); }
[data-theme="dark"] .heat-i.l1 { background: #1E332A; color: #7FBFA0; }
[data-theme="dark"] .heat-i.l2 { background: #24503C; color: #A8D9BF; }
[data-theme="dark"] .heat-i.l3 { background: #2E6B50; color: #D3EDDF; }
[data-theme="dark"] .heat-i.l4 { background: #3AA47E; color: #0D2A20; }
[data-theme="dark"] .heat-i.over { background: var(--danger); color: #2A1310; }


/* ─────────────────────────── people hero ─────────────────────────── */
.people-hero { padding: 18px 20px; }
.ph-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.ph-amount { font-family: 'Sora', sans-serif; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 14px; }
.ph-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.ph-k { font-size: 11px; color: var(--ink-3); }
.ph-v { font-size: 15px; font-weight: 600; margin-top: 2px; }

/* theme seg uses the existing .seg styles; nothing extra needed */
