:root {
  --bg: #f4f5f2; --card: #ffffff; --ink: #1d2320; --ink2: #56605b; --muted: #8a938e; --line: #e6e8e4;
  --brand: #0f6e56; --brand-soft: #e2f1ec; --series: #2a6fdb;
  --ok: #1f8a4c; --warn: #b26a00; --warn-bg: #fff4e0; --crit: #c0392b; --crit-bg: #fdecea; --info-bg: #eef3fb;
  --radius: 16px; --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111513; --card: #1a201d; --ink: #eef2ef; --ink2: #b8c1bc; --muted: #86908b; --line: #2a322e;
    --brand: #3cc29a; --brand-soft: #173a30; --series: #6ea2f5; --ok: #47c17a; --warn: #f0a63a; --warn-bg: #3a2c12;
    --crit: #ff7a6b; --crit-bg: #3d1d19; --info-bg: #1b2636; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 560px; margin: 0 auto; padding: 0 14px; }
h1 { font-size: 26px; margin: 6px 0; } h2 { font-size: 16px; margin: 0 0 10px; }
button { font: inherit; color: inherit; background: none; border: 0; text-align: left; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; margin-top: 4px; }
textarea { resize: vertical; }
label { display: block; font-size: 14px; color: var(--ink2); margin: 10px 0; }
code { font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); } .small { font-size: 13px; } .neg { color: var(--crit); } .pos { color: var(--ok); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.demo { background: var(--warn-bg); color: var(--warn); font-size: 13px; padding: 8px 12px; border-radius: 10px; margin-top: 10px; text-align: center; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 8px; background: var(--bg); }
.month { font-weight: 700; font-size: 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--card); text-align: center; font-size: 22px; }

.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 10px; }
.label { font-size: 13px; color: var(--ink2); }
.meter { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.meter.thin { height: 8px; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.meter i.warn { background: var(--warn); } .meter i.crit { background: var(--crit); } .meter i.ok { background: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { font-weight: 700; font-size: 17px; }

.alerts { display: grid; gap: 8px; margin: 12px 0; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 14px; background: var(--info-bg); width: 100%; }
.alert.warn { background: var(--warn-bg); } .alert.crit { background: var(--crit-bg); }

.bar-row { display: block; width: 100%; padding: 6px 0; }
.bar-head { display: flex; justify-content: space-between; font-size: 14px; gap: 8px; }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.line:last-child { border-bottom: 0; }
.line.total { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.tag { font-size: 11px; background: var(--brand-soft); color: var(--brand); padding: 1px 6px; border-radius: 6px; margin-left: 4px; white-space: nowrap; }
.tips p { font-size: 14px; margin: 8px 0; }

.chart-wrap { position: relative; }
svg#pace { width: 100%; height: auto; display: block; touch-action: pan-y; }
svg .spend { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; }
svg .proj { stroke: var(--series); stroke-width: 2; stroke-dasharray: 4 4; opacity: .55; }
svg .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
svg .base { stroke: var(--line); stroke-width: 1; }
svg .dot { fill: var(--series); stroke: var(--card); stroke-width: 2; }
svg .cross { stroke: var(--muted); stroke-width: 1; }
svg .axis { fill: var(--muted); font-size: 10px; }
.tip { display: none; position: absolute; top: 0; background: var(--ink); color: var(--card); font-size: 12px; padding: 6px 8px; border-radius: 8px; pointer-events: none; width: 110px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink2); margin-top: 6px; flex-wrap: wrap; }
.sw { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--series); vertical-align: middle; margin-right: 5px; }
.sw.proj { border-top-style: dashed; opacity: .55; } .sw.ref { border-top: 1px dashed var(--muted); }

.day { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 14px 0 4px; }
.tx, .bill { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ic { width: 34px; height: 34px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; flex: none; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { text-align: right; font-weight: 600; white-space: nowrap; font-size: 14px; }
.amt.muted { font-weight: 400; }

.review .rv, .unrec { border-top: 1px solid var(--line); padding: 10px 0; }
.rv-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.rv-row select { flex: 1; min-width: 150px; margin: 0; }
.small-input { font-size: 13px; padding: 6px 10px; margin-top: 6px; }
.chk { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
.chk input { width: auto; margin: 0; }

.pot { padding: 10px 0; border-bottom: 1px solid var(--line); }
.pot-head { display: flex; justify-content: space-between; width: 100%; gap: 10px; font-size: 14px; }
.budget-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0; color: var(--ink); }
.budget-row input { width: 110px; margin: 0; text-align: right; }
.copy { display: flex; align-items: center; gap: 8px; background: var(--bg); padding: 8px 10px; border-radius: 10px; margin-top: 4px; }
.copy code { flex: 1; }

.btn { display: block; width: 100%; text-align: center; background: var(--brand); color: #fff; font-weight: 600; padding: 12px; border-radius: 12px; margin-top: 10px; }
.btn.small { display: inline-block; width: auto; padding: 7px 12px; font-size: 13px; margin: 0; border-radius: 9px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.danger { color: var(--crit); background: var(--crit-bg); }
.btn:disabled { opacity: .6; }

.fab { position: fixed; right: max(18px, calc(50% - 262px)); bottom: calc(80px + var(--safe-b)); width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 30px; text-align: center; box-shadow: 0 6px 18px rgba(15,110,86,.35); z-index: 6; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + var(--safe-b)); z-index: 6; }
.tabs button { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.tabs button span { font-size: 20px; } .tabs button.on { color: var(--brand); font-weight: 700; }
.spacer { height: calc(150px + var(--safe-b)); }

.sheet { position: fixed; inset: 0; z-index: 20; display: none; }
.sheet.open { display: block; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 90vh; overflow: auto;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + var(--safe-b)); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { margin: 0; flex: 1; } .seg input { display: none; }
.seg label { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--bg); font-size: 13px; color: var(--ink); }
.seg label:has(input:checked) { background: var(--brand); color: #fff; }

.login { margin-top: 18vh; text-align: center; } .login form, .login .btn { text-align: left; }
.login .logo { font-size: 44px; }
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--card);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 30; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.alert.more { display: none; }
.line > span:last-child { white-space: nowrap; text-align: right; }
.line > span:first-child { min-width: 0; }
