/* 布局：账本式控制台。顶部是日期，所有数字都围绕"这一天"；概览用一条"收入 − 成本 = 毛利"的算式开场，
   合计行沿用会计的"上单线、下双线"；数字一律等宽，像对账单一样逐位对齐。 */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #161a24;
  --ink-2: #474e63;
  --muted: #7d8397;
  --line: #e2e5ec;
  --line-2: #cbd0db;
  --accent: #3047c4;
  --accent-ink: #ffffff;
  --accent-soft: #e9ecfb;
  --accent-mid: #9aa7ea;
  --gain: #127a52;
  --gain-soft: #e3f3eb;
  --warn: #9c5a00;
  --warn-soft: #fbf0d9;
  --warn-mark: #e3a23a;
  --loss: #c4352b;
  --loss-soft: #fbe8e5;
  --loss-mark: #e06a5f;
  --shadow: 0 1px 2px rgba(22, 26, 36, .06), 0 8px 24px -12px rgba(22, 26, 36, .14);
  --scrim: rgba(16, 19, 28, .38);

  --font-ui: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px; --fs-hero: 44px;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f15; --surface: #151821; --surface-2: #1a1e29; --ink: #e8eaf1; --ink-2: #b3b8c8; --muted: #7e8498;
    --line: #252a37; --line-2: #343a4b; --accent: #8c9dff; --accent-ink: #0d0f15; --accent-soft: #1d2442; --accent-mid: #4a5bb5;
    --gain: #45c98f; --gain-soft: #12291f; --warn: #f0b155; --warn-soft: #33260f; --warn-mark: #d69a3c;
    --loss: #ff7d72; --loss-soft: #36191a; --loss-mark: #d9574d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6); --scrim: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f15; --surface: #151821; --surface-2: #1a1e29; --ink: #e8eaf1; --ink-2: #b3b8c8; --muted: #7e8498;
  --line: #252a37; --line-2: #343a4b; --accent: #8c9dff; --accent-ink: #0d0f15; --accent-soft: #1d2442; --accent-mid: #4a5bb5;
  --gain: #45c98f; --gain-soft: #12291f; --warn: #f0b155; --warn-soft: #33260f; --warn-mark: #d69a3c;
  --loss: #ff7d72; --loss-soft: #36191a; --loss-mark: #d9574d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6); --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: var(--fs-md); line-height: 1.55; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.n { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.r { text-align: right; }
.muted { color: var(--muted); }
.gain { color: var(--gain); } .warn { color: var(--warn); } .loss { color: var(--loss); }
.label { font-size: var(--fs-xs); color: var(--muted); letter-spacing: .04em; }

/* ---------- 顶部 ---------- */
.masthead { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 8; background: var(--surface); border-bottom: 1px solid var(--line); }
.mast-row { display: flex; align-items: center; gap: 20px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.seal { flex: none; width: 32px; height: 32px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 17px; }
.brand-name { font-weight: 700; font-size: var(--fs-lg); line-height: 1.2; white-space: nowrap; }
.brand-sub { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.datebar { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.step { width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 16px; line-height: 1; }
.step:hover { background: var(--surface-2); }
.date { display: flex; align-items: baseline; gap: 8px; padding: 0 10px; min-width: 132px; justify-content: center; }
.date-main { font-weight: 700; font-size: var(--fs-xl); }
.date-week { color: var(--muted); font-size: var(--fs-sm); }
.today { height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: var(--fs-sm); }
.who { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { position: relative; padding: 10px 12px 12px; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); }
.tabs a.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tabs .count { margin-left: 6px; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--loss-soft); color: var(--loss); font-family: var(--font-num); }

main.wrap { padding-block: 24px 80px; }
.page { display: none; } .page.on { display: grid; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.page-head h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.01em; }
.page-head .meta { color: var(--muted); font-size: var(--fs-sm); }
.section-title { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; }
.section-title h2 { font-size: var(--fs-lg); font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; }
.panel-head h3 { font-size: var(--fs-md); font-weight: 600; }
.panel-head .aside { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); }
.panel-head.lead { padding: 16px 18px 4px; gap: 12px; }
.panel-head.lead h3 { font-size: var(--fs-lg); }
.head-ico { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.head-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.head-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-width: 0; }
.head-total { font-size: var(--fs-md); color: var(--muted); white-space: nowrap; }
.head-total b { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (hover: none) { .hover-hint { display: none; } }
.panel-body { padding: 14px 18px 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; }
.grid-2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.plain::before { display: none; }
.chip.gain { background: var(--gain-soft); color: var(--gain); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.loss { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.chip.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- 概览：损益算式 ---------- */
.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px 24px 20px; display: grid; gap: 18px; }
.ledger-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ledger-top h1 { font-size: var(--fs-xl); font-weight: 700; }
.ledger-top .meta { color: var(--muted); font-size: var(--fs-sm); }
.equation { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.1fr); align-items: end; gap: 8px 18px; }
.term { min-width: 0; display: grid; gap: 4px; }
.term-val { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-hero); font-weight: 500; line-height: 1.05; letter-spacing: -.03em; white-space: nowrap; }
.term-val small { font-size: .45em; color: var(--muted); font-weight: 400; margin-right: 4px; letter-spacing: 0; }
.term-note { font-size: var(--fs-xs); color: var(--muted); }
.op { font-family: var(--font-num); font-size: 32px; color: var(--line-2); padding-bottom: 26px; }
.term.result .term-val { padding-bottom: 4px; border-bottom: 3px double var(--ink); justify-self: start; }
.ledger-foot { display: flex; flex-wrap: wrap; gap: 8px 24px; padding-top: 14px; border-top: 1px dashed var(--line-2); font-size: var(--fs-sm); color: var(--ink-2); }
.ledger-foot b { font-family: var(--font-num); font-weight: 500; color: var(--ink); }
.ledger-foot b.gain, .head-total b.gain { color: var(--gain); } .ledger-foot b.loss, .head-total b.loss { color: var(--loss); }

/* 图表 */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font-num); font-size: 11px; fill: var(--muted); }
.chart .val { fill: var(--ink); font-size: 12px; font-weight: 500; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--line-2); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar.est { fill: url(#hatch); stroke: var(--accent-mid); stroke-width: 1; }
.chart .band:hover + .bar, .chart .bar.hot { opacity: .82; }
.chart .hit { fill: transparent; cursor: default; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 7px; padding: 9px 11px; font-size: var(--fs-xs); line-height: 1.6; min-width: 170px; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .12s; }
.tip.on { opacity: 1; }
.tip .t { font-weight: 600; margin-bottom: 2px; }
.tip .row { display: flex; justify-content: space-between; gap: 16px; }
.tip .row span:last-child { font-family: var(--font-num); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-xs); color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--accent); }
.legend i.est { background: repeating-linear-gradient(135deg, var(--accent-mid) 0 2px, transparent 2px 4px); border: 1px solid var(--accent-mid); }
.linkbtn { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: var(--fs-xs); }

/* 需要处理 */
.todo { display: grid; }
.todo-item { display: grid; grid-template-columns: 4px minmax(0, 1fr); gap: 0 12px; padding: 12px 18px 12px 0; border-top: 1px solid var(--line); }
.todo-item:first-child { border-top: none; }
.todo-item .stripe { border-radius: 0 3px 3px 0; background: var(--line-2); }
.todo-item.loss .stripe { background: var(--loss-mark); }
.todo-item.warn .stripe { background: var(--warn-mark); }
.todo-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; }
.todo-text { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
.todo-text .n { color: var(--ink); }

/* 往来 */
.big { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-2xl); font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.debtors { display: grid; gap: 10px; margin-top: 16px; }
.debtor { display: grid; grid-template-columns: 110px minmax(0, 1fr) 84px; align-items: center; gap: 12px; font-size: var(--fs-sm); }
.debtor .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: flex; }
.track span { display: block; height: 100%; }
.fill-loss { background: var(--loss-mark); } .fill-paid { background: var(--line-2); }
.fill-gain { background: var(--gain); } .fill-warn { background: var(--warn-mark); }
.kv-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.kv-line:first-child { border-top: none; }
.kv-line .n { font-size: var(--fs-md); }
.cover { margin-top: 16px; display: grid; gap: 8px; }
.cover-bar { position: relative; height: 14px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.cover-bar span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px 0 0 3px; }
.cover-legend { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }
.balances { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; margin-top: 16px; }
.balances div { display: grid; }
.balances .n { font-size: var(--fs-md); }

details.explain { color: var(--ink-2); font-size: var(--fs-sm); }
details.explain summary { cursor: pointer; color: var(--muted); }
details.explain ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; max-width: 78ch; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); letter-spacing: .04em; background: var(--surface); border-bottom-color: var(--line-2); }
td.n, th.r { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.total td { font-weight: 600; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
tr.sub td { background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-xs); padding-block: 8px; }
tr.sub td:first-child { padding-left: 40px; }
tr.sub.note td { white-space: normal; }
.up-name { display: flex; align-items: center; gap: 8px; }
.caret { width: 16px; height: 16px; display: inline-grid; place-items: center; color: var(--muted); transition: transform .15s; font-size: 10px; }
tr.open .caret { transform: rotate(90deg); }
.sub-line { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
tr.click:hover .sticky-col { background: var(--surface-2); }

.bullet { position: relative; width: 120px; height: 10px; display: inline-block; vertical-align: middle; margin-left: 10px; }
.bullet .bg { position: absolute; inset: 3px 0; border-radius: 2px; background: var(--surface-2); }
.bullet .zero { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.bullet .thr { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 1px dashed var(--muted); }
.bullet .val { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; }

.paybar { width: 140px; }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg-filter { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.fchip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2); }
.fchip:hover { color: var(--ink); }
.fchip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.fchip .n { margin-left: 4px; opacity: .7; font-size: var(--fs-xs); }
.search { margin-left: auto; height: 32px; min-width: 200px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-sm); }
.statline { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.stat { display: grid; }
.stat .n { font-size: var(--fs-xl); font-weight: 500; }

/* ---------- 表单 ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: var(--fs-xs); color: var(--muted); letter-spacing: .04em; }
.input, select.input { height: 38px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; width: 100%; }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input.money { height: 52px; font-family: var(--font-num); font-size: 24px; font-weight: 500; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-2); border-radius: 7px; padding: 3px; gap: 3px; background: var(--surface-2); }
.seg button { border: none; height: 30px; border-radius: 5px; background: transparent; cursor: pointer; color: var(--ink-2); font-size: var(--fs-sm); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.impact { border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 6px; }
.impact .conv { font-family: var(--font-num); font-size: var(--fs-2xl); font-weight: 500; letter-spacing: -.02em; }
.impact .chg { font-size: var(--fs-sm); color: var(--ink-2); }
.impact .chg .n { color: var(--ink); }
.btn { height: 40px; padding: 0 20px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); font-weight: 500; }
.btn.sm { height: 30px; padding: 0 12px; font-size: var(--fs-sm); }
.icon-btn { border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; height: 28px; padding: 0 8px; font-size: var(--fs-xs); }
.icon-btn:hover { color: var(--loss); border-color: var(--line-2); }
.check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); height: 38px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.pay-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.pay-form { position: sticky; top: 130px; }

/* ---------- 设置 ---------- */
.set-row { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 16px 32px; padding: 22px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: none; padding-top: 4px; }
.set-row h3 { font-size: var(--fs-md); font-weight: 600; }
.set-row p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.set-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.cell-input { width: 72px; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-family: var(--font-num); text-align: right; }
.cell-input::placeholder { color: var(--warn); }

/* ---------- 抽屉 ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .18s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100%); z-index: 31; background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; transform: translateX(102%); transition: transform .22s ease;
  padding: calc(20px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) 20px; display: grid; grid-auto-rows: max-content; gap: 18px; align-content: start; }
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; }
.drawer-head h2 { font-size: var(--fs-xl); }
.drawer-head .btn { margin-left: auto; }
.dstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.dstats > div { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; }
.dstats .n { font-size: var(--fs-lg); font-weight: 500; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 72vh; display: grid; place-items: center; }
.login { width: min(380px, 100%); display: grid; gap: 16px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.login .seal { width: 44px; height: 44px; font-size: 22px; border-radius: 10px; }
.login h1 { font-size: var(--fs-xl); }

@media (max-width: 900px) {
  .grid-2, .grid-2.even, .pay-layout { grid-template-columns: minmax(0, 1fr); }
  .pay-form { position: static; }
  .set-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 720px) {
  .mast-row { flex-wrap: wrap; gap: 10px; }
  .who { display: none; }
  .datebar { margin-left: 0; width: 100%; }
  .date { flex: 1; justify-content: flex-start; padding: 0 4px; min-width: 0; }
  .equation { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .op { display: none; }
  .term { grid-template-columns: 72px minmax(0, 1fr); align-items: baseline; column-gap: 12px; }
  .term-label { grid-row: span 2; }
  .term-val { font-size: 30px; }
  .term.result { padding-top: 12px; border-top: 1px solid var(--ink); }
  .ledger { padding: 18px 16px; }
  .balances { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .debtor { grid-template-columns: 92px minmax(0, 1fr) 72px; }
  .search { margin-left: 0; width: 100%; min-width: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .dstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- 运行时补充 ---------- */
.chart .bar.partial { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 4 3; }
.chart .bar.neg { fill: var(--loss-mark); }
.legend i.partial { background: var(--accent-soft); border: 1px dashed var(--accent); }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: var(--fs-lg); margin-bottom: 4px; }
.loading { opacity: .55; transition: opacity .15s; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: var(--fs-sm); transition: opacity .18s, transform .18s; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--loss); color: #fff; }
.form-error { color: var(--loss); font-size: var(--fs-sm); min-height: 1.4em; }
.icon-btn.confirm { color: #fff; background: var(--loss); border-color: var(--loss); }
.date-btn { border: none; background: none; cursor: pointer; padding: 0; }
.date-btn:hover .date-main { color: var(--accent); }
.date-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.datebar { position: relative; }
.logout { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: var(--fs-sm); }
.cell-input.saved { border-color: var(--gain); }
.note-line { font-size: var(--fs-xs); color: var(--muted); }
.mini td { padding-block: 7px; }
