/* GrowthPi app */
:root {
  color-scheme: light;
  --bg: #f4f8f5; --card: #ffffff; --text: #13201a; --muted: #5a6b60; --line: #e1e9e3; --line-2: #cfdcd3;
  --green: #1e8e3e; --green-deep: #146c2e; --mint: #eaf6ec; --ink: #0f1b13;
  --inc: #1e8e3e; --exp: #6250d6;                 /* chart series (validated pair) */
  --good: #0a7d0a; --warn: #a86a00; --over: #d03b3b; /* status text (with icon + label) */
  --good-bar: #0ca30c; --warn-bar: #fab219; --over-bar: #d03b3b;
  --shadow: 0 1px 2px rgba(15,27,19,.05), 0 8px 24px -14px rgba(15,27,19,.22);
  --r: 20px; --r-sm: 12px; --toast-bg: #13201a; --toast-fg: #fff; --toast-btn: #7ed349;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Poppins", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b130e; --card: #121f17; --text: #e5eee8; --muted: #9db0a3; --line: #213328; --line-2: #2c4334;
    --green: #2fa84f; --green-deep: #5cc56f; --mint: #163322; --inc: #2fa84f; --exp: #9085e9;
    --good: #3fc23f; --warn: #fab219; --over: #ff7a7a; --toast-bg: #e5eee8; --toast-fg: #0b130e; --toast-btn: #146c2e; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b130e; --card: #121f17; --text: #e5eee8; --muted: #9db0a3; --line: #213328; --line-2: #2c4334;
  --green: #2fa84f; --green-deep: #5cc56f; --mint: #163322; --inc: #2fa84f; --exp: #9085e9;
  --good: #3fc23f; --warn: #fab219; --over: #ff7a7a; --toast-bg: #e5eee8; --toast-fg: #0b130e; --toast-btn: #146c2e; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-tap-highlight-color: transparent; }
body.noscroll { overflow: hidden; }
a { color: var(--green-deep); }
button, input, select { font: inherit; color: inherit; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small, small { font-size: .86rem; }
.row { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; } .gap { gap: 10px; } .end { justify-content: flex-end; } .grow { flex: 1; }
.stack { display: grid; gap: 10px; }
.sep { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* shell */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font: 800 1.15rem var(--display); letter-spacing: .2px; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand b { color: var(--green); }
body.onboard .topbar .icon-btn { visibility: hidden; }
main { padding: 4px 16px calc(110px + var(--safe-b)); }
body.onboard main { padding-bottom: 40px; }
.page-title { font: 700 1.5rem var(--display); margin: 6px 0 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--mint); } .icon-btn:disabled { opacity: .3; cursor: default; background: none; }

/* cards & text */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.h { font: 700 1.05rem var(--display); margin: 0 0 10px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green-deep); }
.hint { background: var(--mint); border-radius: var(--r-sm); padding: 10px 12px; font-size: .9rem; margin: 12px 0 0; }
.big-num { font: 800 2.4rem/1.1 var(--display); margin: 10px 0 14px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.big-num small { display: block; font: 600 .85rem var(--font); color: var(--muted); letter-spacing: 0; margin-bottom: 4px; }
.big2 { font: 700 1.5rem var(--display); }
.inc { color: var(--inc); }
.hero-card { background: linear-gradient(160deg, var(--card) 40%, var(--mint)); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; margin-top: 14px; }
.mini-stats > div { display: flex; flex-direction: column; }
.mini-stats small { color: var(--muted); } .mini-stats b { font: 700 1.05rem var(--display); font-variant-numeric: tabular-nums; }
.card.mini-stats { margin-top: 0; }
.streak { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 700; color: #c2410c; background: #fff1e6; border-radius: 999px; padding: 3px 10px; }
:root[data-theme="dark"] .streak { background: #3a2412; color: #ffb37a; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .streak { background: #3a2412; color: #ffb37a; } }

/* status */
.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--good-bar); }
.bar i.warn { background: var(--warn-bar); } .bar i.over { background: var(--over-bar); } .bar i.goalbar { background: var(--green); }
.st { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; } .st .i { width: 16px; height: 16px; }
.st.good { color: var(--good); } .st.warn { color: var(--warn); } .st.over { color: var(--over); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #fff; } .btn.primary:hover { background: var(--green-deep); }
.btn.ghost { background: var(--card); border-color: var(--line-2); color: var(--text); }
.btn.danger { background: #d03b3b; color: #fff; } .danger-t { color: var(--over) !important; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; margin-top: 8px; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--green-deep); font-weight: 700; cursor: pointer; padding: 6px 0; text-decoration: none; font-size: .95rem; }
.link-btn .i { width: 16px; height: 16px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quick .btn { min-height: 56px; font-size: 1.05rem; }
.btn.exp { background: var(--card); border-color: var(--line-2); }
.btn.inc { background: var(--mint); color: var(--green-deep); border-color: transparent; }

/* tip */
.tip h3 { font: 700 1.15rem/1.3 var(--display); margin: 8px 0 6px; } .tip p { margin: 0 0 6px; color: var(--muted); }

/* lists */
.tx-list { display: grid; }
.tx, .goal, .budget { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.tx:last-child, .goal:last-child, .budget:last-child { border-bottom: 0; }
.card.tx-list { padding: 4px 14px; }
.emoji { width: 42px; height: 42px; border-radius: 13px; background: var(--mint); display: grid; place-items: center; font-size: 1.25rem; flex: none; }
.tx-main, .goal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-main b { font-weight: 600; } .tx-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal-main .bar { margin: 6px 0 4px; height: 8px; }
.day { margin-bottom: 6px; } .day-head { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); font-weight: 600; padding: 6px 4px; }
.empty { text-align: center; padding: 22px 8px; } .empty p { color: var(--muted); margin: 0 0 14px; }

/* month switch & filters */
.month-switch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; outline: 0; background: none; width: 100%; min-height: 44px; color: var(--text); }
.filters select, .field select, .field input, .newcat input { min-height: 46px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); padding: 0 12px; width: 100%; }
.filters select { width: auto; max-width: 45%; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; } .field > span { font-weight: 600; font-size: .9rem; }
.field input:focus, .field select:focus, .search:focus-within, .amount-field:focus-within, .newcat input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.amount-field { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 16px; padding: 6px 16px; margin: 14px 0; background: var(--card); }
.amount-field .cur { font: 700 1.6rem var(--display); color: var(--muted); }
.amount-field input { border: 0; outline: 0; background: none; width: 100%; font: 800 2rem var(--display); min-height: 56px; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { min-height: 42px; border: 0; border-radius: 10px; background: none; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.cat-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-cat { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: .9rem; font-weight: 600; }
.chip-cat.on { border-color: var(--green); background: var(--mint); color: var(--green-deep); box-shadow: inset 0 0 0 1px var(--green); }
.chip-cat.add { border-style: dashed; color: var(--muted); }
.newcat { margin-top: 10px; } .newcat input { flex: 1; }
.err { color: var(--over); font-weight: 600; margin: 6px 0; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-pick button { width: 46px; height: 46px; border-radius: 13px; border: 1px solid var(--line-2); background: var(--card); font-size: 1.3rem; cursor: pointer; }
.icon-pick button.on { border-color: var(--green); background: var(--mint); box-shadow: inset 0 0 0 1px var(--green); }

/* insights */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.tile small { color: var(--muted); display: block; } .tile b { font: 700 1.25rem var(--display); font-variant-numeric: tabular-nums; }
.tiles + .hint { margin-bottom: 14px; }
.catbars { display: grid; gap: 12px; }
.catbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .92rem; }
.cb-label { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.cb-val { font-weight: 700; font-variant-numeric: tabular-nums; } .cb-val small { color: var(--muted); font-weight: 600; }
.cb-track { grid-column: 1 / -1; height: 10px; } .cb-track i { display: block; height: 100%; min-width: 4px; border-radius: 0 4px 4px 0; background: var(--exp); }
.legend { display: flex; gap: 16px; font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.legend span, .tt span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .tt i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
i.s-inc { background: var(--inc); } i.s-exp { background: var(--exp); }
.chart-wrap { position: relative; }
.trend { width: 100%; height: 190px; display: block; overflow: visible; }
.trend .s-inc { fill: var(--inc); } .trend .s-exp { fill: var(--exp); }
.trend .axis { stroke: var(--line-2); stroke-width: 1; }
.trend text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.trend .hit { fill: transparent; cursor: pointer; outline: none; }
.trend .tg.on .hit { fill: var(--text); fill-opacity: .05; }
.tt { position: absolute; top: 0; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line-2); box-shadow: var(--shadow); border-radius: 12px; padding: 8px 12px; font-size: .84rem; display: grid; gap: 2px; pointer-events: none; white-space: nowrap; }
.table-view { margin-top: 10px; font-size: .9rem; } .table-view summary { cursor: pointer; color: var(--green-deep); font-weight: 600; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); } .table-view th:first-child, .table-view td:first-child { text-align: left; }

/* ads */
.ad { margin: 0 0 14px; text-align: center; } .ad > span { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; padding: 0 0 var(--safe-b); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.nav-in { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; max-width: 560px; align-items: end; }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; border: 0; background: none; color: var(--muted); font-size: .72rem; font-weight: 600; cursor: pointer; }
.nav button[aria-current="page"] { color: var(--green-deep); }
.nav .fab { align-self: center; }
.nav .fab span { width: 56px; height: 56px; margin-top: -24px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px -6px rgba(30,142,62,.6); border: 4px solid var(--bg); }
.nav .fab .i { width: 26px; height: 26px; stroke-width: 2.4; }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(5,12,8,.45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
.sheet.on { opacity: 1; }
.sheet-card { width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow: auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 8px 18px calc(22px + var(--safe-b)); transform: translateY(30px); transition: transform .22s ease; overscroll-behavior: contain; }
.sheet.on .sheet-card { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; background: var(--card); padding: 8px 0; z-index: 1; }
.sheet-head h2 { font: 700 1.2rem var(--display); margin: 0; }
.sheet-body .btn { margin-top: 12px; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 24px; max-height: 86vh; padding-bottom: 22px; } }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 10px); z-index: 60; background: var(--toast-bg); color: var(--toast-fg); border-radius: 14px; padding: 12px 16px; display: flex; gap: 16px; align-items: center; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); opacity: 0; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); font-size: .95rem; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast button { border: 0; background: none; color: var(--toast-btn); font-weight: 800; cursor: pointer; }

/* welcome */
.welcome { padding: 18px 4px 10px; }
.welcome-logo { border-radius: 20px; box-shadow: var(--shadow); }
.welcome h1 { font: 800 2rem/1.15 var(--display); margin: 18px 0 10px; letter-spacing: -.3px; }
.welcome .lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 16px; }
.ticks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; font-weight: 600; }
.ticks li { display: flex; gap: 10px; align-items: center; } .ticks .i { color: var(--green); }
.fine { font-size: .8rem; color: var(--muted); margin-top: 16px; }

/* desktop frame */
@media (min-width: 700px) {
  body { background: radial-gradient(1000px 600px at 20% -10%, var(--mint), transparent 60%), var(--bg); }
  main { padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

p .st { vertical-align: bottom; }
