:root {
  --bg: #F2F2F7; --card: #FFFFFF; --text: #1C1C1E; --muted: #63636A; --line: #E3E3E8; --track: #E5E5EA;
  --accent: #0B63CE; --accent-bg: #E6F0FC; --red: #C4221B; --red-bg: #FDECEC; --orange: #A75A04; --orange-bg: #FFF2E0;
  --green: #187A3B; --green-bg: #E5F5EA; --purple: #6B3FA0; --purple-bg: #F1EAFB; --chip: #EDEDF1;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1C1C1E; --text: #F2F2F7; --muted: #A1A1A8; --line: #2C2C2E; --track: #3A3A3C;
    --accent: #4C9BFF; --accent-bg: #10243F; --red: #FF6B62; --red-bg: #3A1514; --orange: #FFB04D; --orange-bg: #3A2A12;
    --green: #4CD27A; --green-bg: #123321; --purple: #C9A6FF; --purple-bg: #2B2140; --chip: #2C2C2E;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif; font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.num { font-variant-numeric: tabular-nums; }

/* 顶栏、内容、底部页签 */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); padding: calc(var(--safe-top) + 10px) 16px 8px; }
.top-row { display: flex; align-items: center; gap: 8px; }
.top h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.3px; flex: 1; }
.stamp { font-size: 12px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; }
.icon-btn:active { background: var(--chip); }
.icon-btn[disabled] { opacity: .4; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.view { padding: 4px 16px calc(var(--safe-bottom) + 96px); display: flex; flex-direction: column; gap: 12px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: color-mix(in srgb, var(--card) 92%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding: 6px 4px calc(var(--safe-bottom) + 4px); }
.tab { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 48px; font-size: 11px; font-weight: 600; position: relative; }
.tab[aria-current="page"] { color: var(--accent); }
.tab .badge { position: absolute; top: 2px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* 卡片、提醒 */
.card { background: var(--card); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.tap { cursor: pointer; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head strong { font-size: 17px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.red { background: var(--red); } .dot.orange { background: #E08A1E; } .dot.gray { background: #A1A1A8; } .dot.green { background: #2DB563; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.red { background: var(--red-bg); color: var(--red); } .chip.orange { background: var(--orange-bg); color: var(--orange); }
.chip.green { background: var(--green-bg); color: var(--green); } .chip.blue { background: var(--accent-bg); color: var(--accent); }
.chip.purple { background: var(--purple-bg); color: var(--purple); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.alert { border-radius: 14px; padding: 12px 14px; display: flex; gap: 8px; align-items: flex-start; font-size: 15px; }
.alert.red { background: var(--red-bg); color: var(--red); } .alert.orange { background: var(--orange-bg); color: var(--orange); }
.alert.ok { background: var(--green-bg); color: var(--green); }
.alert b { font-weight: 700; }
.alert svg { flex: none; margin-top: 2px; }
.usage-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.orange > i { background: #E08A1E; } .bar.red > i { background: var(--red); }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b.red { color: var(--red); } .stat b.orange { color: var(--orange); }
.rows { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; font-size: 14px; }
.row > span:first-child { color: var(--muted); }
.row .red { color: var(--red); } .row .orange { color: var(--orange); }
.foot { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.err { color: var(--red); }

/* 按钮、表单 */
.btn { min-height: 44px; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; background: var(--chip); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); color: #FFFFFF; }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; }
.btn[disabled] { opacity: .45; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--chip); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; min-height: 36px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.group { background: var(--card); border-radius: 14px; overflow: hidden; }
.group-title { font-size: 13px; color: var(--muted); padding: 6px 4px 0; }
.opt { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-align: left; min-height: 52px; }
.opt + .opt { border-top: 1px solid var(--line); }
.opt .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #A1A1A8; flex: none; }
.radio.on { border: 7px solid var(--accent); }
.field { display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 52px; }
.field + .field { border-top: 1px solid var(--line); }
.field label { flex: none; width: 72px; color: var(--text); }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; padding: 6px 0; text-align: right; }
.stepper { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.stepper button { width: 40px; height: 36px; border: 0; border-radius: 8px; background: var(--chip); font-size: 20px; line-height: 1; }
.stepper output { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; font-size: 16px; }
.check { font-size: 13px; padding: 0 16px 10px; text-align: right; }
.check.ok { color: var(--green); } .check.bad { color: var(--red); }
.search { width: 100%; border: 0; border-radius: 10px; background: var(--chip); padding: 10px 12px; font-size: 16px; outline: none; }
.scroll-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.scroll-chips::-webkit-scrollbar { display: none; }
.scroll-chips button { flex: none; border: 0; border-radius: 99px; padding: 6px 14px; min-height: 36px; background: var(--chip); font-weight: 600; font-size: 14px; color: var(--muted); }
.scroll-chips button[aria-pressed="true"] { background: var(--accent); color: #FFFFFF; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px; word-break: break-all; background: var(--bg); border-radius: 10px; padding: 10px 12px; user-select: all; -webkit-user-select: all; }
.voided { opacity: .55; }
.voided .code { text-decoration: line-through; }
.mini { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.mini i { flex: 1; background: var(--accent); opacity: .55; border-radius: 2px 2px 0 0; min-height: 1px; }
.mini i:last-child { opacity: 1; }
.mini-labels { display: flex; gap: 3px; font-size: 10px; color: var(--muted); }
.mini-labels span { flex: 1; text-align: center; }

/* 底部弹出层、提示 */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; }
.sheet-wrap[hidden] { display: none; }
.sheet { width: 100%; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 18px 16px calc(var(--safe-bottom) + 18px); display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 20px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 84px); z-index: 30; background: #1C1C1E; color: #FFFFFF; border-radius: 12px; padding: 12px 14px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--red); }
.toast[hidden] { display: none; }

/* 登录页 */
.login { min-height: 100vh; padding: calc(var(--safe-top) + 12vh) 28px calc(var(--safe-bottom) + 24px); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.login img { width: 88px; height: 88px; border-radius: 20px; }
.login h1 { margin: 4px 0 0; font-size: 28px; }
.login .btn.big { margin-top: 18px; max-width: 360px; }
.login .hint { margin-top: 18px; background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: var(--muted); text-align: left; max-width: 360px; }
.login input { width: 100%; max-width: 360px; border: 0; border-radius: 12px; background: var(--card); padding: 12px 14px; font-size: 16px; text-align: center; }
.msg { min-height: 22px; font-size: 14px; }
