:root {
  --bg: #e9ece7;
  --panel: #ffffff;
  --ink: #18201c;
  --muted: #66706a;
  --line: #d6dbd4;
  --display: #16201b;
  --display-ink: #e8f4ec;
  --display-muted: #8fa597;
  --display-num: #7fe0ac;
  --accent: #1e7a52;
  --accent-ink: #ffffff;
  --ok: #1e7a52;
  --ok-bg: #dff3e7;
  --warn: #9a6200;
  --warn-bg: #fff0cc;
  --bad: #c0332b;
  --bad-bg: #fde3e0;
  --changed: #fff4d1;
  --changed-line: #e2b43c;
  --key: #fbfcfa;
  --shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.num { font-variant-numeric: tabular-nums; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 0 12px calc(84px + env(safe-area-inset-bottom)); }
.app.no-bar { padding-bottom: 24px; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 2px 10px; min-height: 52px; }
.topbar .meta { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .meta b { color: var(--ink); font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: rgba(0, 0, 0, .06); }
.icon-btn svg { width: 20px; height: 20px; }

.pill { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.green { color: var(--ok); background: var(--ok-bg); }
.pill.yellow { color: var(--warn); background: var(--warn-bg); }
.pill.red { color: var(--bad); background: var(--bad-bg); }
button.pill:active { filter: brightness(.95); }

/* 显示屏 */
.display { background: var(--display); color: var(--display-ink); border-radius: 18px; padding: 16px 18px 14px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04); }
.display-label { font-size: 13px; color: var(--display-muted); }
.display-value { font-size: 56px; line-height: 1.05; font-weight: 600; letter-spacing: -.5px; color: var(--display-num); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.display-value small { font-size: 16px; font-weight: 500; color: var(--display-muted); margin-left: 6px; letter-spacing: 0; }
.display-sub { font-size: 14px; color: var(--display-ink); opacity: .85; font-variant-numeric: tabular-nums; }
.display-empty { padding: 26px 0 22px; text-align: center; color: var(--display-muted); font-size: 16px; }
.display-empty strong { display: block; color: var(--display-ink); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.display-error { padding: 14px 0 8px; color: #ffb4ab; font-size: 15px; }

.cells { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 14px; background: rgba(255, 255, 255, .08); border-radius: 12px; overflow: hidden; }
.cell { background: var(--display); padding: 10px 12px; }
.cell .k { font-size: 12px; color: var(--display-muted); }
.cell .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell .v small { font-size: 12px; font-weight: 400; color: var(--display-muted); margin-left: 3px; }
.cell .h { font-size: 12px; color: var(--display-muted); font-variant-numeric: tabular-nums; }

/* 提示 */
.notes { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.notes li { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--warn-bg); color: #5c3d00; }
.notes li.red { background: var(--bad-bg); color: #7d1d17; }
.notes li.info { background: #eef1ed; color: var(--muted); }

/* 明细 */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 12px; }
.card-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 4px; font-size: 13px; color: var(--muted); }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chev { transition: transform .15s; }
details.card[open] > summary .chev { transform: rotate(180deg); }
.kv { display: grid; grid-template-columns: 1fr 1fr; padding: 4px 6px 10px; }
.kv > div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #eef0ec; font-size: 14px; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* 参数键 */
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.key { position: relative; background: var(--key); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 10px 9px; text-align: left; min-height: 66px; border: 1px solid transparent; }
.key:active { transform: translateY(1px); background: #f1f3ef; }
.key .k { display: block; font-size: 12px; color: var(--muted); }
.key .v { display: block; font-size: 19px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.key .v small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.key .v.placeholder { color: #a3aba5; font-weight: 500; font-size: 15px; }
.key.changed { background: var(--changed); border-color: var(--changed-line); }
.key .tag { position: absolute; top: 6px; right: 7px; font-size: 10px; color: #8a6400; background: #ffe7a3; border-radius: 6px; padding: 0 5px; line-height: 16px; }
.key.more { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.key.more .v { font-size: 15px; }

/* 底部按钮 */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: linear-gradient(to top, var(--bg) 70%, rgba(233, 236, 231, 0)); padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.bottombar-inner { max-width: 456px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 16px; white-space: nowrap; border-radius: 14px; font-size: 17px; font-weight: 600; background: var(--panel); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.small { height: 40px; font-size: 15px; padding: 0 14px; border-radius: 11px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 22px; height: 22px; }
.link { color: var(--accent); font-weight: 600; }

/* 次级页面 */
.page-head { display: flex; align-items: center; gap: 6px; padding: 10px 0 6px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.page-head h1 { flex: 1; margin: 0; font-size: 18px; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 4px 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 4px; }

/* 核对页表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 10px; }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 100%; }
table.sheet th, table.sheet td { padding: 0; border-bottom: 1px solid #eef0ec; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
table.sheet th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px; background: #f7f8f6; position: sticky; top: 0; }
table.sheet .name { position: sticky; left: 0; z-index: 1; background: var(--panel); text-align: left; padding: 6px 10px; max-width: 128px; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 #eef0ec; }
table.sheet th.name { z-index: 2; background: #f7f8f6; }
table.sheet .name small { display: block; font-size: 11px; color: var(--muted); }
table.sheet td button { display: block; width: 100%; min-width: 56px; padding: 9px 8px; text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td button:active { background: #eef1ed; }
table.sheet td.bad button { background: var(--bad-bg); color: var(--bad); font-weight: 700; box-shadow: inset 0 0 0 2px var(--bad); border-radius: 6px; }
table.sheet td.maybe button { background: #fff1e0; color: #a14f00; box-shadow: inset 0 0 0 1px #f0a64a; border-radius: 6px; }
table.sheet td.edited button { background: var(--changed); }
table.sheet td.reread button { background: #e3f1ff; }
table.sheet td.empty button { color: #b3bab5; }
table.sheet tr.sum td, table.sheet tr.sum .name { background: #f7f8f6; font-weight: 600; }
table.sheet tr.recalc td, table.sheet tr.recalc .name { background: #f1f6f2; color: var(--muted); }
table.sheet tr.recalc td { padding: 9px 8px; }
table.sheet td.off { color: var(--bad); font-weight: 700; }
.ratios { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ratio-box { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; text-align: left; }
.ratio-box .k { font-size: 12px; color: var(--muted); }
.ratio-box .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ratio-box .r { font-size: 12px; color: var(--muted); }
.ratio-box.bad { box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-bg); }
.note-box { background: #fffbea; border: 1px dashed #e0c877; border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.note-box span { color: var(--muted); font-size: 12px; display: block; }

/* 参数列表 */
.plist { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pitem { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border-bottom: 1px solid #eef0ec; text-align: left; }
.pitem:last-child { border-bottom: 0; }
.pitem:active { background: #f4f6f3; }
.pitem .l { flex: 1; min-width: 0; }
.pitem .l b { font-weight: 500; }
.pitem .l small { display: block; color: var(--muted); font-size: 12px; }
.pitem .r { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 17px; }
.pitem .r small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.pitem.changed { background: var(--changed); }
.seg { display: inline-flex; background: #eceee9; border-radius: 10px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* 弹层与数字键盘 */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(12, 18, 15, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet-modal { width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); animation: rise .18s ease-out; }
.sheet-modal h2 { margin: 0; font-size: 16px; }
.sheet-modal .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kp-screen { background: var(--display); color: var(--display-num); border-radius: 14px; padding: 10px 14px; margin: 12px 0 10px; text-align: right; font-size: 38px; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 64px; overflow-wrap: anywhere; }
.kp-screen small { font-size: 15px; color: var(--display-muted); margin-left: 4px; }
.kp-screen.err { color: #ffb4ab; }
.kp-msg { min-height: 18px; font-size: 13px; color: var(--bad); margin: -4px 2px 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { padding: 7px 12px; border-radius: 999px; background: var(--panel); box-shadow: var(--shadow); font-size: 15px; font-variant-numeric: tabular-nums; }
.chip.suggest { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip small { color: var(--muted); font-size: 12px; margin-right: 4px; }
.kp { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kp button { height: 54px; border-radius: 12px; background: var(--key); box-shadow: var(--shadow); font-size: 22px; font-weight: 500; }
.kp button:active { background: #e6e9e4; }
.kp button.fn { font-size: 16px; color: var(--muted); background: #f1f3ef; }
.kp button.ok { grid-row: span 2; height: auto; background: var(--accent); color: #fff; font-size: 18px; font-weight: 600; }
.kp button.zero { grid-column: span 2; }

/* 进度 */
.progress { position: fixed; inset: 0; z-index: 60; background: rgba(12, 18, 15, .6); display: grid; place-items: center; padding: 24px; }
.progress-box { width: 100%; max-width: 320px; background: var(--display); color: var(--display-ink); border-radius: 18px; padding: 22px 20px; text-align: center; }
.progress-box .step { font-size: 17px; font-weight: 600; margin-top: 12px; }
.progress-box .sec { font-size: 13px; color: var(--display-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: rgba(255, 255, 255, .12); border-radius: 4px; overflow: hidden; margin-top: 14px; }
.bar i { display: block; height: 100%; width: 30%; background: var(--display-num); border-radius: 4px; animation: slide 1.2s ease-in-out infinite; }
.spinner { width: 36px; height: 36px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--display-num); animation: spin .9s linear infinite; }

/* 登录 */
.login { min-height: 90vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 0 8px; }
.login h1 { margin: 0; font-size: 24px; }
.login p { margin: 0; color: var(--muted); }
.field { width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); padding: 0 14px; font-size: 18px; outline: none; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30, 122, 82, .15); }
.err-text { color: var(--bad); font-size: 14px; min-height: 20px; }

/* 管理与测试 */
.row-list { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; border-bottom: 1px solid #eef0ec; text-align: left; font-size: 14px; }
.row-item:last-child { border-bottom: 0; }
.row-item .l { flex: 1; min-width: 0; }
.row-item .l small { display: block; color: var(--muted); font-size: 12px; }
.row-item .r { text-align: right; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; text-align: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
pre.json { background: #f4f6f3; border-radius: 10px; padding: 10px; font-size: 12px; overflow: auto; max-height: 240px; margin: 6px 0 0; }
.upload { display: grid; gap: 8px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.upload label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.upload input[type=text] { height: 42px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(10px); background: #1d2622; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: 88vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

@media (max-width: 360px) {
  .display-value { font-size: 46px; }
  .key .v { font-size: 17px; }
  .kv { grid-template-columns: 1fr; }
  .kv > div:nth-last-child(2) { border-bottom: 1px solid #eef0ec; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
