/* ==========================================================================
   Ev Bütçesi design system
   Neutral surfaces, one emerald accent, Inter, tabular figures for money.
   Light and dark are each tuned (not an automatic inversion).
   ========================================================================== */
:root {
  --bg: #f5f2ea;
  --card: #fffdf8;
  --tile: #f0ece1;          /* icon tiles, inputs, inset blocks */
  --text: #191d17;
  --muted: #6c6f62;
  --faint: #a2a294;
  --line: #e9e4d7;
  --glow: #c9f26b;
  --accent: #0f8a63;
  --accent-strong: #0a6b4c;
  --accent-soft: rgba(15, 138, 99, .12);
  --on-accent: #ffffff;
  --pos: #0e9f6e; --neg: #e5484d; --warn: #d97706;
  --hero-1: #24654f; --hero-2: #143f31; --hero-3: #0a241c;
  --shadow: 0 1px 1px rgba(60, 50, 20, .03), 0 6px 18px -8px rgba(60, 50, 20, .12);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
  --r-lg: 22px; --r-md: 16px; --r-sm: 12px;
  /* Categorical chart slots (validated CVD-safe order); --s-other = folded tail. */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #6250d6; --s-other: #a8aca9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e0c; --card: #151a16; --tile: #1f2620; --text: #f2f3ec; --muted: #a0a698; --faint: #6d7367; --line: #262d27;
    --accent: #34d399; --accent-strong: #6ee7b7; --accent-soft: rgba(52, 211, 153, .13); --on-accent: #052e1f;
    --pos: #34d399; --neg: #f87171; --warn: #fbbf24;
    --hero-1: #1f5a46; --hero-2: #133a2d; --hero-3: #0a211a;
    --shadow: none; --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #9085e9; --s-other: #5c625e;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Browser pull-to-refresh is off (it fired inside sheets); app.js has its own, main screen only. */
html, body { overscroll-behavior-y: none; }
/* No zooming: double-tap zoom off (pinch is blocked in app.js for iOS). */
html { touch-action: manipulation; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
b, strong { font-weight: 650; }
small { font-size: 13px; }
h1 { font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -.025em; margin: 0; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 12px; color: var(--text); }
h3 { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; margin: 22px 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
.pos { color: var(--pos); } .neg { color: var(--neg); }
small.warn, span.warn { color: var(--warn); } small.over { color: var(--neg); }
.center { padding: 48px 20px; text-align: center; }
/* Money lines up in columns. */
.tx > span:last-child, .tx .r2, .line b, .card b, .hero-amt, .pf-value, .cattop, .items, .legend-list .pc, .amount { font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; /* 16px: iOS won't zoom on focus */
  border: 1.5px solid transparent; border-radius: var(--r-sm); background: var(--tile); transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--card); }
input::placeholder { color: var(--faint); }
label { display: block; margin: 12px 0; font-size: 13px; font-weight: 550; color: var(--muted); }
label > input, label > select { margin-top: 6px; color: var(--text); font-weight: 400; }

.primary, .ghost, .danger {
  display: block; width: 100%; margin-top: 10px; padding: 14px 18px; border-radius: 14px;
  font-weight: 650; font-size: 15px; letter-spacing: -.01em; transition: transform .08s, filter .15s;
}
.primary:active, .ghost:active, .danger:active { transform: scale(.98); }
.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.ghost { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .ghost { color: var(--accent); } }
.danger { background: color-mix(in srgb, var(--neg) 10%, transparent); color: var(--neg); }
.sm { padding: 10px 14px; font-size: 14px; border-radius: 12px; }
.link { color: var(--muted); margin-top: 20px; text-decoration: underline; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row .emoji { flex: 0 0 60px; text-align: center; font-size: 22px; }

/* Segmented control */
.seg { display: flex; gap: 2px; background: var(--tile); border-radius: 13px; padding: 3px; }
.seg label { flex: 1; margin: 0; }
.seg input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .kind-seg button {
  display: block; width: 100%; text-align: center; padding: 9px 8px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.seg input:checked + span, .kind-seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.kind-seg { margin: 16px 0 0; }

/* Chips (category picker) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chips label { margin: 0; }
.chips span { display: block; padding: 8px 13px; border-radius: 99px; background: var(--tile); color: var(--text); font-size: 14px; font-weight: 500; border: 1.5px solid transparent; }
.chips input:checked + span { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); font-weight: 600; }
@media (prefers-color-scheme: dark) { .chips input:checked + span { color: var(--accent); } }
.chips .chip-add { padding: 8px 13px; border-radius: 99px; border: 1.5px dashed var(--faint); color: var(--muted); font-size: 14px; font-weight: 600; }

label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 500; }
label.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: 0 0 22px; }

/* ---------- app chrome ---------- */
.demo { background: #fef3c7; color: #92400e; text-align: center; font-size: 12px; font-weight: 600; padding: 6px; }
header {
  padding: calc(18px + env(safe-area-inset-top)) 20px 10px; max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.monthnav { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: 99px; padding: 4px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.monthnav span { padding: 0 6px; white-space: nowrap; }
.monthnav button { width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1; color: var(--text); display: grid; place-items: center; }
.monthnav button:active { background: var(--tile); }
main { padding: 0 16px 90px; max-width: 640px; margin: 0 auto; }
section { background: var(--card); border-radius: var(--r-lg); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.small-note { font-size: 12px; margin: 16px 4px; line-height: 1.5; color: var(--faint); }
.code { display: block; font-size: 13px; padding: 12px; background: var(--tile); border-radius: var(--r-sm); word-break: break-all; user-select: all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Bottom tab bar: translucent, line icons, active tint */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
nav button { flex: 1; max-width: 120px; padding: 6px 0 4px; font-size: 10.5px; font-weight: 550; color: var(--faint); display: flex; flex-direction: column; align-items: center; gap: 3px; }
nav .ni { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 99px; transition: background .2s; }
nav .ni svg { width: 22px; height: 22px; }
nav button.on { color: var(--text); font-weight: 650; }
nav button.on .ni { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { nav button.on .ni { color: var(--accent); } }

.fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 6;
  width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--hero-1), var(--hero-2)); color: #fff;
  box-shadow: 0 10px 24px -6px rgba(5, 150, 105, .55); transition: transform .1s;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 550;
  max-width: 90vw; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- Özet ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 26px; padding: 22px 20px 18px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .18), transparent 55%),
    linear-gradient(150deg, var(--hero-1) 0%, var(--hero-2) 55%, var(--hero-3) 100%);
  box-shadow: 0 16px 34px -14px rgba(6, 95, 70, .6);
}
.hero small { color: rgba(255, 255, 255, .78); font-weight: 550; }
.hero-amt { font-size: 38px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; margin: 4px 0 16px; }
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-pill {
  display: flex; align-items: center; gap: 10px; text-align: left; color: #fff; padding: 10px 12px; border-radius: 16px;
  background: rgba(255, 255, 255, .12); border: 1.5px solid transparent; transition: background .15s;
}
.hero-pill.sel { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .35); }
.hero-pill i { flex: 0 0 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-style: normal; background: rgba(255, 255, 255, .2); }
.hero-pill i svg { width: 16px; height: 16px; }
.hero-pill span { display: block; min-width: 0; }
.hero-pill small { display: block; font-size: 12px; }
.hero-pill b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.catrow { margin: 4px 0; }
button.catrow { display: block; width: 100%; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); }
button.catrow:last-child { border-bottom: 0; }
.cattop { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 15px; }
.cattop > span:first-child { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.bar { height: 6px; background: var(--tile); border-radius: 99px; overflow: hidden; margin: 8px 0 2px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--faint); }
.bar.ok i, .bar.inc i { background: var(--accent); }
.bar.warn i { background: var(--warn); } .bar.over i { background: var(--neg); }
.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.line:last-child { border-bottom: 0; }

/* Legacy card grid (still used by some screens) */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); text-align: left; }
.card small { color: var(--muted); display: block; }
.card b { font-size: 20px; }
.card.wide { grid-column: span 2; }
.card.wide b { font-size: 28px; letter-spacing: -.02em; }

/* ---------- lists (transactions, assets, debts, sheets) ---------- */
.list { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; margin: 6px 0 14px; }
.day { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 20px 6px 8px; }
.tx {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: transparent; position: relative;
}
.tx + .tx::before { content: ""; position: absolute; top: 0; left: 66px; right: 0; border-top: 1px solid var(--line); }
.list .tx:active, .sheet .tx:active { background: var(--tile); }
.tx .ico { flex: 0 0 40px; height: 40px; border-radius: 13px; background: var(--tile); display: grid; place-items: center; font-size: 19px; }
.tx .mid { flex: 1; min-width: 0; }
.tx .mid b, .tx .mid small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .mid b { font-weight: 600; font-size: 15px; }
.tx .mid small { color: var(--muted); margin-top: 1px; }
.tx > span:last-child { font-weight: 650; white-space: nowrap; font-size: 15px; }
.tx .r2 { text-align: right; white-space: nowrap; }
.tx .r2 b, .tx .r2 small { display: block; }
.sheet .tx { padding-left: 4px; padding-right: 4px; }
.sheet .tx + .tx::before { left: 4px; }
.debt-list .tx { padding-left: 0; padding-right: 0; }
.debt-list .tx + .tx::before { left: 52px; }
.debt-list details summary { cursor: pointer; padding: 10px 0; font-size: 14px; }
.netline { margin-top: 6px; }

.goal { background: var(--card); border-radius: var(--r-lg); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.goal .cattop b { font-size: 16px; }
.goal .row { margin-top: 8px; }

/* ---------- sheets ---------- */
.overlay {
  position: fixed; inset: auto 0; top: var(--vvtop, 0px); height: var(--vvh, 100%); z-index: 10;
  background: rgba(8, 10, 14, .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px; max-height: calc(var(--vvh, 100vh) * 0.92); overflow-y: auto;
  overscroll-behavior: contain; border-radius: 28px 28px 0 0; padding: 8px 20px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
.grip-area { position: sticky; top: -8px; z-index: 2; margin: -8px -20px 6px; padding: 10px 0 12px; background: var(--card); touch-action: none; cursor: grab; }
.grip { width: 40px; height: 5px; border-radius: 4px; background: var(--line); margin: 0 auto; }
.sheet h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 14px; }
/* Save / delete stay visible at the bottom while the sheet content scrolls. */
.sheet form > .row:last-child, .sheet .sticky-actions {
  position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); z-index: 1;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  margin: 14px -20px calc(-18px - env(safe-area-inset-bottom));
  padding: 4px 20px calc(14px + env(safe-area-inset-bottom));
}
.amount {
  font-size: 40px; font-weight: 750; letter-spacing: -.03em; text-align: center;
  border: 0; background: transparent; margin: 12px 0 4px; padding: 10px;
}
.amount:focus { background: transparent; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.receipt-row { margin-bottom: 10px; }
.receipt-row .sm { margin-top: 0; }
.scan-status { font-size: 14px; margin: 6px 0 10px; padding: 10px 12px; background: var(--tile); border-radius: var(--r-sm); }
.scan-status:has(.scan-cancel) { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scan-status:has(.scan-cancel)[hidden] { display: none; }
.scan-status > span { flex: 1; min-width: 0; }
.scan-cancel { margin: 0; flex: none; width: auto; }
.det { margin: 12px 0; background: var(--tile); border-radius: var(--r-md); padding: 10px 14px; }
.det summary { cursor: pointer; font-weight: 650; padding: 4px 0; }
.det .line span { text-align: right; max-width: 65%; overflow-wrap: anywhere; }
.items { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0; }
.items td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.items .q { color: var(--muted); white-space: nowrap; padding: 6px 8px; }
.items .r { text-align: right; white-space: nowrap; }
.items .sum td { font-weight: 650; border-bottom: 0; }
.sthead { background: var(--tile); border-radius: var(--r-md); padding: 12px 14px; margin: 10px 0; display: grid; gap: 4px; }
.receipt-img { display: block; width: 100%; border-radius: var(--r-md); background: #fff; }
.btnlink { display: block; text-align: center; text-decoration: none; }
.imp { border-bottom: 1px solid var(--line); padding: 10px 0; }
.imp.off { opacity: .5; }
.imp-top { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--text); }
.imp-top input { width: 22px; height: 22px; flex: 0 0 22px; accent-color: var(--accent); }
.imp-top .mid { flex: 1; min-width: 0; }
.imp-top .mid b, .imp-top .mid small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-top > span:last-child { font-weight: 650; white-space: nowrap; }
.imp select { margin-top: 8px; padding: 8px 10px; font-size: 16px; }
.wipe-list { margin: 4px 0 8px; padding-left: 20px; font-size: 14px; }
.wipe-list li { margin: 4px 0; }

/* ---------- charts ---------- */
.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut { flex: 0 0 140px; height: 140px; }
.donut-btn { flex: 0 0 140px; padding: 0; border-radius: 50%; }
.donut circle { fill: none; stroke-width: 18; transition: stroke-width .15s; cursor: pointer; }
.donut circle.on { stroke-width: 24; }
.donut text { fill: var(--text); text-anchor: middle; }
.donut .c1 { font-size: 8.5px; fill: var(--muted); font-weight: 550; }
.donut .c2 { font-size: 14px; font-weight: 750; letter-spacing: -.02em; }
.donut .c3 { font-size: 8px; fill: var(--accent); font-weight: 650; }
.legend-list { flex: 1; min-width: 0; display: grid; gap: 2px; }
.legend-list button { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; text-align: left; padding: 6px 6px; border-radius: 10px; font-size: 13.5px; }
.legend-list button.on, .legend-list button:active { background: var(--tile); }
.legend-list .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list .pc { color: var(--muted); font-weight: 550; }

.pf-head { padding: 4px 4px 8px; }
.pf-value { font-size: 36px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; margin: 2px 0 4px; }
.live { color: var(--pos); font-size: 11px; font-weight: 650; }
.chart-wrap { margin: 6px -16px 0; }
.chart { display: block; width: 100%; height: 190px; touch-action: none; }
.chart path { vector-effect: non-scaling-stroke; fill: none; }
.chart .val { stroke-width: 2.5; stroke: var(--pos); stroke-linejoin: round; }
.chart.down .val { stroke: var(--neg); }
.chart .area { fill: var(--pos); opacity: .1; }
.chart.down .area { fill: var(--neg); }
.chart .cost { stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .cursor { stroke: var(--text); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .4; }
.ranges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: space-between; margin: 10px 0 6px; background: var(--card); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); }
.ranges button { flex: 1; padding: 7px 0; border-radius: 10px; font-size: 13px; color: var(--muted); font-weight: 650; }
.ranges button.on { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .ranges button.on { color: var(--accent); } }
.legend { display: block; text-align: center; font-size: 12px; margin-bottom: 4px; }
.lg-val, .lg-cost { display: inline-block; width: 14px; height: 0; border-top: 2.5px solid var(--pos); vertical-align: middle; margin: 0 3px 0 8px; }
.lg-cost { border-top: 1.5px dashed var(--faint); }

/* ---------- misc ---------- */
.auth { max-width: 400px; margin: 0 auto; padding: calc(56px + env(safe-area-inset-top)) 24px; text-align: center; }
.auth .logo {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; font-size: 38px;
  background: linear-gradient(150deg, var(--hero-1), var(--hero-3)); box-shadow: 0 14px 30px -12px rgba(6, 95, 70, .7);
}
.auth h1 { font-size: 28px; }
.auth form { text-align: left; margin-top: 26px; }
.auth input { margin-bottom: 10px; }
.auth h3 { text-align: left; }

/* Pull-to-refresh indicator (app.js). Sits above the top edge until pulled into view. */
.ptr {
  position: fixed; z-index: 30; left: 50%; top: calc(env(safe-area-inset-top) - 28px); width: 38px; height: 38px; margin-left: -19px;
  border-radius: 50%; background: var(--card); color: var(--accent); box-shadow: var(--shadow-lg);
  display: grid; place-items: center; font-size: 20px; font-weight: 700; opacity: 0; pointer-events: none;
  transition: transform .2s ease-out, opacity .2s;
}
.ptr.spin { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { from { rotate: 0deg; } to { rotate: 360deg; } }
/* Segmented controls that sit directly on the page background need their own track colour. */
.kind-seg { background: color-mix(in srgb, var(--text) 7%, transparent); }
.donut, .donut-btn { flex-basis: 128px; }
.donut { height: 128px; }

/* ==========================================================================
   Motion. Enter animations run only while #app has .enter (set by playEnter in app.js on a
   screen change), so live refreshes from the other phone don't replay them.
   ========================================================================== */
:root { --ease-out: cubic-bezier(.16, 1, .3, 1); --ease-in: cubic-bezier(.4, 0, 1, 1); }

/* Screen transitions: slide in the direction of travel, then stagger the blocks. */
#app.enter.from-right main { animation: in-right .42s var(--ease-out) both; }
#app.enter.from-left main { animation: in-left .42s var(--ease-out) both; }
#app.enter.fade-in main { animation: fade .5s ease-out both; }
#app.enter main > * { animation: rise .5s var(--ease-out) both; }
#app.enter main > *:nth-child(2) { animation-delay: .04s; }
#app.enter main > *:nth-child(3) { animation-delay: .08s; }
#app.enter main > *:nth-child(4) { animation-delay: .12s; }
#app.enter main > *:nth-child(5) { animation-delay: .16s; }
#app.enter main > *:nth-child(6) { animation-delay: .2s; }
#app.enter main > *:nth-child(7) { animation-delay: .24s; }
#app.enter main > *:nth-child(n+8) { animation-delay: .28s; }
#app.enter header h1 { animation: rise .45s var(--ease-out) both; }
#app.enter nav button.on .ni { animation: pop .4s var(--ease-out); }
@keyframes in-right { from { transform: translateX(28px); opacity: 0; } }
@keyframes in-left { from { transform: translateX(-28px); opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.08); } }

/* Charts grow in. */
#app.enter .bar i { animation: grow-x .8s var(--ease-out) both; animation-delay: .15s; transform-origin: left center; }
@keyframes grow-x { from { transform: scaleX(0); } }
#app.enter .donut circle { animation: donut-in .9s var(--ease-out) both; }
#app.enter .donut circle:nth-child(2) { animation-delay: .06s; }
#app.enter .donut circle:nth-child(3) { animation-delay: .12s; }
#app.enter .donut circle:nth-child(4) { animation-delay: .18s; }
#app.enter .donut circle:nth-child(5) { animation-delay: .24s; }
#app.enter .donut circle:nth-child(6) { animation-delay: .3s; }
@keyframes donut-in { from { stroke-dasharray: 0 400; } }
#app.enter .chart .val { stroke-dasharray: 1; animation: draw-line 1.1s var(--ease-out) both; animation-delay: .1s; }
#app.enter .chart .area, #app.enter .chart .cost { animation: fade .8s ease-out both; animation-delay: .5s; }
@keyframes draw-line { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.hero { animation: none; }
#app.enter .hero { animation: hero-in .6s var(--ease-out) both; }
@keyframes hero-in { from { transform: translateY(10px) scale(.98); opacity: 0; } }

/* Touch feedback. */
.tx, button.catrow, .card, .hero-pill, .legend-list button, .monthnav button, nav button, .chips span, .ranges button {
  transition: transform .14s ease-out, background-color .15s, border-color .15s, color .15s;
}
.tx:active, button.catrow:active, .card:active, .hero-pill:active, .legend-list button:active { transform: scale(.975); }
nav button:active .ni { transform: scale(.88); }
nav .ni { transition: background .25s, transform .14s ease-out; }
.chips label:active span { transform: scale(.94); }
.fab svg { transition: transform .25s var(--ease-out); }
.fab:active svg { transform: rotate(90deg); }

/* Sheets: smooth deceleration in, quick slide out. */
.sheet { animation: up .45s var(--ease-out); }
.overlay.closing { animation: fade-out .23s ease-in forwards; pointer-events: none; }
.overlay.closing .sheet { transform: translateY(100%) !important; transition: transform .23s var(--ease-in) !important; }
@keyframes fade-out { to { opacity: 0; } }
.sheet .det[open] > *:not(summary) { animation: rise .3s var(--ease-out) both; }

/* Toasts slide away. */
.toast.out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, -10px); } }

/* Respect the phone's "reduce motion" setting. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- assistant ---------- */
.fab-ai {
  bottom: calc(156px + env(safe-area-inset-bottom)); right: 23px; width: 48px; height: 48px; border-radius: 16px;
  background: var(--card); color: var(--accent-strong); box-shadow: var(--shadow-lg);
}
@media (prefers-color-scheme: dark) { .fab-ai { color: var(--accent); } }
.fab-ai svg { width: 22px; height: 22px; }
.fab.fab-ai:active svg { transform: none; }
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--tile); border-bottom-left-radius: 6px; }
.msg.err { align-self: stretch; max-width: none; background: color-mix(in srgb, var(--neg) 10%, transparent); color: var(--neg); font-size: 14px; }
.ideas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.idea { padding: 9px 13px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; font-weight: 550; text-align: left; }
@media (prefers-color-scheme: dark) { .idea { color: var(--accent); } }
.proposal { margin-top: 10px; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.proposal.dismissed { opacity: .6; }
.pc-list { margin: 8px 0 2px; max-height: 260px; overflow-y: auto; }
.pc-row { padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.pc-row small { color: var(--muted); }
.pc-row.del { color: var(--neg); }
.pc-row.add { color: var(--accent-strong); }
.pc-row.gone { color: var(--faint); font-style: italic; }
.proposal .row .sm { margin-top: 6px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; }
.chat-form textarea { resize: none; min-height: 48px; max-height: 140px; line-height: 1.35; margin-top: 10px; }
.chat-form .send { width: 48px; height: 48px; flex: none; padding: 0; display: grid; place-items: center; border-radius: 14px; }
.chat-form .send svg { width: 22px; height: 22px; }

/* ---------- monthly money picture ---------- */
.hint { font-size: 13px; margin: 0 0 10px; }
.due { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.due-main { flex: 1; min-width: 0; text-align: left; display: block; }
.due-main > span { display: block; font-weight: 550; overflow-wrap: anywhere; }
.due-main small { display: block; font-size: 12px; margin-top: 2px; }
.due-main small.over { color: var(--neg); font-weight: 600; }
.due-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-variant-numeric: tabular-nums; }
.due-side .sm { margin: 0; width: auto; padding: 7px 12px; font-size: 13px; }
.line.total { font-weight: 650; }

.alertbox { margin: 12px 0; padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; font-weight: 550; color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, transparent); }
.hero-row > * { flex: 1 1 0; min-width: 0; }
.hero-pill { padding-right: 10px; }
.hero-pill b { font-size: 14px; }

.spend { margin: 12px 0; padding: 14px 16px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.spend summary { font-weight: 650; cursor: pointer; }

/* ==========================================================================
   Warm surfaces, pine hero with a lime progress accent, floating tab bar.
   ========================================================================== */
h1 { font-weight: 800; letter-spacing: -.035em; }
h3 { margin: 24px 6px 8px; }
section, .list, .goal, .spend, .tile, .ov, .card { border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.hint.soft { margin: 0 6px 12px; }

/* Hero: slow drifting light behind the figures. */
.hero { padding: 20px; border-radius: 28px; isolation: isolate; box-shadow: 0 22px 40px -22px rgba(10, 36, 28, .85); }
.hero > * { position: relative; z-index: 1; }
.hero::before, .hero::after { content: ""; position: absolute; z-index: 0; border-radius: 50%; filter: blur(46px); pointer-events: none; }
.hero::before { width: 240px; height: 240px; top: -110px; right: -70px; background: rgba(201, 242, 107, .3); animation: drift-a 13s ease-in-out infinite alternate; }
.hero::after { width: 200px; height: 200px; bottom: -120px; left: -60px; background: rgba(52, 211, 153, .3); animation: drift-b 17s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate(-70px, 50px) scale(1.25); } }
@keyframes drift-b { to { transform: translate(90px, -40px) scale(.85); } }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.hero-label { display: block; }
.hero-amt { font-size: 42px; font-weight: 800; letter-spacing: -.045em; margin: 2px 0 14px; }
.hero .pos { color: var(--glow); } .hero .neg { color: #ffb4a8; }
.hero .muted { color: rgba(255, 255, 255, .66); }
.hero .live { color: var(--glow); }
.hero.pf { font-size: 15px; }
.hero .pf-value, .hero.pf .pf-value { font-size: 40px; font-weight: 800; letter-spacing: -.045em; }

.chip { flex: none; padding: 5px 10px; border-radius: 99px; font-size: 12px; font-weight: 650; color: #fff; background: rgba(255, 255, 255, .15); }
.chip.urgent { background: #ff8a73; color: #3a0f06; animation: nudge 2.4s ease-in-out infinite; }
.chip.ok { background: var(--glow); color: #1f3208; }
.chip.ok.solid { background: var(--accent-soft); color: var(--accent-strong); }
@keyframes nudge { 50% { transform: scale(1.06); } }

.meter { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.meter i { position: relative; display: block; height: 100%; min-width: 10px; border-radius: 99px; background: var(--glow); overflow: hidden; transform-origin: left center; }
.meter i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .75) 50%, transparent 70%); animation: sheen 3.2s ease-in-out infinite; }
@keyframes sheen { from { transform: translateX(-100%); } 55%, to { transform: translateX(100%); } }
.meter-cap { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 13px; font-weight: 550; color: rgba(255, 255, 255, .82); font-variant-numeric: tabular-nums; }
.hero-btn { display: block; width: 100%; margin-top: 16px; padding: 14px; border-radius: 16px; font-weight: 700; font-size: 15px; color: #1f3208; background: var(--glow); transition: transform .14s var(--ease-out), filter .15s; }
.hero-btn:active { transform: scale(.97); filter: brightness(.94); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.tile { position: relative; background: var(--card); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.tile b { display: block; font-size: 19px; font-weight: 750; letter-spacing: -.025em; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.wide { grid-column: span 2; display: flex; align-items: center; gap: 10px; }
.tile.wide small { flex: 1; }
.tile.wide b { margin: 0; font-size: 16px; }

.empty-card { text-align: center; padding: 40px 24px; margin: 14px 0; border-radius: 28px; border: 1.5px dashed var(--line); }
.empty-ico { font-size: 40px; margin-bottom: 10px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* Month overview */
.ov { background: var(--card); border-radius: 26px; padding: 18px; margin: 10px 0 12px; box-shadow: var(--shadow); }
.ov small { display: block; }
.ov-amt { font-size: 36px; font-weight: 800; letter-spacing: -.04em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mbars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-top: 16px; }
.mbar { padding: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.mbar-track { display: flex; align-items: flex-end; width: 100%; height: 84px; border-radius: 8px; }
.mbar i { display: block; width: 100%; border-radius: 7px 7px 3px 3px; background: color-mix(in srgb, var(--accent) 24%, var(--tile)); transition: background .2s; transform-origin: bottom; }
.mbar.on i { background: var(--accent); }
.mbar small { font-size: 9.5px; color: var(--faint); font-weight: 600; }
.mbar.on small { color: var(--text); font-weight: 750; }
.strip { display: flex; gap: 2px; height: 10px; margin-top: 16px; border-radius: 99px; overflow: hidden; }
.strip i { min-width: 3px; transform-origin: left; }
.strip-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.strip-legend span { display: inline-flex; align-items: center; gap: 5px; }
.strip-legend i { width: 8px; height: 8px; border-radius: 3px; }
.strip-legend b { color: var(--text); font-variant-numeric: tabular-nums; }

.spend summary { list-style: none; display: flex; justify-content: space-between; align-items: center; }
.spend summary::-webkit-details-marker { display: none; }
.spend summary::after { content: "›"; font-size: 20px; line-height: 1; color: var(--muted); transition: transform .3s var(--ease-out); }
.spend[open] summary::after { transform: rotate(90deg); }
.spend[open] > *:not(summary) { animation: rise .4s var(--ease-out) both; }

/* Goals */
.goal-top { display: flex; align-items: center; gap: 14px; }
.ring { position: relative; flex: 0 0 64px; height: 64px; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--tile); }
.ring-val { stroke: var(--accent); stroke-linecap: round; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; }
.goal-info { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.goal-info b { display: block; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-info > small { display: block; margin-top: 2px; }
.goal-info > div { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-info > div small { font-size: 12.5px; }
.goal-pct { font-size: 20px; font-weight: 800; letter-spacing: -.03em; color: var(--accent-strong); }
.goal .row { margin-top: 12px; }
.goal .row .sm { margin-top: 0; }
.goal.done { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }

/* Assets */
.chart-card { padding: 14px 12px 10px; overflow: hidden; }
.chart-wrap { position: relative; margin: 0; }
.chart .area, .chart.down .area { opacity: 1; }
.chart.up { color: var(--pos); } .chart.down { color: var(--neg); }
.chart-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; background: var(--pos); pointer-events: none; }
.chart-dot.down { background: var(--neg); }
.chart-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.9s ease-out infinite; }
@keyframes ping { to { transform: scale(3.4); opacity: 0; } }
.ranges { background: var(--tile); box-shadow: none; }
.ranges button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(60, 50, 20, .14); }

/* Floating tab bar with a gliding highlight. */
nav {
  left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; padding: 6px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 26px; box-shadow: 0 14px 34px -14px rgba(30, 30, 10, .4);
}
nav button { position: relative; z-index: 1; flex: 1; max-width: none; padding: 7px 0 5px; }
nav .ni { width: auto; height: 26px; }
nav button.on .ni { background: none; }
.nav-ind { position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 5); border-radius: 20px; background: var(--accent-soft); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform .42s var(--ease-out); }
.fab { background: var(--hero-2); box-shadow: 0 14px 26px -10px rgba(10, 36, 28, .8); }
.fab-ai svg { animation: twinkle 3.6s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: scale(1.14) rotate(10deg); } }

/* Enter choreography. */
#app.enter .fab { animation: fab-in .55s var(--ease-out) .18s both; }
@keyframes fab-in { from { transform: scale(.4); opacity: 0; } }
#app.enter .meter i { animation: grow-x 1.1s var(--ease-out) .2s both; }
#app.enter .hero-btn, #app.enter .meter-cap { animation: rise .5s var(--ease-out) .3s both; }
#app.enter .mbar i { animation: grow-y .7s var(--ease-out) both; animation-delay: calc(var(--i) * 28ms + .1s); }
@keyframes grow-y { from { transform: scaleY(0); } }
#app.enter .strip i { animation: grow-x .8s var(--ease-out) .35s both; }
#app.enter .ring-val { animation: ring-in 1.1s var(--ease-out) .15s both; }
@keyframes ring-in { from { stroke-dasharray: 0 100; } }
#app.enter .list .tx { animation: rise .42s var(--ease-out) both; }
#app.enter .list .tx:nth-child(2) { animation-delay: .05s; }
#app.enter .list .tx:nth-child(3) { animation-delay: .1s; }
#app.enter .list .tx:nth-child(n+4) { animation-delay: .14s; }
.tile, .goal { transition: transform .14s ease-out; }

.confetti { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -14px; width: 8px; height: 13px; border-radius: 2px; animation: confetti-fall 1.9s cubic-bezier(.25, .6, .5, 1) both; }
@keyframes confetti-fall { to { transform: translate(var(--x), 105vh) rotate(var(--r)); opacity: .7; } }

.boot { display: grid; place-items: center; min-height: 80vh; }
.boot i { width: 44px; height: 44px; border-radius: 16px; background: var(--hero-2); animation: boot 1s ease-in-out infinite alternate; }
@keyframes boot { to { transform: scale(.7) rotate(90deg); border-radius: 50%; opacity: .6; } }

/* Keep the reduced-motion promise for the loops above. */
@media (prefers-reduced-motion: reduce) {
  .hero::before, .hero::after, .meter i::after, .chip.urgent, .chart-dot::after, .fab-ai svg, .empty-ico { animation: none !important; }
}

.chart .val { stroke-width: 2; }
.hilo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.hilo > div { padding: 10px 12px; border-radius: 14px; background: var(--tile); min-width: 0; }
.hilo small { display: block; font-size: 11.5px; color: var(--muted); }
.hilo b { display: block; font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

.fchips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 10px; padding: 2px 16px; scrollbar-width: none; }
.fchips::-webkit-scrollbar { display: none; }
.fchips button { flex: none; padding: 8px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 650; color: var(--muted); background: var(--card); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); transition: background .2s, color .2s, transform .14s ease-out; }
.fchips button:active { transform: scale(.94); }
.fchips button.on { background: var(--hero-2); border-color: transparent; color: #fff; }
.fchips.sub button { padding: 6px 12px; font-size: 12.5px; font-weight: 600; background: transparent; }
.fchips.sub button.on { background: var(--accent-soft); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .fchips.sub button.on { color: var(--accent); } }
