:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e8edf3;
  --border-strong: #d8e0ea;
  --text: #17212f;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #3370ff;
  --primary-dark: #245bdb;
  --primary-soft: #eaf1ff;
  --primary-grad: linear-gradient(135deg, #3370ff 0%, #5a8bff 60%, #7ba2ff 100%);
  --success: #16a34a;
  --success-soft: #e7f7ee;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 33, 47, 0.04), 0 4px 16px rgba(23, 33, 47, 0.05);
  --shadow-lg: 0 4px 12px rgba(23, 33, 47, 0.06), 0 16px 40px rgba(23, 33, 47, 0.10);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

::selection { background: rgba(51, 112, 255, .18); }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(51, 112, 255, 0.07), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(99, 102, 241, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3 { font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 20% 10%, rgba(51, 112, 255, 0.16), transparent 55%),
    radial-gradient(900px 500px at 85% 85%, rgba(124, 58, 237, 0.12), transparent 55%),
    linear-gradient(160deg, #eef3fb 0%, #e4ebf7 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 40px 34px 32px;
  box-shadow: 0 8px 24px rgba(23, 33, 47, 0.08), 0 32px 80px rgba(23, 33, 47, 0.14);
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 28px; }
.login-card label { display: block; margin-bottom: 16px; font-size: 13px; font-weight: 500; color: var(--muted); }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(51, 112, 255, 0.12); }
.login-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 20px; }

/* ---------- 顶部 ---------- */
.topbar {
  height: 60px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--primary-grad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(51, 112, 255, 0.35);
}
.brand-mark::after {
  content: "🔑"; font-size: 13px; line-height: 1;
}
.brand-text { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.whoami { color: var(--muted); font-size: 13px; }
.mode-badges { display: flex; gap: 6px; }

.badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  border: none;
  background: #f1f5f9;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}
.badge.mock { background: var(--warn-soft); color: var(--warn); }
.badge.real { background: var(--success-soft); color: var(--success); }

/* ---------- 标签页 ---------- */
.tabs {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  gap: 6px;
  position: sticky;
  top: 60px;
  z-index: 19;
}
.tab {
  background: none;
  border: none;
  padding: 13px 16px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  font-weight: 500;
  transition: color .15s;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: rgba(51, 112, 255, 0.04); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.main { max-width: 1400px; margin: 0 auto; padding: 28px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-head h2::before {
  content: "";
  display: inline-block;
  width: 4px; height: 15px;
  background: var(--primary-grad);
  border-radius: 2px;
  margin-right: 9px;
  vertical-align: -2px;
}
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } }

/* ---------- 统计 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--primary-grad);
}
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, #16a34a, #4ade80); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafc;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #f6f9ff; }
.data-table .name-cell { font-weight: 600; }
.data-table .sub { color: var(--faint); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 2.5px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.pill.ok { background: var(--success-soft); color: #15803d; }
.pill.warn { background: var(--warn-soft); color: #b45309; }
.pill.danger { background: var(--danger-soft); color: #b91c1c; }
.pill.neutral { background: #f1f5f9; color: var(--muted); }
.pill.info { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- 按钮 ---------- */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7.5px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
  box-shadow: 0 1px 2px rgba(23, 33, 47, 0.04);
}
.btn:hover { background: #f8fafc; border-color: #c8d3e0; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(23, 33, 47, 0.08); }
.btn:active { transform: none; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 4px 11px; font-size: 12.5px; }
.btn-primary { background: var(--primary-grad); border: none; color: #fff; box-shadow: 0 2px 8px rgba(51, 112, 255, 0.35); }
.btn-primary:hover { background: linear-gradient(135deg, #245bdb 0%, #4479ee 100%); border: none; box-shadow: 0 4px 14px rgba(51, 112, 255, 0.45); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); border: none; color: #fff; box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3); }
.btn-danger:hover { background: linear-gradient(135deg, #b91c1c, #dc2626); border: none; box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4); }
.btn-ghost { background: #fff; border-color: var(--border-strong); box-shadow: 0 1px 2px rgba(23, 33, 47, 0.04); color: var(--text); }
.btn-ghost:hover { background: #f6f9ff; border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; padding: 11px; font-size: 14px; font-weight: 600; margin-top: 6px; }
.btn-link { background: none; border: none; padding: 0 6px; color: var(--primary); cursor: pointer; font-size: 13px; font-family: inherit; font-weight: 500; }
.copy-mask { cursor: pointer; border-bottom: 1px dashed #94a3b8; }
.copy-mask:hover { color: var(--primary); }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.input {
  padding: 7.5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(51, 112, 255, 0.12); }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
select.input { cursor: pointer; }
.hint { font-size: 12.5px; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* ---------- 套餐 / 部门列表 ---------- */
.team-list, .dept-list { display: flex; flex-direction: column; gap: 14px; }
.team-row, .dept-row { display: flex; align-items: center; gap: 12px; }
.team-row .tname, .dept-row .dname { min-width: 0; }
.team-row .tname { width: 130px; }
.dept-row .dname { flex: 0 0 130px; }
.bar { flex: 1; height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary-grad); border-radius: 4px; transition: width .3s ease; }
.bar > i.full { background: linear-gradient(90deg, #dc2626, #ef4444); }
.bar > i.low { background: linear-gradient(90deg, #16a34a, #4ade80); }
.tnum { font-size: 12.5px; color: var(--muted); width: 82px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
  animation: fadeIn .15s ease-out;
}
.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
  animation: popIn .18s ease-out;
}
.modal.wide { max-width: 760px; }
.modal-head {
  padding: 20px 24px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 6px 24px 18px; }
.modal-foot {
  padding: 14px 24px 20px;
  display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border);
}
.modal-close {
  background: #f1f5f9; border: none; font-size: 14px; color: var(--muted);
  cursor: pointer; line-height: 1; width: 28px; height: 28px;
  border-radius: 50%; transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }

.field { margin-bottom: 15px; }
.field > label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 7px; }
.field .input, .field select { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 12px; color: var(--faint); margin-top: 6px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 8px; }

.secret-box {
  background: linear-gradient(160deg, #0f172a, #1e293b);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  line-height: 1.7;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.15);
}
.secret-warn {
  background: var(--warn-soft);
  color: #b45309;
  border: 1px solid #fcd9a1;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* ---------- 诊断 / KV ---------- */
.diag-list { display: flex; flex-direction: column; gap: 10px; }
.diag-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.diag-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: 0 0 8px; }
.diag-dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.diag-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.kv-list { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13px; }
.kv-list dt { color: var(--muted); }
.kv-list dd { margin: 0; word-break: break-all; }

.outbox-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow: auto; }
.outbox-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #f8fafc; transition: border-color .15s; }
.outbox-item:hover { border-color: #c7d6ee; }
.outbox-meta { font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.outbox-body { font-size: 12.5px; color: #334155; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; line-height: 1.65; }

/* ---------- 提示 ---------- */
.toast-root { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: #1e293b;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  max-width: 420px;
  animation: slideIn .18s ease-out;
}
.toast.error { background: linear-gradient(135deg, #b91c1c, #dc2626); }
.toast.success { background: linear-gradient(135deg, #15803d, #22a04e); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }

.empty { padding: 32px; text-align: center; color: var(--faint); font-size: 13px; }
.progress-inline { font-size: 12.5px; color: var(--primary); font-weight: 500; }
.spin {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(51, 112, 255, 0.2); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
