:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --navy-900: #0b1220;
  --navy-800: #111a2c;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --green: #16a34a;
  --green-bg: #ecfdf3;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --radius: 8px;
  --control-h: 36px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.10);
  --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink-900);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
::selection { background: var(--blue-100); }

/* ---------- 启动 / 登录 ---------- */
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--ink-500);
}
.boot-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--blue-600), #60a5fa);
  animation: boot-pulse 1.2s ease-in-out infinite;
}
@keyframes boot-pulse { 0%,100% { opacity: .55; transform: scale(.92); } 50% { opacity: 1; transform: scale(1); } }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr);
  background: var(--surface);
}
.login-brand {
  position: relative;
  overflow: hidden;
  padding: 56px clamp(32px, 6vw, 88px);
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(59, 130, 246, .28), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(37, 99, 235, .18), transparent 60%),
    var(--navy-900);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.75), transparent 75%);
  pointer-events: none;
}
.brand-lockup { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.brand-symbol {
  width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 8px 24px rgba(37, 99, 235, .35);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px; letter-spacing: -.04em;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand-sub { color: #94a3b8; font-size: 12px; margin-top: 2px; }
.brand-copy { position: relative; z-index: 1; max-width: 560px; margin: 72px 0 40px; }
.brand-copy h1 { margin: 0 0 16px; font-size: clamp(28px, 3.4vw, 44px); line-height: 1.16; letter-spacing: -.03em; }
.brand-copy p { margin: 0; color: #cbd5e1; font-size: 14px; line-height: 1.8; max-width: 480px; }
.brand-points { position: relative; z-index: 1; display: grid; gap: 10px; max-width: 480px; }
.brand-point { display: flex; align-items: center; gap: 10px; color: #cbd5e1; font-size: 12.5px; }
.brand-point i { width: 6px; height: 6px; border-radius: 50%; background: #60a5fa; box-shadow: 0 0 0 4px rgba(96, 165, 250, .12); }
.login-foot { position: relative; z-index: 1; color: #64748b; font-size: 11.5px; }

.login-panel { display: grid; place-items: center; padding: 40px clamp(24px, 6vw, 80px); background: #fbfcfe; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.login-card .muted-line { margin: 0 0 28px; color: var(--ink-500); font-size: 13px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-700); }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--control-h); border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: #fff; color: var(--ink-900);
  padding: 0 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 84px; padding: 9px 11px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-400); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}
.field .hint { color: var(--ink-500); font-size: 11.5px; }
.feature-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 14px; padding: 8px 0; }
.feature-option { display: flex; align-items: center; gap: 7px; color: var(--ink-700); font-size: 12px; min-width: 0; }
.feature-option input[type="checkbox"] {
  width: 16px; height: 16px; flex: 0 0 16px; margin: 0; padding: 0;
  accent-color: var(--blue-600); border-radius: 4px;
}
.feature-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn {
  height: var(--control-h); padding: 0 14px; border-radius: var(--radius);
  border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; font-weight: 600; font-size: 12.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: 0 3px 10px rgba(37, 99, 235, .20); }
.btn-primary:hover { background: var(--blue-700); }
.btn-secondary { background: #fff; border-color: var(--line-strong); color: var(--ink-700); }
.btn-secondary:hover { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }
.btn-ghost { background: transparent; color: var(--ink-500); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink-900); }
.btn-danger { background: var(--red-bg); border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.login-submit { height: 40px; margin-top: 4px; }
.form-error {
  display: none; margin: 0 0 14px; padding: 9px 11px; border-radius: var(--radius);
  background: var(--red-bg); border: 1px solid #fecaca; color: var(--red); font-size: 12px;
}
.form-error.show { display: block; }
.login-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; color: var(--ink-400); font-size: 11.5px; }

/* ---------- 应用壳 ---------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar {
  background: var(--navy-900); color: #e2e8f0; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sidebar-brand .brand-symbol { width: 32px; height: 32px; font-size: 15px; }
.sidebar-brand strong { display: block; font-size: 13px; letter-spacing: .01em; }
.sidebar-brand span { display: block; font-size: 10.5px; color: #94a3b8; margin-top: 1px; }
.nav-label { padding: 14px 10px 6px; color: #64748b; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 10px;
  border-radius: var(--radius); color: #cbd5e1; font-size: 12.5px;
}
.nav-item i { width: 16px; height: 16px; display: grid; place-items: center; color: #94a3b8; font-style: normal; font-size: 13px; }
.nav-item:hover { background: rgba(148, 163, 184, .10); color: #fff; }
.nav-item.active { background: rgba(59, 130, 246, .16); color: #fff; box-shadow: inset 2px 0 0 #60a5fa; }
.nav-item.active i { color: #93c5fd; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 4px; color: #64748b; font-size: 10.5px; border-top: 1px solid rgba(148,163,184,.12); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; padding: 0 24px; background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.crumb { display: flex; align-items: center; gap: 8px; color: var(--ink-500); font-size: 12px; }
.crumb strong { color: var(--ink-900); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 9px; height: var(--control-h); padding: 0 10px 0 5px; border-radius: var(--radius); background: #f8fafc; border: 1px solid var(--line); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700); display: grid; place-items: center; font-weight: 700; font-size: 11px; }
.user-chip span { color: var(--ink-700); font-size: 11.5px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-500); font-size: 12px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- 卡片 / 指标 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 650; }
.card-head .sub { color: var(--ink-500); font-size: 11.5px; margin-top: 2px; }
.card-body { padding: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  padding: 14px 16px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .label { color: var(--ink-500); font-size: 11.5px; }
.stat .value { margin-top: 6px; font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .meta { margin-top: 6px; color: var(--ink-400); font-size: 10.5px; }
.stat.blue { background: linear-gradient(180deg, #eff6ff, #ffffff 70%); border-color: var(--blue-200); }
.stat.blue .value { color: var(--blue-700); }
.stat.green .value { color: var(--green); }
.stat.amber .value { color: var(--amber); }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fbfcfe;
  border-radius: 10px 10px 0 0;
}
.search { position: relative; }
.search input {
  height: var(--control-h); width: 240px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0 11px; outline: none; background: #fff;
}
.search input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.select {
  height: var(--control-h); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0 28px 0 10px; background: #fff; color: var(--ink-700); outline: none;
}
.select:focus { border-color: var(--blue-500); }
.spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--ink-500); font-size: 11px;
  padding: 9px 14px; background: #fbfcfe; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 0 14px; height: 44px; border-bottom: 1px solid #eef2f7; color: var(--ink-700); vertical-align: middle; }
table.data tr:hover td { background: #f8fafc; }
table.data td .strong { color: var(--ink-900); font-weight: 600; }
table.data td .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--ink-500); }
table.data .actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.empty { padding: 44px 16px; text-align: center; color: var(--ink-400); font-size: 12px; }
.empty strong { display: block; color: var(--ink-500); font-size: 13px; margin-bottom: 4px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; color: var(--ink-500); font-size: 11.5px; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 6px; align-items: center; }
.pager button { height: 28px; min-width: 28px; padding: 0 8px; border: 1px solid var(--line); background: #fff; border-radius: 7px; color: var(--ink-700); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.pager button:hover:not(:disabled) { border-color: var(--blue-200); background: var(--blue-50); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.amber { color: var(--amber); background: var(--amber-bg); }
.badge.red { color: var(--red); background: var(--red-bg); }
.badge.blue { color: var(--blue-700); background: var(--blue-50); }
.badge.gray { color: var(--ink-500); background: #f1f5f9; }

/* ---------- 弹窗 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); display: grid; place-items: center; z-index: 60; padding: 24px; animation: fade-in .15s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: #fff;
  border-radius: 12px; box-shadow: var(--shadow-md); animation: modal-in .18s ease;
}
@keyframes modal-in { from { transform: translateY(8px); opacity: .7; } to { transform: none; opacity: 1; } }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-head h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.modal-head p { margin: 4px 0 0; color: var(--ink-500); font-size: 12px; }
.modal-x { width: 30px; height: 30px; border: 0; border-radius: 7px; background: #f1f5f9; color: var(--ink-500); font-size: 16px; }
.modal-body { padding: 18px 20px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.code-box { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: var(--radius); background: #0f172a; color: #e2e8f0; }
.code-box code { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.code-box .btn { background: rgba(255,255,255,.08); color: #e2e8f0; border-color: rgba(255,255,255,.16); }
.notice { padding: 10px 12px; border-radius: var(--radius); font-size: 12px; line-height: 1.6; }
.notice.info { background: var(--blue-50); border: 1px solid var(--blue-200); color: var(--blue-700); }
.notice.warn { background: var(--amber-bg); border: 1px solid #fde68a; color: var(--amber); }

/* ---------- 其他 ---------- */
.loading { padding: 28px; text-align: center; color: var(--ink-400); font-size: 12px; }
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.toast { min-width: 220px; max-width: 360px; padding: 10px 13px; border-radius: var(--radius); background: #0f172a; color: #f8fafc; box-shadow: var(--shadow-md); font-size: 12px; animation: toast-in .18s ease; }
.toast.error { background: #7f1d1d; }
.toast.ok { background: #14532d; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.copy-inline { border: 0; background: none; color: var(--blue-600); font-size: 11.5px; padding: 2px 4px; border-radius: 5px; }
.copy-inline:hover { background: var(--blue-50); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.section-gap { margin-top: 18px; }
.split-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; font-size: 12px; }
.kv dt { color: var(--ink-500); }
.kv dd { margin: 0; color: var(--ink-900); word-break: break-all; }
.health-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 2px 7px; border-radius: 999px; background: #f1f5f9; color: var(--ink-500); font-size: 10.5px; }

@media (max-width: 980px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { padding: 32px 22px; min-height: 100vh; background: linear-gradient(180deg, #eef4ff, #fbfcfe 40%); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 10px 14px; overflow: visible; }
  .sidebar-brand { padding-bottom: 8px; }
  .nav-label, .sidebar-foot { display: none; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-item { flex: 1 1 110px; justify-content: center; }
  .nav-item.active { box-shadow: inset 0 -2px 0 #60a5fa; }
  .content { padding: 18px; }
  .split-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 14px; height: 54px; }
  .user-chip span { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .search input { width: 100%; }
  .toolbar .search { flex: 1 1 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-height: calc(100vh - 20px); }
}
