:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #687386;
  --line: #dde5ef;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --mint: #0f9f6e;
  --warn: #b45309;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(36, 48, 72, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 34rem),
    linear-gradient(135deg, #f7fbff 0%, var(--bg) 55%, #eef7f4 100%);
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(430px, 100%);
  padding: 36px;
  border: 1px solid rgba(221, 229, 239, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(135deg, #2563eb, #0f9f6e);
  font-size: 24px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.auth-panel h1,
.teacher-header h1,
.topbar h1 {
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.2;
}

.muted {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 310px;
  resize: vertical;
  padding: 16px;
  line-height: 1.75;
}

input:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}

.primary-button {
  color: white;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  color: var(--brand);
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.08);
}

.ghost-button {
  color: #334155;
  border-color: var(--line);
  background: white;
}

.danger-button {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.08);
}

.subtle-link,
.logout-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  text-decoration: none;
}

.exam-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.exam-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.student-card,
.progress-card,
.question-panel,
.stat-card,
.import-panel {
  border: 1px solid rgba(221, 229, 239, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 28px rgba(36, 48, 72, 0.06);
}

.student-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: #0f9f6e;
  font-size: 22px;
  font-weight: 800;
}

.student-name {
  margin: 0 0 4px;
  font-weight: 800;
}

.student-no {
  margin: 0;
  color: var(--muted);
}

.progress-card {
  padding: 16px;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef7;
}

.progress-track div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--mint));
  transition: width 0.2s;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  overflow: auto;
}

.nav-dot {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #475569;
  background: white;
  cursor: pointer;
  font-weight: 800;
}

.nav-dot.done {
  color: var(--mint);
  border-color: rgba(15, 159, 110, 0.35);
  background: rgba(15, 159, 110, 0.08);
}

.nav-dot.active {
  color: white;
  border-color: var(--brand);
  background: var(--brand);
}

.answer-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 22px;
  padding: 28px;
}

.topbar,
.teacher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.save-state {
  min-width: 118px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.save-state.success {
  color: var(--mint);
  border-color: rgba(15, 159, 110, 0.3);
  background: rgba(15, 159, 110, 0.08);
}

.save-state.error {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.08);
}

.question-panel {
  padding: 26px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 800;
}

.question-panel h2 {
  margin-bottom: 22px;
  white-space: pre-wrap;
  font-size: 22px;
  line-height: 1.65;
}

.action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-bottom: 8px;
}

.teacher-shell {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 24px 0;
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.import-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.import-panel h2 {
  margin-bottom: 8px;
}

.import-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.manager-section {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid rgba(221, 229, 239, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 28px rgba(36, 48, 72, 0.06);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading > span,
.answer-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.table-list {
  display: grid;
  gap: 10px;
}

.add-row {
  margin-bottom: 16px;
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.05);
}

.question-edit-row,
.student-edit-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.question-edit-row {
  grid-template-columns: 70px 110px 80px minmax(220px, 1.4fr) minmax(220px, 1fr) 76px auto auto;
}

.student-edit-row {
  grid-template-columns: 120px 110px 150px 80px 150px 86px auto auto auto;
}

.question-edit-row input,
.student-edit-row input {
  height: 38px;
  padding: 0 10px;
}

.question-edit-row textarea {
  min-height: 74px;
  padding: 10px;
  line-height: 1.5;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.inline-check input {
  width: 16px;
  height: 16px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.toast-stack {
  position: fixed;
  z-index: 20;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #172033;
  background: white;
  box-shadow: var(--shadow);
}

.toast.success {
  color: var(--mint);
}

.toast.error {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.44);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(420px, 100%);
  padding: 26px;
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.modal p {
  color: var(--muted);
  line-height: 1.7;
}

.empty-state {
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

@media (max-width: 860px) {
  .exam-shell {
    grid-template-columns: 1fr;
  }

  .exam-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .question-nav {
    grid-template-columns: repeat(8, 1fr);
  }

  .topbar,
  .teacher-header,
  .action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .stat-grid,
  .import-grid {
    grid-template-columns: 1fr;
  }

  .question-edit-row,
  .student-edit-row {
    grid-template-columns: 1fr;
  }
}
