/* ===================== 设计变量 ===================== */
:root {
  --bg: #0a0c12;
  --bg-soft: #10131c;
  --panel: #141823;
  --panel-2: #1a1f2e;
  --line: #232a3b;
  --line-soft: #1c2231;

  --text: #e8ecf6;
  --text-dim: #8e9bb5;
  --text-faint: #5d6884;

  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-dim: #4f46e5;

  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .7);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性会被 display:grid / display:flex 覆盖，必须显式压掉 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 背景光晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(680px 380px at 12% -6%, rgba(99, 102, 241, .16), transparent 62%),
    radial-gradient(560px 320px at 92% 4%, rgba(56, 189, 248, .10), transparent 60%);
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

/* ===================== 侧边栏 ===================== */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: linear-gradient(180deg, rgba(20, 24, 35, .92), rgba(10, 12, 18, .92));
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px; }

.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-dim));
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .8);
}
.brand-mark svg { width: 19px; height: 19px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: .3px; }
.brand-text span { font-size: 11px; color: var(--text-faint); letter-spacing: .8px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px;
  transition: background .16s, color .16s;
  user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, .20), rgba(99, 102, 241, .05));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item.active svg { opacity: 1; color: var(--accent-2); }

.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-family: var(--mono);
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: var(--text-dim);
}

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }

.health-mini {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--text-dim);
}
.health-mini .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.health-mini span { display: inline-flex; align-items: center; margin-right: 9px; }

/* ===================== 主区 ===================== */
.main { padding: 28px 32px 60px; max-width: 1500px; }

.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; font-weight: 650; letter-spacing: -.2px; }
.page-head .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }
.head-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ===================== 按钮 ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: #202736; border-color: #2e3850; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-dim));
  border-color: transparent;
  box-shadow: 0 6px 18px -8px rgba(99, 102, 241, .9);
}
.btn-primary:hover { background: linear-gradient(140deg, var(--accent-2), var(--accent)); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, .05); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: #fda4af; border-color: #4c1d24; background: #241318; }
.btn-danger:hover { background: #331a20; border-color: #6b2630; }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ===================== 统计卡 ===================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(220px 90px at 100% 0%, rgba(99, 102, 241, .10), transparent 70%);
  pointer-events: none;
}
.stat-label { font-size: 11.5px; color: var(--text-faint); letter-spacing: .4px; }
.stat-value {
  font-size: 27px; font-weight: 660; letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
}
.stat-foot { font-size: 11.5px; color: var(--text-faint); }

.c-good { color: var(--good); }
.c-warn { color: var(--warn); }
.c-bad { color: var(--bad); }
.c-info { color: var(--info); }

/* ===================== 面板 ===================== */
.panel-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 1080px) { .panel-grid { grid-template-columns: 1fr; } }

.panel {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.panel-head h2 { font-size: 14px; font-weight: 600; letter-spacing: .1px; }
.panel-head .hint { font-size: 11.5px; color: var(--text-faint); }
.link { color: var(--accent-2); font-size: 12.5px; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* 健康条 */
.health-bars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: 74px 1fr 46px; align-items: center; gap: 11px; }
.hbar-label { font-size: 12.5px; color: var(--text-dim); }
.hbar-track { height: 8px; border-radius: 999px; background: #1b2130; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.hbar-val { font-size: 12px; font-family: var(--mono); color: var(--text-dim); text-align: right; }

/* 迷你列表 */
.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.mini-row:last-child { border-bottom: none; }
.mini-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.empty-line { padding: 16px 0; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* ===================== 表单 ===================== */
.toolbar { display: flex; gap: 9px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar.inline { margin-bottom: 0; }

.field {
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-width: 130px;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .16); }
.field.grow { flex: 1; min-width: 180px; }
select.field { cursor: pointer; }
textarea.field { resize: vertical; min-height: 150px; font-family: var(--mono); font-size: 12px; line-height: 1.7; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 11.5px; color: var(--text-dim); letter-spacing: .3px; }
.form-row .field { width: 100%; }
.form-hint { font-size: 11px; color: var(--text-faint); line-height: 1.6; }

/* ===================== 表格 ===================== */
.table-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  background: var(--panel);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-faint);
  letter-spacing: .5px;
  background: rgba(255, 255, 255, .022);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255, 255, 255, .022); }
.table .right { text-align: right; }
.table .mono { font-family: var(--mono); font-size: 11.8px; color: var(--text-dim); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 42px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* 状态徽标 */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }

.pill-ok { background: rgba(34, 197, 94, .13); color: #6ee7a0; }
.pill-ok .dot { background: var(--good); box-shadow: 0 0 8px rgba(34, 197, 94, .8); }
.pill-slow { background: rgba(245, 158, 11, .14); color: #fcd34d; }
.pill-slow .dot { background: var(--warn); }
.pill-down { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.pill-down .dot { background: var(--bad); }
.pill-unknown { background: rgba(142, 155, 181, .14); color: var(--text-dim); }
.pill-unknown .dot { background: var(--text-faint); }
.pill-info { background: rgba(56, 189, 248, .14); color: #7dd3fc; }
.pill-info .dot { background: var(--info); }

.tag {
  display: inline-block;
  padding: 1.5px 7px;
  border-radius: 6px;
  background: rgba(99, 102, 241, .15);
  color: var(--accent-2);
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.ip { font-family: var(--mono); font-size: 11.8px; }
.ip-mismatch { color: #fca5a5; }

/* 分组卡片 */
.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.group-card {
  padding: 15px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  position: relative;
}
.group-card h3 { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.group-card .desc { font-size: 11.5px; color: var(--text-faint); margin-bottom: 10px; min-height: 17px; }
.group-card .metrics { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-dim); }
.group-card .metrics b { color: var(--text); font-weight: 600; font-family: var(--mono); }
.group-card .del { position: absolute; top: 10px; right: 10px; }

/* ===================== 弹窗 ===================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 7, 12, .72);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fade .16s ease;
}
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .9);
}
.modal.wide { width: min(720px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
}

/* ===================== Toast ===================== */
.toasts {
  position: fixed; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 9px;
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: slidein .22s ease;
  max-width: 380px;
}
.toast.ok { border-color: rgba(34, 197, 94, .4); }
.toast.err { border-color: rgba(239, 68, 68, .45); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3142; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #38415a; }

/* ===================== 登录页 ===================== */
.login-page {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
  background:
    radial-gradient(700px 400px at 18% -8%, rgba(99, 102, 241, .20), transparent 60%),
    radial-gradient(560px 340px at 88% 8%, rgba(56, 189, 248, .12), transparent 58%),
    var(--bg);
}

.login-card {
  width: min(390px, 100%);
  padding: 34px 32px 26px;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(22, 27, 40, .96), rgba(14, 17, 25, .96));
  border: 1px solid var(--line);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .95);
  backdrop-filter: blur(14px);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .brand-mark {
  width: 50px; height: 50px;
  margin: 0 auto 15px;
  border-radius: 15px;
}
.login-brand .brand-mark svg { width: 26px; height: 26px; }
.login-brand h1 { font-size: 18px; font-weight: 640; letter-spacing: -.2px; }
.login-brand p { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }

#login-form { display: flex; flex-direction: column; gap: 15px; }
#login-form .field { width: 100%; padding: 11px 14px; font-size: 14px; }
#login-form label { font-size: 12px; }

.login-submit {
  margin-top: 5px;
  padding: 11px;
  font-size: 14px;
  justify-content: center;
  width: 100%;
}

.login-error {
  padding: 9px 13px;
  border-radius: 9px;
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .32);
  color: #fca5a5;
  font-size: 12.5px;
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .3px;
}

/* ===================== 用户区 ===================== */
.user-box {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 11px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line-soft);
}
.user-info { display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-avatar {
  width: 26px; height: 26px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), var(--accent-dim));
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.user-name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-actions { display: flex; gap: 6px; }
.user-actions .btn { flex: 1; justify-content: center; padding: 4px 8px; font-size: 11.5px; }
