:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  --background: #0b0f14;
  --surface: #121820;
  --surface-muted: #171e27;
  --surface-hover: #1b2430;
  --border: #27313d;
  --border-strong: #364352;
  --text: #edf2f7;
  --muted: #8d9aaa;
  --subtle: #667485;
  --accent: #52b9e9;
  --accent-strong: #7dd3fc;
  --accent-ink: #07131a;
  --success: #65d58a;
  --danger: #f07c8c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
}

button,
input { font: inherit; }

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

button:hover { background: var(--accent-strong); }
button:disabled { opacity: .58; cursor: wait; }

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(82, 185, 233, .26);
  outline-offset: 2px;
}

button.secondary {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

button.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

button.quiet:hover {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

button.danger {
  border-color: rgba(240, 124, 140, .3);
  background: rgba(240, 124, 140, .1);
  color: #ffabb7;
}

button.danger:hover { background: rgba(240, 124, 140, .18); }
button.compact { min-height: 32px; padding: 5px 9px; font-size: 12px; }

h1,
h2,
p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: -.03em;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  letter-spacing: -.01em;
}

.eyebrow,
.panel-kicker {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* 登录页只保留一个必要操作面板。 */
.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 392px);
}

.login-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(0, 0, 0, .22);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 20px;
  font-weight: 800;
}

.login-card h1 { font-size: 28px; }
.login-description { margin: 10px 0 26px; color: var(--muted); }

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: #c6d0db;
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  background: #0d131a;
  color: var(--text);
}

.login-form button { width: 100%; margin-top: 4px; }

.login-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: #ffabb7;
  font-size: 13px;
}

/* 数据页使用平面层级，避免登录与运营内容混杂。 */
.dashboard-page > main {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 64px;
}

.page-header,
.header-actions,
.panel-heading,
.section-heading,
.range-switcher,
.legend,
.actions {
  display: flex;
  align-items: center;
}

.page-header,
.panel-heading,
.section-heading { justify-content: space-between; }

.page-header {
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-actions { gap: 8px; }
.updated-at { margin-right: 4px; color: var(--subtle); font-size: 12px; }

#message {
  min-height: 20px;
  margin: 0 0 12px;
  color: #ffabb7;
  font-size: 13px;
}

.range-switcher {
  width: max-content;
  gap: 3px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.range-button {
  min-height: 32px;
  padding: 5px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.range-button:hover { background: var(--surface-hover); color: var(--text); }
.range-button.active { background: #203344; color: var(--accent-strong); }

.panel,
.metrics article,
.table-wrap {
  border: 1px solid var(--border);
  background: var(--surface);
}

.panel { border-radius: 13px; padding: 19px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metrics article {
  min-height: 108px;
  padding: 15px;
  border-radius: 11px;
}

.metrics span,
.metrics small,
.runtime-metrics span {
  display: block;
  color: var(--muted);
}

.metrics span { font-size: 12px; font-weight: 650; }

.metrics strong {
  display: block;
  margin: 9px 0 4px;
  font-size: clamp(23px, 2.4vw, 31px);
  letter-spacing: -.035em;
}

.metrics small { font-size: 11px; }

.trend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.chart-panel { min-width: 0; }
.panel-heading { align-items: flex-start; gap: 14px; margin-bottom: 8px; }

.legend {
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 11px;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.cyan { background: #22d3ee; }
.legend-dot.violet { background: #a78bfa; }
.legend-dot.blue { background: #60a5fa; }
.legend-dot.red { background: #fb7185; }
.legend-dot.amber { background: #fbbf24; }
.legend-dot.green { background: #4ade80; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.grid-line { stroke: #2b3541; stroke-width: 1; stroke-dasharray: 4 6; }
.axis-label { fill: #708092; font-size: 10px; }

.operations-panel { margin-top: 12px; }

.runtime-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--border);
}

.runtime-metrics div { padding: 13px; background: var(--surface-muted); }
.runtime-metrics span { font-size: 11px; }
.runtime-metrics strong { display: block; margin-top: 5px; font-size: 15px; }

.enrollment-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 12px;
}

.enrollment-card p:last-child { margin: 7px 0 0; color: var(--muted); }

.enrollment-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(101, 213, 138, .25);
  border-radius: 999px;
  background: rgba(101, 213, 138, .09);
  color: #8ee7aa;
  font-size: 12px;
  font-weight: 700;
}

.gateway-section { margin-top: 24px; }
.section-heading { margin-bottom: 10px; }

.count-pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
}

.table-wrap { overflow: auto; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }

th,
td {
  padding: 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .05em;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-muted); }
.gateway-name { display: block; margin-bottom: 4px; }
code { color: var(--subtle); font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #687687;
}

.status.online { color: #92e6ac; }
.status.online::before { background: var(--success); }
.status.disabled { color: #ffabb7; }
.status.disabled::before { background: var(--danger); }
.actions { gap: 6px; }
.empty-row { padding: 36px; color: var(--muted); text-align: center; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .dashboard-page > main { width: min(100% - 24px, 720px); padding-top: 22px; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 16px; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .updated-at { flex: 1 0 100%; }
  .trend-grid { grid-template-columns: 1fr; }
  .enrollment-card { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .login-page { padding: 16px; }
  .login-card { padding: 24px 20px; }
  .login-card h1 { font-size: 25px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article { min-height: 102px; padding: 13px; }
  .panel { padding: 15px; }
  .panel-heading { flex-direction: column; }
  .legend { justify-content: flex-start; }
  .header-actions button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
