:root {
  --primary: #2563eb;
  --primary-light: #eef2ff;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #d97706;
  --bg: #f5f6f8;
  --text: #1f2329;
  --text-sub: #5a6472;
  --muted: #9aa2af;
  --border: #e5e7eb;
  --card: #ffffff;
}

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

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

/* ===== 登录 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  text-align: center;
}

.login-logo { font-size: 48px; }
.login-title { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-sub { color: var(--muted); margin: 4px 0 24px; }
.login-tip { color: var(--muted); font-size: 12px; margin-top: 16px; }
.beian-footer { margin-top: 20px; font-size: 12px; color: rgba(255, 255, 255, 0.85); text-align: center; }
.beian-footer a { color: rgba(255, 255, 255, 0.85); text-decoration: none; }
.beian-footer a:hover { text-decoration: underline; }
.beian-mini { margin-top: 10px; font-size: 11px; text-align: center; }
.beian-mini a { color: var(--muted); text-decoration: none; }
.beian-mini a:hover { text-decoration: underline; }

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

.sidebar {
  width: 220px;
  background: #1f2937;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo { font-size: 28px; margin-right: 10px; }
.brand-name { font-size: 18px; font-weight: 700; }
.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

/* 侧边栏用户区（账号信息 + 退出，固定顶部） */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.btn-logout {
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fecaca;
  width: auto;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.btn-logout:hover { background: rgba(220, 38, 38, 0.92); border-color: transparent; color: #fff; }

.nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
  display: block;
  padding: 14px 24px;
  color: #cbd5e1;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

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

.nav-group {
  padding: 14px 24px 6px;
  font-size: 12px;
  font-weight: 700;
  color: #f0b429;
  letter-spacing: 1px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 8px;
}

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

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

/* ===== 卡片/统计 ===== */
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
}

.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; table-layout: auto; }
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
.table th { color: var(--text-sub); font-weight: 600; background: #f9fafb; }
.table tr:hover td { background: #fafbfc; }
/* 内容区较长时允许折行（如报告单链接列可在 td 内单独覆盖） */
.table td.wrap { white-space: normal; }

/* 文本过长时省略，避免列重叠 */
.text-ellipsis {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.text-ellipsis-sm { max-width: 160px; }
.text-ellipsis-lg { max-width: 360px; }

/* 考点评分细则弹窗表格 */
.modal .table { margin-top: 0; }
.modal .table td { white-space: normal; }
.modal .table .text-ellipsis-sm { max-width: 220px; }

/* 模拟考试记录弹窗：列固定、不折行、居中 */
.record-table { table-layout: fixed; }
.record-table td, .record-table th { white-space: nowrap; }
.record-table td.text-center, .record-table th.text-center { text-align: center; }
.record-table .btn-link {
  display: inline-block;
  color: var(--primary);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 4px;
}
.record-table .btn-link:hover { background: var(--primary-light); }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }

/* ===== 表单/按钮 ===== */
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { min-height: 80px; resize: vertical; }

.form-row { display: flex; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.form-row .input, .form-row .select { flex: 1; }
.form-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.form-col .input, .form-col .select, .form-col .textarea { width: 100%; }
.form-label { font-size: 13px; color: var(--text-sub); margin-bottom: 6px; display: block; font-weight: 500; }
.form-label .required { color: var(--red); margin-left: 2px; }
.input, .select, .textarea { min-height: 40px; }
.input[type="date"], .input[type="datetime-local"] { padding: 9px 12px; }

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: #fff; color: var(--text-sub); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===== 徽章 ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.badge-green { background: #dcfce7; color: var(--green); }
.badge-red { background: #fee2e2; color: var(--red); }
.badge-gray { background: #f3f4f6; color: var(--text-sub); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-yellow { background: #fef3c7; color: var(--orange); }

/* ===== 工具条 ===== */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .input, .toolbar .select { width: auto; min-width: 120px; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.pagination button { padding: 6px 14px; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 520px;
  max-width: 92vw;
  max-height: 85vh;
  overflow: auto;
}
.modal.wide { width: 860px; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 2000;
}
.toast.show { opacity: 1; }

/* 选项编辑器 */
.option-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.option-key { width: 36px; text-align: center; font-weight: 700; color: var(--text-sub); }

/* ===== 响应式（手机/平板） ===== */
@media (max-width: 768px) {
  .login-card { width: 92vw; max-width: 400px; padding: 28px 20px; }
  .login-title { font-size: 20px; }

  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; }
  .brand { padding: 14px 16px; }
  .menu-toggle { display: inline-flex; }
  .nav { display: none; padding: 6px 0; }
  .sidebar.nav-open .nav { display: block; }
  .nav-item { padding: 12px 18px; font-size: 15px; }
  .sidebar-user { padding: 10px 16px; }
  .sidebar-footer { display: none; }

  .content { padding: 14px; overflow-x: hidden; }
  .page-title { font-size: 18px; margin-bottom: 14px; }
  .toolbar { gap: 8px; }
  .toolbar .input, .toolbar .select { width: auto; min-width: 100px; }

  .form-row { flex-direction: column; gap: 10px; }
  .form-row .input, .form-row .select, .form-row .textarea { width: 100%; }

  .modal { padding: 18px; width: 94vw; }
  .modal-title { font-size: 16px; margin-bottom: 14px; }

  .card { overflow-x: auto; }
  .table { min-width: 600px; }
  .table th, .table td { padding: 10px 8px; font-size: 12px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-num { font-size: 22px; }
}

/* ============ 官网管理：媒体库 ============ */
.badge-orange { background: #fff7ed; color: #ea580c; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.media-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.media-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
  background: #f3f4f6;
}
.media-info { padding: 10px 12px; }
.media-name {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-actions { display: flex; gap: 6px; }

.pager { margin-top: 16px; display: flex; align-items: center; gap: 12px; color: var(--text-sub); font-size: 13px; }
.text-left { text-align: left; }
