/* ============================================================
   运动会选课系统 · 设计稿风格（明亮蓝紫 / 浅蓝面板 / 渐变主按钮）
   配色取自设计稿像素分析：主蓝 #2e60e3~#5a87fb，浅蓝 #e8f1ff，
   深紫黑文字 #2e2e40，浅米黄提示 #fffaed。仅换肤，不改结构与类名。
   ============================================================ */

:root {
  --brand: #3b6ded;
  --brand-deep: #2e60e3;
  --brand-bright: #5a87fb;
  --grad-brand: linear-gradient(135deg, #5a87fb 0%, #3b6ded 55%, #2e60e3 100%);
  --brand-soft: #e8f1ff;
  --brand-softer: #f4f7ff;
  --brand-line: #c9d6fe;
  --ink: #2e2e40;
  --ink-2: #555564;
  --ink-3: #8a8a9a;
  --line: #e6e9f2;
  --bg: #f5f7ff;
  --card: #ffffff;
  --warm: #fffaed;
  --warm-line: #f0e3bf;
  --success: #16a36a;
  --success-soft: #e6f6ef;
  --danger: #ef5b5b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(46, 96, 227, 0.09);
  --shadow-sm: 0 2px 12px rgba(46, 96, 227, 0.06);
}

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

/* 确保 HTML5 hidden 在任何 display 规则（含 flex）下都能真正隐藏，
   否则 .modal-mask/.toast 的 display:flex 会覆盖默认 display:none，
   导致遮罩常驻全屏拦截点击。 */
[hidden] { display: none !important; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink-2);
  line-height: 1.6;
}

/* ---------------- 顶栏（白底 + 细底边线，贴合设计稿无深色头） ---------------- */

.topbar {
  background: var(--card);
  color: var(--ink);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.topbar h1 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: .5px;
}
.topbar h1::before {
  content: "";
  width: 6px;
  height: 20px;
  border-radius: 4px;
  background: var(--grad-brand);
}
.topbar a {
  color: var(--brand);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.topbar a:hover { color: var(--brand-deep); }

.container { max-width: 980px; margin: 28px auto; padding: 0 16px; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 17px;
  margin-bottom: 18px;
  color: var(--ink);
  font-weight: 700;
}

.form-row { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
label { display: flex; flex-direction: column; font-size: 13px; color: var(--ink-2); gap: 6px; }

input[type="text"], input[type="password"], input[type="number"], select {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  min-width: 180px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 109, 237, 0.14);
}

/* ---------------- 拖拽上传区（浅蓝底 + 蓝色虚线） ---------------- */

.dropzone {
  border: 2px dashed var(--brand-line);
  border-radius: var(--radius);
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: all .18s;
  background: var(--brand-softer);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.dropzone p { margin: 4px 0; }
.hint { font-size: 12px; color: var(--ink-3); }
.picked-file { margin: 10px 0; font-size: 13px; color: var(--brand-deep); font-weight: 500; }

/* ---------------- 按钮 ---------------- */

.btn {
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, opacity .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 96, 227, 0.28);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(46, 96, 227, 0.36); }
.btn-small { padding: 7px 15px; font-size: 13px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { box-shadow: 0 6px 16px rgba(239, 91, 91, 0.3); }
.btn-ghost {
  background: var(--brand-softer);
  color: var(--brand-deep);
  border: 1px solid var(--brand-line);
}
.btn-ghost:hover { background: var(--brand-soft); }

/* ---------------- 学生表格 ---------------- */

.student-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.student-table th, .student-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}
.student-table th {
  background: var(--brand-softer);
  color: var(--ink);
  font-weight: 600;
}
.student-table tr:hover td { background: #fafbff; }

.tag {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-radius: 12px;
  padding: 2px 11px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}
.tag .tag-remove { cursor: pointer; margin-left: 6px; color: var(--ink-3); }
.tag .tag-remove:hover { color: var(--danger); }
.empty-events { color: #b3b6c2; font-size: 13px; }

/* ---------------- 模态窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(38, 48, 96, 0.48);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 18px;
  width: 640px;
  max-width: 92vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(30, 40, 90, 0.28);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--brand-softer);
}
.modal-header h3 { font-size: 16px; color: var(--ink); }
.modal-close {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3);
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px 24px; overflow-y: auto; }

.event-group { margin-bottom: 18px; }
.event-group h4 {
  font-size: 13px;
  color: var(--brand-deep);
  border-left: 3px solid var(--brand);
  padding-left: 8px;
  margin-bottom: 10px;
}
.event-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color .15s, background .15s;
}
.event-item:hover { border-color: var(--brand-line); background: var(--brand-softer); }
.event-item.full { opacity: .55; }
.event-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.event-item .btn { min-width: 76px; }
.btn-selected { background: var(--success); color: #fff; }
.btn-selected:hover { box-shadow: 0 6px 16px rgba(22, 163, 106, 0.3); }
.btn-disabled { background: #d4d7e0; color: #fff; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 580px);
  padding: 11px 26px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  color: #fff;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(30, 40, 90, 0.22);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------------- 管理页布局 ---------------- */

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 820px) { .admin-grid { grid-template-columns: 1fr; } }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.inline-form input, .inline-form select { min-width: 0; width: auto; flex: 1; }
.event-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  transition: border-color .15s, background .15s;
}
.event-list-row:hover { border-color: var(--brand-line); background: var(--brand-softer); }
.event-list-row .actions { display: flex; gap: 8px; }
.upload-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  gap: 10px;
}
.upload-row .meta { color: var(--ink-3); font-size: 12px; }
a.download-link { color: var(--brand); text-decoration: none; white-space: nowrap; font-weight: 500; }
a.download-link:hover { text-decoration: underline; }
.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

/* ---------------- 每班上限设置行 ---------------- */

.per-class-row {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 13px 15px;
  background: var(--warm);
  border: 1px solid var(--warm-line);
  border-radius: var(--radius-sm);
}
.per-class-row label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.switch-label { font-size: 14px; color: var(--ink); cursor: pointer; }
.switch-label input[type="checkbox"] { min-width: 0; width: auto; transform: scale(1.2); cursor: pointer; accent-color: var(--brand); }
.per-class-row input[type="number"] { min-width: 90px; width: 90px; padding: 8px 10px; }
.per-class-row input[type="number"]:disabled { background: #f1f2f6; color: #b3b6c2; cursor: not-allowed; }

/* ---------------- 模式切换 tab ---------------- */

.mode-tabs { display: flex; gap: 10px; margin-bottom: 18px; }
.mode-tab {
  padding: 10px 20px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  transition: all .15s;
}
.mode-tab:hover { border-color: var(--brand-line); color: var(--brand-deep); }
.mode-tab.active {
  background: var(--grad-brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(46, 96, 227, 0.26);
}

/* ---------------- 班级操作行 ---------------- */

.class-actions { display: flex; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }

/* ---------------- 登录页 ---------------- */

.login-wrap { max-width: 410px; margin: 9vh auto; }
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 30px;
  box-shadow: var(--shadow);
}
.login-card h2 { margin-bottom: 22px; font-size: 19px; text-align: center; color: var(--ink); font-weight: 700; }
.login-card label { margin-bottom: 16px; }
.login-card input { width: 100%; min-width: 0; }
.login-card .btn { width: 100%; padding: 12px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: center; }

/* ---------------- admin 顶栏 / 班级管理 / 改密 ---------------- */

.admin-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-badge { background: var(--brand-soft); color: var(--brand-deep); border-radius: 12px; padding: 3px 12px; font-size: 12px; font-weight: 600; }
.class-manage-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 8px; font-size: 14px; transition: border-color .15s, background .15s;
}
.class-manage-row:hover { border-color: var(--brand-line); background: var(--brand-softer); }
.class-manage-row .meta { color: var(--ink-3); font-size: 12px; margin-left: 8px; }
.class-manage-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.password-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.password-form label { flex: 1; min-width: 160px; }
