:root {
  /* Mission-control light — cyan / ice slate */
  --bg: #e8eef5;
  --bg-elevated: #f7fafc;
  --panel: #ffffff;
  --panel-hover: #eef4fa;
  --border: #c5d0de;
  --border-soft: #dbe3ee;
  --text: #0b1829;
  --muted: #526579;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: rgba(15, 118, 110, 0.12);
  --accent: #0369a1;
  --accent-2: #0891b2;
  --ok: #047857;
  --ok-soft: rgba(4, 120, 87, 0.12);
  --bad: #b91c1c;
  --bad-soft: rgba(185, 28, 28, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.12);
  --violet: #0284c7;
  --shadow: 0 12px 32px rgba(11, 24, 41, 0.08);
  --shadow-sm: 0 1px 2px rgba(11, 24, 41, 0.05);
  --radius: 14px;
  --sidebar-w: 260px;
  --topbar-h: 3.15rem;
  --admin-footer-h: 2.5rem;
  --font-sans: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Space Grotesk", "IBM Plex Sans", "PingFang SC", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --grid-line: rgba(15, 118, 110, 0.07);
  --rail: linear-gradient(180deg, #14b8a6 0%, #0f766e 55%, #0369a1 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem 0 1.6rem;
  background: rgba(247, 250, 252, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.topbar-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--brand-strong);
}

.topbar-sep {
  width: 1px;
  height: 1rem;
  background: var(--border);
}

.topbar-page {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-user {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border-soft);
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--brand-strong);
  background: #fff;
  border: 1px solid var(--border);
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  min-width: 4.6rem;
  text-align: center;
}

.main {
  padding: 1.35rem 1.6rem calc(var(--admin-footer-h) + 1.25rem);
  min-width: 0;
  width: 100%;
  flex: 1;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 55% 40% at 92% -8%, rgba(15, 118, 110, 0.13), transparent 58%),
    radial-gradient(ellipse 45% 35% at 0% 100%, rgba(3, 105, 161, 0.08), transparent 55%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

.admin-footer {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 30;
  height: var(--admin-footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
}

.admin-footer p { margin: 0; }

.admin-footer--login {
  left: 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
}

.login-shell {
  min-height: 100vh;
  padding-bottom: var(--admin-footer-h);
}

.admin-footer-preview {
  color: var(--text);
  font-size: 0.85rem;
}

.main > h2 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.section-rail {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.35rem 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-rail span {
  display: inline-grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 4px;
  color: #fff;
  background: var(--brand);
  letter-spacing: 0;
}

/* ── Sidebar ── */
.sidebar {
  position: relative;
  background:
    linear-gradient(180deg, #ffffff 0%, #f4f8fb 100%);
  border-right: 1px solid var(--border);
  padding: 1.1rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: 4px 0 24px rgba(11, 24, 41, 0.04);
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--rail);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0.45rem 1rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 11px;
  background: transparent;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  border: 1px solid var(--border-soft);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-mark svg { width: 1.15rem; height: 1.15rem; color: #fff; }

.brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.brand-text strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text span {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.brand-chip {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 6px;
  padding: 0.22rem 0.4rem;
}

.nav-section {
  margin: 0.65rem 0.55rem 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a9aab;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.58rem 0.7rem;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.nav-link:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.14), rgba(15, 118, 110, 0.05));
  color: var(--brand-strong);
  box-shadow: inset 3px 0 0 var(--brand);
  font-weight: 600;
}

.nav-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  opacity: 0.85;
}

.nav-icon svg { width: 100%; height: 100%; }

.nav-link.active .nav-icon { opacity: 1; color: var(--brand); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-soft);
  display: grid;
  gap: 0.55rem;
}

.sidebar-live {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ok);
  text-transform: uppercase;
}

.sidebar-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.18);
  animation: pulse 2s ease-in-out infinite;
}

.logout { margin: 0; padding: 0; border: none; }

.nav-logout {
  width: 100%;
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  padding: 0.58rem 0.7rem !important;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Dashboard header ── */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.95), rgba(236, 253, 245, 0.55) 45%, rgba(240, 249, 255, 0.7));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.dash-header::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.12), transparent 70%);
  pointer-events: none;
}

.dash-eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dash-eyebrow-code {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #fff;
  background: var(--brand);
  border-radius: 4px;
  padding: 0.12rem 0.35rem;
  letter-spacing: 0;
}

.dash-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.dash-subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 36rem;
}

.dash-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.dash-hud {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dash-hud-item {
  display: grid;
  gap: 0.1rem;
  min-width: 4.2rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-soft);
}

.dash-hud-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #8a9aab;
}

.dash-hud-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}

.dash-hud-value.is-ok { color: var(--ok); }
.dash-hud-value.is-bad { color: var(--bad); }
.dash-hud-value.is-muted { color: var(--muted); }

.dash-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  background: #fff;
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
}

.dash-admin { font-size: 0.78rem; }

.dash-alert {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

/* ── Analytics dashboard ── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.analytics-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.05rem;
  box-shadow: var(--shadow-sm);
  min-height: 8.8rem;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.analytics-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--rail);
}

.analytics-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(15, 118, 110, 0.35);
}

.analytics-card-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.analytics-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid rgba(14, 116, 144, 0.22);
}

.analytics-badge--soft {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.12);
}

.analytics-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.analytics-metric { min-width: 0; flex: 1; }

.analytics-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.analytics-value {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.analytics-value--sm { font-size: 1.35rem; }

.analytics-foot {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.analytics-chart {
  flex-shrink: 0;
  width: 4.5rem;
  height: 4.5rem;
  position: relative;
}

.analytics-chart--donut canvas {
  width: 100% !important;
  height: 100% !important;
}

.analytics-row {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.analytics-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.analytics-row--2 { grid-template-columns: 1.35fr 1fr; }

.analytics-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.analytics-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--rail);
  opacity: 0.85;
}

.analytics-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.analytics-panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.analytics-panel-chart {
  position: relative;
  height: 11.5rem;
}

.analytics-panel-chart--compact { height: 9.5rem; }
.analytics-panel-chart--tall { height: 13.5rem; }

.analytics-delta {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.analytics-delta.up {
  color: var(--ok);
  background: var(--ok-soft);
}

.analytics-delta.flat {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.1);
}

/* ── KPI cards (legacy) ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.kpi-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.kpi-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.kpi-icon svg { width: 1.25rem; height: 1.25rem; }

.kpi-icon-blue { background: var(--brand-soft); color: var(--brand); }
.kpi-icon-violet { background: rgba(2, 132, 199, 0.12); color: var(--accent); }
.kpi-icon-green { background: var(--ok-soft); color: var(--ok); }
.kpi-icon-red { background: var(--bad-soft); color: var(--bad); }
.kpi-icon-amber { background: var(--warn-soft); color: var(--warn); }

.kpi-body { min-width: 0; }

.kpi-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.kpi-value {
  margin: 0.15rem 0 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-value-sm { font-size: 1.25rem; }

.kpi-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.1rem;
}

.kpi-foot {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Dashboard panels ── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dash-panel { margin-bottom: 0; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.panel-desc {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.panel-link {
  font-size: 0.82rem;
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
}

.panel-link:hover { text-decoration: underline; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill.ok { background: var(--ok-soft); color: var(--ok); }
.status-pill.bad { background: var(--bad-soft); color: var(--bad); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}

.metric-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  font-size: 0.82rem;
  word-break: break-all;
}

.node-status-hint {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border-soft);
}

.login-node-alert {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.login-node-alert strong {
  font-size: 0.9rem;
}

.login-submit:disabled,
.login-card input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.panel-actions { margin-top: 0; }

.panel-note {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.82rem;
  color: var(--muted);
}

.panel-note summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  user-select: none;
}

.panel-note p { margin: 0.5rem 0 0; }

.config-dl { margin: 0 0 1rem; }

.config-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.85rem;
}

.config-row:last-child { border-bottom: none; }

.config-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.config-row dd { margin: 0; min-width: 0; }

.channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.channel-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
}

.channel-chip.on {
  background: var(--ok-soft);
  border-color: rgba(34, 197, 94, 0.25);
}

.channel-chip.off {
  background: rgba(143, 163, 191, 0.06);
}

.channel-name { font-weight: 500; }

.channel-state { color: var(--muted); font-size: 0.78rem; }
.channel-chip.on .channel-state { color: var(--ok); }

/* ── Quick links ── */
.quick-links h3 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.quick-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.quick-item:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.quick-icon-svg {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--brand);
  opacity: 0.9;
}

.quick-icon-svg svg { width: 100%; height: 100%; }

.quick-icon { font-size: 1.1rem; line-height: 1; }

.quick-label {
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.quick-desc {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Cards & forms (shared) ── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  width: 100%;
  box-shadow: var(--shadow);
}

.stat { font-size: 2rem; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f5f8fb;
}

input, select, textarea, button { font: inherit; }

input, select, textarea {
  width: 100%;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

button, .btn {
  background: linear-gradient(180deg, #14b8a6 0%, var(--brand) 55%, var(--brand-strong) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, filter 0.15s;
  box-shadow: 0 1px 2px rgba(15, 28, 46, 0.12);
}

button:hover, .btn:hover { opacity: 0.92; }

button:disabled,
.btn:disabled,
button.is-loading,
.btn.is-loading {
  opacity: 0.72;
  cursor: wait;
  pointer-events: none;
}

form.is-submitting {
  cursor: wait;
}

form.is-submitting input:not([type="hidden"]),
form.is-submitting select,
form.is-submitting textarea {
  pointer-events: none;
  opacity: 0.92;
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.secondary:hover { background: var(--panel-hover); opacity: 1; }

.btn.danger-outline {
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--bad);
}

.btn.danger-outline:hover {
  background: var(--bad-soft);
  opacity: 1;
}

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; width: 100%; }

.form-stack { display: grid; gap: 0.75rem; width: 100%; }
.form-stack label { display: grid; gap: 0.35rem; }
.form-stack label.checkbox { display: flex; align-items: center; gap: 0.5rem; width: auto; }

.field-label { display: grid; gap: 0.4rem; font-size: 0.88rem; font-weight: 500; color: var(--muted); }

.inline-form { display: grid; gap: 0.4rem; margin-top: 0.5rem; }
.expiry-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.expiry-inline-form input[type="date"] {
  width: auto;
  min-width: 9rem;
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
}

.flash { padding: 0.65rem 0.85rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.88rem; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(34, 197, 94, 0.2); }
.flash.bad { background: var(--bad-soft); color: var(--bad); border: 1px solid rgba(220, 38, 38, 0.22); }

.hint { color: var(--muted); font-size: 0.85rem; }

.checkbox { display: flex; align-items: center; gap: 0.5rem; }
.checkbox input { width: auto; }

/* ── Toggle switch（分段式 ON/OFF，拟物质风格） ── */
.toggle-switch {
  --toggle-w: 4.5rem;
  --toggle-h: 1.75rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  width: auto;
  margin: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: var(--toggle-w);
  height: var(--toggle-h);
  padding: 2px;
  border-radius: 6px;
  background: linear-gradient(180deg, #e8eef5 0%, #d5dee8 100%);
  border: 1px solid var(--border);
  box-shadow:
    inset 0 1px 2px rgba(15, 28, 46, 0.06),
    inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.toggle-highlight {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  border-radius: 4px;
  background: linear-gradient(180deg, #22d3ee 0%, #0e7490 52%, #155e75 100%);
  box-shadow:
    0 1px 2px rgba(15, 28, 46, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
  pointer-events: none;
}

.toggle-segment {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  pointer-events: none;
  transition: color 0.18s ease;
}

.toggle-segment--on {
  color: rgba(148, 163, 184, 0.75);
}

.toggle-segment--off {
  color: rgba(148, 163, 184, 0.75);
}

.toggle-switch input:checked + .toggle-track .toggle-highlight {
  transform: translateX(0);
}

.toggle-switch input:checked + .toggle-track .toggle-segment--on {
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.toggle-switch input:checked + .toggle-track .toggle-segment--off {
  color: rgba(148, 163, 184, 0.55);
}

.toggle-switch input:not(:checked) + .toggle-track .toggle-highlight {
  transform: translateX(calc(100% + 2px));
  background: linear-gradient(180deg, #eef1f5 0%, #d8dee8 52%, #c5ceda 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.toggle-switch input:not(:checked) + .toggle-track .toggle-segment--on {
  color: rgba(148, 163, 184, 0.55);
}

.toggle-switch input:not(:checked) + .toggle-track .toggle-segment--off {
  color: #475569;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.toggle-switch input:disabled + .toggle-track {
  opacity: 0.45;
  cursor: not-allowed;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
}

.toggle-row-desc {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

.toggle-switch--block {
  margin: 0.75rem 0;
}

.section-head .toggle-switch {
  margin-left: auto;
}

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% -15%, rgba(14, 116, 144, 0.14), transparent 55%),
    radial-gradient(ellipse 45% 40% at 100% 90%, rgba(2, 132, 199, 0.08), transparent 50%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

.login-card {
  width: min(420px, 92vw);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.1rem 1.85rem 1.85rem;
  display: grid;
  gap: 1rem;
  box-shadow: var(--shadow);
  margin: auto;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--rail);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.login-brand .brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
}

.login-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-submit {
  margin-top: 0.35rem;
  width: 100%;
  padding: 0.65rem;
  font-size: 0.95rem;
}

/* ── Misc pages ── */
textarea.code { min-height: 360px; width: 100%; font-family: ui-monospace, monospace; font-size: 0.75rem; }
textarea.code.compact { min-height: 120px; }
.config-section h3 { margin: 0; font-size: 1rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.inline-toggle { margin: 0; white-space: nowrap; }
.checkbox-row { margin-top: 0.75rem; }
.grid2 .span2 { grid-column: 1 / -1; }
.period-table { width: 100%; margin: 0.75rem 0 1rem; }
.period-table input { min-width: 8rem; }

pre { background: var(--bg); padding: 0.75rem; border-radius: 8px; overflow: auto; }

.ops-nav { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.ops-nav a {
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.ops-nav a.active, .ops-nav a:hover { border-color: var(--brand); color: var(--brand); }

.ok-text { color: var(--ok); }
.warn-text { color: #d97706; }
.bad-text { color: var(--bad); }

.badge { display: inline-block; padding: 0.15rem 0.45rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.badge.muted { background: rgba(143, 163, 191, 0.12); color: var(--muted); }

.table-wrap { overflow-x: auto; width: 100%; }
.table-wrap table { width: 100%; min-width: 960px; }

code { font-size: 0.8rem; word-break: break-all; font-family: ui-monospace, "Cascadia Code", monospace; }

.hwid-cell { max-width: 14rem; }
.hwid-mono { display: inline-block; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.hwid-detail code { display: inline; max-width: none; white-space: normal; word-break: break-all; }

.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.btn-row form { display: inline; margin: 0; }

.bulk-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.inline-delete { display: inline-block; margin-top: 0.5rem; }
.col-check { width: 2.25rem; text-align: center; }
.col-check input[type="checkbox"] { width: auto; margin: 0; vertical-align: middle; cursor: pointer; }
.flash[data-auto-dismiss] { overflow: hidden; }

.page-head { margin-bottom: 1rem; }
.page-head h2 { margin: 0 0 0.35rem; }
.page-head .hint { margin: 0; }

.page-head-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-head-main { min-width: 0; }

.page-head-actions-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.page-subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.page-subnav a {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.page-subnav a:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
  color: var(--brand-strong);
}

.config-dl.wide .config-row {
  grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr);
  gap: 1.25rem;
  padding: 0.75rem 0;
}

/* ── KV grid（运维结果摘要） ── */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0 1rem;
}

.kv-grid > div {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(148, 163, 184, 0.03);
}

.kv-grid dt {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kv-grid dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.kv-grid dd code {
  font-size: 0.82rem;
}

/* ── Spec list（部署连接等只读配置表） ── */
.spec-list {
  margin: 1rem 0 0.75rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(148, 163, 184, 0.02);
}

.spec-item {
  display: grid;
  grid-template-columns: minmax(10.5rem, 15rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: center;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--border-soft);
}

.spec-item:last-child {
  border-bottom: none;
}

.spec-item:nth-child(even) {
  background: rgba(148, 163, 184, 0.04);
}

.spec-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.spec-label-main {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

.spec-env {
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.spec-value {
  min-width: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.spec-value code {
  display: inline-block;
  max-width: 100%;
  padding: 0.35rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 0.8rem;
  word-break: break-all;
}

.spec-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.spec-badge--ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.spec-badge--muted {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
}

.spec-footnote {
  margin: 0;
}

.spec-actions {
  margin-top: 1rem;
}

.rules-sync-status h3 {
  margin-bottom: 0.25rem;
}

@media (max-width: 700px) {
  .spec-item {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    align-items: start;
  }
}

/* ── Rules guide ── */
.rules-guide { margin-bottom: 1rem; }
.rules-guide-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  user-select: none;
  list-style: none;
}
.rules-guide-summary::-webkit-details-marker { display: none; }
.rules-guide-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.45rem;
  transition: transform 0.15s;
  color: var(--brand);
}
.rules-guide[open] .rules-guide-summary::before { transform: rotate(90deg); }
.rules-guide-body {
  margin-top: 1rem;
  display: grid;
  gap: 1.25rem;
  font-size: 0.88rem;
  color: var(--text);
}
.rules-guide-lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}
.rules-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.rules-guide-body h3 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.rules-guide-body section > p { margin: 0 0 0.5rem; color: var(--muted); line-height: 1.6; }
.guide-list {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.25rem;
  color: var(--muted);
  line-height: 1.65;
}
.guide-list li { margin-bottom: 0.25rem; }
.guide-table {
  width: 100%;
  font-size: 0.82rem;
  margin-top: 0.35rem;
}
.guide-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.guide-table td:first-child { white-space: nowrap; width: 8rem; }
.guide-warn {
  margin: 0.65rem 0 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
  font-size: 0.82rem;
  line-height: 1.55;
}
.guide-code {
  margin: 0.5rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  color: #cbd5e1;
  max-height: 320px;
}
.rules-editor .btn-row { margin-top: 0.25rem; }

.stripe-mode-hint { margin: 0 0 0.85rem; line-height: 1.65; }

.stripe-env-panel {
  margin-top: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
}

.stripe-env-panel[hidden] {
  display: none !important;
}

.stripe-env-panel.is-active {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: inset 3px 0 0 var(--brand);
}

.stripe-env-title {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.stripe-env-panel.is-active .stripe-env-title { color: var(--brand-strong); }

.section-save {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.subscription-pricing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.35);
}

.subscription-rate-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-width: 10rem;
}

.subscription-rate-input {
  width: 8rem;
  max-width: 100%;
}

.subscription-convert-hint {
  flex: 1 1 12rem;
  margin: 0;
  align-self: center;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: auto;
  padding: 0.5rem 1.1rem;
}

.btn-with-icon .btn-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  opacity: 0.92;
}

.btn-with-icon .btn-icon svg {
  width: 100%;
  height: 100%;
}

.raw-json summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  user-select: none;
  margin-bottom: 0.5rem;
}

.raw-json pre { margin-top: 0.75rem; }

.ops-busy {
  display: none;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand-strong);
  font-size: 0.9rem;
}

.ops-busy.is-visible {
  display: block;
}

.ops-busy strong {
  color: var(--brand-strong);
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-row--3 { grid-template-columns: 1fr; }
  .analytics-row--2 { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr; }
  .rules-guide-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border-soft); }
  .sidebar::before { width: 100%; height: 3px; bottom: auto; }
  .admin-footer { left: 0; }
  .topbar { padding-inline: 1rem; }
  .dash-meta { align-items: flex-start; }
}
