:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wrap {
  max-width: 1100px; width: 100%;
  margin: 0 auto;
  padding: 14px 16px 8px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.topbar {
  background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #3b82f6);
  color: #fff;
  padding: 14px 0;
  box-shadow: 0 2px 10px rgba(30, 58, 138, .25);
  flex: none;
}
.topbar-in {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-text { min-width: 0; }
.topbar h1 { margin: 0 0 2px; font-size: 20px; letter-spacing: 1px; }
.topbar .sub { margin: 0; opacity: .9; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user { color: rgba(255,255,255,.85); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin: 18px 0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .06);
}
.card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--primary-dark);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}
.card h2.mt { margin-top: 26px; }

.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: #eff6ff; }
.dropzone.small { padding: 18px; }
.dz-icon { font-size: 38px; }
.dz-title { margin: 6px 0 2px; font-weight: 600; color: var(--text); }
.dz-hint { margin: 0; color: var(--muted); font-size: 13px; }

.file-info {
  margin-top: 10px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #166534;
  font-size: 14px;
}
.file-info.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.hidden { display: none !important; }

.row-actions { margin-top: 12px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tip { color: var(--muted); font-size: 12px; }

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.config-grid label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); gap: 6px; }
.config-grid input, .config-grid select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
}
.checks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.check { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }

#btn-run { font-size: 16px; padding: 13px 34px; }
.loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(3px);
  color: var(--primary);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.loading::before {
  content: "";
  width: 20px; height: 20px;
  border: 3px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

button:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.warnings {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.warnings li { margin: 2px 0; }

.rounds-info {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.rounds-info .ri-title { margin-bottom: 8px; }
.rounds-info table.mini { border-collapse: collapse; font-size: 12px; }
.rounds-info table.mini th, .rounds-info table.mini td {
  border: 1px solid #d1fae5;
  padding: 3px 10px;
  text-align: center;
}
.rounds-info table.mini th { background: #d1fae5; }

.seed-record {
  background: #eff6ff;
  border: 1px dashed #60a5fa;
  color: #1e40af;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.metric-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  flex: none;
}
.metric {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 4px 12px;
  text-align: center;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.metric .m-label { font-size: 12px; color: var(--muted); }
.metric .m-value { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.metric .m-unit { font-size: 11px; color: var(--muted); }
.metric.good .m-value { color: var(--ok); }

.block { margin: 22px 0; }
.block h3 {
  font-size: 15px;
  margin: 0 0 10px;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
table.data th, table.data td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: center;
  white-space: nowrap;
}
table.data th { background: #f1f5f9; font-weight: 600; position: sticky; top: 0; }
table.data tr:nth-child(even) { background: #f8fafc; }
table.data tr.gap-row td { background: #fffbeb; font-weight: 600; }
table.data td.l, table.data th.l { text-align: left; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tabs button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.dup-info { display: flex; flex-wrap: wrap; gap: 8px; }
.dup-info .chip {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 13px;
}

.downloads { margin: 24px 0 8px; }
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 0 30px;
}

/* ================= 阳光分班：分步骤界面 ================= */
.topbar-in { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.btn.light { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn.light:hover { background: rgba(255,255,255,.26); }
.btn.accent { background: var(--warn); color: #fff; }
.btn.sm { padding: 6px 14px; font-size: 13px; }

.stepper {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 0 4px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.stepper .step {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 22px;
  border-radius: 24px;
  color: var(--muted);
  font-size: 14px;
  transition: all .15s;
  user-select: none;
}
.stepper .step .n {
  width: 24px; height: 24px; border-radius: 50%;
  background: #e2e8f0; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.stepper .step.active { background: var(--primary); color: #fff; }
.stepper .step.active .n { background: #fff; color: var(--primary); }
.stepper .step.done { color: var(--primary); }
.stepper .step.done .n { background: #dbeafe; color: var(--primary); }
.stepper .step.clickable { cursor: pointer; }
.stepper .step.clickable:hover { background: #eff6ff; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px 28px;
  margin: 0 0 14px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .06);
}
.panel.panel-screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* 欢迎页一屏大屏：内容垂直居中 */
.panel#step-1 { justify-content: center; }
.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--primary-dark);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}
.panel-inner {
  margin-top: 20px;
  border: 1px dashed #fbbf24;
  border-radius: 10px;
  background: #fffbeb;
  padding: 18px 20px;
}
.panel-inner h3 { margin: 0 0 8px; font-size: 15px; color: #92400e; }

.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.result-head h2 { margin-bottom: 12px; }

/* 结果页一屏：顶部信息 + 指标 + 标签页 + 内容区 */
.res-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex: none;
  margin-bottom: 8px;
}
.res-head-info { flex: 1; min-width: 0; }
.res-head-info .rounds-info { margin-bottom: 8px; }
.elapsed-info {
  display: inline-block;
  font-size: 13px;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 4px 14px;
  margin-bottom: 4px;
}
.res-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }

.res-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  flex: none;
  margin-bottom: 10px;
}
.res-tabs button {
  border: none;
  background: none;
  padding: 8px 20px;
  font-size: 15px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.res-tabs button:hover { color: var(--primary); }
.res-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.res-tab-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.rtab { display: none; padding: 12px; }
.rtab.active { display: block; }
.rtab table.data { width: 100%; }
.teacher-empty { color: var(--muted); font-size: 14px; padding: 10px 0; }

/* 各班名单双列间隔列 */
#roster-table .roster-gap {
  width: 18px;
  min-width: 18px;
  border: none !important;
  background: transparent !important;
}

/* 欢迎页（大屏） */
.hero { text-align: center; padding: 30px 10px 10px; }
.hero h2 { border: none; padding: 0; font-size: 30px; letter-spacing: 2px; color: var(--primary-dark); margin: 0 0 12px; }
.hero p { color: var(--muted); max-width: 720px; margin: 0 auto; font-size: 15px; }
.welcome-stats { display: flex; justify-content: center; gap: 40px; margin: 34px 0; }
.welcome-stats .stat { text-align: center; }
.welcome-stats .s-val { font-size: 46px; font-weight: 800; color: var(--primary); }
.welcome-stats .s-lab { color: var(--muted); font-size: 14px; }
.hero-cta { text-align: center; margin: 6px 0 14px; }
.welcome-flow { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

.btn.big { font-size: 17px; padding: 15px 46px; border-radius: 30px; }

.nav-btns { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }
.nav-btns.center { justify-content: center; }
.result-actions { display: flex; gap: 12px; margin: 26px 0 6px; flex-wrap: wrap; }

/* 分班列表弹层 */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%; max-width: 780px;
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(15,23,42,.25);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; color: var(--primary-dark); }
.modal-close {
  border: none; background: #f1f5f9; color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px; font-size: 20px; cursor: pointer; line-height: 1;
}
.modal-close:hover { background: #e2e8f0; }
.history-list { padding: 12px 22px 22px; overflow-y: auto; }
.hrow {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.hrow:hover { border-color: var(--primary); background: #f8fafc; }
.h-title { font-weight: 700; margin-bottom: 4px; }
.h-meta { color: var(--muted); font-size: 13px; }
.h-actions { display: flex; gap: 8px; }
.error-text { color: var(--danger); font-size: 14px; }
.ok-note {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin: 0 0 14px;
}

/* 轻提示 toast */
.toast-box {
  position: fixed;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(15,23,42,.25);
  max-width: 80vw;
  animation: toast-in .25s ease;
  transition: opacity .3s, transform .3s;
}
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* 确认框 */
.modal-box.small { max-width: 420px; }
.confirm-msg { padding: 18px 22px 6px; margin: 0; color: var(--text); font-size: 15px; line-height: 1.7; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }

/* 输入框 */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.input-hint { color: var(--muted); font-size: 12px; margin: 8px 22px 16px; }

/* 系统设置 */
.settings-tabs { display: flex; gap: 0; border-bottom: 1px solid #e5e7eb; padding: 0 22px; }
.settings-tab { padding: 12px 20px; border: none; background: none; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.settings-panel { padding-top: 16px; }
.form-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f3f4f6; flex-wrap: wrap; }
.form-label { min-width: 120px; font-size: 14px; color: var(--text); font-weight: 500; }
.form-hint { font-size: 12px; color: var(--muted); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 24px; transition: .2s; }
.switch .slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.user-fields { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.user-fields .input { flex: 1; min-width: 100px; padding: 8px 10px; font-size: 13px; }
.user-fields .user-username { max-width: 140px; }
.user-fields .user-nickname { max-width: 140px; }
.user-fields .user-password { max-width: 140px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid #eee; }

/* ================= server 版补充样式 ================= */
.h-info { flex: 1; min-width: 0; }
.user-chip { display: inline-block; background: #f1f5f9; border: 1px solid #e2e8f0; color: #334155; border-radius: 6px; padding: 4px 10px; font-size: 13px; }
.user-chip.chip-admin { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.user-chip.dim { background: transparent; border-color: transparent; color: #94a3b8; }
.user-add-row { background: #f8fafc; border-radius: 8px; padding: 10px; }
.user-add-actions { display: flex; gap: 8px; flex-shrink: 0; }
.user-del { color: #dc2626 !important; border-color: #fecaca !important; }
.user-row .input { min-width: 100px; padding: 8px 10px; font-size: 13px; }
.settings-body { min-height: 220px; }