:root {
  --bg: #070b12;
  --panel: #0d1523;
  --panel-2: #121c2d;
  --line: rgba(148, 178, 224, .14);
  --line-strong: rgba(148, 178, 224, .26);
  --text: #e8eef8;
  --muted: #8fa1bb;
  --dim: #5b6b83;
  --accent: #4d8dff;
  --accent-soft: rgba(77, 141, 255, .16);
  --mint: #37d6c0;
  --danger: #ff5f6d;
  --danger-soft: rgba(255, 95, 109, .14);
  --warn: #f5b942;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 520px at 12% 0%, rgba(77, 141, 255, .16), transparent 60%),
    radial-gradient(760px 480px at 95% 100%, rgba(55, 214, 192, .10), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.hidden { display: none !important; }

/* ---------------- 登录 / 邀请 / 重置 ---------------- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
}

.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(20, 31, 50, .94), rgba(11, 18, 30, .96));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 21px; color: #04101f;
  background: linear-gradient(135deg, #7fb0ff, var(--mint));
  box-shadow: 0 8px 24px rgba(77, 141, 255, .35);
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.auth-card .brand { margin-bottom: 24px; }
.auth-tip { margin: 14px 0 0; font-size: 12.5px; color: var(--dim); text-align: center; line-height: 1.7; }
.auth-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; text-align: center; }
.auth-ok { min-height: 20px; margin: 10px 0 0; color: var(--mint); font-size: 13px; text-align: center; }

/* ---------------- 表单 ---------------- */

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea, .inp {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(7, 12, 21, .75);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus {
  border-color: rgba(77, 141, 255, .65);
  box-shadow: 0 0 0 3px rgba(77, 141, 255, .14);
}
.field input::placeholder, .field textarea::placeholder { color: var(--dim); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-line {
  display: flex; align-items: center; align-self: end; gap: 9px;
  min-height: 42px; margin-bottom: 14px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); background: rgba(7, 12, 21, .5);
}
.check-line input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.update-detail { white-space: pre-wrap; overflow-wrap: anywhere; color: #f4d79a; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13.5px;
  white-space: nowrap;
  transition: border-color .15s, background .15s, transform .1s;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }

.btn.primary {
  border: 0; color: #04101f; font-weight: 650;
  background: linear-gradient(135deg, #7fb0ff, var(--mint));
  box-shadow: 0 10px 26px rgba(77, 141, 255, .25);
}
.btn.ghost { background: transparent; }
.btn.danger { color: #ffd6da; border-color: rgba(255, 95, 109, .35); background: var(--danger-soft); }
.btn.small { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; height: 46px; font-size: 15px; }
.btn.link { height: auto; padding: 0; border: 0; background: none; color: var(--accent); }

/* ---------------- 布局 ---------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  flex: none;
  width: 232px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px 18px;
  background: rgba(9, 15, 25, .88);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.sidebar .brand { padding: 0 6px; }
.sidebar .brand h1 { font-size: 17px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}
.nav button:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: #cfe0ff; }
.nav .nav-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }

.side-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.side-foot .who { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who b { color: var(--text); font-weight: 600; }

.main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 30px 70px;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: .2px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stack { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: rgba(13, 21, 35, .82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .card-sub { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat {
  background: rgba(13, 21, 35, .82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
}
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { margin-top: 6px; font-size: 26px; font-weight: 680; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.stat .hint { margin-top: 2px; font-size: 11.5px; color: var(--dim); }
.stat.accent .value { color: #9cc4ff; }
.stat.ok .value { color: var(--mint); }
.stat.danger .value { color: var(--danger); }

.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.metric-list { display: flex; flex-direction: column; gap: 7px; }
.metric-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(7, 12, 21, .4);
}
.metric-row .sub { color: var(--muted); font-size: 12px; text-align: right; }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
td .strong { font-weight: 600; }
td .sub { color: var(--dim); font-size: 11.5px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 22px; text-align: center; color: var(--dim); font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.on { color: #a9f3e6; border-color: rgba(55, 214, 192, .35); background: rgba(55, 214, 192, .10); }
.badge.off { color: #ffc3c8; border-color: rgba(255, 95, 109, .3); background: var(--danger-soft); }
.badge.warn { color: #ffe0a3; border-color: rgba(245, 185, 66, .35); background: rgba(245, 185, 66, .10); }
.badge.info { color: #b9d4ff; border-color: rgba(77, 141, 255, .35); background: var(--accent-soft); }
.badge.muted { color: var(--dim); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: #55637a; display: inline-block; }
.dot.on { background: var(--mint); box-shadow: 0 0 0 3px rgba(55, 214, 192, .14); }
.dot.off { background: var(--danger); }

/* ---------------- 提示 / 空态 ---------------- */

.note {
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(7, 12, 21, .5);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}
.note.warn { border-color: rgba(245, 185, 66, .3); color: #f4d79a; background: rgba(245, 185, 66, .07); }
.note.ok { border-color: rgba(55, 214, 192, .3); color: #b9f3e9; background: rgba(55, 214, 192, .07); }
.note code { color: #cfe0ff; }

/* ---------------- 模态框 ---------------- */

.modal-mask {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background: rgba(3, 6, 12, .72);
  backdrop-filter: blur(6px);
  z-index: 80;
}
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: linear-gradient(180deg, rgba(18, 28, 45, .98), rgba(10, 17, 28, .99));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  padding: 20px 20px 18px;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: 18px; line-height: 1; }
.modal-body { color: var(--text); font-size: 13.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; margin: 10px 0 0; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-all; }

.code-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed rgba(77, 141, 255, .45);
  background: rgba(77, 141, 255, .08);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 20px;
  letter-spacing: 2px;
  color: #cfe0ff;
  word-break: break-all;
}
.code-box.small { font-size: 13px; letter-spacing: 0; }

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .inp { flex: 1; min-width: 0; font-size: 12.5px; }

/* ---------------- 抽屉式详情（复用 modal） ---------------- */

.detail-section { margin-top: 18px; }
.detail-section > h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.detail-section .inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-section .inline-form .inp { flex: 1 1 150px; width: auto; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(7, 12, 21, .45);
  font-size: 12.5px;
}
.list-item .left { min-width: 0; }
.list-item .name { font-weight: 600; color: var(--text); }
.list-item .meta { color: var(--dim); font-size: 11.5px; }

/* ---------------- 提示条 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(8px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 10px;
  background: rgba(18, 28, 45, .98);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 120;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255, 95, 109, .45); color: #ffd6da; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: static; width: auto; min-height: 0;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: 10px; padding: 12px 14px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar .brand p { display: none; }
  .sidebar .brand-mark { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
  .nav { flex-direction: row; flex: 1 1 100%; overflow-x: auto; gap: 6px; }
  .nav button { width: auto; white-space: nowrap; }
  .side-foot { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 10px; }
  .side-foot .who { margin: 0; }
  .main { padding: 18px 16px 60px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .field-row, .overview-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 异常告警 */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: 10px;
  background: rgba(245, 185, 66, .04);
}
.alert-item.critical {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.alert-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
