:root {
  --bg: #0f1420;
  --bg-soft: #161d2c;
  --card: #1a2232;
  --card-hover: #1f2940;
  --line: #253046;
  --text: #e6edf7;
  --text-dim: #8d9bb5;
  --text-mute: #63718c;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #172033 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login-layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(800px 400px at 50% 0%, #1b2b3f 0%, #0b0f17 70%);
  z-index: 100;
}
.login-card {
  width: 340px;
  padding: 32px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-title { font-size: 19px; font-weight: 600; letter-spacing: 0.5px; }
.login-sub { font-size: 12px; color: var(--text-mute); margin-top: -8px; }
.login-card input {
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #111827;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  height: 42px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #2dd4bf, #38bdf8);
  color: #06232b;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 2px;
}
.login-card button:disabled { opacity: 0.6; cursor: default; }
.login-tip { min-height: 16px; font-size: 12px; color: var(--danger); }
.login-foot { font-size: 11px; color: var(--text-mute); text-align: center; }

/* ---------------- 主框架 ---------------- */
.main { padding: 0 24px 40px; max-width: 1680px; margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 14px;
  background: linear-gradient(180deg, rgba(15, 20, 32, 0.98), rgba(15, 20, 32, 0.75));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.toolbar { display: flex; gap: 10px; align-items: center; }
.select, .btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.select:hover, .btn:hover { border-color: #34435f; background: var(--card-hover); }
.btn-primary { background: linear-gradient(135deg, #2dd4bf, #38bdf8); color: #06232b; border: none; font-weight: 600; }
.btn-ghost { background: transparent; }

.freshness {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.freshness.bad { color: var(--warn); border-color: #4a3a15; }

/* ---------------- KPI ---------------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute;
  left: 0; top: 0; width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.6;
}
.kpi-label { font-size: 12px; color: var(--text-mute); margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 12px; color: var(--text-mute); margin-left: 4px; font-weight: 400; }
.kpi-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.kpi-sub .up { color: var(--ok); }
.kpi-sub .down { color: var(--danger); }

/* ---------------- 卡片与图表 ---------------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: 1fr; }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.tag {
  font-size: 11px;
  color: var(--text-mute);
  background: #111827;
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.chart { width: 100%; height: 300px; }
.chart-tall { height: 330px; }
.note {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-mute);
  background: #111827;
  border-left: 2px solid #2a3a52;
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
}
.note b { color: var(--warn); font-weight: 600; }

.seg { display: flex; gap: 4px; background: #111827; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg-btn {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 12px; padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.seg-btn.active { background: var(--card-hover); color: var(--accent); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-mute);
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid #1d2739;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.table tbody tr:hover { background: #1c2536; }
.table .num, .table th.num { text-align: right; }
.table-sm { font-size: 12.5px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; color: var(--text-dim); }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; border: 1px solid transparent;
}
.pill.ok { color: var(--ok); background: rgba(52, 211, 153, 0.1); border-color: rgba(52,211,153,0.25); }
.pill.warn { color: var(--warn); background: rgba(251, 191, 36, 0.1); border-color: rgba(251,191,36,0.25); }
.pill.bad { color: var(--danger); background: rgba(248, 113, 113, 0.1); border-color: rgba(248,113,113,0.25); }
.pill.mute { color: var(--text-mute); background: #111827; border-color: var(--line); }

/* ---------------- 日志/告警 ---------------- */
.log-list { margin-top: 10px; max-height: 200px; overflow-y: auto; }
.log-item {
  font-size: 12px; color: var(--text-dim);
  padding: 6px 0; border-bottom: 1px dashed #1d2739;
  display: flex; gap: 8px;
}
.log-item .t { color: var(--text-mute); flex-shrink: 0; }
.log-item.fail .msg { color: var(--danger); }
.log-item.ok .msg { color: var(--text-dim); }

.alert-list { max-height: 420px; overflow-y: auto; }
.alert-item { padding: 10px 0; border-bottom: 1px solid #1d2739; }
.alert-item .head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.alert-item .msg { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.empty { color: var(--text-mute); font-size: 12.5px; padding: 18px 0; text-align: center; }

/* ---------------- 抽屉 ---------------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 480px; max-width: 92vw;
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: slideIn 0.22s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px; overflow-y: auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12px; color: var(--text-dim); }
.form-row input {
  height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #111827; color: var(--text); outline: none; font-size: 13px;
}
.form-row input:focus { border-color: var(--accent); }
.form-row-inline { flex-direction: row; align-items: center; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.form-tip { font-size: 12px; color: var(--text-dim); }
.divider { margin: 22px 0 12px; font-size: 12px; color: var(--text-mute); border-top: 1px solid var(--line); padding-top: 12px; }
.game-list { display: flex; flex-direction: column; gap: 10px; }
.game-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  background: var(--card);
}
.game-item .line1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.game-item .name { font-weight: 600; font-size: 13.5px; }
.game-item .meta { font-size: 12px; color: var(--text-mute); }
.game-item .ops { display: flex; gap: 8px; margin-top: 10px; }
.game-item .ops .btn { height: 28px; font-size: 12px; padding: 0 10px; }

.foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--text-mute);
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #24304a; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
