:root, [data-theme="dark"] {
  --bg-base: #0B0E11; --bg-card: #181A20; --bg-elevated: #1E2329; --border: #2B3139;
  --text-primary: #EAECEF; --text-secondary: #848E9C; --text-disabled: #5E6673;
  --brand: #F0B90B; --up: #0ECB81; --down: #F6465D; --warning: #F0B90B; --danger: #F6465D; --info: #1E88E5;
  --shadow: none; color-scheme: dark;
}
[data-theme="light"] {
  --bg-base: #FFFFFF; --bg-card: #F5F5F5; --bg-elevated: #FFFFFF; --border: #EAECEF;
  --text-primary: #1E2329; --text-secondary: #707A8A; --text-disabled: #B7BDC6;
  --brand: #C99400; --up: #03A66D; --down: #CF304A; --warning: #C99400; --danger: #CF304A; --info: #1565C0;
  --shadow: 0 2px 8px rgba(0,0,0,.06); color-scheme: light;
}
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    --bg-base: #FFFFFF; --bg-card: #F5F5F5; --bg-elevated: #FFFFFF; --border: #EAECEF;
    --text-primary: #1E2329; --text-secondary: #707A8A; --text-disabled: #B7BDC6;
    --brand: #C99400; --up: #03A66D; --down: #CF304A; --warning: #C99400; --danger: #CF304A; --info: #1565C0;
    --shadow: 0 2px 8px rgba(0,0,0,.06); color-scheme: light;
  }
}
[data-color="red-up"] { --up-swap: var(--down); --down-swap: var(--up); }
:root { --c-up: var(--up-swap, var(--up)); --c-down: var(--down-swap, var(--down)); }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg-base); color: var(--text-primary); }
body {
  font: 15px/22px -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.num { font-family: "DIN Pro", "Roboto Mono", ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.display { font-size: 28px; line-height: 36px; font-weight: 600; }
.h1 { font-size: 20px; line-height: 28px; font-weight: 600; }
.h2 { font-size: 17px; line-height: 24px; font-weight: 500; }
.caption { font-size: 13px; line-height: 18px; }
.micro { font-size: 11px; line-height: 16px; }
.muted { color: var(--text-secondary); }
.disabled { color: var(--text-disabled); }
.up { color: var(--c-up); } .down { color: var(--c-down); }
.warn { color: var(--warning); } .danger-t { color: var(--danger); } .info-t { color: var(--info); }
.right { text-align: right; } .center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.hidden { display: none !important; }

.card { background: var(--bg-card); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card.alert { box-shadow: inset 0 0 0 1px var(--danger); }
.card.click { cursor: pointer; }
.card.click:active { opacity: .85; }
.kv { display: flex; justify-content: space-between; align-items: baseline; min-height: 28px; gap: 12px; }
.kv > :first-child { color: var(--text-secondary); font-size: 13px; }
.kv > :last-child { text-align: right; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 48px; padding: 0 20px;
  border-radius: 8px; border: 0; cursor: pointer; font-weight: 500; min-width: 44px; white-space: nowrap; user-select: none;
}
.btn.block { width: 100%; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.md { height: 40px; padding: 0 16px; }
.btn-primary { background: var(--brand); color: #181A20; }
.btn-secondary { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-text { background: transparent; color: var(--brand); padding: 0 8px; height: 44px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; color: var(--text-secondary); }
.input {
  height: 48px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elevated);
  padding: 0 12px; outline: none; width: 100%;
}
textarea.input { height: auto; padding: 10px 12px; min-height: 80px; }
.input:focus { border-color: var(--brand); }
.input.err { border-color: var(--danger); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 64px; }
.input-wrap .addon { position: absolute; right: 4px; }
.err-text { color: var(--danger); font-size: 13px; }
.hint { color: var(--text-secondary); font-size: 12px; line-height: 16px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--border); border: 0; cursor: pointer; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--up); }
.switch.on::after { transform: translateX(18px); }
.switch:disabled { opacity: .45; }

.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag-up { color: var(--c-up); background: color-mix(in srgb, var(--c-up) 15%, transparent); }
.tag-down { color: var(--c-down); background: color-mix(in srgb, var(--c-down) 15%, transparent); }
.tag-info { color: var(--info); background: color-mix(in srgb, var(--info) 15%, transparent); }
.tag-muted { color: var(--text-secondary); background: color-mix(in srgb, var(--text-secondary) 15%, transparent); }
.tag-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 15%, transparent); }
.tag-warn { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }
.tag-brand { color: var(--brand); background: color-mix(in srgb, var(--brand) 15%, transparent); }

.seg { display: flex; background: var(--bg-elevated); border-radius: 8px; padding: 3px; gap: 3px; }
.seg > button { flex: 1; height: 38px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--text-secondary); }
.seg > button.on { background: var(--bg-card); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--brand); }

.banner { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13px; }
.banner.error { background: color-mix(in srgb, var(--danger) 18%, var(--bg-base)); color: var(--danger); }
.banner.warning { background: color-mix(in srgb, var(--warning) 18%, var(--bg-base)); color: var(--warning); }
.banner.info { background: color-mix(in srgb, var(--info) 18%, var(--bg-base)); color: var(--info); }
.banner .grow { color: inherit; }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(88px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 100; }
.toast { background: var(--bg-elevated); color: var(--text-primary); padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 86vw; font-size: 14px; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { background: var(--bg-elevated); border-radius: 12px; padding: 20px; width: 100%; max-width: 400px; max-height: 86vh; overflow: auto; }
.dialog .title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.dialog .body { color: var(--text-secondary); font-size: 14px; }
.dialog .actions { display: flex; gap: 12px; margin-top: 20px; }
.dialog .actions .btn { flex: 1; }
.mask.sheet { align-items: flex-end; padding: 0; }
.mask.sheet .dialog { max-width: 520px; border-radius: 16px 16px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); animation: up .2s; }
@keyframes up { from { transform: translateY(40px); } }

.skel { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.flash-up { animation: fu .3s; } .flash-down { animation: fd .3s; }
@keyframes fu { from { background: color-mix(in srgb, var(--c-up) 30%, transparent); } }
@keyframes fd { from { background: color-mix(in srgb, var(--c-down) 30%, transparent); } }

.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; position: relative; }
.progress > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand); border-radius: 3px; transition: width .3s; }
.progress.warn > i { background: var(--warning); }
.progress.danger > i { background: var(--danger); }

.list-row { display: flex; align-items: center; min-height: 48px; gap: 8px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); }
.tabs > button { background: none; border: 0; height: 44px; color: var(--text-secondary); cursor: pointer; position: relative; padding: 0; }
.tabs > button.on { color: var(--text-primary); font-weight: 500; }
.tabs > button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-secondary); }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { height: 48px; padding: 0 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; white-space: nowrap; }
table.tbl th { color: var(--text-secondary); font-weight: 400; font-size: 13px; }
table.tbl td.r, table.tbl th.r { text-align: right; }
