:root {
  --bg: #0b1020;
  --bg2: #0f1628;
  --card: #131b30;
  --card2: #18213a;
  --line: #23304d;
  --text: #e6ebf5;
  --muted: #8b96ad;
  --accent: #4f8cff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16224a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.6 "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 26px;
  background: rgba(11, 16, 32, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .3px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.nav { display: flex; gap: 6px; margin-left: 12px; }
.nav a {
  padding: 7px 14px; border-radius: 9px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--card2); color: var(--text); }
.nav a.active { background: var(--card2); color: var(--text); }
.spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1440px; margin: 0 auto; padding: 24px 26px 60px; }
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label { color: var(--muted); font-size: 12px; letter-spacing: .5px; text-transform: uppercase; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* ---------- 服务器卡片 ---------- */
.srv {
  position: relative; cursor: pointer; overflow: hidden;
  transition: transform .15s ease, border-color .15s ease;
}
.srv:hover { transform: translateY(-2px); border-color: #35507f; }
.srv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.srv-name { font-weight: 650; font-size: 15px; }
.srv-ip { color: var(--muted); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.env-生产 { color: #fca5a5; border-color: #7f1d1d; background: #3f1414; }
.badge.env-测试 { color: #93c5fd; border-color: #1e3a8a; background: #10214a; }
.badge.env-Demo { color: #c4b5fd; border-color: #4c1d95; background: #241146; }
.spark { height: 46px; margin: 6px -6px 0; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.metric { background: #0e1526; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.metric .k { font-size: 11px; color: var(--muted); }
.metric .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 999px; background: #1d2740; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .4s ease; }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #101728; position: sticky; top: 0; }
tbody tr:hover { background: #16203a; }
td.wrap-cell { white-space: normal; max-width: 320px; }

/* ---------- 表单 / 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card2); cursor: pointer; transition: .15s;
}
.btn:hover { border-color: #3d5a92; background: #1d2947; }
.btn.primary { background: linear-gradient(180deg, #4f8cff, #2f6ae0); border-color: #3b74e0; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #fca5a5; border-color: #7f1d1d; background: #2a1214; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn.ghost { background: transparent; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #0d1424; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4, 7, 14, .72);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  z-index: 60; padding: 24px;
}
.modal {
  width: min(980px, 100%); max-height: 88vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.modal.narrow { width: min(520px, 100%); }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.close-x { float: right; cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); border: 1px solid transparent; }
.tab:hover { color: var(--text); background: var(--card2); }
.tab.active { background: var(--card2); color: var(--text); border-color: var(--line); }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 100%);
  border: 1px solid var(--line); border-radius: 18px; padding: 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.err { color: #fca5a5; font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- 其它 ---------- */
.ico { display: inline-flex; align-items: center; justify-content: center; vertical-align: -3px; color: var(--muted); }
.ico svg { width: 100%; height: 100%; }

.viewtoggle { display: flex; gap: 6px; margin-left: auto; }
.viewtoggle .btn.active { border-color: var(--accent); color: #cfe0ff; background: #16264a; }

.srv-row { cursor: pointer; }
.srv-row:hover { background: #16203a; }
.cell-metric { display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.cell-metric .bar { width: 64px; margin: 0; }
.hostcell { display: flex; align-items: center; gap: 9px; }
.hostcell .meta { line-height: 1.25; }
.hostcell .meta .nm { font-weight: 600; }

.chart { width: 100%; height: 240px; }
.chart-sm { width: 100%; height: 120px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; z-index: 90;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.err { border-color: #7f1d1d; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 6px; align-items: center; }
.pager .tab { padding: 5px 12px; font-size: 12px; }
