/* ============================================================
   阳光分班系统 · 样式
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --sun: #f59e0b;
  --sun-light: #fef3c7;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1e2537;
  --ink-2: #55607a;
  --ink-3: #8a93aa;
  --line: #e4e8f2;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --c1: #2563eb;
  --c2: #f59e0b;
  --c3: #16a34a;
  --c4: #db2777;
  --c5: #7c3aed;
  --c6: #0891b2;
  --c7: #ea580c;
  --c8: #65a30d;
}

* { box-sizing: border-box; }

/* hidden 属性必须始终生效：作者样式里的 display 会压过 UA 样式表的 [hidden] 规则，
   例如 .modal { display: grid } 会让带 hidden 的弹窗永远关不掉。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: linear-gradient(120deg, #1e3a8a 0%, #2563eb 55%, #0ea5e9 100%);
  color: #fff;
  box-shadow: 0 6px 20px -10px rgba(37, 99, 235, .9);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: grid; place-items: center;
  font-size: 26px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
}
.brand-text h1 { margin: 0; font-size: 20px; letter-spacing: 1px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; opacity: .82; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seed-chip {
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .35);
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .32); color: #fff; }
.topbar .btn:hover { background: rgba(255, 255, 255, .26); }

/* ---------------- 步骤条 ---------------- */
.stepper {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 26px 0;
  max-width: 1400px; margin: 0 auto;
}
.step {
  flex: 1 1 150px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink-2); cursor: pointer; font-size: 14px;
  transition: .18s;
}
.step:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.step .num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--line); color: var(--ink-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.step.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow); }
.step.active .num { background: rgba(255, 255, 255, .28); color: #fff; }
.step.done .num { background: var(--ok); color: #fff; }

/* ---------------- 主体 / 标签页 ---------------- */
.main { max-width: 1400px; margin: 0 auto; padding: 18px 26px 40px; }
.tab { display: none; animation: fade .25s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 18px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fbfcff);
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.card-head h2::before {
  content: ""; display: inline-block; width: 4px; height: 15px;
  background: var(--primary); border-radius: 2px; margin-right: 9px;
  vertical-align: -2px;
}
.card-body { padding: 18px 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.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: 1000px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------------- 按钮 ---------------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff;
  color: var(--ink); padding: 7px 14px; border-radius: 9px;
  font-size: 13px; cursor: pointer; transition: .15s; white-space: nowrap;
  font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: #f8faff; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

.btn-big {
  font-size: 19px; padding: 16px 46px; border-radius: 999px;
  background: linear-gradient(120deg, var(--primary), #0ea5e9);
  border: none; color: #fff; font-weight: 700; letter-spacing: 2px;
  box-shadow: 0 12px 26px -12px rgba(37, 99, 235, .85);
}
.btn-big:hover { transform: translateY(-2px); color: #fff; filter: brightness(1.06); }
.btn-big:disabled { transform: none; filter: none; opacity: .6; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 13px; color: var(--ink-2);
  margin-bottom: 7px; font-weight: 600;
}
.inline-val { color: var(--primary); font-size: 14px; margin-left: 4px; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--ink); transition: .15s;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
input[type="range"] {
  width: 100%; accent-color: var(--primary); height: 24px;
}
.tip { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.6; }
.notice {
  background: #f0f7ff; border: 1px solid #d6e8ff; border-left: 3px solid var(--primary);
  padding: 11px 14px; border-radius: 9px; font-size: 13px;
  color: var(--ink-2); margin-top: 14px; line-height: 1.85;
}
.notice b { color: var(--primary-dark); }

.radio-cards { display: grid; gap: 10px; }
.radio-card {
  display: block; position: relative;
  border: 1.5px solid var(--line); border-radius: 11px;
  padding: 11px 14px 11px 40px; cursor: pointer; transition: .15s;
}
.radio-card input { position: absolute; left: 14px; top: 15px; accent-color: var(--primary); }
.radio-card:hover { border-color: #b9cdfb; background: #fafcff; }
.radio-card.active { border-color: var(--primary); background: #f2f7ff; }
.rc-title { display: block; font-weight: 700; font-size: 14px; }
.rc-desc { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
  transition: .15s;
}
.check-chip input { accent-color: var(--primary); margin: 0; }
.check-chip.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.check-chip.empty { color: var(--ink-3); cursor: default; border-style: dashed; }

/* ---------------- KPI ---------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 6px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px;
}
.kpi .k-label { font-size: 12px; color: var(--ink-3); }
.kpi .k-value { font-size: 24px; font-weight: 700; color: var(--primary-dark); line-height: 1.3; }
.kpi .k-value.small { font-size: 17px; }
.kpi .k-sub { font-size: 11px; color: var(--ink-3); }
.kpi.accent { background: linear-gradient(135deg, #eff6ff, #f8fafc); border-color: #cfe0ff; }

/* ---------------- 表格 ---------------- */
.table-scroll { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 10px; margin-top: 14px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 8px 11px; text-align: left; white-space: nowrap; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f7f9fe; color: var(--ink-2); font-weight: 700;
  border-bottom: 2px solid var(--line);
}
table.grid tbody tr:hover { background: #f9fbff; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.center, table.grid th.center { text-align: center; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; background: var(--line); color: var(--ink-2);
}
.tag.male { background: #dbeafe; color: #1d4ed8; }
.tag.female { background: #fce7f3; color: #be185d; }
.tag.talent { background: var(--sun-light); color: #b45309; }
.tag.blue { background: var(--primary-light); color: var(--primary-dark); }

/* ---------------- 粘贴面板 ---------------- */
.paste-panel { margin-top: 14px; padding: 14px; border: 1px dashed var(--primary); background: #f8faff; border-radius: 11px; }
.paste-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--primary-dark); }
.paste-panel textarea { min-height: 170px; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.paste-panel .btn-row { margin-top: 10px; }

/* ---------------- 执行分班 ---------------- */
.run-body { text-align: center; padding: 34px 20px 24px; }
.run-summary {
  display: flex; justify-content: center; gap: 26px; flex-wrap: wrap;
  margin-bottom: 22px; color: var(--ink-2); font-size: 14px;
}
.run-summary b { color: var(--primary-dark); font-size: 17px; }
.progress {
  height: 9px; background: var(--line); border-radius: 999px;
  margin: 24px auto 8px; max-width: 640px; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  transition: width .2s;
}
.progress-text { font-size: 12px; color: var(--ink-3); min-height: 18px; }
.console {
  margin-top: 18px; text-align: left;
  background: #101828; color: #b9e6c9; border-radius: 11px;
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px;
  padding: 14px 16px; height: 280px; overflow: auto; line-height: 1.75;
}
.console .line { white-space: pre-wrap; word-break: break-all; }
.console .warn { color: #fcd34d; }
.console .ok { color: #86efac; }
.console .head { color: #7dd3fc; }
.console .time { color: #64748b; margin-right: 8px; }

/* ---------------- 结果 ---------------- */
.empty-tip { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 46px; }
.empty-tip p { margin: 8px 0; font-size: 16px; color: var(--ink-2); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 1000px) { .charts { grid-template-columns: 1fr; } }
.chart-box { border: 1px solid var(--line); border-radius: 11px; padding: 10px 8px 4px; background: #fff; }
.chart-title { font-size: 13px; font-weight: 700; padding: 0 8px 4px; color: var(--ink-2); }
.chart-box svg { width: 100%; height: auto; display: block; }

.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.class-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.class-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 13px; color: #fff; font-weight: 700; font-size: 14px;
}
.class-card-head .cc-meta { font-size: 12px; font-weight: 400; opacity: .92; }
.class-teacher { padding: 8px 13px; background: #f8fafc; border-bottom: 1px dashed var(--line); font-size: 12.5px; color: var(--ink-2); }
.class-teacher b { color: var(--primary-dark); }
.class-card .table-scroll { max-height: 330px; margin: 0; border: none; border-radius: 0; }
.class-card table.grid thead th { font-size: 12px; }

/* ---------------- 弹窗 / 提示 ---------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.modal-box {
  position: relative; width: min(880px, 94vw); max-height: 88vh;
  background: #fff; border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-3); }
.modal-body { padding: 18px 22px 26px; overflow: auto; }
.modal-body h3 { font-size: 15px; margin: 20px 0 8px; color: var(--primary-dark); }
.modal-body h3:first-child { margin-top: 0; }
.modal-body ol, .modal-body ul { padding-left: 22px; margin: 8px 0; }
.modal-body li { margin-bottom: 5px; }
.modal-body pre {
  background: #f6f8fc; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; overflow: auto; font-size: 12.5px; line-height: 1.7;
}
table.doc-table { border-collapse: collapse; width: 100%; font-size: 13px; }
table.doc-table th, table.doc-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
table.doc-table th { background: #f7f9fe; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #101828; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 80; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .6);
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.footer { text-align: center; padding: 16px; color: var(--ink-3); font-size: 12px; }

.score-good { color: var(--ok); font-weight: 700; }
.score-mid { color: var(--sun); font-weight: 700; }
.score-bad { color: var(--danger); font-weight: 700; }

/* ---------------- 打印 ---------------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .stepper, .footer, .btn-row, .btn, .toast, .modal, #tabData, #tabConfig,
  #tabTeacher, #tabRun, #resultEmpty, .charts { display: none !important; }
  .main { padding: 0; max-width: none; }
  .tab { display: none !important; }
  #tabResult { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 10px; }
  .table-scroll { max-height: none; overflow: visible; }
  .class-grid { display: block; }
  .class-card { break-inside: avoid; margin-bottom: 12px; border: 1px solid #999; }
  .class-card .table-scroll { max-height: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
