/* 明亮、柔和、简洁；手机优先，主要操作放在拇指够得到的底部 */
:root {
  color-scheme: light dark;
  --bg: #f7f4ef;
  --card: #ffffff;
  --ink: #1f2430;
  --mut: #6b6f7a;
  --line: #ebe6de;
  --soft: #fff1ea;
  --pri: #ff6a3d;
  --pri-ink: #ffffff;
  --ok: #129c5b;
  --warn: #c77800;
  --over: #e0393e;
  --ok-bg: #e7f7ee;
  --warn-bg: #fff4db;
  --over-bg: #ffe8e8;
  --shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 6px 18px rgba(40, 30, 20, .06);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15161a; --card: #1f2127; --ink: #eef0f4; --mut: #a3a7b2; --line: #2d3038; --soft: #2b211d; --ok-bg: #12291d; --warn-bg: #2e2510; --over-bg: #331718; --ok: #3ccf86; --warn: #f0b13c; --over: #ff6b6f; --shadow: none; }
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
a { color: var(--pri); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn-like { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); font-weight: 600; }
.danger { color: var(--over); }
.ghost { background: transparent; border: 0; padding: 0 6px; min-height: 40px; color: var(--pri); }
.wide { width: 100%; margin-top: 10px; }
input, select, textarea { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 8px 12px; font-size: 16px; width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pri) 55%, transparent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--mut); }
.small { font-size: 14px; }
h1 { font-size: 19px; margin: 0; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 14px 0 6px; }

#app { max-width: 640px; margin: 0 auto; min-height: 100%; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 80px 1fr 80px; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.top h1 { text-align: center; }
.top #back { justify-self: start; }
.top #back[hidden], .top #toSettings[hidden] { display: inline-flex !important; visibility: hidden; }
.top #toSettings { justify-self: end; display: inline-flex; align-items: center; min-height: 40px; }
main { padding: 4px 16px 16px; }
.view { display: none; }
.view.on { display: block; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.label { display: block; font-weight: 600; margin-bottom: 8px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btns.col { flex-direction: column; }
.btns.col > * { width: 100%; }
.foot { text-align: center; font-size: 13px; margin-top: 18px; }

/* 首页状态卡 */
.status-card { background: var(--card); border-radius: 22px; padding: 18px 18px 16px; box-shadow: var(--shadow); border: 2px solid transparent; }
.status-card .big { font-size: clamp(40px, 12vw, 56px); font-weight: 750; letter-spacing: -.02em; line-height: 1.1; margin: 2px 0 12px; }
.small-gap { margin-top: 6px; }
.hm-nav { display: inline-flex; align-items: center; gap: 2px; margin-left: -8px; }
.hm-nav .ghost { min-height: 36px; min-width: 32px; font-size: 20px; color: var(--mut); }
.hm-nav .ghost:disabled { visibility: hidden; }
.result-card .rc-l { flex: 1 1 100%; }
.result-card .rc-b { display: flex; gap: 8px; flex-wrap: wrap; }
.meter { position: relative; height: 12px; background: var(--line); border-radius: 99px; overflow: visible; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--ok); width: 0; transition: width .4s ease; }
.meter b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--mut); border-radius: 1px; }
.state { font-size: 18px; font-weight: 650; margin: 12px 0 6px; }
.inc { display: flex; gap: 18px; flex-wrap: wrap; color: var(--mut); font-size: 15px; }
.inc b { color: var(--ink); }
.status-card.lv-warn { border-color: var(--warn); background: linear-gradient(var(--warn-bg), var(--card) 70%); }
.status-card.lv-warn .meter i { background: var(--warn); } .status-card.lv-warn .state { color: var(--warn); }
.status-card.lv-reached, .status-card.lv-over { border-color: var(--over); background: linear-gradient(var(--over-bg), var(--card) 70%); }
.status-card.lv-reached .meter i, .status-card.lv-over .meter i { background: var(--over); } .status-card.lv-reached .state, .status-card.lv-over .state { color: var(--over); }
.status-card.lv-ok .state { color: var(--ok); }

.notice { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-weight: 600; background: var(--warn-bg); color: var(--warn); }
.notice.limit { background: var(--over-bg); color: var(--over); }
.pending-banner { display: block; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--soft); color: var(--ink); }
.result-card { margin-top: 12px; padding: 14px; border-radius: 14px; background: var(--ok-bg); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.recent { margin-top: 20px; }
.recent h2 { margin: 0; }

/* 交易行 */
.tx-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 12px 2px; min-height: 56px; }
.tx-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-row .s { grid-column: 1; font-size: 13px; color: var(--mut); }
.tx-row .a { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 650; text-align: right; }
.tx-row .a.in { color: var(--ok); }
.tx-row .a.neutral { color: var(--mut); font-weight: 500; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--soft); font-size: 12px; color: var(--ink); }
.day-h { font-size: 13px; color: var(--mut); margin: 16px 0 2px; display: flex; justify-content: space-between; }
.empty { color: var(--mut); padding: 20px 0; text-align: center; }

/* 底部操作 */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); max-width: 640px; margin: 0 auto; }
.dock .side { min-height: 52px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 600; box-shadow: var(--shadow); }
.mic-btn { width: 112px; height: 92px; border-radius: 28px; background: var(--pri); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 700; box-shadow: 0 8px 22px color-mix(in srgb, var(--pri) 40%, transparent); }
.mic-btn svg, .mic-big svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* 语音 */
.listen { text-align: center; padding: 24px 0 8px; }
.mic-big { width: 128px; height: 128px; border-radius: 50%; background: var(--pri); color: #fff; border: 0; box-shadow: 0 10px 30px color-mix(in srgb, var(--pri) 45%, transparent); }
.mic-big svg { width: 52px; height: 52px; }
.mic-big.rec { background: var(--over); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--over) 18%, transparent); } }
@media (prefers-reduced-motion: reduce) { .mic-big.rec { animation: none; } .meter i { transition: none; } }
.mic-state { font-weight: 650; margin: 16px 0 4px; }
.live { min-height: 3em; font-size: 18px; padding: 0 8px; }
.listen .btns { justify-content: center; }

/* 导入 */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.pick { position: relative; background: var(--card); border-radius: var(--radius); padding: 18px 14px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 96px; justify-content: center; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick:focus-within { outline: 3px solid color-mix(in srgb, var(--pri) 55%, transparent); }
.pk-t { font-size: 18px; font-weight: 700; }
.pk-s { color: var(--mut); font-size: 14px; }
.progress { padding: 12px 14px; border-radius: 14px; background: var(--soft); margin: 12px 0; white-space: pre-line; }
.map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.map-grid label { font-size: 14px; color: var(--mut); display: grid; gap: 4px; }
.scroll { overflow-x: auto; margin-top: 10px; }
.preview { border-collapse: collapse; font-size: 13px; width: max-content; min-width: 100%; }
.preview th, .preview td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.preview td.r { text-align: right; }

/* 核对卡片 */
.rv-head { margin: 4px 0 12px; }
.rv-head .orig { background: var(--card); border-radius: 14px; padding: 10px 12px; margin-top: 8px; font-size: 15px; box-shadow: var(--shadow); }
.dc { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); border: 2px solid transparent; }
.dc.exc { border-color: var(--warn); }
.dc.off { opacity: .55; }
.dc .l1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 17px; font-weight: 650; }
.dc .l1 .m { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.dc .catsel { width: auto; min-height: 36px; padding: 2px 28px 2px 10px; border-radius: 99px; background-color: var(--soft); border-color: transparent; font-weight: 650; }
.dc .l2 { color: var(--mut); font-size: 14px; margin-top: 4px; }
.dc .inc-box { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; min-height: 32px; }
.dc .inc-box input { width: 22px; height: 22px; min-height: 0; }
.flags { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.flag { font-size: 14px; padding: 4px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); }
.flag.note { background: var(--soft); color: var(--ink); }
.flag.skip { background: var(--line); color: var(--mut); }
.src { margin-top: 8px; font-size: 14px; color: var(--mut); overflow-wrap: anywhere; }
.src mark { background: color-mix(in srgb, var(--pri) 25%, transparent); color: var(--ink); border-radius: 4px; padding: 0 2px; }
.need-amt { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.need-amt input { border-color: var(--warn); }
.edit { margin-top: 10px; }
.edit summary { cursor: pointer; color: var(--pri); min-height: 32px; display: flex; align-items: center; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.fgrid label { display: grid; gap: 4px; font-size: 13px; color: var(--mut); }
.fgrid .full { grid-column: 1 / -1; }
.dup { margin-top: 10px; border: 1px dashed var(--warn); border-radius: 14px; padding: 10px; }
.dup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 14px; }
.dup-grid div { background: var(--bg); border-radius: 10px; padding: 8px; }
.dup-grid h4 { margin: 0 0 4px; font-size: 13px; color: var(--mut); }
.dup-opts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 15px; }
.dup-opts label { display: flex; gap: 6px; align-items: center; min-height: 36px; }
.dup-opts input { width: 20px; height: 20px; min-height: 0; }
.confirm-bar { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-radius: 18px; margin-top: 8px; }
.confirm-bar .primary { min-height: 54px; font-size: 18px; }
.skipped { margin: 8px 0 16px; }
.skipped summary { color: var(--mut); cursor: pointer; min-height: 36px; display: flex; align-items: center; }

/* 交易页 */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0 10px; font-weight: 650; font-size: 17px; }
.month-nav button { width: 44px; padding: 0; font-size: 20px; }
.sum-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sum-row div { background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.sum-row span { display: block; font-size: 13px; color: var(--mut); }
.sum-row b { font-size: 17px; }
.cat-bars { margin: 14px 0; }
.cb { display: grid; grid-template-columns: 4em minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; padding: 4px 0; }
.cb .bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.cb .bar i { display: block; height: 100%; background: var(--pri); border-radius: 99px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.filters input { grid-column: 1 / -1; }
.batches { margin-top: 24px; }
.batch { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* 设置 */
.field { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 10px; align-items: center; margin-bottom: 10px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.short { width: 5em; }
.inline .mon { width: 10.5em; flex: none; }
.inline #sMonthLimit { flex: 1; width: auto; }
.switch { display: inline-flex; align-items: center; gap: 6px; }
.switch input { width: 22px; height: 22px; min-height: 0; }
.plain { padding-left: 18px; margin: 0; }
.ai-line { margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: var(--soft); font-size: 14px; }
.ai-line.err { background: var(--warn-bg); color: var(--warn); }

dialog { border: 0; border-radius: 20px; padding: 18px; width: min(520px, calc(100vw - 24px)); background: var(--card); color: var(--ink); max-height: 90vh; }
dialog::backdrop { background: rgba(20, 15, 10, .45); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(6px + env(safe-area-inset-top)); z-index: 20; background: #22252d; color: #fff; padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px); display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
#toast button { min-height: 34px; background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }

@media (max-width: 380px) { .mic-btn { width: 96px; } .fgrid, .map-grid { grid-template-columns: 1fr; } .dup-grid { grid-template-columns: 1fr; } }
@media (min-width: 900px) { #app { max-width: 760px; } .dock { max-width: 760px; } }
