:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #fafbfd;
  --border: #e4e8f0;
  --border-strong: #d0d7e4;
  --text: #1a2233;
  --text-2: #5b6880;
  --text-3: #8b97ad;
  --primary: #4f6ef7;
  --primary-dark: #3a55d4;
  --primary-soft: #eef1ff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fef4e6;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #0891b2;
  --info-soft: #e4f6fb;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(20, 30, 55, .06), 0 6px 20px rgba(20, 30, 55, .05);
  --shadow-lg: 0 4px 12px rgba(20, 30, 55, .09), 0 18px 44px rgba(20, 30, 55, .07);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #101728;
  color: #b9c3d6;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: #6f7d96; }

.nav { padding: 12px 10px; flex: 1; }
.nav-title {
  font-size: 11px; color: #5c6880; text-transform: uppercase;
  letter-spacing: .08em; padding: 14px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #b9c3d6; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 500; }
.nav a .ico { width: 16px; text-align: center; opacity: .9; }
.nav a .badge {
  margin-left: auto; background: rgba(255, 255, 255, .14);
  padding: 1px 6px; border-radius: 9px; font-size: 11px;
}

.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 58px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--border);
  cursor: pointer; font-size: 13px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

.content { padding: 24px; flex: 1; }

/* ============ 卡片 ============ */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { font-size: 14.5px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1200px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; } }

/* ============ 统计卡 ============ */
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; right: -18px; top: -18px;
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--primary-soft); opacity: .55;
}
.stat-label { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; position: relative; z-index: 1; }
.stat-value { font-size: 24px; font-weight: 650; letter-spacing: -.4px; position: relative; z-index: 1; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.stat-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; position: relative; z-index: 1; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 600; color: var(--text-2);
  background: var(--panel-2); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  font-size: 12.5px;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
.table-empty { padding: 40px; text-align: center; color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer; transition: all .13s; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #b9c3d4; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-block { width: 100%; }

/* ============ 表单 ============ */
.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=email],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; font-size: 13.5px; font-family: inherit; color: var(--text);
  transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, .12);
}
textarea { resize: vertical; min-height: 76px; font-family: var(--mono); font-size: 12.5px; }
select { cursor: pointer; }
.checkbox { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.checkbox input { width: auto; margin: 0; cursor: pointer; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ============ 标签 ============ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 11px;
  font-size: 11.5px; font-weight: 500; line-height: 18px;
}
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-primary { background: var(--primary-soft); color: var(--primary); }
.tag-muted { background: #eef0f4; color: var(--text-2); }

/* ============ 提示条 ============ */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-info { background: var(--info-soft); color: #0e7490; border-color: #bae6fd; }
.alert-success { background: var(--success-soft); color: #15803d; border-color: #bbf7d0; }
.alert-warn { background: var(--warn-soft); color: #b45309; border-color: #fde68a; }
.alert-danger { background: var(--danger-soft); color: #b91c1c; border-color: #fecaca; }

/* ============ 模态 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 880px; }
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head .spacer { flex: 1; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-3); line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end;
}

/* ============ Toast ============ */
#toast-host {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px;
}
.toast {
  background: #101728; color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 13px;
  box-shadow: var(--shadow-lg); max-width: 360px;
  animation: toastIn .22s ease; display: flex; align-items: center; gap: 8px;
}
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.warn { background: #b45309; }
@keyframes toastIn { from { opacity: 0; transform: translateX(22px); } }

/* ============ 分页 ============ */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 13px 18px; }
.pager button {
  min-width: 30px; padding: 4px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff; cursor: pointer; font-size: 12.5px;
}
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ============ 工具 ============ */
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12px; }
.bold { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.w-full { width: 100%; }
.copy-box {
  display: flex; gap: 8px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 11px;
}
.copy-box code { flex: 1; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* ============ 进度条 ============ */
.bar { height: 7px; background: #eef0f4; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }

/* ============ 代码块 ============ */
pre.code {
  background: #101728; color: #c9d4e8; padding: 14px 16px;
  border-radius: var(--radius-sm); overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
}
pre.code .c { color: #6f7d96; }
pre.code .k { color: #8b5cf6; }
pre.code .s { color: #4ade80; }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }
