:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #e7ebf0;
  --line-2: #f0f2f5;
  --text: #1d2129;
  --muted: #86909c;
  --primary: #0058e9;
  --primary-2: #1a6fff;
  --primary-soft: #e8f3ff;
  --danger: #f53f3f;
  --warn: #ff7d00;
  --ok: #00b42a;
  --sidebar: #ffffff;
  --sidebar-text: #4e5969;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --header-h: 56px;
  --side-w: 220px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.layout { display: flex; min-height: 100vh; }
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 40;
}
.sidebar {
  width: var(--side-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--line);
  padding: 0 0 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 50;
}
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .02em;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}
.sidebar nav { padding: 8px 10px; }
.sidebar .group {
  font-size: 12px;
  color: var(--muted);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  min-height: 36px;
}
.sidebar a:hover { background: var(--line-2); color: var(--text); }
.sidebar a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text);
  flex-shrink: 0;
}
.nav-toggle svg { display: block; }
.content { padding: 16px; flex: 1; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card > strong:first-child, .card h3 { font-size: 15px; font-weight: 600; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 22px; font-weight: 700; margin-top: 6px; color: var(--text); }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f7f8fa; }
tr:hover td { background: #fafbfc; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  background: #f2f3f5;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  min-height: 32px;
  text-align: center;
  transition: background-color .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.96); }
.btn.ghost { background: #fff; border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--line-2); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.is-busy { opacity: .65; pointer-events: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 2px;
  font-size: 12px;
  background: #f2f3f5;
  color: var(--sidebar-text);
}
.badge.on { background: #e8ffea; color: #009a29; }
.badge.off { background: #ffece8; color: #cb2634; }
.badge.warn { background: #fff7e8; color: #d25f00; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 88, 233, .12);
}
textarea { min-height: 90px; font-family: Consolas, "Courier New", monospace; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 6px; color: var(--text); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
}
.modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal .box {
  background: #fff;
  width: 560px;
  max-width: 100%;
  border-radius: 8px 8px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow: auto;
  transform: translateY(18px);
  transition: transform .22s ease;
}
.modal.show .box { transform: translateY(0); }
.modal .box.wide { width: 720px; }
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.alert { padding: 10px 12px; border-radius: var(--radius); margin: 10px 0; }
.alert.err { background: #ffece8; color: #cb2634; }
.alert.ok { background: #e8ffea; color: #009a29; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f8;
  padding: 16px;
}
.auth-card {
  width: 400px;
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.auth-tabs {
  display: flex;
  margin: -32px -28px 24px;
  border-bottom: 1px solid var(--line);
}
.auth-tabs a {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.auth-tabs a:hover { color: var(--text); background: var(--line-2); }
.auth-tabs a.active {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
  background: transparent;
}
.install-card { width: 640px; }
.env-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.env-head h3 { margin: 0; font-size: 15px; }
.env-table-wrap { overflow: auto; margin: 10px 0; -webkit-overflow-scrolling: touch; }
table.env-table { min-width: 0; }
table.env-table td { white-space: normal; font-size: 13px; vertical-align: top; }
.env-req { font-size: 11px; color: var(--danger); }
.brand { font-size: 22px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 10px; }
code { background: #f2f3f5; padding: 1px 6px; border-radius: 2px; font-size: 12px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-sub.up { color: var(--ok); }
.kpi-sub.down { color: var(--danger); }
.kpi-unit { font-size: 12px; font-weight: 600; color: var(--muted); }
.chart-box {
  height: 240px;
  position: relative;
  margin-top: 8px;
}
.chart-box-sm { height: 180px; }
.chart-box svg { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: #1d2129;
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  display: none;
  z-index: 2;
  white-space: nowrap;
  transform: translate(-50%, -120%);
}
.chart-tabs { display: flex; gap: 6px; }
.chart-tabs .btn.active { background: var(--primary); color: #fff; }
.hbar { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.hbar .name {
  width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  flex-shrink: 0;
  color: var(--text);
}
.hbar .bar {
  flex: 1;
  height: 8px;
  background: #f2f3f5;
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}
.hbar .bar i {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}
.hbar .val { width: 84px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.meter {
  height: 8px;
  background: #f2f3f5;
  border-radius: 4px;
  overflow: hidden;
}
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; max-width: 100%; }
.meter.warn > i { background: var(--warn); }
.meter.danger > i { background: var(--danger); }
.meter-row {
  display: grid;
  grid-template-columns: 36px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-size: 12px;
  color: var(--muted);
}
.meter-row em { font-style: normal; text-align: right; color: var(--text); }
.node-meter { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.node-meter:last-child { border-bottom: 0; }
.node-meter-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quota-row { margin: 12px 0; }
.quota-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.status-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.donut-wrap { display: flex; justify-content: center; margin: 8px 0 16px; }
.chart-donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.chart-donut-legend { font-size: 12px; color: var(--muted); }
.chart-donut-legend div { margin: 4px 0; display: flex; align-items: center; gap: 6px; }
.chart-donut-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
html { overscroll-behavior: none; }
.sidebar { overscroll-behavior: contain; }
.sidebar a { transition: background-color .15s ease, color .15s ease; }
.content { animation: fade-up .22s ease; }
.toast-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #1d2129;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  animation: toast-in .22s ease;
  white-space: pre-wrap;
}
.toast.ok { background: #009a29; }
.toast.err { background: #cb2634; }
.toast.warn { background: #d25f00; }
.toast.out { animation: toast-out .18s ease forwards; }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  font-size: 13px;
}
.empty-row td { white-space: normal; background: #fff !important; }
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 12px 6px 6px;
  font-size: 13px;
  color: var(--text);
}
.step b {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.inline-copy { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meter > i, .hbar .bar i { transition: width .45s ease; }
.auth-card { animation: fade-up .28s ease; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

@media (min-width: 769px) {
  .modal { align-items: center; padding: 16px; }
  .modal .box { border-radius: 8px; padding: 20px; transform: translateY(10px) scale(.98); }
  .modal.show .box { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 8px 0 24px rgba(0,0,0,.12); }
  body.nav-open .sidebar-mask { display: block; }
  body.nav-open { overflow: hidden; }
  .content { padding: 12px; }
  .cards, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; }
  .topbar h1 { font-size: 15px; }
  .card { padding: 12px; }
  .toolbar { align-items: stretch; }
  .toolbar > div { width: 100%; }
  .toolbar .btn, .toolbar > .btn { flex: 1; }
  table { min-width: 640px; }
  th, td { padding: 10px 8px; }
  .btn.sm { min-height: 32px; }
  label { margin: 8px 0; }
  .auth-card { padding: 24px 16px; }
  .install-card { width: 100%; }
  .toast-wrap { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: none; }
}
