:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --violet: #7c3aed;
  --amber: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
  --tx-color: #2563eb;
  --rx-color: #10b981;
  --grid-line: rgba(100, 116, 139, 0.16);
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #172033;
  --border: #1f2937;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --emerald: #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.16);
  --violet: #a78bfa;
  --amber: #fbbf24;
  --danger: #f87171;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --tx-color: #60a5fa;
  --rx-color: #34d399;
  --grid-line: rgba(148, 163, 184, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 20px 14px 40px;
}

.shell {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-title { display: flex; align-items: center; gap: 8px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--emerald-soft);
  color: var(--emerald);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.sync-pill {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-variant-numeric: tabular-nums;
}

.theme-btn {
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
}

.theme-btn:hover { border-color: var(--primary); color: var(--primary); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.hero-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.plan-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.plan-row h1 { font-size: 20px; font-weight: 700; }

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 6px;
}
.chip-primary { background: var(--primary-soft); color: var(--primary); }
.chip-muted { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.spec-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.spec-sep { opacity: 0.45; }

.route-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.route-pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.billing-meta { text-align: right; }
@media (max-width: 680px) { .billing-meta { text-align: left; } }
.price-val { font-size: 20px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.price-val small { font-size: 12px; font-weight: 500; color: var(--muted); }
.countdown { font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.uptime-line { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 15px; font-weight: 700; }
.head-note { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; display: inline-block; }
.sub-line { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }

.pct-pill {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.traffic-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 900px) { .traffic-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .traffic-stats { grid-template-columns: 1fr; } }

.t-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.t-label { font-size: 12px; color: var(--muted); }
.t-val { font-size: 14px; font-variant-numeric: tabular-nums; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 880px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card { padding: 15px 16px; }
.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.kpi-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.net-pair { display: flex; gap: 10px; font-size: 16px; align-items: baseline; }
.up-txt { color: var(--tx-color); }
.down-txt { color: var(--rx-color); }

.kpi-bar { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.kpi-bar-fill { height: 100%; border-radius: 999px; transition: width 0.35s ease; }
.kpi-blue { background: #3b82f6; }
.kpi-violet { background: var(--violet); }
.kpi-amber { background: var(--amber); }
.kpi-emerald { background: var(--emerald); }
.kpi-foot { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.split-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
}
@media (max-width: 820px) { .split-grid { grid-template-columns: 1fr; } }

.legend { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.lg-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-tx { background: var(--tx-color); }
.dot-rx { background: var(--rx-color); }

.svg-wrap { width: 100%; height: 200px; }
#bw-chart { width: 100%; height: 100%; display: block; }

.ping-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.ping-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.ping-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 7px; }
.ping-name strong { font-weight: 700; }
.ping-route { font-size: 11px; color: var(--muted); margin-left: 6px; }
.ping-ms { font-weight: 700; font-variant-numeric: tabular-nums; }
.ping-track { height: 6px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.ping-fill { height: 100%; border-radius: 999px; transition: width 0.35s ease; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
@media (max-width: 900px) { .health-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .health-grid { grid-template-columns: repeat(2, 1fr); } }

.h-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.led-ok { background: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-soft); }
.led-bad { background: var(--danger); }