/* ---------- 设计变量：浅色 / 深色各选一套（深色不是自动反转）---------- */
:root {
  color-scheme: light;
  --page: #f6f6f3; --surface: #fcfcfb; --surface-2: #f3f3ef;
  --ink: #0b0b0b; --ink-2: #52514e; --ink-3: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, .10);
  --accent: #2a78d6; --accent-ink: #fff; --series-1: #2a78d6;
  --good: #0ca30c; --warn: #fab219; --crit: #d03b3b; --good-text: #006300;
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 10px 30px -12px rgba(11, 11, 11, .10);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #fff; --ink-2: #c3c2b7; --ink-3: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
    --accent: #3987e5; --accent-ink: #0b0b0b; --series-1: #3987e5; --good-text: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #fff; --ink-2: #c3c2b7; --ink-3: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
  --accent: #3987e5; --accent-ink: #0b0b0b; --series-1: #3987e5; --good-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink-3); }
.sub { color: var(--ink-2); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; }

/* ---------- 按钮 / 表单 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; white-space: nowrap; font-weight: 550; transition: filter .12s, background .12s; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: transparent; color: var(--crit); border-color: var(--border); }
.btn.danger:hover { background: color-mix(in srgb, var(--crit) 10%, transparent); filter: none; }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); }
.field input, .field select, .input { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); min-width: 0; }
.field input:focus, .field select:focus, .input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { color: var(--crit); font-size: 13px; min-height: 20px; margin: 2px 0 8px; }

/* ---------- 登录页 ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side { position: relative; padding: 56px 56px 40px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 0% 0%, #4d93ee 0%, transparent 60%), linear-gradient(160deg, #1c5cab 0%, #0d366b 100%); overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 56px solid rgba(255, 255, 255, .07); }
.auth-side h1 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; font-weight: 700; }
.auth-side p { margin: 0; opacity: .82; max-width: 30em; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; }
.auth-points .ico { margin-top: 3px; opacity: .9; }
.auth-points b { display: block; font-weight: 600; }
.auth-points span { opacity: .75; font-size: 13px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 24px; margin-bottom: 4px; }
.tabs { display: flex; gap: 22px; margin: 22px 0 18px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; padding: 0 0 10px; color: var(--ink-3); cursor: pointer; font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.auth-side .brand .logo { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- 顶栏 / 布局 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 20px 56px; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-pop button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.menu-pop button:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); display: grid; place-items: center; font-weight: 700; border: 0; cursor: pointer; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.hero-grid { grid-template-columns: 1.75fr 1fr; margin-bottom: 16px; }
.split { grid-template-columns: 1.75fr 1fr; align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.filters { display: flex; gap: 10px; align-items: center; margin: 24px 0 12px; flex-wrap: wrap; }
.filters h2 { margin-right: 8px; }

/* ---------- 套餐 / 大数字 / Meter ---------- */
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.pill { padding: 1px 9px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-size: 12px; font-weight: 600; }
.hero { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 14px; flex-wrap: wrap; }
.hero .v { font-size: 56px; line-height: 1.05; font-weight: 700; letter-spacing: -.03em; }
.hero .u { font-size: 20px; color: var(--ink-2); font-weight: 600; }
.hero .of { color: var(--ink-3); font-size: 15px; }
.meter { height: 10px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--meter, var(--accent)) 16%, var(--surface)); }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--meter, var(--accent)); transition: width .5s cubic-bezier(.2, .7, .2, 1); min-width: 0; }
.meter-sm { height: 6px; }
.facts { display: flex; gap: 28px; margin-top: 16px; flex-wrap: wrap; }
.fact .k { font-size: 12px; color: var(--ink-3); }
.fact .v { font-weight: 600; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 13px; color: var(--ink-2); }
.stat .v { font-size: 28px; font-weight: 680; letter-spacing: -.02em; line-height: 1.2; }
.stat .s { font-size: 12px; color: var(--ink-3); }
.warn-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); }
.warn-note.crit { background: color-mix(in srgb, var(--crit) 12%, var(--surface)); }

/* ---------- 分段控件 ---------- */
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 550; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* ---------- 图表 ---------- */
.chart { position: relative; transition: opacity .15s; }
.chart.loading { opacity: .5; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg:focus-visible { outline-offset: 4px; }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-axis { stroke: var(--axis); stroke-width: 1; }
.ch-tick { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.ch-area { fill: var(--series-1); opacity: .10; }
.ch-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.ch-cross { stroke: var(--axis); stroke-width: 1; }
.ch-end { fill: var(--ink-2); font-size: 12px; font-weight: 600; font-family: var(--font); }
.ch-empty { fill: var(--ink-3); font-size: 13px; font-family: var(--font); }
.ch-tip { position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 10px 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; }
.ch-tip .d { color: var(--ink-3); margin-bottom: 4px; }
.ch-tip .m { display: flex; align-items: center; gap: 8px; }
.ch-tip .m b { font-size: 16px; font-weight: 700; }
.ch-tip .key { width: 14px; height: 2px; background: var(--series-1); border-radius: 2px; flex: none; }
.ch-tip .r { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.scroll { overflow: auto; max-height: 340px; }
.scroll-x { overflow-x: auto; }
.hbars { display: grid; gap: 12px; }
.hbar .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; gap: 10px; }
.hbar .bar { height: 14px; background: none; }
.hbar .bar i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }

/* ---------- 隧道 ---------- */
.tunnel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.tunnel:last-child { border-bottom: 0; }
.tunnel .name { font-weight: 650; }
.tag { display: inline-block; padding: 0 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 11px; font-weight: 600; margin-left: 8px; vertical-align: 1px; }
.route { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.route .pub { color: var(--ink); }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); box-shadow: 0 0 0 2px var(--surface); flex: none; }
.dot.on { background: var(--good); }
.empty { text-align: center; padding: 34px 10px; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.keybox { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.keybox .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.dls { display: grid; gap: 8px; margin: 10px 0; }
.dls a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  color: var(--ink); text-decoration: none; }
.dls a:hover { background: var(--surface-2); }
.dls small { color: var(--ink-3); }
.steps { margin: 12px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.steps li { margin: 3px 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); padding: 3px 11px; border-radius: 99px; cursor: pointer; font-size: 12px; color: var(--ink); }
.chip:hover { border-color: var(--accent); }

/* ---------- 弹窗 / 提示 ---------- */
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 24px; background: var(--surface); color: var(--ink); width: min(460px, 92vw); box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35); }
dialog.wide { width: min(720px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .42); backdrop-filter: blur(2px); }
dialog h3 { font-size: 18px; margin-bottom: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px); background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 10px;
  opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; z-index: 100; max-width: 90vw; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 60%, var(--surface)), var(--surface-2)); background-size: 200% 100%;
  animation: sk 1.4s infinite; border-radius: 10px; min-height: 18px; }
@keyframes sk { to { background-position: -200% 0; } }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: 32px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 24px; }
  .auth-side h1 { font-size: 26px; }
  .auth-points { display: none; }
  .hero-grid, .split { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .hero .v { font-size: 46px; }
}
@media (max-width: 560px) {
  .wrap { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .two { grid-template-columns: 1fr; }
  .tunnel { grid-template-columns: 1fr auto; }
  .tunnel .state { grid-column: 1; }
  .topbar-in { gap: 8px; padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
