:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e5e9f0;
  --line-strong: #d3dae5;
  --text: #101828;
  --text-2: #475467;
  --muted: #8a94a6;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff5ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fffaeb;
  --danger: #dc2626;
  --danger-soft: #fef3f2;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
  --sidebar-w: 224px;
  --header-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: "Cascadia Mono", Consolas, "Courier New", monospace; }
.nowrap { white-space: nowrap; }
.hide-sm { display: table-cell; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(720px 420px at 12% 8%, rgba(37, 99, 235, 0.10), transparent 62%),
    radial-gradient(640px 420px at 88% 92%, rgba(14, 165, 233, 0.10), transparent 62%),
    var(--bg);
}

.login-card {
  width: 408px;
  padding: 32px 32px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.brand-sm { padding: 4px 6px 18px; }

#login-form { margin-top: 26px; display: grid; gap: 15px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.field textarea { resize: vertical; min-height: 92px; line-height: 1.6; font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

.form-error { min-height: 18px; color: var(--danger); font-size: 13px; }
.login-hint { margin-top: 14px; text-align: center; font-size: 12px; color: var(--muted); }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.nav { display: grid; gap: 2px; margin-top: 4px; flex: 1; align-content: start; }
.nav-group-title {
  font-size: 11px;
  color: var(--muted);
  padding: 12px 10px 6px;
  letter-spacing: 0.5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 17px; height: 17px; fill: currentColor; opacity: 0.8; flex: 0 0 17px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 8px;
}
.admin-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 700; border: 1px solid #d6e6ff;
  flex: 0 0 32px;
}
.admin-meta { line-height: 1.35; font-size: 13px; min-width: 0; }
.admin-meta > div:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  min-height: var(--header-h);
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: 0.2px; }
.topbar .page-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.nav-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-2);
}

.view { padding: 20px 24px 40px; }

/* ---------------- 通用组件 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  white-space: nowrap;
  font-size: 13.5px;
}
.btn:hover { background: var(--surface-2); border-color: #c2cbdb; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f4c7c3; background: var(--danger-soft); }
.btn-danger:hover { background: #fde8e6; border-color: #efb4ae; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-icon { padding: 6px; width: 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* 概览指标 */
.metric { padding: 18px 20px; }
.metric-label { font-size: 12.5px; color: var(--muted); }
.metric-value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: 0.5px; line-height: 1.1; }
.metric-value.sm { font-size: 22px; }
.metric-foot { margin-top: 8px; font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.metric-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
  flex: 0 0 34px;
}

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: 0; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: #f2f4f7; color: var(--text-2);
  border: 1px solid var(--line);
  line-height: 1.6;
}
.badge.on, .badge.success { background: var(--success-soft); color: var(--success); border-color: #c9ecd6; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f5e0b4; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #f4c7c3; }
.badge.info { background: var(--primary-soft); color: var(--primary); border-color: #d6e6ff; }

.secret { cursor: pointer; color: var(--muted); letter-spacing: 1px; user-select: none; }
.secret:hover { color: var(--primary); }
.secret[data-shown="1"] { color: var(--text); letter-spacing: 0.2px; }

/* 工具栏与筛选 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 150px; }
.input, .select {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); outline: none; min-width: 0;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10); }

.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.filter-bar .input { width: 220px; }
.filter-bar .select { width: 130px; }
.filter-count { margin-left: auto; font-size: 12px; color: var(--muted); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line);
  background: var(--surface);
}

/* 进度与列表 */
.progress { height: 7px; border-radius: 999px; background: #eef1f6; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }

.tier-row { display: grid; grid-template-columns: 88px 1fr 56px; gap: 10px; align-items: center; margin-bottom: 13px; }
.tier-row:last-child { margin-bottom: 0; }
.tier-label { font-size: 12.5px; color: var(--text-2); }
.tier-count { font-size: 12px; text-align: right; color: var(--muted); }

.list { display: grid; gap: 2px; }
.list-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 20px; border-bottom: 1px solid #f0f3f8;
}
.list-item:last-child { border-bottom: 0; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-top: 7px; flex: 0 0 6px; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 13px; }
.list-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 6px; font-size: 14px; font-weight: 600; }

/* Tab */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.tab { padding: 6px 14px; border-radius: 6px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; }
.tab.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

.section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.section-tab {
  padding: 10px 16px; border: 0; background: transparent; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.section-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 24, 40, 0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  width: 560px; max-width: 100%; max-height: 88vh; overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.15s ease-out;
}
@keyframes pop { from { transform: translateY(8px) scale(0.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: transparent; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.code-box {
  display: grid; gap: 5px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; letter-spacing: 0.6px;
  max-height: 260px; overflow: auto;
}

/* 详情键值 */
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 10px 14px; font-size: 13px; }
.kv-label { color: var(--muted); }
.kv-value { color: var(--text); word-break: break-all; }

/* ---------------- 提示 ---------------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; }
.toast {
  min-width: 200px; max-width: 380px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: slide 0.16s ease-out;
  border-left: 3px solid var(--primary);
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); color: var(--danger); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 移动端遮罩 */
.nav-mask { display: none; position: fixed; inset: 0; background: rgba(16, 24, 40, 0.4); z-index: 25; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
    width: 248px;
    flex-basis: 248px;
  }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .nav-mask { display: block; }
  .nav-toggle { display: inline-flex; }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 17px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .hide-sm { display: none; }
  .filter-bar { padding: 12px 14px; gap: 8px; }
  .filter-bar .input { width: 100%; }
  .filter-bar .select { width: calc(50% - 4px); }
  .filter-count { margin-left: 0; width: 100%; }
  .card-head { padding: 14px; flex-wrap: wrap; }
  .card-pad { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .metric-value { font-size: 26px; }
  .modal { width: 100%; max-height: 92vh; }
  .modal-body { padding: 14px; }
  .toast-root { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .pager { padding: 10px 14px; }
  .tier-row { grid-template-columns: 76px 1fr 48px; }
}
