/* Budgetty — phone-first. Tokens first, then layout, components, charts. */
:root {
  color-scheme: light;
  --bg: #f4f5f0; --card: #ffffff; --card-2: #f8f9f5; --ink: #16211d; --ink-2: #44524b; --muted: #66746d;
  --line: #e3e8e0; --track: #e9ede6;
  --brand: #174d3b; --brand-2: #1f6a50; --on-brand: #ffffff; --on-brand-2: #cfe5da; --tint: #e6f1eb;
  --good: #0b6b3a; --good-bg: #e3f3e9; --bad: #b3261e; --bad-bg: #fbe9e6; --warn: #8a5a0b; --warn-bg: #fdf2d8;
  --info-bg: #eaf1fb; --info: #1c5cab;
  --fill-ok: #1f7a55; --fill-warn: #e2a30b; --fill-over: #d03b3b; --fill-none: #a9b5ad;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s-muted: #9aa69f; --grid: #e6eae3;
  --shadow: 0 1px 2px rgba(22, 33, 29, .05), 0 6px 20px rgba(22, 33, 29, .05);
  --radius: 18px; --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101412; --card: #1a1f1c; --card-2: #202622; --ink: #eef1ec; --ink-2: #c9d1cb; --muted: #9aa69f;
    --line: #2b332e; --track: #2b332e;
    --brand: #1b5a45; --brand-2: #23745a; --on-brand: #ffffff; --on-brand-2: #c5e0d4; --tint: #1f2f28;
    --good: #6fd09a; --good-bg: #173326; --bad: #ff8f85; --bad-bg: #3a1d1a; --warn: #f0c060; --warn-bg: #362b12;
    --info-bg: #17263a; --info: #8dbcf5;
    --fill-ok: #2f9a6f; --fill-warn: #e2a30b; --fill-over: #e05a55; --fill-none: #5b665f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s-muted: #6f7b74; --grid: #29302c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.num, .amt { font-variant-numeric: tabular-nums; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 8px; }

/* ---------- shell ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 0 16px calc(var(--tabs-h) + var(--safe-b) + 28px); }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: calc(var(--safe-t) + 8px) 0 8px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top h1 { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-content { display: flex; flex: 1; min-width: 0; gap: 8px; align-items: center; }
#undo-last { flex: none; background: var(--tint); }
#undo-last:active { background: var(--track); }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 14px; color: var(--ink-2); }
.icon-btn:active { background: var(--track); }
.icon-btn:disabled { opacity: .3; }
.month-nav { display: flex; align-items: center; flex: 1; min-width: 0; margin-left: -10px; }
.month-nav h1 { flex: 0 1 auto; padding: 0 2px; }
.month-nav .today-chip { margin-left: 6px; }
.month-compact { display: none; }
@media (max-width: 500px) {
  .top:has(#undo-last:not([hidden])) .month-nav h1 { font-size: 1rem; }
  .top:has(#undo-last:not([hidden])) .month-nav :is(.month-full, .today-chip > span:first-child) { display: none; }
  .top:has(#undo-last:not([hidden])) .month-compact { display: inline; }
  .top:has(#undo-last:not([hidden])) .month-nav .today-chip {
    display: grid; place-items: center; width: 36px; height: 44px; margin: 0; padding: 0; flex: none;
  }
  .month-compact svg.ic { display: block; width: 18px; height: 18px; }
}
@media (max-width: 350px) {
  .top:has(#undo-last:not([hidden])) .month-nav:has(.today-chip) {
    display: grid; grid-template-columns: 44px minmax(0, auto) 44px; justify-content: start;
  }
  .top:has(#undo-last:not([hidden])) .month-nav .today-chip {
    grid-column: 2; justify-self: center; width: auto; height: auto; padding: 3px 9px;
  }
  .top:has(#undo-last:not([hidden])) .month-nav .today-chip > span:first-child { display: inline; }
  .top:has(#undo-last:not([hidden])) .month-nav .today-chip .month-compact { display: none; }
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--card) 92%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; font-weight: 650; color: var(--muted); }
.tab[aria-current="page"] { color: var(--brand-2); }
.tab-add { display: grid; place-items: center; }
.tab-add span { width: 52px; height: 52px; border-radius: 18px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(23, 77, 59, .35); transform: translateY(-8px); }
.tab-add:active span { transform: translateY(-8px) scale(.95); }
.tab-add svg.ic { width: 26px; height: 26px; stroke-width: 2.4; }
.brand { display: none; }

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 220px 1fr; }
  .tabs { position: sticky; top: 0; height: 100vh; grid-template-columns: 1fr; align-content: start; gap: 4px; padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line); background: var(--card); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; padding: 4px 10px 18px; letter-spacing: -.02em; }
  .brand img { width: 30px; height: 30px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: .95rem; padding: 11px 12px; border-radius: 12px; }
  .tab[aria-current="page"] { background: var(--tint); }
  .tab-add { order: -1; margin-bottom: 10px; }
  .tab-add span { transform: none; width: 100%; height: 46px; border-radius: 14px; display: flex; gap: 8px; font-weight: 700; font-size: .95rem; box-shadow: none; }
  .tab-add span::after { content: "Add"; }
  .tab-add:active span { transform: scale(.98); }
  .page { max-width: 1080px; width: 100%; padding: 0 32px 48px; }
  .cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }
}

/* ---------- building blocks ---------- */
.stack > * + * { margin-top: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 2px 10px; }
.section-head h2 { font-size: 1.05rem; font-weight: 720; letter-spacing: -.01em; }
.section-head .link { font-size: .88rem; font-weight: 650; color: var(--brand-2); padding: 6px 0 6px 12px; }
.section-head .links { display: flex; gap: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.note { font-size: .84rem; color: var(--muted); margin: 8px 2px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: .95rem; }
.empty b { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 680; background: var(--track); color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.ghost { background: transparent; color: var(--brand-2); }
.btn.small { min-height: 36px; padding: 0 13px; border-radius: 11px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 13px; border-radius: 99px; font-size: .88rem; font-weight: 620; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.chip[aria-pressed="true"], .chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px; margin: 0 -16px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.today-chip { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--tint); color: var(--brand-2); white-space: nowrap; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--track); border-radius: 13px; padding: 3px; }
.seg button { min-height: 38px; border-radius: 10px; font-weight: 650; font-size: .9rem; color: var(--muted); padding: 0 8px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.pill { display: inline-block; font-size: .7rem; font-weight: 720; border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.due { background: var(--warn-bg); color: var(--warn); }
.pill.off { background: var(--track); color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .muted { color: var(--muted); }

/* ---------- hero ---------- */
.hero { background: linear-gradient(150deg, var(--brand-2), var(--brand) 60%); color: var(--on-brand); border-radius: 24px; padding: 20px 20px 18px; box-shadow: 0 10px 28px rgba(23, 77, 59, .28); display: block; width: 100%; text-align: left; }
.hero.over { background: linear-gradient(150deg, #a8452f, #7c2a1c 65%); box-shadow: 0 10px 28px rgba(124, 42, 28, .28); }
.hero-label { font-size: .86rem; font-weight: 650; color: var(--on-brand-2); display: flex; justify-content: space-between; gap: 10px; }
.hero.over .hero-label, .hero.over .hero-sub, .hero.over .meter-legend { color: #f6d6cd; }
.hero-big { font-size: clamp(2.3rem, 11vw, 3.1rem); font-weight: 780; letter-spacing: -.035em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero-big small { font-size: .5em; font-weight: 700; opacity: .85; letter-spacing: -.01em; }
.hero-sub { font-size: .92rem; color: var(--on-brand-2); margin-top: 4px; }
.meter { position: relative; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .22); margin-top: 16px; }
.meter-fill { height: 100%; border-radius: 99px; background: #fff; min-width: 4px; }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px rgba(23, 77, 59, .55); }
.meter-legend { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--on-brand-2); margin-top: 7px; }
.hero-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.hero-fact { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 8px 10px; min-width: 0; text-align: left; }
.hero-fact span { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--on-brand-2); }
.hero-fact b { display: block; margin-top: 2px; font-size: .98rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-fact small { display: block; margin-top: 1px; font-size: .72rem; font-weight: 600; color: var(--on-brand-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-fact.open { background: rgba(255, 224, 138, .22); }
.hero.over .hero-fact span, .hero.over .hero-fact small { color: #f6d6cd; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 11px 12px; text-align: left; min-width: 0; box-shadow: var(--shadow); display: block; }
.tile-label { font-size: .76rem; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 1.12rem; font-weight: 740; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.tile-sub { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 520px) { .tiles.four { grid-template-columns: repeat(4, 1fr); } }
.tiles.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 520px) { .tiles.four { grid-template-columns: repeat(4, 1fr); } }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--warn-bg); color: var(--warn); font-size: .92rem; font-weight: 600; width: 100%; text-align: left; }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner span { flex: 1; }

/* ---------- year card ---------- */
.small { font-size: .82rem; }
.row-ic.bad { background: var(--bad-bg); color: var(--bad); }
.warn-text { color: var(--warn); font-weight: 650; }
.bar-sub .good, .bar-sub .bad { font-weight: 650; }
.year { overflow: hidden; }
.year > * + * { border-top: 1px solid var(--line); }
.verdict { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.verdict b { font-size: 1.05rem; letter-spacing: -.01em; }
.verdict p { font-size: .88rem; color: var(--ink-2); margin-top: 2px; }
.verdict-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--info-bg); color: var(--info); }
.verdict-ic svg.ic { width: 19px; height: 19px; }
.verdict.good { background: var(--good-bg); } .verdict.good .verdict-ic { background: var(--card); color: var(--good); } .verdict.good b { color: var(--good); }
.verdict.warn { background: var(--warn-bg); } .verdict.warn .verdict-ic { background: var(--card); color: var(--warn); } .verdict.warn b { color: var(--warn); }
.verdict.bad { background: var(--bad-bg); } .verdict.bad .verdict-ic { background: var(--card); color: var(--bad); } .verdict.bad b { color: var(--bad); }
.year-income { display: flex; align-items: baseline; gap: 8px; padding: 10px 16px; font-size: .9rem; color: var(--muted); }
.year-income b { color: var(--ink); font-variant-numeric: tabular-nums; }
.year-income small { margin-left: auto; font-size: .76rem; }
.year > .year-income + .plan-line { border-top: 0; }
.year > .plan-line + .plan-line { border-top: 0; padding-top: 2px; }
.plan-line { display: block; padding: 10px 16px 12px; }
.plan-line .bar-name { display: flex; align-items: center; gap: 6px; }
.plan-line .bar-name svg.ic { width: 16px; height: 16px; color: var(--s1); }
.year-months { padding: 12px 16px; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-bottom: 8px; }
.mo { height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: .72rem; font-weight: 750; background: var(--track); color: var(--muted); }
.mo.ok { background: var(--good-bg); color: var(--good); }
.mo.over { background: var(--bad-bg); color: var(--bad); }
.mo.now { background: var(--tint); color: var(--brand-2); box-shadow: inset 0 0 0 1.5px var(--brand-2); }
.mo.now.over { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.mo.later, .mo.none { opacity: .55; }
.mo.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
button.mo:active { filter: brightness(.95); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin: 0 4px 0 8px; vertical-align: 0; background: var(--fill-none); }
.dot.ok { background: var(--fill-ok); } .dot.over { background: var(--fill-over); }
.dot.current { background: var(--s-muted); } .dot.saving { background: var(--s3); } .dot.investment { background: var(--s1); }
.year-goals > * + * { border-top: 1px solid var(--line); }
.year-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: .8rem; color: var(--muted); width: 100%; text-align: left; background: var(--card-2); }
.year-foot span { flex: 1; }
.year-foot svg.ic { width: 18px; height: 18px; }

.worth { display: block; }
.worth-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.worth-change { font-size: .8rem; font-weight: 650; white-space: nowrap; }
.worth-big { font-size: 1.6rem; font-weight: 760; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.worth-split { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.worth-split .dot { margin-left: 0; }
.worth-split b { color: var(--ink); font-weight: 680; font-variant-numeric: tabular-nums; }

/* ---------- insights cards ---------- */
.finds { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.finds::-webkit-scrollbar { display: none; }
.find { flex: 0 0 78%; max-width: 320px; scroll-snap-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.finds.list { display: grid; overflow: visible; margin: 0; padding: 0; }
.finds.list .find { max-width: none; }
@media (min-width: 620px) { .finds.list { grid-template-columns: 1fr 1fr; } .find { flex-basis: 300px; } }
.find-head { display: flex; align-items: center; gap: 9px; font-weight: 720; font-size: .98rem; letter-spacing: -.01em; }
.find-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--info-bg); color: var(--info); flex: none; }
.find-ic svg.ic { width: 18px; height: 18px; }
.find.good .find-ic { background: var(--good-bg); color: var(--good); }
.find.warn .find-ic { background: var(--warn-bg); color: var(--warn); }
.find.bad .find-ic { background: var(--bad-bg); color: var(--bad); }
.find p { font-size: .88rem; color: var(--ink-2); margin-top: 8px; }

/* ---------- lists ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list > * + * { border-top: 1px solid var(--line); }
.list-head { display: flex; justify-content: space-between; gap: 8px; font-size: .74rem; font-weight: 720; color: var(--muted); padding: 8px 16px; background: var(--card-2); text-transform: uppercase; letter-spacing: .05em; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; width: 100%; text-align: left; min-height: 58px; }
button.row:active, a.row:active { background: var(--card-2); }
.row-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--tint); color: var(--brand-2); font-weight: 750; font-size: .95rem; flex: none; }
.row-ic.in { background: var(--good-bg); color: var(--good); }
.row-ic.other { background: var(--track); color: var(--muted); }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.row-amt small { display: block; font-weight: 500; font-size: .76rem; color: var(--muted); }
.row .chev { color: var(--muted); width: 18px; height: 18px; }
.row.total { background: var(--card-2); }

.bar { padding: 12px 16px; display: block; width: 100%; text-align: left; }
button.bar:active { background: var(--card-2); }
.bar-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.bar-name { font-weight: 640; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 680; }
.bar-amt span { color: var(--muted); font-weight: 450; }
.track { height: 8px; border-radius: 99px; background: var(--track); margin: 7px 0 5px; overflow: hidden; }
.fill { height: 100%; border-radius: 99px; background: var(--fill-ok); }
.fill.warn { background: var(--fill-warn); } .fill.over { background: var(--fill-over); } .fill.none { background: var(--fill-none); }
.fill.s1 { background: var(--s1); }
.bar-sub { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.bar-sub .over { color: var(--bad); font-weight: 650; }
.bar-sub .warn { color: var(--warn); font-weight: 650; }

.rank { display: grid; grid-template-columns: minmax(0, 1fr) 64px auto; gap: 4px 12px; align-items: center; padding: 11px 16px; width: 100%; text-align: left; }
button.rank:active { background: var(--card-2); }
.rank .track { grid-column: 1 / -1; margin: 0; height: 6px; }
.rank .spark { width: 64px; height: 22px; }

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; padding-top: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; font-size: .74rem; color: var(--muted); font-weight: 650; }
.wd i { display: block; width: 100%; max-width: 30px; border-radius: 4px 4px 0 0; background: var(--s1); opacity: .45; min-height: 3px; }
.wd.peak i { opacity: 1; }
.wd b { font-size: .72rem; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 650; }

/* ---------- charts ---------- */
.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--s-muted); stroke-width: 1; }
.chart .guide { fill: var(--ink); opacity: .06; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--ink-2); margin-bottom: 8px; }
.legend i, .tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.dash, .tip i.dash { height: 0; border-top: 2px dashed; border-radius: 0; background: none !important; vertical-align: 3px; }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 10px; font-size: .78rem; line-height: 1.5; white-space: nowrap; z-index: 5; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); font-variant-numeric: tabular-nums; }
.tip b { display: block; font-size: .8rem; }
.tip span { float: right; margin-left: 14px; font-weight: 650; }

.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 9px 12px; text-align: right; white-space: nowrap; border-top: 1px solid var(--line); }
table.data th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; background: var(--card-2); }
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
table.data th:first-child { background: var(--card-2); }
details.fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 660; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; flex: none; }
details.fold[open] > summary::after { transform: rotate(-135deg); }
details.fold > .fold-body { border-top: 1px solid var(--line); }

/* ---------- sheet & forms ---------- */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; background: var(--card); color: var(--ink); border-radius: 24px 24px 0 0; overflow: hidden; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); }
.sheet::backdrop { background: rgba(10, 16, 13, .5); }
.sheet[open] { display: flex; flex-direction: column; animation: rise .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 24px; max-height: 88dvh; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 8px 20px; flex: none; }
.sheet-head h2 { flex: 1; font-size: 1.15rem; font-weight: 740; letter-spacing: -.01em; }
.sheet-body { padding: 4px 20px calc(20px + var(--safe-b)); overflow-y: auto; overscroll-behavior: contain; }
.sheet-body > * + * { margin-top: 14px; }

.field { display: block; }
.field > span { display: block; font-size: .8rem; font-weight: 650; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea, .search input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 13px; border: 1px solid var(--line); background: var(--card-2); font-size: 16px; appearance: none; -webkit-appearance: none;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field input:focus, .field select:focus, .search input:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
.field small { display: block; font-size: .78rem; color: var(--muted); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .94rem; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
.amount-box { text-align: center; padding: 6px 0 2px; }
.amount-box label { display: inline-flex; align-items: baseline; gap: 6px; font-size: 2.6rem; font-weight: 780; letter-spacing: -.03em; }
.amount-box input { width: 5.2ch; min-width: 3ch; max-width: 100%; border: 0; background: none; font-size: 2.6rem; font-weight: 780; letter-spacing: -.03em; text-align: left; padding: 0; outline: none; font-variant-numeric: tabular-nums; }
.amount-box input::placeholder { color: var(--fill-none); }
.form-error { background: var(--bad-bg); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: .9rem; font-weight: 600; }
.search { position: relative; }
.search input { padding-left: 42px; background: var(--card); }
.search svg.ic { position: absolute; left: 13px; top: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 18px); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 620; font-size: .92rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- sign in ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: 100%; max-width: 380px; }
.gate-card > * + * { margin-top: 14px; }
.gate-logo { width: 64px; height: 64px; border-radius: 18px; }
.gate h1 { font-size: 1.7rem; font-weight: 780; letter-spacing: -.03em; }
.gate p { color: var(--muted); }

.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--track) 25%, var(--card) 50%, var(--track) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.fold-body > .bar + .bar, .fold-body > .row + .row { border-top: 1px solid var(--line); }
@media (min-width: 960px) {
  .brand { order: -2; }
  .finds:not(.list) { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; margin: 0; padding: 0; }
  .finds:not(.list) .find { max-width: none; }
}
