:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #f1f4f3;
  --surface-3: #e8eeec;
  --border: #e3e9e7;
  --text: #10201d;
  --text-2: #64746f;
  --text-3: #93a19c;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: #e2f5f2;
  --accent-ink: #ffffff;
  --gold: #f5b51b;
  --income: #12a37f;
  --expense: #f26b2a;
  --transfer: #3b82f6;
  --good: #0e8a5f;
  --warn: #a15c00;
  --bad: #d23c3c;
  --warn-bg: #fff3d6;
  --bad-bg: #ffe9e7;
  --good-bg: #e1f6ec;
  --shadow-sm: 0 1px 2px rgba(16, 32, 29, .05);
  --shadow: 0 1px 2px rgba(16, 32, 29, .04), 0 6px 20px rgba(16, 32, 29, .06);
  --shadow-lg: 0 12px 32px rgba(6, 78, 71, .28);
  --radius: 20px;
  --hero: linear-gradient(135deg, #0d9488 0%, #0f766e 45%, #0b4f49 100%);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 4px 0; font-size: 14px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.2px; }
h2 { font-size: 16.5px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 22px; height: 22px; flex: none; display: block; }
.hide-amt .sensitive { filter: blur(9px); user-select: none; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 60% at 50% 0%, #c9f1ea 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); padding: 32px 24px 26px; border-radius: 28px;
  box-shadow: 0 20px 50px rgba(6, 78, 71, .14); text-align: center; }
.login-card .field { text-align: left; margin-top: 22px; }
.login-logo { display: block; margin: -72px auto 14px; border-radius: 26px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -.6px; color: var(--accent); }
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .login-card h1 { background: linear-gradient(90deg, var(--accent), #e48a00); -webkit-background-clip: text; background-clip: text; color: transparent; }
}
.login-card .btn.primary { margin-top: 4px; padding: 14px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px; background: rgba(243, 246, 245, .9); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 11px; box-shadow: 0 4px 12px rgba(6, 78, 71, .25); }
.topbar h1 { font-size: 21px; font-weight: 800; letter-spacing: -.4px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn { border: 0; background: var(--surface); width: 42px; height: 42px; border-radius: 14px; cursor: pointer;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border) inset; color: var(--text); display: grid; place-items: center; }
.icon-btn:active { transform: scale(.95); }
.view { max-width: 760px; margin: 0 auto; padding: 2px 16px 120px; }

/* bottom nav */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: center;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -1px 0 var(--border), 0 -8px 24px rgba(16, 32, 29, .05); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; max-width: 150px; background: none; border: 0; padding: 4px 2px; font-size: 11.5px; font-weight: 600;
  color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.tabs button span { width: 56px; height: 30px; border-radius: 99px; display: grid; place-items: center; transition: background .2s; }
.tabs button.active { color: var(--accent); }
.tabs button.active span { background: var(--accent-soft); }
.fab { position: fixed; right: max(18px, calc(50vw - 362px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 11;
  width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--hero); color: #fff;
  box-shadow: var(--shadow-lg); cursor: pointer; display: grid; place-items: center; }
.fab svg.i { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }

/* hero */
.card.hero { position: relative; overflow: hidden; background: var(--hero); color: #fff; border: 0; border-radius: 24px;
  padding: 20px 20px 18px !important; box-shadow: var(--shadow-lg); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::before { width: 220px; height: 220px; right: -70px; top: -90px; background: radial-gradient(circle, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 70%); }
.hero::after { width: 150px; height: 150px; right: -40px; bottom: -95px; border: 22px solid rgba(245, 181, 27, .22); }
.hero > * { position: relative; z-index: 1; }
.hero .label { opacity: .85; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.hero .big { font-size: 32px; font-weight: 800; letter-spacing: -.8px; margin: 4px 0 14px; }
.eye { background: rgba(255, 255, 255, .16); border: 0; color: #fff; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.eye svg.i { width: 17px; height: 17px; }
.hero-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 11.5px; }
.hero-row > div { background: rgba(255, 255, 255, .13); border-radius: 14px; padding: 9px 10px; min-width: 0; }
.hero-row b { display: block; font-size: 13.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }

/* quick actions */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 6px; }
.quick button { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text); padding: 0; }
.quick button span { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.quick button:active span { transform: scale(.94); }
.q-teal { background: var(--accent-soft); color: var(--accent); }
.q-violet { background: #efeaff; color: #6d4ee6; }
.q-blue { background: #e6f0ff; color: #2f6fe0; }
.q-orange { background: #fff0e4; color: #e0621f; }

/* cards & lists */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head a, .link { color: var(--accent); font-size: 13.5px; font-weight: 700; text-decoration: none; cursor: pointer; background: none; border: 0; padding: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.stat .value { font-weight: 800; font-size: 15px; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; }
.flow2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.flow2 .stat { display: flex; gap: 10px; align-items: center; padding: 14px 12px; }
.flow2 .stat > div { min-width: 0; }
.dot-ic { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.dot-ic svg.i { width: 19px; height: 19px; }
.dot-ic.in { background: var(--good-bg); color: var(--income); }
.dot-ic.out { background: #ffeee4; color: var(--expense); }
.net-line { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: 16px;
  padding: 11px 14px; margin-top: 10px; box-shadow: var(--shadow); font-size: 13.5px; }
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; cursor: pointer; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 54px; right: 0; height: 1px; background: var(--border); }
.row .ico { width: 42px; height: 42px; flex: none; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; }
.row .ico svg.i { width: 20px; height: 20px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row .end { text-align: right; font-size: 14.5px; }
.row .end b { font-weight: 800; }
.day-head { font-size: 12.5px; color: var(--text-2); font-weight: 700; margin: 16px 4px 4px; display: flex; justify-content: space-between; }
.empty { text-align: center; color: var(--text-2); padding: 26px 10px; font-size: 14px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); margin-top: 3px; }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.good { background: var(--good-bg); color: var(--good); }
.progress { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 99px; }
.progress.over > div { background: var(--bad); }
.alert { display: flex; gap: 10px; align-items: flex-start; background: var(--bad-bg); color: #8f2424; border-radius: 16px; padding: 12px 14px; margin: 14px 0; font-size: 13.5px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0 10px; }
.toolbar select, .toolbar input { padding: 9px 12px; border-radius: 99px; border: 0; background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border) inset;
  min-width: 0; font-size: 13.5px; font-weight: 600; }
.toolbar input[type=search] { flex: 1 1 100%; padding: 11px 16px; font-weight: 500; }
.month-nav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border-radius: 99px; padding: 4px; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border) inset; }
.month-nav b { min-width: 124px; text-align: center; font-size: 14px; }
.month-nav .btn.small { border: 0; background: var(--surface-2); width: 32px; height: 32px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.month-nav .btn.small svg.i { width: 16px; height: 16px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 22px 2px 10px; gap: 8px; }

/* buttons & forms */
.btn { border: 0; background: var(--surface); box-shadow: 0 0 0 1px var(--border) inset; padding: 11px 16px; border-radius: 14px;
  cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--hero); color: #fff; box-shadow: 0 6px 16px rgba(15, 118, 110, .28); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn:active { transform: scale(.98); }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid transparent;
  background: var(--surface-2); transition: border-color .15s, background .15s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent-2); background: var(--surface); }
.field .hint { font-size: 12px; color: var(--text-2); margin-top: 5px; }
.rp-wrap { position: relative; }
.rp-wrap > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-weight: 700; pointer-events: none; }
.rp-wrap input { padding-left: 44px !important; }
.rp-wrap:has(.amount-input) > span { font-size: 20px; left: 16px; }
.rp-wrap .amount-input { font-size: 28px !important; font-weight: 800; letter-spacing: -.5px; padding: 14px 14px 14px 58px !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }
.form-actions .btn { padding: 14px 18px; }
.form-actions .btn.primary { flex: 1; }
.kind-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 16px; background: var(--surface-2); padding: 4px; border-radius: 16px; }
.kind-switch label { text-align: center; padding: 10px 4px; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--text-2); transition: background .15s; }
.kind-switch input { display: none; }
.kind-switch label:has(input:checked) { background: var(--surface); box-shadow: var(--shadow); }
.kind-switch label:has(input[value=expense]:checked) { color: var(--expense); }
.kind-switch label:has(input[value=income]:checked) { color: var(--income); }
.kind-switch label:has(input[value=transfer]:checked) { color: var(--transfer); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.chips label { padding: 8px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; font-weight: 600; cursor: pointer; border: 1.5px solid transparent; }
.chips input { display: none; }
.chips label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ai-box { background: linear-gradient(180deg, #f2efff, #faf9ff); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; font-size: 13.5px; }
.ai-box img { max-width: 100%; max-height: 220px; display: block; margin: 0 auto 10px; border-radius: 12px; }
.ai-box table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ai-box td { padding: 2px 0; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(9, 26, 23, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 28px 28px 0 0; display: flex; flex-direction: column; animation: up .25s cubic-bezier(.2, .8, .2, 1); }
.sheet::before { content: ""; width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 10px auto 0; flex: none; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 28px; } .sheet::before { display: none; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px 8px; }
.sheet-head h2 { font-size: 19px; font-weight: 800; }
.sheet-head .icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); box-shadow: none; }
.sheet-body { overflow: auto; padding: 6px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet-body .card { box-shadow: none; background: var(--surface-2); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 60;
  background: #10201d; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; max-width: 90vw; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 22px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* charts */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13.5px; cursor: pointer; align-items: center; }
.bar-row .ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; grid-row: span 2; }
.bar-row .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { grid-column: 2 / -1; height: 8px; background: var(--surface-2); border-radius: 99px; position: relative; }
.bar-row .fill { height: 100%; background: var(--expense); border-radius: 99px; min-width: 4px; }
.bar-row.over .fill { background: var(--bad); }
.bar-row .budget-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 2px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--border); stroke-dasharray: 3 4; }
.chart text { fill: var(--text-3); font-size: 10.5px; font-weight: 600; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.on { fill: var(--surface-2); }
.tooltip { position: fixed; z-index: 70; pointer-events: none; background: var(--surface); color: var(--text);
  border-radius: 14px; padding: 10px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(16, 32, 29, .18); min-width: 160px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 12px; }
details.table-view summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 700; margin-top: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.data th, table.data td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }

/* pockets as cards */
.pocket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.pocket { background: var(--surface); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); cursor: pointer; position: relative; min-width: 0; }
.pocket .ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; margin-bottom: 12px; }
.pocket .name { font-size: 13px; color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pocket .bal { font-size: 16.5px; font-weight: 800; letter-spacing: -.3px; overflow: hidden; text-overflow: ellipsis; }
.pocket .edit { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 10px; border: 0; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.pocket .edit svg.i { width: 15px; height: 15px; }
.pocket.add { display: grid; place-items: center; text-align: center; color: var(--accent); font-weight: 700; font-size: 13.5px; background: transparent; box-shadow: none; border: 2px dashed var(--surface-3); min-height: 128px; }

/* transaction filters: one scrollable row of pills */
.search { width: 100%; padding: 12px 16px; border-radius: 99px; border: 0; background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border) inset; font-size: 14px; margin-bottom: 10px; }
.search:focus { outline: 2px solid var(--accent-2); outline-offset: 0; }
.toolbar.filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 2px 16px; }
.toolbar.filters::-webkit-scrollbar { display: none; }
.toolbar.filters select { flex: none; max-width: 70vw; }
.row .end .btn.small { margin-top: 6px; padding: 6px 14px; box-shadow: none; }

/* personal / family switch */
.scope { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: 16px; margin: 2px 0 14px; }
.scope button { border: 0; background: none; padding: 9px 8px; border-radius: 12px; font-weight: 700; font-size: 13.5px; color: var(--text-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.scope button svg.i { width: 17px; height: 17px; }
.scope button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--text); }
.member-row { cursor: default; align-items: flex-start; }
.member-row .end { white-space: nowrap; }
.share { height: 6px; background: var(--surface-2); border-radius: 99px; margin-top: 7px; overflow: hidden; }
.share > div { height: 100%; background: var(--expense); border-radius: 99px; min-width: 3px; }
.card.account { display: flex; align-items: center; gap: 12px; }
.card.account .main { flex: 1; min-width: 0; }
.card.account .title { font-weight: 800; }
.card.account .sub { font-size: 12.5px; color: var(--text-2); }
.login-card .field { margin-top: 14px; }
