:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --ok-bg: #ecfdf5;
  --ok-ink: #047857;
  --warn-bg: #fffbeb;
  --warn-ink: #b45309;
  --err-bg: #fef2f2;
  --err-ink: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 8px 24px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.align-right { text-align: right; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #e0e7ff 0, var(--bg) 45%); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; }
.login-card h1 { font-size: 24px; margin: 24px 0 4px; }
.login-card form { margin-top: 22px; }
.login-brand, .brand { display: flex; align-items: center; gap: 10px; }
.login-brand strong, .brand strong { display: block; font-size: 16px; letter-spacing: .3px; }
.login-brand small, .brand small { display: block; font-size: 11px; color: var(--muted); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-weight: 700; font-size: 19px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* 表单 */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
label .input { margin-top: 6px; }
.input, input[type="text"], input[type="password"], input[type="number"], input[type="search"], select {
  width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 0 12px; font: inherit; color: var(--ink); outline: none;
}
.input:focus, input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-label input { width: 16px; height: 16px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, opacity .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: #f9fafb; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 42px; }

/* 提示 */
.notice { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.notice-error { background: var(--err-bg); color: var(--err-ink); }
.notice-ok { background: var(--ok-bg); color: var(--ok-ink); }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 224px; flex: 0 0 224px; background: var(--sidebar); color: #e5e7eb; display: flex; flex-direction: column; padding: 20px 14px; }
.sidebar .brand { padding: 0 8px 22px; }
.sidebar .brand small { color: #9ca3af; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: #d1d5db; font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--sidebar-soft); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid #374151; }
.api-badge { display: inline-block; border: 1px solid #374151; border-radius: 6px; padding: 2px 8px; font-size: 11px; color: #9ca3af; margin-bottom: 8px; }
.sidebar-foot .muted { color: #9ca3af; }

.content { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 19px; }
.topbar p { font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.badge-role { background: #eff6ff; color: var(--primary); }
.user-chip { font-weight: 600; }
.main { padding: 24px 28px 40px; }
.view { display: none; }
.view.active { display: block; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* 面板与表格 */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-narrow { max-width: 720px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); background: #fafbfc; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .input { width: 220px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 11px 16px; background: #f9fafb; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 16px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbff; }
.table .empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.cell-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.badge-status { border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; background: var(--warn-bg); color: var(--warn-ink); }
.status-on { background: var(--ok-bg); color: var(--ok-ink); }
.status-off { background: #f3f4f6; color: #6b7280; }
.status-bad { background: var(--err-bg); color: var(--err-ink); }
.result-ok { color: var(--ok-ink); font-weight: 600; }
.result-fail { color: var(--err-ink); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.detail-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 表单区 */
.form-pad { padding: 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* 弹窗 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 440px; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.2); padding: 24px; }
.modal-sm { max-width: 380px; }
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 轻提示 */
.toast { position: fixed; top: 20px; right: 20px; z-index: 100; max-width: 420px; background: #111827; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 13px; }
.toast[hidden] { display: none; }
.toast.ok { background: #047857; }
.toast.error { background: #b91c1c; }

@media (max-width: 900px) {
  .sidebar { width: 68px; flex-basis: 68px; padding: 16px 8px; }
  .sidebar .brand div, .nav-item span:not(.nav-icon), .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .topbar, .main { padding-left: 16px; padding-right: 16px; }
  .toolbar .input { width: 100%; }
}
