:root {
  --bg: #F5F1E8; --card: #FFFDF8; --line: #E2DACB; --line2: #EDE6D8; --soft: #F0EADC; --ink: #2A2823; --muted: #66605A;
  --accent: #2D4A6B; --accent-bg: #E7EDF3; --accent2: #B5702F; --warn-bg: #F7EBDC; --warn-line: #E5C9A6; --warn-ink: #8A4E0E;
  --err: #A33A2A; --err-bg: #F8E5E1; --chip: #D6CDBB;
  --heat0: #EDE6D8; --heat1: #C9D6E3; --heat2: #9DB3CB; --heat3: #5E7C9C; --heat4: #2D4A6B;
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --serif: "Songti TC", "Noto Serif TC", "PMingLiU", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1B19; --card: #262420; --line: #3A3631; --line2: #33302B; --soft: #302D28; --ink: #EDE8DE; --muted: #ABA397;
    --accent: #8FB0D4; --accent-bg: #2B3846; --accent2: #D49A5C; --warn-bg: #3A2E21; --warn-line: #5C4630; --warn-ink: #E7B67E;
    --err: #F08C7A; --err-bg: #3E2622; --chip: #4A453E;
    --heat0: #33302B; --heat1: #34485C; --heat2: #4A6888; --heat3: #6F92B8; --heat4: #A6C4E2;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-text-size-adjust: 100%; }
body.noscroll { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.num, .big, .tile-big, .row-amt, .big2, table { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }
h2 { font-size: 17px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .up { color: var(--warn-ink); }
.splash { padding: 40vh 0; text-align: center; color: var(--muted); }

.app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.app.form-page { padding-bottom: 32px; }
.page { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.hdr { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(env(safe-area-inset-top) + 14px) 0 4px; }
.hdr-pad { width: 4px; }
.hdr-title { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hdr-title h1 { font-size: 24px; }
.hdr-sub { font-size: 12px; color: var(--muted); }
.hdr-right { display: flex; align-items: center; gap: 4px; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); border-radius: 12px; cursor: pointer; }
.link-btn { border: none; background: none; color: var(--accent); font-weight: 500; padding: 10px 6px; cursor: pointer; min-height: 44px; }
.link-btn:disabled { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.card.dashed { border-style: dashed; border-color: var(--chip); }
.card.soft { background: var(--soft); border-color: transparent; }
.card.list { padding: 0; gap: 0; overflow: hidden; }
.card-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-ft { display: flex; justify-content: flex-end; gap: 16px; }
.big { font-size: 34px; font-weight: 700; line-height: 1.15; }
.big2 { font-size: 18px; font-weight: 700; }
.pad { padding: 0 4px; } .pad-h { padding: 14px 18px 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tile { text-decoration: none; color: var(--ink); gap: 4px; padding: 14px; }
.tile.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.tile-big { font-size: 20px; font-weight: 700; }
.sec-hd { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 4px 0; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; }
.s1 { background: var(--accent); } .s2 { background: var(--accent2); } .s3 { background: var(--chip); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.legend-mark i { display: inline-block; width: 2px; height: 12px; background: var(--accent2); margin-right: 5px; vertical-align: -2px; }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--soft); color: var(--ink); text-decoration: none; border: none; text-align: left; min-height: 44px; width: 100%; margin: 0; font-size: 14px; }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner .count { width: 32px; height: 32px; border-radius: 16px; background: var(--accent2); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.banner-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.prog { display: flex; flex-direction: column; gap: 6px; }
.prog-hd { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.btnlike { border: none; background: none; padding: 4px 0; text-align: left; width: 100%; cursor: pointer; }
.bar { height: 8px; background: var(--line2); border-radius: 4px; position: relative; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.bar-fill.warn { background: var(--accent2); }
.bar-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--accent2); }
.catrow { display: flex; flex-direction: column; }
.subs { display: flex; flex-direction: column; padding: 4px 0 8px 10px; border-left: 2px solid var(--line2); margin: 4px 0 4px 2px; }
.subrow { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; border: none; background: none; padding: 9px 4px; text-align: left; font-size: 14px; cursor: pointer; min-height: 40px; }

.day { display: flex; flex-direction: column; gap: 6px; }
.day-hd { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 0; }
.day-hd h3 { font-size: 15px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: none; border-bottom: 1px solid var(--line2); background: none; width: 100%; text-align: left; text-decoration: none; color: var(--ink); min-height: 56px; cursor: pointer; }
.row:last-child { border-bottom: none; }
.row.static { cursor: default; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.row-amt { font-size: 15px; font-weight: 700; }
.badge { font-size: 11.5px; padding: 1px 7px; border-radius: 9px; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.err { background: var(--err-bg); color: var(--err); }
.dot { width: 9px; height: 9px; border-radius: 5px; background: var(--chip); flex: none; }
.dot.ok { background: var(--accent); } .dot.warn { background: var(--accent2); }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.kvrow { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line2); }
.kvrow:last-child { border-bottom: none; }
.kvlist { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; padding-top: 6px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 13px; color: var(--muted); }
.input { height: 48px; border: 1px solid var(--chip); border-radius: 12px; background: var(--card); padding: 0 14px; font-size: 16px; width: 100%; }
select.input { appearance: auto; }
.amount-input { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.amount-input span { font-size: 22px; color: var(--muted); }
.amount-input input { flex: 1; min-width: 0; border: none; background: transparent; font-size: 38px; font-weight: 700; padding: 0; outline: none; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--chip); background: transparent; font-size: 14px; cursor: pointer; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--card); }
.chips button.off { color: var(--muted); text-decoration: line-through; }
.chips.small button { min-height: 34px; padding: 0 12px; font-size: 13px; background: var(--card); }
.chips.small button.on { background: var(--accent-bg); color: var(--accent); border: 1.5px solid var(--accent); font-weight: 700; }
.chip-fav { min-height: 40px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--chip); background: var(--card); font-size: 14px; cursor: pointer; }
.subbox { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--bg); border-radius: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.pm { min-height: 44px; border-radius: 10px; border: 1px solid var(--chip); background: transparent; font-size: 13px; padding: 4px; cursor: pointer; }
.pm.on { border: 1.5px solid var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.seg { display: grid; background: var(--soft); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { min-height: 40px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.split-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--chip); background: transparent; font-size: 20px; cursor: pointer; }
.stepper span { min-width: 48px; text-align: center; }
.inline-step span { min-width: 0; flex: 1; }
.split-sum { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { width: 110px; height: 44px; border: 1px solid var(--chip); border-radius: 10px; background: var(--card); padding: 0 10px; font-size: 16px; }
.row-btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 18px; border: 1px solid var(--chip); border-radius: 12px; background: transparent; font-size: 15px; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--card); font-weight: 700; flex: 1; }
.btn.big { min-height: 52px; font-size: 17px; }
.btn.block { width: 100%; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger-outline { color: var(--err); border-color: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.check.grow { flex: 1; color: var(--muted); }
.error { color: var(--err); margin: 0; font-size: 14px; }
.foot-note { font-size: 12.5px; color: var(--muted); line-height: 1.6; padding: 0 8px; margin: 0; }
.file { position: relative; min-height: 52px; border: 1.5px dashed var(--heat2); border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--accent); font-weight: 500; cursor: pointer; padding: 0 12px; text-align: center; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.budget-row { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 6.5em; gap: 10px; align-items: center; font-size: 15px; }
.filters { display: flex; flex-direction: column; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; height: 46px; border: 1px solid var(--chip); border-radius: 12px; background: var(--card); padding: 0 12px; color: var(--muted); }
.search input { flex: 1; border: none; background: transparent; font-size: 16px; outline: none; color: var(--ink); min-width: 0; }
.filter-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.filter-row select { height: 40px; border: 1px solid var(--chip); border-radius: 10px; background: var(--card); padding: 0 6px; font-size: 13.5px; min-width: 0; }

.inbox .tag { font-size: 12px; color: var(--warn-ink); font-weight: 500; }
.inbox .t { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.items { line-height: 1.5; margin: 0; }
.cmp { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { font-weight: 400; color: var(--muted); font-size: 12px; text-align: right; padding: 4px 2px; }
.tbl td { text-align: right; padding: 8px 2px; border-top: 1px solid var(--line2); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.heat { display: grid; grid-template-columns: 2.6em repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; align-items: center; }
.heat .cell { height: 22px; border-radius: 4px; }

.detail { display: flex; flex-direction: column; gap: 12px; }
.detail-amt { font-size: 30px; font-weight: 700; }
.detail-title { font-size: 16px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px 10px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.evidence summary { cursor: pointer; color: var(--accent); min-height: 32px; }
.ev { font-size: 13px; padding: 6px 0; border-top: 1px solid var(--line2); overflow-wrap: anywhere; }
.ev ul { margin: 4px 0 0; padding-left: 18px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(20, 18, 15, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 88vh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet-hd { display: flex; justify-content: space-between; align-items: center; padding: 10px 8px 4px 18px; }
.sheet-bd { padding: 6px 18px 22px; overflow-y: auto; }
@media (min-width: 760px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; max-height: 80vh; } }

.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 40; }
.nav a { text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; min-height: 48px; justify-content: center; }
.nav a.on { color: var(--accent); font-weight: 700; }
.nav .nav-add { justify-self: center; width: 54px; height: 54px; min-height: 54px; border-radius: 27px; background: var(--accent); color: var(--card); }
.nav-ic { position: relative; display: inline-flex; }
.nav-badge { position: absolute; top: -4px; right: -10px; background: var(--accent2); color: #fff; border-radius: 9px; font-size: 10.5px; padding: 0 5px; line-height: 16px; font-weight: 700; }
@media (min-width: 760px) { .nav { max-width: 720px; margin: 0 auto; border-radius: 18px 18px 0 0; border: 1px solid var(--line); } }
.status { position: sticky; top: 0; z-index: 30; background: var(--accent-bg); color: var(--accent); font-size: 13px; padding: 6px 16px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.status.off { background: var(--soft); color: var(--muted); }
.status.remind { background: var(--warn-bg); color: var(--warn-ink); justify-content: space-between; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; max-width: 90vw; }
.toast.err { background: var(--err); color: #fff; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 28px; display: flex; align-items: center; gap: 8px; }
code { font-size: 13px; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
details summary { cursor: pointer; }
.card p { margin: 0; }
