/* ===== 基础 ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
}
.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.2;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: transparent; border-color: transparent; color: #e5e7eb; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-block { width: 100%; }

/* ===== 登录页 ===== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}
.login-card {
  width: 340px;
  background: #fff;
  padding: 32px 28px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-sub { margin: 0 0 20px; text-align: center; color: #6b7280; font-size: 13px; }
.login-card label { display: block; margin: 12px 0 6px; font-weight: 600; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: #2563eb; }
.error-text { color: #dc2626; min-height: 18px; margin: 10px 0 0; font-size: 13px; }

/* ===== 布局 ===== */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  padding: 18px 20px; font-size: 18px; font-weight: 700;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.nav { flex: 1; padding: 10px 0; }
.nav-item {
  display: block; padding: 11px 20px; color: #cbd5e1; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  padding: 16px 24px; background: #fff; border-bottom: 1px solid #e5e7eb;
}
.topbar h2 { margin: 0; font-size: 18px; }
.view { padding: 22px 24px; }

/* ===== 卡片 ===== */
.card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.stat-tile {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px;
}
.stat-tile .num { font-size: 28px; font-weight: 700; color: #2563eb; }
.stat-tile .lbl { color: #6b7280; margin-top: 4px; }

/* ===== 筛选条 ===== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: #6b7280; }
.field input, .field select {
  padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
  min-width: 150px;
}
.field input:focus, .field select:focus { outline: none; border-color: #2563eb; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
th { background: #f9fafb; font-weight: 600; color: #374151; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
.stem-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 4px; padding: 1px 7px; margin: 1px 3px 1px 0; font-size: 12px; }
.empty { padding: 30px; text-align: center; color: #9ca3af; }

/* ===== 分页 ===== */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.pager .info { color: #6b7280; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 640px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #9ca3af; line-height: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid #e5e7eb; }

/* 表单行 */
.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.form-row textarea { resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: #2563eb; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* 选项行 */
.option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.opt-key {
  width: 26px; height: 30px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: #eef2ff; color: #4338ca; border-radius: 6px; font-weight: 700;
}
.option-row .opt-text { flex: 1; }
.del-opt {
  width: 30px; height: 30px; flex-shrink: 0; border: 1px solid #fecaca; background: #fef2f2;
  color: #dc2626; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1;
}
.chk { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }

/* ===== 导入结果 ===== */
.import-result { margin-top: 14px; }
.import-result .ok { color: #16a34a; }
.import-result .skip { color: #d97706; }
.err-list { margin: 8px 0 0; max-height: 200px; overflow-y: auto; padding-left: 18px; color: #dc2626; font-size: 13px; }

/* ===== Toast ===== */
#toast-root {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 220px; max-width: 360px; padding: 11px 14px; border-radius: 8px;
  color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toast-in .2s ease;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===== 角色徽标（侧边栏） ===== */
.role-badge {
  padding: 6px 10px; margin-bottom: 8px; font-size: 12px;
  color: #cbd5e1; background: rgba(255,255,255,.06); border-radius: 6px;
}
.role-badge.admin { color: #86efac; }
.role-badge.readonly { color: #fcd34d; }

/* ===== 侧边栏禁用项（统计占位） ===== */
.nav-item.disabled { opacity: .45; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; color: #cbd5e1; }

/* ===== 题目预览 ===== */
.preview-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 4px 0 14px; }
.preview-meta .kv { font-size: 13px; }
.preview-meta .kv b { color: #6b7280; font-weight: 600; margin-right: 4px; }
.preview-opts { margin: 6px 0; }
.preview-opts .opt { padding: 3px 0; }
.preview-opts .opt.correct { color: #16a34a; font-weight: 600; }
.preview-section { margin-top: 14px; }
.preview-section h4 { margin: 0 0 6px; font-size: 13px; color: #374151; }

/* ===== 批量改题区块 ===== */
.bu-block { border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.bu-block h4 { margin: 0 0 10px; font-size: 14px; }
.bu-hint { color: #6b7280; font-size: 12px; margin: 6px 0 0; }
