/* 深色主题 · 色板取自验证过的默认 dataviz 参考实例 */

:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series: #3987e5;
  --series-fill: rgba(57, 135, 229, 0.14);
  --good: #0ca30c;
  --critical: #d03b3b;
  --critical-text: #e66767;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.hidden { display: none !important; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

/* ---------- 登录 ---------- */

.auth-card {
  max-width: 380px;
  margin: 96px auto 0;
  text-align: center;
  padding: 36px 32px;
}

.auth-logo {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--series), #1c5cab);
}

.auth-card h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 24px;
}

#login-form input {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

#login-form input:focus {
  border-color: var(--series);
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 { font-size: 20px; margin: 0; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
}

/* ---------- 按钮 / 表单控件 ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  font-family: inherit;
}

.btn.primary {
  background: var(--series);
  color: #fff;
}

.btn.primary:hover { filter: brightness(1.12); }

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border);
}

.btn.ghost:hover { color: var(--ink); }

.btn.ghost.danger { color: var(--critical-text); }

.btn.block { display: block; width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

select {
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--baseline);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}

.error {
  color: var(--critical-text);
  font-size: 13px;
  margin: 10px 0 0;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 18px 0;
  margin: 0;
}

/* ---------- 测速主区 ---------- */

.hero-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.hero-num {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-unit {
  font-size: 16px;
  color: var(--muted);
  margin-left: 8px;
}

.hero-state {
  text-align: right;
}

.stat-label,
.metric-label,
.tile-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

#state-text { font-size: 14px; color: var(--ink-2); }

.metrics-row {
  display: flex;
  gap: 28px;
  margin-top: 14px;
}

.metric-val { font-size: 15px; }

.metric-val b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 6px;
  background: var(--grid);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 18px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--series);
  border-radius: 999px;
  transition: width 0.2s linear;
}

#live-chart {
  width: 100%;
  height: 150px;
  margin-top: 16px;
  display: block;
}

.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.controls .btn { margin-left: auto; }

/* ---------- 历史 ---------- */

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.history-head h2 {
  font-size: 16px;
  margin: 0;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.tile-num {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-box {
  position: relative;
  margin-bottom: 8px;
}

#trend-chart {
  width: 100%;
  height: 170px;
  display: block;
}

.table-scroll {
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid var(--grid);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 8px;
  white-space: nowrap;
}

td {
  padding: 9px 8px;
  border-top: 1px solid var(--grid);
  color: var(--ink-2);
  white-space: nowrap;
}

th.num, td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.colo-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

/* ---------- 悬浮提示 ---------- */

.tooltip {
  position: fixed;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  color: var(--ink-2);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.tooltip b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .hero-num { font-size: 42px; }
  .metrics-row { gap: 18px; }
  .card { padding: 18px; }
}
