/* ==========================================================================
   启慧答题 · 运营后台样式
   纯手写，不依赖任何 CDN，离线可用
   ========================================================================== */
:root {
  --brand: #4f46e5;
  --brand-light: #818cf8;
  --brand-dark: #4338ca;
  --gold: #d97706;
  --danger: #dc2626;
  --success: #059669;
  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #131c31;
  --page-bg: #f6f7f9;
  --card-bg: #ffffff;
  --border: #e8eaee;
  --border-soft: #f1f3f6;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --text-4: #9ca3af;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

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

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 40;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #f59e0b);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}
.brand-text { line-height: 1.25; overflow: hidden; }
.brand-name { color: #f8fafc; font-weight: 600; font-size: 14.5px; letter-spacing: .01em; }
.brand-sub { color: #64748b; font-size: 11px; margin-top: 2px; }

.nav { padding: 10px 0 20px; flex: 1; }
.nav-group { padding: 14px 18px 6px; font-size: 10.5px; color: #52637c; letter-spacing: .1em; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 10px; padding: 9px 11px;
  border-radius: 8px;
  color: #b6c2d4; font-size: 13.5px;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.055); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.3), rgba(99, 102, 241, 0.07));
  color: #fff; font-weight: 500;
  box-shadow: inset 2px 0 0 var(--brand-light);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: #ef4444; color: #fff;
  font-size: 10.5px; font-weight: 600;
  padding: 1px 6px; border-radius: 9px;
  min-width: 18px; text-align: center;
}
.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: #52637c; font-size: 11px; line-height: 1.7;
}

.main { margin-left: 236px; flex: 1; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 62px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
}
.page-title { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; }
.page-sub { font-size: 12.5px; color: var(--text-4); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.admin-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 13px; font-weight: 600;
  display: grid; place-items: center;
}
.logout-link { font-size: 13px; color: var(--text-3); padding: 6px 10px; border-radius: 7px; }
.logout-link:hover { background: #f3f4f6; color: var(--text); }

.content { padding: 22px 28px 64px; max-width: 1560px; }

/* ----------------------------------------------------------------- 卡片 */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }
.card-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-desc { font-size: 12.5px; color: var(--text-4); margin-top: 3px; font-weight: 400; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 13px 20px; border-top: 1px solid var(--border-soft); background: #fcfcfd; }

/* ----------------------------------------------------------------- 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 25px; font-weight: 700; letter-spacing: -.025em; margin-top: 7px; line-height: 1.15; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-4); margin-left: 3px; }
.stat-sub { font-size: 12px; color: var(--text-4); margin-top: 7px; display: flex; align-items: center; gap: 6px; }
.stat-icon {
  position: absolute; right: 14px; top: 14px;
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: #eef2ff; color: var(--brand);
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-icon.gold { background: #fffbeb; color: #d97706; }
.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }

.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ----------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 10px 16px;
  background: #fafbfc; color: var(--text-3);
  font-weight: 600; font-size: 12px; letter-spacing: .02em;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid #f5f6f8; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fbfcfe; }
.table .num { font-variant-numeric: tabular-nums; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table .muted { color: var(--text-4); font-size: 12.5px; }
.table .strong { font-weight: 600; }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--text-4); margin-top: 3px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ----------------------------------------------------------------- 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2.5px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-green { background: #ecfdf5; color: #047857; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-yellow { background: #fffbeb; color: #b45309; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-blue { background: #eef2ff; color: #4338ca; }
.badge-purple { background: #f5f3ff; color: #6d28d9; }
.badge-gold { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* ----------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
  background: none;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; border-color: #e0e3e8; color: var(--text-2); }
.btn-ghost:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-success { background: #fff; border-color: #a7f3d0; color: #047857; }
.btn-success:hover { background: #ecfdf5; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------------- 表单 */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 13px; color: #374151; font-weight: 500; margin-bottom: 6px; }
.label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid #e0e3e8; border-radius: 8px;
  font-size: 13.5px; color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.hint { font-size: 12px; color: var(--text-4); margin-top: 5px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }

.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--border-soft);
  background: #fcfcfd;
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; padding: 7px 11px; font-size: 13px; }
.filter-bar .input.wide { min-width: 220px; }
.filter-spacer { flex: 1; }

.radio-row { display: flex; gap: 18px; align-items: center; padding-top: 4px; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }

/* ----------------------------------------------------------------- 提示 */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 10px;
  font-size: 13px; line-height: 1.65;
  margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.alert-info { background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #d1fae5; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fef3c7; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fee2e2; }
.alert b { font-weight: 650; }

.toast {
  position: fixed; top: 18px; right: 22px; z-index: 100;
  background: #111827; color: #fff;
  padding: 11px 18px; border-radius: 9px;
  font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toastIn .3s ease, toastOut .3s ease 2.8s forwards;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); visibility: hidden; } }

/* ----------------------------------------------------------------- 进度条 */
.progress { height: 8px; background: #eef0f3; border-radius: 5px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #6366f1, #818cf8); transition: width .4s; }
.progress-bar.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar.danger { background: linear-gradient(90deg, #ef4444, #f87171); }
.progress-bar.green { background: linear-gradient(90deg, #10b981, #34d399); }

/* ----------------------------------------------------------------- 图表 */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 158px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 7px; }
.bar-stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; }
.bar { width: 100%; border-radius: 4px; min-height: 2px; transition: opacity .15s; }
.bar-answers { background: linear-gradient(180deg, #818cf8, #6366f1); }
.bar:hover { opacity: .78; }
.bar-label { font-size: 11px; color: var(--text-4); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-3); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ----------------------------------------------------------------- 分页 */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; border-top: 1px solid var(--border-soft);
  font-size: 13px; color: var(--text-3);
  flex-wrap: wrap; gap: 10px;
}
.page-links { display: flex; gap: 4px; align-items: center; }
.page-link {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; border: 1px solid #e5e7eb; background: #fff;
  color: var(--text-2); font-size: 13px;
}
.page-link:hover { background: #f9fafb; border-color: #d1d5db; }
.page-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-link.disabled { opacity: .45; pointer-events: none; }

/* ----------------------------------------------------------------- 空状态 */
.empty { padding: 56px 20px; text-align: center; color: var(--text-4); }
.empty-icon {
  width: 46px; height: 46px; margin: 0 auto 14px;
  border-radius: 13px; background: #f3f4f6;
  display: grid; place-items: center; color: #9ca3af;
}
.empty-title { font-size: 14px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.empty-desc { font-size: 12.5px; }

/* ----------------------------------------------------------------- 布局辅助 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 1.65fr 1fr; gap: 18px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 1.9fr; gap: 18px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-4); }
.text-sm { font-size: 12.5px; }
.text-right { text-align: right; }
.text-gold { color: var(--gold); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }

/* ----------------------------------------------------------------- 登录页 */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  background: #0f172a;
  background-image:
    radial-gradient(ellipse 900px 500px at 20% 0%, rgba(99, 102, 241, .32), transparent 62%),
    radial-gradient(ellipse 700px 420px at 85% 100%, rgba(168, 85, 247, .22), transparent 62%),
    radial-gradient(ellipse 500px 300px at 60% 40%, rgba(245, 158, 11, .08), transparent 70%);
  padding: 24px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 34px 32px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .38);
}
.login-logo {
  width: 50px; height: 50px; border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #f59e0b);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 22px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, .42);
}
.login-title { color: #f8fafc; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.login-sub { color: #94a3b8; font-size: 13px; margin-top: 6px; margin-bottom: 26px; line-height: 1.6; }
.login-card .label { color: #cbd5e1; }
.login-card .input {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.13);
  color: #f1f5f9;
}
.login-card .input::placeholder { color: #64748b; }
.login-card .input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, .18);
  background: rgba(255, 255, 255, 0.08);
}
.login-btn {
  width: 100%; padding: 11px;
  border-radius: 9px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff; font-size: 14.5px; font-weight: 600;
  margin-top: 6px;
  box-shadow: 0 6px 18px rgba(99, 102, 241, .34);
  transition: transform .12s, box-shadow .15s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(99, 102, 241, .42); }
.login-err {
  background: rgba(239, 68, 68, .14);
  border: 1px solid rgba(239, 68, 68, .3);
  color: #fca5a5;
  padding: 9px 12px; border-radius: 8px;
  font-size: 12.5px; margin-bottom: 16px;
}
.login-foot { color: #475569; font-size: 11.5px; text-align: center; margin-top: 22px; line-height: 1.7; }

/* ----------------------------------------------------------------- 题位卡片 */
.slot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.slot {
  border: 1px solid var(--border); border-radius: 11px;
  overflow: hidden; background: #fff;
}
.slot-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #fafbfc;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.slot-no {
  width: 24px; height: 24px; border-radius: 7px;
  background: #eef2ff; color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 650; margin-right: 8px;
}
.slot-no.red { background: #fff1f2; color: #e11d48; }
.slot-q { padding: 12px 14px; border-bottom: 1px solid #f5f6f8; }
.slot-q:last-child { border-bottom: none; }
.slot-q-text { font-size: 13px; line-height: 1.6; color: var(--text); }
.slot-q-opts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.opt {
  font-size: 12.5px; padding: 3px 9px; border-radius: 6px;
  background: #f3f4f6; color: var(--text-2);
}
.opt.correct { background: #ecfdf5; color: #047857; font-weight: 600; }
.slot-empty { padding: 16px 14px; color: #cbd5e1; font-size: 12.5px; text-align: center; }

/* ----------------------------------------------------------------- 响应式 */
@media (max-width: 1400px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .stat-grid, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .slot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stat-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* 工具类补充 */
.nowrap { white-space: nowrap; }
