:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #1f2937;
  --text-soft: #4b5563;
  --muted: #8b95a5;
  --border: #e4e8ee;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0e7490;
  --info-soft: #ecfeff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .04);
  --radius: 10px;
  --sidebar-w: 236px;
}

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

/* ---------- 滚动条：全局细滚动条 + 侧边栏深色款 ---------- */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }
.sidebar nav { scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.sidebar nav::-webkit-scrollbar { width: 7px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: #475569; background-clip: content-box; }
/* 深色区域（弹窗遮罩等）通用细滚动条 */
.modal-body, .code-block { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 启动加载 ---------- */
.boot-loading {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--muted); font-size: 13px;
}
.boot-loading .spinner { border-color: #dbe3ef; border-top-color: var(--primary); width: 24px; height: 24px; }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 55%, #eef2ff 100%);
}
.login-card {
  width: 400px; max-width: calc(100vw - 32px); background: #fff;
  border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 18px 50px rgba(30, 58, 138, .10);
  padding: 36px 34px 30px;
}
.login-logo {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 20px; letter-spacing: -.5px;
}
.login-card h1 { font-size: 22px; margin: 18px 0 6px; letter-spacing: -.3px; }
.login-card p.sub { color: var(--muted); margin: 0 0 26px; font-size: 13px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 8px; height: 42px; }
.login-tip { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 布局 ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: #0f172a;
  color: #cbd5e1; display: flex; flex-direction: column; z-index: 20;
}
.sidebar-brand {
  height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.07); color: #fff; font-weight: 700; font-size: 16px;
}
.sidebar-brand .mark {
  width: 28px; height: 28px; border-radius: 8px; background: #3b82f6;
  display: grid; place-items: center; font-size: 14px; font-weight: 800;
}
.sidebar nav { flex: 1; overflow-y: auto; padding: 14px 10px 24px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 11px; letter-spacing: .08em; color: #64748b; text-transform: uppercase;
  padding: 8px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px;
  border: 0; background: transparent; color: #cbd5e1; border-radius: 8px; cursor: pointer;
  text-align: left; font-size: 13px; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: #1d4ed8; color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; font-size: 14px; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; color: #64748b; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 16px; margin: 0; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--text-soft); font-size: 13px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.content { padding: 24px 28px 48px; max-width: 1500px; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; color: var(--text-soft); cursor: pointer; font-size: 13px;
  font-weight: 550; white-space: nowrap; transition: .15s;
}
.btn:hover { border-color: #cbd5e1; background: var(--panel-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: var(--danger-soft); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-link { border: 0; background: transparent; color: var(--primary); padding: 0 4px; height: auto; }
.btn-link:hover { background: transparent; text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 7px; background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-line input { width: 16px; height: 16px; min-height: 0; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.toolbar .field { margin: 0; min-width: 150px; flex: 1 1 160px; }
.toolbar .btn { margin-bottom: 0; }

.table-wrap { overflow-x: auto; }
/* 表格里的多选列：窄列居中，去掉表单单选时的额外间距 */
th.col-check, td.col-check { width: 38px; padding-right: 0; text-align: center; }
th.col-check input, td.col-check input { width: 16px; height: 16px; min-height: 0; margin: 0; cursor: pointer; }
.bulk-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.bulk-bar .count { font-size: 13px; color: var(--text-soft); }
.bulk-bar .count b { color: var(--text); }
.bulk-bar .spacer { flex: 1 1 auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
th { background: var(--panel-soft); color: var(--text-soft); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
td.nowrap, th.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.dim { color: var(--muted); }
.strong { font-weight: 650; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.pager .dim { font-size: 12px; }
.pager-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.pager-btns .btn { min-width: 30px; padding: 0 8px; }
.pager-btns .btn:disabled { opacity: .4; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; line-height: 1.7; white-space: nowrap;
  background: #f1f5f9; color: #475569;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-card .foot { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-card.accent .value { color: var(--primary); }
.stat-card.good .value { color: var(--success); }
.stat-card.bad .value { color: var(--danger); }

.empty { padding: 44px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 28px; display: block; margin-bottom: 8px; opacity: .5; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 18px; }
.tab { padding: 10px 14px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 650; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid;
  place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: 620px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.18);
}
.modal.wide { width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }

.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.10); padding: 10px 14px;
  min-width: 240px; max-width: 420px; font-size: 13px;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.code-block {
  background: #0f172a; color: #dbeafe; border-radius: 8px; padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-all; max-height: 380px; overflow: auto; margin: 0;
}
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.notice {
  border-radius: 8px; padding: 10px 14px; font-size: 12px; line-height: 1.6;
  background: var(--primary-soft); color: #1e40af; border: 1px solid #dbeafe; margin-bottom: 16px;
}
.notice.warn { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: static; width: 100%; height: auto; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 8px; }
  .nav-group { margin: 0; display: flex; }
  .nav-group-title, .sidebar-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4, .split { grid-template-columns: 1fr; }
}
