/* ============================================================================
 * 共用主题：与打字页（index.html）同一套视觉语言
 * 渐变头图 + 白色圆角卡片 + 紫色主色 + 等宽数字
 * ==========================================================================*/

:root {
  --accent: #4b16c8;
  --accent-soft: #6174b4;
  --danger: #d93025;
  --warn: #f57c00;
  --ok: #2b7a3d;
  --ink: #333;
  --muted: #888;
  --line: #e6e6e6;
  --bg: #f9f9f9;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Microsoft YaHei", sans-serif;
  --mono: "Roboto Mono", "Courier New", monospace;
}

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

html, body { min-height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); }

/* ---------------------------------------------------------------- 顶部渐变条 */
.topbar {
  position: relative;
  background: linear-gradient(135deg, #4b16c8, #e94057, #f27121);
  color: #fff;
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  overflow: hidden;
}

.topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: 0.5px; }
.topbar .sub { font-size: 13px; opacity: 0.85; margin-top: 4px; }

.topbar .spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(8px);
  font-size: 13px;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.pill:hover { background: rgba(255, 255, 255, 0.3); }

/* ---------------------------------------------------------------- 布局 */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.wrap.narrow { max-width: 760px; }

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 { font-size: 18px; margin-bottom: 4px; }
.card h2 + .hint { margin-bottom: 16px; }

.hint { font-size: 13px; color: var(--muted); }

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

@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, opacity 0.15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f3f3f3; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }
.btn.link {
  background: none; color: var(--accent); padding: 4px 6px; font-weight: 500;
}
.btn.link.danger { color: var(--danger); }

/* ---------------------------------------------------------------- 表单 */
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 13px; color: #555; margin-bottom: 6px; font-weight: 500;
}
input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(75, 22, 200, 0.12);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.7; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .tight { flex: 0 0 auto; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  font-size: 12.5px;
  color: #666;
  font-weight: 600;
  background: #fafafa;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: #fafaff; }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.actions { white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- 标签 */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e8f5e9;
  color: var(--ok);
}
.badge.gray { background: #eee; color: #666; }
.badge.blue { background: #e8eaf6; color: var(--accent); }
.badge[data-level="low"] { background: #fdf3d7; color: #8a6100; }
.badge[data-level="medium"] { background: #ffe9d5; color: #a34b00; }
.badge[data-level="high"] { background: #fde0dd; color: var(--danger); }

/* ---------------------------------------------------------------- Tab */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tabs button {
  padding: 11px 20px;
  font-size: 14.5px;
  font-family: inherit;
  font-weight: 600;
  color: #666;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tabs button:hover { color: var(--accent); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- 统计块 */
.stat {
  background: #f7f7fb;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat .val {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--mono);
  line-height: 1.2;
}
.stat .lbl { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  padding: 26px;
}
.modal.wide { max-width: 900px; }
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------------------------------------------------------------- 提示条 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: #2b2b33;
  color: #fff;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

.status-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  min-height: 18px;
}
.status-note.error { color: var(--danger); font-weight: 600; }
.status-note.ok { color: var(--ok); font-weight: 600; }

/* ---------------------------------------------------------------- 曲线图 */
.chart-box {
  position: relative;
  width: 100%;
  height: 300px;
  background: linear-gradient(135deg, #4b16c8, #e94057);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 10px;
}

/* 绘图区：四周留白给坐标轴刻度 */
.chart-plot {
  position: absolute;
  left: 56px;
  right: 56px;
  top: 46px;
  bottom: 42px;
}

.chart-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-plot .grid-line { stroke: rgba(255, 255, 255, 0.14); stroke-width: 1; }

.chart-plot .curve {
  fill: none;
  stroke: #1a1a1a;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart-plot .curve.acc {
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}

.chart-plot .tick {
  position: absolute;
  font-size: 11px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.chart-plot .tick.y {
  right: calc(100% + 8px);
  transform: translateY(-50%);
  text-align: right;
  font-family: var(--mono);
}

.chart-plot .tick.y2 {
  left: calc(100% + 8px);
  transform: translateY(-50%);
  font-family: var(--mono);
}

.chart-plot .tick.x {
  top: calc(100% + 12px);
  transform: translateX(-50%);
  font-family: var(--mono);
}

.chart-legend {
  position: absolute;
  top: 12px;
  left: 16px;
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #fff;
  z-index: 3;
}
.chart-legend i {
  display: inline-block;
  width: 18px;
  height: 0;
  margin-right: 6px;
  vertical-align: middle;
  border-top: 2px solid #1a1a1a;
}
.chart-legend i.dash { border-top: 2px dashed rgba(255, 255, 255, 0.92); }

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.chart-caption {
  position: absolute;
  top: calc(100% + 26px);
  left: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- 批量操作条 */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px 14px;
  background: #f7f7fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.bulk-bar .bulk-title { font-weight: 600; color: #555; }
.bulk-bar .bulk-sep { color: #ccc; margin: 0 2px; }

/* ---------------------------------------------------------------- 翻页器 */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-size: 13px;
  color: #666;
}
.pager .grow { flex: 1; }
.pager button {
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.pager button:hover:not(:disabled) { background: #f3f3f3; }
.pager button:disabled { opacity: 0.45; cursor: not-allowed; }
.pager select {
  width: auto;
  padding: 5px 8px;
  font-size: 13px;
}
.pager .info { font-family: var(--mono); }

/* ---------------------------------------------------------------- 登录页 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #4b16c8, #e94057, #f27121);
}
.login-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-card h1 { font-size: 23px; margin-bottom: 6px; }
.login-card .sub { font-size: 13.5px; color: var(--muted); margin-bottom: 26px; }
.login-card .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }

/* ---------------------------------------------------------------- 学生主页 */
.exam-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.exam-item .title { font-weight: 600; font-size: 15.5px; }
.exam-item .meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.exam-item .done { font-size: 13px; color: var(--ok); font-weight: 600; }

.secret-hint {
  position: fixed;
  right: 18px;
  bottom: 18px;
  font-size: 11px;
  color: #bbb;
  user-select: none;
  pointer-events: none;
}
