@font-face { font-family: 'Num'; src: url(fonts/bsc-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Num'; src: url(fonts/bsc-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Num'; src: url(fonts/bsc-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }

/* 账本配色：封皮绿 + 纸面 + 墨色；红只给亏损和未达标 */
:root {
  --band: #0f3d34; --band-ink: #ffffff; --band-sub: #9fc4b9;
  --bg: #eef2ef; --card: #ffffff; --ink: #17212b; --sub: #68737d; --rule: #dbe2de; --soft: #f5f8f6;
  --green: #0e7c66; --green-soft: #e3f1ec; --red: #c8372d; --red-soft: #fbeae8; --amber: #a86b00;
  --r-lg: 18px; --r-sm: 10px;
  --num: 'Num', 'DIN Alternate', -apple-system, 'PingFang SC', sans-serif;
  --cn: -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
:root.dark {
  --band: #0a2a23; --band-sub: #7fae9f;
  --bg: #0c1512; --card: #14201c; --ink: #e6edea; --sub: #8c9a95; --rule: #233430; --soft: #1a2824;
  --green: #34b392; --green-soft: #183a31; --red: #ff6b5e; --red-soft: #3a1d1a; --amber: #e0a43a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--cn); font-size: 15px; line-height: 1.5; }
body { min-height: 100vh; padding-bottom: calc(72px + var(--safe-b)); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* 顶栏 */
.bar { background: var(--band); color: var(--band-ink); position: sticky; top: 0; z-index: 5; }
.bar-in { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 12px; max-width: 640px; margin: 0 auto; }
.bar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: .04em; }
.who { font-size: 12px; color: var(--band-sub); }
.who b { color: var(--band-ink); font-weight: 600; margin-left: 4px; padding: 2px 8px; border: 1px solid rgba(255,255,255,.28); border-radius: 99px; }

main { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; }

/* 底部分页 */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--rule); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--sub); }
.tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current='page'] { color: var(--green); font-weight: 600; }

/* 通用块 */
.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; margin-bottom: 12px; }
.h { font-size: 13px; color: var(--sub); margin: 18px 4px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.h:first-child { margin-top: 4px; }
.h b { color: var(--ink); font-size: 15px; font-weight: 700; }
.muted { color: var(--sub); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--rule); background: var(--card); border-radius: 99px; padding: 7px 14px; font-size: 14px; white-space: nowrap; }
.chip[aria-pressed='true'] { background: var(--band); border-color: var(--band); color: #fff; font-weight: 600; }
.chip.add { border-style: dashed; color: var(--green); }
.chip input[type=date] { border: 0; background: none; padding: 0; width: 7.5em; font-family: var(--num); }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 7px 0; font-size: 14px; color: var(--sub); }
.seg button[aria-pressed='true'] { background: var(--band); color: #fff; font-weight: 600; }

/* 填报凭证 */
.voucher { padding: 0; overflow: hidden; }
.voucher-head { background: var(--band); color: #fff; padding: 14px 16px 16px; display: flex; justify-content: space-between; align-items: flex-end; }
.voucher-head .t { font-size: 20px; font-weight: 700; }
.voucher-head .d { font-family: var(--num); font-size: 17px; color: var(--band-sub); }
.voucher-perf { height: 10px; background: radial-gradient(circle at 5px -1px, var(--bg) 4px, transparent 4.5px) 0 0 / 14px 10px repeat-x, var(--card); }
.row { display: flex; align-items: center; gap: 10px; padding: 4px 16px; min-height: 58px; border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row label { flex: 1; font-size: 15px; white-space: nowrap; }
.row label small { display: block; color: var(--sub); font-size: 12px; }
.row input.v { width: 52%; text-align: right; border: 0; background: none; font-family: var(--num); font-size: 26px; font-weight: 600; padding: 6px 0; outline: none; }
.row input.v::placeholder { color: var(--rule); }
.row .u { color: var(--sub); font-size: 13px; width: 1.6em; }
.row .x { border: 0; background: none; color: var(--sub); font-size: 18px; padding: 4px 2px 4px 6px; }
.row.add-field { gap: 8px; }
.row.add-field input { border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--soft); padding: 8px 10px; min-width: 0; }
.row.add-field input.n { flex: 1; }
.row.add-field input.unit { width: 4.5em; }
.btn-link { border: 0; background: none; color: var(--green); font-weight: 600; padding: 14px 16px; width: 100%; text-align: left; }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--green); color: #fff; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; padding: 15px; font-size: 16px; }
textarea.note { width: 100%; border: 0; background: none; resize: none; padding: 14px 16px; min-height: 56px; outline: none; }
.banner { background: var(--green-soft); color: var(--green); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.banner.warn { background: var(--red-soft); color: var(--red); }

/* 账页：项目 + 右对齐数字 */
.ledger { width: 100%; border-collapse: collapse; }
.ledger th { font-weight: 400; font-size: 12px; color: var(--sub); text-align: right; padding: 0 0 8px; border-bottom: 1.5px solid var(--ink); }
.ledger th:first-child, .ledger td:first-child { text-align: left; }
.ledger td { padding: 11px 0; border-bottom: 1px solid var(--rule); text-align: right; font-family: var(--num); font-size: 17px; font-weight: 500; white-space: nowrap; }
.ledger td:first-child { font-family: var(--cn); font-size: 14px; font-weight: 400; }
.ledger td .s { display: block; font-size: 11px; color: var(--sub); font-family: var(--cn); }
.ledger tr.total td { font-weight: 700; border-bottom: 0; }
.ledger tr.total td.dbl, .dbl { border-bottom: 4px double var(--ink); }
.ledger tr.sep td { padding: 0; border-bottom: 1.5px solid var(--ink); }
.up { color: var(--green); } .down { color: var(--red); } .flat { color: var(--sub); }
.d { font-size: 13px; font-weight: 600; }
.scroll-x { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.scroll-x .ledger td, .scroll-x .ledger th { padding-left: 14px; }
.scroll-x .ledger td:first-child, .scroll-x .ledger th:first-child { padding-left: 0; position: sticky; left: 0; background: var(--card); }

/* 报表头：净额是全页唯一的大字 */
.hero { background: var(--band); color: #fff; border-radius: var(--r-lg); padding: 18px 18px 16px; margin-bottom: 12px; }
.hero .k { color: var(--band-sub); font-size: 13px; display: flex; justify-content: space-between; }
.hero .big { font-family: var(--num); font-weight: 700; font-size: 46px; line-height: 1.1; display: inline-block; margin: 6px 0 14px; padding-bottom: 2px; border-bottom: 5px double rgba(255,255,255,.75); }
.hero .big.neg { color: #ffb4ab; }
.hero .trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid rgba(255,255,255,.16); padding-top: 12px; }
.hero .trio div { font-size: 12px; color: var(--band-sub); }
.hero .trio b { display: block; font-family: var(--num); font-size: 21px; color: #fff; font-weight: 600; }

/* KPI 条 */
.kpi { display: grid; grid-template-columns: 6.5em 1fr 4.6em; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.kpi:last-child { border-bottom: 0; }
.kpi .track { height: 8px; background: var(--soft); border-radius: 99px; position: relative; overflow: hidden; }
.kpi .track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--green); }
.kpi .track i.bad { background: var(--red); } .kpi .track i.mid { background: var(--amber); }
.kpi .track::after { content: ''; position: absolute; left: 66.6%; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .35; }
.kpi .sc { text-align: right; font-family: var(--num); font-weight: 700; font-size: 17px; }
.kpi .sc small { display: block; font-family: var(--cn); font-size: 11px; font-weight: 600; }

/* 图 */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* 记录 */
.day-h { font-family: var(--num); font-size: 14px; color: var(--sub); margin: 16px 4px 6px; display: flex; justify-content: space-between; }
.rec { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--rule); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.rec:last-child { border-bottom: 0; }
.rec .c { flex: 1; min-width: 0; }
.rec .c b { font-weight: 600; }
.rec .c small { display: block; color: var(--sub); font-size: 12px; }
.rec .n { text-align: right; font-family: var(--num); font-size: 16px; font-weight: 600; }
.rec .n small { display: block; font-size: 12px; font-weight: 500; }

/* 成员 */
.mem { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.mem:last-child { border-bottom: 0; }
.mem .av { width: 36px; height: 36px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-weight: 700; flex: none; }
.mem .c { flex: 1; min-width: 0; }
.mem .c small { display: block; color: var(--sub); font-size: 12px; }
.mem .seg { background: var(--soft); flex: none; }
.mem .seg button { padding: 5px 9px; font-size: 12px; }
.mem .acts { display: flex; gap: 6px; }
.mem .acts .btn { padding: 7px 10px; font-size: 13px; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); margin-top: 4px; }
.switch input { accent-color: var(--green); }

.empty { text-align: center; padding: 40px 20px; color: var(--sub); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.gate { text-align: center; padding: 70px 24px; }
.gate .seal { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%; border: 3px double var(--green); display: grid; place-items: center; color: var(--green); font-weight: 700; font-size: 15px; transform: rotate(-8deg); }
.gate b { font-size: 19px; display: block; margin-bottom: 8px; }

#toast { position: fixed; left: 50%; bottom: calc(86px + 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; pointer-events: none; transition: .2s; z-index: 20; max-width: 86vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.skeleton { height: 120px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--card), var(--soft), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.sheet { position: fixed; inset: 0; background: rgba(8,20,16,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-in { background: var(--card); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); display: grid; gap: 14px; }
.sheet-in b { font-size: 17px; }
.sheet-in input { border: 1px solid var(--rule); background: var(--soft); border-radius: 12px; padding: 13px 14px; font-size: 16px; outline: none; }
.sheet-in input:focus { border-color: var(--green); }
.sheet-acts { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
