:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1c2230; --muted: #6b7384; --line: #e3e6ec;
  --accent: #2563eb; --accent-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --ok-bg: #e7f6ec; --warn-bg: #fdf3e1; --bad-bg: #fdebeb; --chip: #eef1f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --card: #1b2029; --ink: #e8ebf2; --muted: #98a1b3; --line: #2a303c;
    --accent: #6ea0ff; --accent-ink: #0b1220; --ok: #5fd08a; --warn: #f0b35a; --bad: #ff8c8c;
    --ok-bg: #16301f; --warn-bg: #3a2c12; --bad-bg: #3b1c1c; --chip: #262c38;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 24px 12px; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.spread { justify-content: space-between; }
.mt { margin-top: 14px; }

/* 外壳 */
.shell { max-width: 1080px; margin: 0 auto; padding: 0 14px 60px; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); margin: 0 -14px 16px; padding: 0 14px; }
.top .brand { font-weight: 700; padding: 12px 0 4px; display: flex; justify-content: space-between; align-items: center; }
nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
nav::-webkit-scrollbar { display: none; }
nav a { padding: 7px 12px; border-radius: 8px; color: var(--ink); white-space: nowrap; font-size: 14px; }
nav a:hover { background: var(--chip); text-decoration: none; }
nav a.on { background: var(--accent); color: var(--accent-ink); }
nav .count { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; margin-left: 4px; }

.groups { display: flex; gap: 6px; padding: 4px 0 6px; }
.groups a { padding: 5px 14px; border-radius: 16px; border: 1px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 600; }
.groups a:hover { text-decoration: none; background: var(--chip); }
.groups a.on { border-color: var(--accent); color: var(--accent); background: var(--card); }
nav[hidden] { display: none; }

/* 卡片、表格 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.cards .card { margin: 0; }
.big { font-size: 22px; font-weight: 700; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--chip); }
td.sub { color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; margin-top: 4px; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.out { color: var(--ink); }
.in { color: var(--ok); }
.transfer { color: var(--muted); }

/* 表单 */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=datetime-local], input[type=search], select, textarea {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; max-width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button:hover:not(:disabled) { background: var(--chip); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; white-space: nowrap; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field .lab { font-size: 13px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { padding: 6px 14px; cursor: pointer; background: var(--card); border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.decision { background: var(--chip); border-radius: 10px; padding: 12px; margin-top: 10px; }
.decision .field { margin-bottom: 8px; }
.checkline { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
hr.line { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
summary { cursor: pointer; }
.badge button.link { padding: 0 2px; }

/* 标记与提示 */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.notice { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); border-radius: 10px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); color: #fff; }
.login { max-width: 360px; margin: 14vh auto 0; }
.progress { height: 10px; background: var(--chip); border-radius: 5px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair > div { background: var(--chip); border-radius: 10px; padding: 10px 12px; }
.pair .lab { font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .pair { grid-template-columns: 1fr; }
  th, td { padding: 8px 6px; }
  .hide-sm { display: none; }
}

/* 代购 */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--chip); border-radius: 12px; padding: 1px 4px 1px 10px; font-size: 13px; }
.chip button.link { padding: 0 4px; color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs .count { margin-left: 4px; font-size: 12px; opacity: .85; }
.subcard { background: var(--chip); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
input.amt { width: 7em; text-align: right; }
td input[type=text], td input[type=number] { width: 100%; min-width: 4em; }
.sticky-actions { position: sticky; bottom: 0; background: var(--card); padding: 10px 0 2px; border-top: 1px solid var(--line); margin-top: 10px; }
.neg { color: var(--bad); }
