:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #176b87;
  --primary-dark: #0f5066;
  --accent: #d97941;
  --success: #2d8a5f;
  --danger: #c24141;
  --shadow: 0 10px 30px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

.home-page {
  display: grid;
  place-items: center;
  padding: 18px;
}

.home-shell {
  width: min(720px, 100%);
  padding: 0;
}

.home-card {
  display: grid;
  gap: 18px;
  padding: 28px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.home-card h1 {
  font-size: clamp(28px, 8vw, 42px);
}

.home-subtitle {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 18px;
}

.home-entry-grid {
  display: grid;
  gap: 12px;
}

.home-entry {
  display: grid;
  gap: 6px;
  padding: 18px;
  color: var(--primary);
  background: #e9f2f5;
  border: 1px solid #c5dbe3;
  border-radius: 8px;
  text-decoration: none;
  text-align: left;
}

.home-entry span {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

.home-entry small {
  color: var(--muted);
  font-size: 14px;
}

.home-entry.primary-entry {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.home-entry.primary-entry span,
.home-entry.primary-entry small {
  color: #ffffff;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  gap: 16px;
  padding: 18px 16px 14px;
  background: rgba(245, 247, 251, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow,
.section-label {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 22px;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.nav-tab,
.primary-btn,
.secondary-btn,
.history-btn,
.icon-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8edf4;
  color: #314055;
  text-decoration: none;
}

.nav-tab.active {
  background: var(--primary);
  color: #ffffff;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.panel,
.result-card,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.intro-panel {
  display: grid;
  gap: 14px;
}

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

.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  color: var(--primary);
  border: 1px solid #b7cad3;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid #c7d0dd;
  border-radius: 8px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.primary-btn {
  padding: 0 18px;
  color: #ffffff;
  background: var(--primary);
}

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

.secondary-btn,
.history-btn {
  padding: 0 14px;
  color: var(--primary);
  background: #e9f2f5;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--primary);
  background: #e9f2f5;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}

.danger-btn {
  min-height: 44px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--danger);
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.full {
  width: 100%;
}

.notice {
  border-left: 4px solid var(--accent);
}

.notice p {
  margin-bottom: 0;
  color: var(--muted);
}

.retry-panel {
  display: grid;
  gap: 10px;
  border-left: 4px solid var(--danger);
}

.retry-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.finish-panel {
  display: grid;
  gap: 10px;
}

.large-action {
  min-height: 54px;
  font-size: 17px;
}

.current-session {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: #eef5f7;
  border-radius: 8px;
  color: #344054;
}

.current-session strong {
  color: var(--text);
}

.result-card {
  padding: 18px;
}

.result-score {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  color: var(--success);
}

.result-meta {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  color: var(--muted);
}

.teacher-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.teacher-main {
  width: min(1280px, 100%);
}

.teacher-topbar {
  grid-template-columns: 1fr;
}

.teacher-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.teacher-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 24px;
}

.stat-card.score-stat {
  border-color: #b9d3dc;
  background: #f4fafc;
}

.stat-card.score-stat strong {
  color: var(--primary-dark);
}

.controls {
  display: grid;
  gap: 12px;
}

.teacher-controls {
  display: grid;
  gap: 16px;
}

.filter-card {
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 4px;
}

.filter-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f6;
}

.filter-card-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.3;
}

.filter-reset-btn {
  min-height: 34px;
  padding: 0 12px;
  color: var(--primary);
  background: #f2f7fa;
  border: 1px solid #c5dbe3;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}

.filter-reset-btn:hover {
  color: var(--primary-dark);
  background: #e6f0f4;
  border-color: #9fc2cf;
}

.filter-reset-btn:active {
  transform: translateY(1px);
}

.filter-row {
  display: grid;
  gap: 12px;
}

.filter-row label {
  gap: 8px;
  color: #263445;
  font-size: 13px;
  letter-spacing: 0;
}

.filter-row input,
.filter-row select {
  min-height: 44px;
  padding: 10px 12px;
  background: #fbfcfe;
  border-color: #d4dce8;
  border-radius: 8px;
}

.filter-row input::placeholder {
  color: #98a2b3;
}

.dashboard-view {
  display: grid;
  gap: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tab-btn {
  min-height: 46px;
  color: var(--primary);
  background: #e9f2f5;
  border: 1px solid #c5dbe3;
  border-radius: 8px;
  font-weight: 800;
}

.tab-btn.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.tab-panel {
  display: grid;
  gap: 14px;
}

.auth-panel {
  display: grid;
  gap: 18px;
  max-width: 520px;
  margin: 36px auto 0;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.password-notice {
  display: grid;
  gap: 18px;
  max-width: 680px;
  margin: 36px auto 0;
  border-left: 4px solid var(--accent);
}

.notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.password-form {
  gap: 14px;
}

.error-text {
  margin-bottom: 0;
  color: var(--danger);
  font-weight: 700;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.distribution-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 36px;
  align-items: center;
  gap: 10px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  background: #e8edf4;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
}

.table-panel {
  overflow: hidden;
}

.teacher-table-panel {
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.teacher-table {
  min-width: 1460px;
}

.class-table {
  min-width: 860px;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: #475467;
  background: #f8fafc;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.student-row {
  cursor: pointer;
}

.student-row:hover td,
.student-row:focus td {
  background: #f1f7f9;
}

.student-row:focus {
  outline: 3px solid rgba(23, 107, 135, 0.18);
  outline-offset: -3px;
}

.history-row td {
  background: #f8fafc;
  white-space: normal;
}

.inline-history {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  color: #475467;
  border-left: 4px solid var(--primary);
}

.inline-history strong {
  color: var(--primary);
}

.class-form {
  display: grid;
  gap: 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
}

.status-chip.active {
  color: var(--success);
  background: #e9f6ef;
}

.status-chip.inactive {
  color: var(--muted);
  background: #eef2f6;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-btn {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(680px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.confirm-dialog {
  width: min(440px, calc(100% - 32px));
}

.confirm-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.confirm-body h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

.confirm-body p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 42px;
  color: #344054;
  background: #eef2f6;
  font-size: 24px;
  line-height: 1;
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: min(66vh, 520px);
  overflow: auto;
  padding: 16px;
}

.history-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-item strong {
  color: var(--primary);
  font-size: 20px;
}

.history-item span {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: calc(100% - 32px);
  padding: 12px 14px;
  color: #ffffff;
  background: #162033;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
    align-items: end;
    padding: 20px 28px 16px;
  }

  .nav-tabs {
    width: 360px;
  }

  main {
    padding: 24px;
  }

  .intro-panel {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .form-grid .full {
    grid-column: span 3;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .controls {
    grid-template-columns: 1fr 280px;
    align-items: end;
  }

  .teacher-topbar {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .teacher-actions {
    grid-template-columns: repeat(4, auto);
  }

  .teacher-stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .filter-card {
    padding: 20px;
  }

  .filter-row-search {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-row-selects {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .class-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
  }

  .home-card {
    padding: 42px;
  }

  .home-entry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 719px) {
  .filter-card {
    padding: 16px;
  }

  .filter-card-head {
    padding-bottom: 10px;
  }

  .filter-card-head h2 {
    font-size: 17px;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .teacher-actions {
    grid-template-columns: 1fr;
  }

  .notice-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-history {
    grid-template-columns: 1fr;
  }

  .confirm-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .teacher-head,
  .teacher-actions {
    align-items: stretch;
  }
}
