:root {
  --bg: #0a0f1c;
  --panel: #10182b;
  --panel2: #16213a;
  --border: #1e2b47;
  --text: #dbe6f5;
  --dim: #8fa3bf;
  --faint: #64778f;
  --accent: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --crit: #f87171;
  --purple: #a78bfa;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #12203c 0%, var(--bg) 65%);
  z-index: 100;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 36px; width: 340px; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 20px; margin: 12px 0 6px; }
.login-sub { color: var(--faint); font-size: 12px; margin-bottom: 24px; }
.login-card input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; margin-top: 14px; padding: 11px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb); color: #fff; font-size: 15px;
  font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: .6; }
.login-err { color: var(--crit); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 布局 ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(10,15,28,.92); backdrop-filter: blur(8px); z-index: 20;
}
.brand { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 20px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.off { background: var(--crit); box-shadow: 0 0 6px var(--crit); }
.head-right { display: flex; align-items: center; gap: 14px; }
.clock { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--dim);
  padding: 5px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

nav {
  display: flex; gap: 4px; padding: 10px 16px 0; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
nav::-webkit-scrollbar { display: none; }
nav button {
  background: transparent; border: none; color: var(--dim); font-size: 14px;
  padding: 8px 16px 10px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.range-bar { display: flex; align-items: center; gap: 6px; padding: 12px 20px 0; flex-wrap: wrap; }
.range-label { color: var(--faint); font-size: 12px; margin-right: 4px; }
.range-bar button {
  background: var(--panel); border: 1px solid var(--border); color: var(--dim);
  padding: 5px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.range-bar button.on { background: rgba(56,189,248,.12); border-color: var(--accent); color: var(--accent); font-weight: 600; }

main { padding: 16px 20px 40px; max-width: 1440px; margin: 0 auto; }
footer { text-align: center; color: var(--faint); font-size: 12px; padding: 20px 0 30px; }

/* ---------- 告警横幅 ---------- */
.alert-banner {
  padding: 10px 20px; font-size: 13px; line-height: 1.7;
  background: linear-gradient(90deg, rgba(248,113,113,.18), rgba(248,113,113,.08));
  border-bottom: 1px solid rgba(248,113,113,.4); color: #fecaca;
}
.alert-banner.warn-only {
  background: linear-gradient(90deg, rgba(251,191,36,.15), rgba(251,191,36,.06));
  border-bottom-color: rgba(251,191,36,.4); color: #fde68a;
}
.alert-banner b { margin-right: 8px; }

/* ---------- 卡片与网格 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin-bottom: 16px;
}
.card-title { color: var(--dim); font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.rt-badge {
  font-size: 10px; color: var(--ok); border: 1px solid rgba(52,211,153,.4);
  padding: 1px 6px; border-radius: 20px; font-weight: 500;
}
.sec-title { font-size: 15px; margin: 22px 0 12px; color: var(--text); }
.sec-hint { font-size: 12px; color: var(--faint); font-weight: 400; }

.grid { display: grid; gap: 16px; }
.grid .card { margin-bottom: 0; }
.grid { margin-bottom: 16px; }
.gauges { grid-template-columns: repeat(4, 1fr); }
.two { grid-template-columns: repeat(2, 1fr); }
.stats { grid-template-columns: repeat(4, 1fr); }
.probes { grid-template-columns: repeat(2, 1fr); }
.certs { grid-template-columns: repeat(2, 1fr); }

.gauge { height: 150px; }
.gauge-sub { text-align: center; color: var(--faint); font-size: 12px; min-height: 17px; }

.chart { height: 240px; }
.chart.tall { height: 280px; }
.chart.xtall { height: 380px; }

/* 统计小卡 */
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.stat-label { color: var(--faint); font-size: 12px; margin-bottom: 6px; }
.stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--faint); font-size: 11px; margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.crit { color: var(--crit); }

/* 每核占用条 */
.core-bars { display: flex; flex-direction: column; gap: 8px; }
.core-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--faint); }
.core-row .bar { flex: 1; height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.core-row .fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .5s; }
.core-row .pct { width: 46px; text-align: right; font-variant-numeric: tabular-nums; color: var(--dim); }

/* 服务状态 */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.svc {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel2); border-radius: 10px; border: 1px solid transparent;
}
.svc .sdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.svc.ok .sdot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.svc.bad { border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.08); animation: pulse 1.2s infinite; }
.svc.bad .sdot { background: var(--crit); box-shadow: 0 0 8px var(--crit); }
@keyframes pulse { 50% { border-color: rgba(248,113,113,.9); } }
.svc-name { font-size: 13px; font-weight: 600; }
.svc-meta { font-size: 11px; color: var(--faint); margin-top: 2px; }
.svc.bad .svc-meta { color: #fca5a5; }

/* 表格 */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--faint); font-weight: 500; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid rgba(30,43,71,.5); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; }
th.num { text-align: right; }
.cmd-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--dim); }
.mini-bar { display: inline-block; height: 6px; background: var(--accent); border-radius: 3px; vertical-align: middle; margin-right: 6px; opacity: .7; }

/* 可用性卡片 */
.probe-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.probe-card.bad { border-color: rgba(248,113,113,.6); background: rgba(248,113,113,.06); }
.probe-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.probe-name { font-weight: 700; font-size: 14px; }
.probe-url { color: var(--faint); font-size: 11px; margin-top: 2px; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.pill.ok { background: rgba(52,211,153,.15); color: var(--ok); }
.pill.bad { background: rgba(248,113,113,.18); color: var(--crit); }
.probe-metrics { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.pm { font-size: 12px; color: var(--faint); }
.pm b { display: block; font-size: 16px; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.pm b.ok { color: var(--ok); } .pm b.warn { color: var(--warn); } .pm b.crit { color: var(--crit); }

/* 证书卡片 */
.cert-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: flex; align-items: center; gap: 16px; }
.cert-card.warn { border-color: rgba(251,191,36,.6); }
.cert-card.crit { border-color: rgba(248,113,113,.7); background: rgba(248,113,113,.06); }
.cert-days { font-size: 34px; font-weight: 800; min-width: 86px; text-align: center; font-variant-numeric: tabular-nums; }
.cert-days small { display: block; font-size: 11px; color: var(--faint); font-weight: 400; }
.cert-card.ok .cert-days { color: var(--ok); }
.cert-card.warn .cert-days { color: var(--warn); }
.cert-card.crit .cert-days { color: var(--crit); }
.cert-info { font-size: 12px; color: var(--dim); line-height: 1.8; }
.cert-info b { color: var(--text); font-size: 14px; }

/* error log */
.err-log { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.8; max-height: 320px; overflow-y: auto; color: var(--dim); word-break: break-all; }
.err-log .lv-error, .err-log .lv-crit { color: #fca5a5; }
.err-log .lv-warn { color: #fde68a; }
.err-log div { padding: 2px 0; border-bottom: 1px dashed rgba(30,43,71,.4); }

/* 告警页 */
.alert-item {
  display: flex; align-items: baseline; gap: 12px; padding: 13px 16px; border-radius: 12px;
  margin-bottom: 10px; border: 1px solid; font-size: 13.5px;
}
.alert-item.critical { background: rgba(248,113,113,.09); border-color: rgba(248,113,113,.5); color: #fecaca; }
.alert-item.warning { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.45); color: #fde68a; }
.alert-item .when { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.lv-tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 700; flex-shrink: 0; }
.lv-tag.critical { background: var(--crit); color: #300; }
.lv-tag.warning { background: var(--warn); color: #430; }
.empty-tip { color: var(--faint); padding: 24px; text-align: center; background: var(--panel); border: 1px dashed var(--border); border-radius: 12px; margin-bottom: 16px; }

/* ---------- 移动端 ---------- */
@media (max-width: 980px) {
  .gauges { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
  .probes, .certs { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 12px 10px 30px; }
  header { padding: 10px 12px; }
  .clock { display: none; }
  .gauges { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stats { gap: 10px; }
  .grid { gap: 10px; }
  .chart { height: 210px; }
  .chart.tall { height: 230px; }
  .stat-value { font-size: 17px; }
  .range-bar { padding: 10px 12px 0; }
  nav button { padding: 8px 11px 10px; font-size: 13px; }
}
