:root {
  --primary: #2563eb;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.full-width { width: 100%; }
.err-text { color: var(--danger); font-size: 13px; margin: 6px 0; }

/* 登录页 */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-brand {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: #eff6ff;
  padding: 3px 10px;
  border-radius: 999px;
}

.login-card h1 { margin: 10px 0 6px; font-size: 22px; }
.login-foot { margin-top: 18px; text-align: center; }
.login-foot a { color: var(--muted); text-decoration: none; font-size: 13px; }

/* 表单元素 */
label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.btn {
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.link-btn { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px; }

/* 后台主布局 */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-brand strong { display: block; font-size: 18px; color: #fff; }
.sidebar-brand span { font-size: 12px; color: #94a3b8; }

.nav-menu {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  border: none;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 14px;
}

.admin-badge strong { display: block; color: #fff; font-size: 14px; }
.admin-badge span { font-size: 12px; color: #94a3b8; }

.sidebar-links {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-links a, .sidebar-links .link-btn { color: #94a3b8; font-size: 12px; text-decoration: none; }

.main-content {
  flex: 1;
  padding: 24px;
  overflow-x: auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-head h2 { margin: 0; font-size: 20px; }

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
}

.pill-ok { background: #dcfce7; color: #15803d; }
.pill-err { background: #fee2e2; color: #b91c1c; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.card h3 { margin: 0 0 12px; font-size: 16px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-card strong { display: block; font-size: 30px; margin: 6px 0; color: var(--primary); }
.kpi-card em { font-style: normal; font-size: 12px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.list-box { display: flex; flex-direction: column; gap: 10px; }

.list-row {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.preset-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip-btn {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.action-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.diff-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.diff-card {
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
}

.diff-add { background: #f0fdf4; border-color: #86efac; }
.diff-mod { background: #fffbeb; border-color: #fcd34d; }
.diff-del { background: #fef2f2; border-color: #fca5a5; }
.diff-ch { background: #eff6ff; border-color: #93c5fd; }

.diff-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-bar input, .filter-bar select { width: auto; flex: 1; min-width: 160px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

th { background: #f8fafc; color: var(--muted); font-weight: 600; }

.q-admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-admin-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.q-admin-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* 弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  padding: 22px;
}

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; padding: 12px; }
  .nav-menu { flex-direction: row; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .kpi-grid, .two-col, .three-col { grid-template-columns: 1fr; }
}
