@font-face { font-family: "Silkscreen"; src: url("/assets/fonts/silkscreen-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("/assets/fonts/silkscreen-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f4efe6;
  --surface: #fbf8f2;
  --surface-2: #f0e9dd;
  --ink: #2b2522;
  --ink-2: #5f5550;
  --ink-3: #8a7f76;
  --line: #e2d9cb;
  --edge: #2b2522;
  --shadow: #d9cfbf;
  --accent: #c2603f;
  --accent-soft: #f3dccf;
  --mascot: #d97757;
  --mascot-ink: #2b2522;
  --mascot-blush: #f2a48c;
  --coin: #f0b429;
  --coin-edge: #c98500;
  --floor-a: #e8dfd0;
  --floor-b: #ded3c1;
  --good: #2f8a4f;
  --warn: #b7791f;
  --danger: #c8453b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --track: #efe2d6;
  --font-pixel: "Silkscreen", ui-monospace, monospace;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1c1917; --surface: #2a2623; --surface-2: #332e2a; --ink: #f3ece3; --ink-2: #c7bcb0; --ink-3: #9a8f84;
    --line: #3e3833; --edge: #0f0d0c; --shadow: #0f0d0c; --accent: #d47352; --accent-soft: #4a3128;
    --mascot: #e0896a; --mascot-ink: #1c1917; --mascot-blush: #f5b7a1; --coin: #f5c247; --coin-edge: #c98500;
    --floor-a: #2f2a26; --floor-b: #37312c; --good: #5cbf7e; --warn: #e0a83e; --danger: #ec6a5f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --track: #3b312b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1917; --surface: #2a2623; --surface-2: #332e2a; --ink: #f3ece3; --ink-2: #c7bcb0; --ink-3: #9a8f84;
  --line: #3e3833; --edge: #0f0d0c; --shadow: #0f0d0c; --accent: #d47352; --accent-soft: #4a3128;
  --mascot: #e0896a; --mascot-ink: #1c1917; --mascot-blush: #f5b7a1; --coin: #f5c247; --coin-edge: #c98500;
  --floor-a: #2f2a26; --floor-b: #37312c; --good: #5cbf7e; --warn: #e0a83e; --danger: #ec6a5f;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --track: #3b312b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.num, .pixel { font-family: var(--font-pixel); font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---------- 像素组件 ---------- */
.card { background: var(--surface); border: 2px solid var(--edge); box-shadow: 4px 4px 0 var(--shadow); padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h2 .tag { margin-left: auto; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.pixel-btn { cursor: pointer; background: var(--accent); color: #fff; border: 2px solid var(--edge); box-shadow: 3px 3px 0 var(--edge);
  padding: 8px 18px; font-weight: 700; transition: transform .05s; }
.pixel-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.pixel-btn.ghost { background: var(--surface); color: var(--ink); }
.pixel-btn.small { padding: 3px 10px; font-size: 13px; box-shadow: 2px 2px 0 var(--edge); }
.chip { display: inline-block; font-size: 12px; padding: 1px 7px; border: 1.5px solid var(--edge); background: var(--surface-2); white-space: nowrap; }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); }
.chip.danger { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.chip.good { background: color-mix(in srgb, var(--good) 18%, var(--surface)); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------- 登录 / 授权 ---------- */
body.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background-image: linear-gradient(var(--bg) 70%, transparent 70%), repeating-conic-gradient(var(--floor-a) 0 25%, var(--floor-b) 0 50%);
  background-size: 100% 100%, 24px 24px; }
.gate-card { width: min(380px, 100%); background: var(--surface); border: 2px solid var(--edge); box-shadow: 6px 6px 0 var(--shadow); padding: 24px; text-align: center; }
.gate-card h1 { margin: 8px 0 4px; font-size: 22px; }
.gate-sub { color: var(--ink-2); margin: 0 0 16px; font-size: 14px; }
.gate-error { color: var(--danger); font-weight: 700; }
.gate-form { display: grid; gap: 12px; text-align: left; }
.gate-form label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.gate-form input { font: 16px var(--font); padding: 10px; border: 2px solid var(--edge); background: var(--bg); color: var(--ink); border-radius: 0; }
.gate-form input:focus { outline: 3px solid var(--accent-soft); }
.gate-actions { display: flex; gap: 12px; justify-content: center; }
.consent { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; text-align: left; background: var(--surface-2); padding: 12px; border: 2px dashed var(--line); }
.consent dt { color: var(--ink-3); } .consent dd { margin: 0; word-break: break-all; }
.mascot-slot { width: 96px; height: 86px; margin: 0 auto; }

/* ---------- 小橘块 ---------- */
.mascot { width: 100%; height: 100%; overflow: visible; }
.mascot .m-blink { transform-box: fill-box; transform-origin: center; animation: blink 4.2s infinite; }
.mascot .m-wave { transform-box: fill-box; transform-origin: 0 100%; animation: wave .6s steps(2) infinite; }
.mascot.mood-idle, .mascot.mood-coin, .mascot.mood-wave { animation: bob 1.2s steps(2) infinite; }
.mascot.mood-happy { animation: hop .7s steps(4) infinite; }
.mascot .m-bubble { animation: blinkslow 1.6s steps(2) infinite; }
.walking .mascot .m-leg.a { animation: step .36s steps(2) infinite; }
.walking .mascot .m-leg.b { animation: step .36s steps(2) infinite reverse; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes bob { 50% { transform: translateY(-3%); } }
@keyframes hop { 50% { transform: translateY(-14%); } }
@keyframes wave { 50% { transform: rotate(-25deg); } }
@keyframes step { 50% { transform: translateY(-1px); } }
@keyframes blinkslow { 50% { opacity: .2; } }

/* ---------- 布局 ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 0 16px 96px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.brand .mini { width: 30px; height: 28px; }
.topbar .spacer { flex: 1; }
.icon-btn { cursor: pointer; background: var(--surface); border: 2px solid var(--edge); box-shadow: 2px 2px 0 var(--edge); width: 36px; height: 36px; display: grid; place-items: center; }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }

.tabs { display: flex; gap: 8px; margin: 4px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { text-decoration: none; color: var(--ink); padding: 6px 14px; border: 2px solid var(--edge); background: var(--surface); white-space: nowrap; font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--surface); }
@media (max-width: 720px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--surface);
    border-top: 2px solid var(--edge); z-index: 10; justify-content: space-around; }
  .tabs a { flex: 1; text-align: center; padding: 6px 4px; }
}

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* 场景：小橘块在像素地板上走来走去 */
.scene { position: relative; height: 184px; border: 2px solid var(--edge); box-shadow: 4px 4px 0 var(--shadow); overflow: hidden;
  background: linear-gradient(var(--surface-2) 0 68%, transparent 68%), repeating-conic-gradient(var(--floor-a) 0 25%, var(--floor-b) 0 50%) 0 0 / 16px 16px; }
.scene .walker { position: absolute; bottom: 30px; left: 0; width: 64px; height: 58px; cursor: pointer; }
.scene .walker.flip .mascot { transform: scaleX(-1); }
.scene .bubble { position: absolute; bottom: 90px; max-width: min(320px, 70vw); background: var(--surface); border: 2px solid var(--edge); padding: 6px 10px;
  font-size: 13px; box-shadow: 3px 3px 0 var(--shadow); white-space: normal; transition: opacity .2s; pointer-events: none; }
.scene .bubble::after { content: ""; position: absolute; left: 18px; bottom: -8px; width: 8px; height: 8px; background: var(--surface); border-right: 2px solid var(--edge); border-bottom: 2px solid var(--edge); transform: rotate(45deg); }
.scene .prop { position: absolute; bottom: 30px; image-rendering: pixelated; }
.scene .hello { position: absolute; left: 16px; top: 12px; right: 16px; }
.scene .hello .date { color: var(--ink-3); font-size: 12px; }
.scene .hello .line { font-weight: 700; font-size: 16px; }

/* 数字卡片 */
.hero .value { font-size: clamp(30px, 8vw, 48px); letter-spacing: -.02em; line-height: 1.05; font-family: var(--font-pixel); font-weight: 400; }
.hero .value small { font-size: .4em; color: var(--ink-3); margin-left: 6px; }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-family: var(--font-pixel); font-weight: 400; font-size: clamp(18px, 5vw, 24px); line-height: 1.2; margin-top: 2px; }
.tile .sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

/* 像素计量条 */
.meter { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; margin: 10px 0 6px; }
.meter i { height: 14px; background: var(--track); }
.meter i.on { background: var(--accent); }
.meter.good i.on { background: var(--good); }
.meter.warn i.on { background: var(--warn); }
.meter.danger i.on { background: var(--danger); }
.meter-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }

/* 提醒 */
.remind { display: grid; gap: 8px; }
.remind li { list-style: none; display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--surface-2); border-left: 4px solid var(--ink-3); }
.remind li.urgent { border-color: var(--danger); } .remind li.warn { border-color: var(--warn); } .remind li.todo { border-color: var(--accent); }
.remind li .txt { flex: 1; }
.remind ul, ul.plain { margin: 0; padding: 0; }
.remind .ico { width: 18px; text-align: center; }

/* 图表 */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart .lbl { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .vlbl { fill: var(--ink); font-size: 12px; font-family: var(--font-pixel); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .ref-line { stroke: var(--ink-3); stroke-width: 1.5; }
.chart .series { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { opacity: .8; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 9px; font-size: 12px; line-height: 1.4;
  border: 2px solid var(--edge); box-shadow: 3px 3px 0 var(--shadow); opacity: 0; transition: opacity .1s; max-width: 240px; }
.tip.show { opacity: 1; }
.tip b { font-family: var(--font-pixel); font-weight: 400; font-size: 14px; }
.stack { display: flex; gap: 2px; height: 22px; margin: 8px 0; }
.stack span { display: block; min-width: 2px; }
.stack span:first-child { border-radius: 4px 0 0 4px; } .stack span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
details.data { margin-top: 8px; font-size: 13px; }
details.data summary { cursor: pointer; color: var(--ink-3); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.t th, table.t td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }

/* 列表 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { font: 14px var(--font); padding: 7px 9px; border: 2px solid var(--edge); background: var(--surface); color: var(--ink); border-radius: 0; min-width: 0; }
.filters input { flex: 1 1 160px; }
.day { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-3); padding: 0 4px 4px; }
.rows { background: var(--surface); border: 2px solid var(--edge); box-shadow: 3px 3px 0 var(--shadow); }
.row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .cat { width: 34px; height: 34px; display: grid; place-items: center; background: var(--surface-2); border: 1.5px solid var(--line); font-size: 17px; }
.row .main { min-width: 0; }
.row .desc, .row .meta { display: block; }
.row .desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.row .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-family: var(--font-pixel); font-weight: 400; font-size: 14px; text-align: right; }
.row .amt .cur { font-size: 11px; color: var(--ink-3); display: block; font-family: var(--font); font-weight: 400; }
.row.void { opacity: .45; text-decoration: line-through; }
.row-detail { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); padding: 8px 10px; margin-top: 4px; word-break: break-all; }
.in { color: var(--good); }

.acct-list .row { grid-template-columns: minmax(0, 1fr) auto; cursor: pointer; }
.section-title { font-size: 13px; color: var(--ink-3); margin: 18px 4px 6px; font-weight: 700; letter-spacing: .05em; }
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: min(640px, 100%); max-height: 86vh; overflow: auto; border: 2px solid var(--edge); border-bottom: 0; padding: 16px; box-shadow: 0 -4px 0 var(--shadow); }
@media (min-width: 721px) { .sheet-bg { align-items: center; } .sheet { border-bottom: 2px solid var(--edge); } }
.chain { font-size: 13px; }
.chain li { list-style: none; padding: 6px 0; border-bottom: 1px dashed var(--line); }

.sub-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sub-row:last-child { border-bottom: 0; }
.sub-row .name { font-weight: 700; }
.sub-row .price { text-align: right; font-family: var(--font-pixel); }
.sub-row .info { font-size: 12px; color: var(--ink-3); }
.sub-row .when { text-align: right; }

.empty { text-align: center; color: var(--ink-3); padding: 24px 0; }
.empty .mascot-slot { width: 72px; height: 64px; }
.loading { display: grid; place-items: center; min-height: 50vh; }
.footer { color: var(--ink-3); font-size: 12px; text-align: center; margin-top: 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.upcoming .row { grid-template-columns: auto minmax(0, 1fr) auto; cursor: default; }
.upcoming .row .meta { white-space: normal; }
.sub-row { grid-template-columns: minmax(0, 1fr) auto; }
.icon-btn svg { width: 18px; height: 18px; }
.chart .vlbl { font-size: 11px; }
.sub-row .info.note, .sheet .acct-note, .chain .muted { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
