.compare-page {
  display: grid;
  gap: 24px;
}

.compare-intro {
  display: grid;
  gap: 8px;
  max-width: 720px;
}

.compare-intro h1,
.compare-intro p {
  margin: 0;
}

.selector-section,
.comparison-section {
  display: grid;
  gap: 16px;
}

.section-heading-row,
.comparison-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading-row h2,
.section-heading-row p,
.comparison-heading h2,
.comparison-heading p {
  margin: 0;
}

.selector-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.student-selector {
  min-width: 0;
  display: grid;
  gap: 13px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.selector-header h3 {
  margin: 0;
  font-size: 1rem;
}

.selector-remove {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger);
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.selector-form {
  display: grid;
  gap: 11px;
}

.selector-form label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.73rem;
  font-weight: 700;
}

.selector-form select,
.selector-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

.selector-submit {
  width: 100%;
}

.selector-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 650;
}

.loaded-student {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.loaded-student strong,
.loaded-student span {
  display: block;
}

.loaded-student strong {
  overflow-wrap: anywhere;
  font-family: var(--font-display);
}

.loaded-student span {
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.75rem;
}

.add-student-button {
  width: max-content;
}

.comparison-section {
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.comparison-feedback {
  min-height: 20px;
  margin: -8px 0 0;
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 650;
}

.comparison-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.comparison-table {
  width: 100%;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
}

.comparison-table th,
.comparison-table td {
  min-width: 190px;
  max-width: 260px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
  overflow-wrap: anywhere;
  text-align: left;
  vertical-align: top;
}

.comparison-table tr:last-child th,
.comparison-table tr:last-child td {
  border-bottom: 0;
}

.comparison-table th:last-child,
.comparison-table td:last-child {
  border-right: 0;
}

.comparison-table thead th {
  background: var(--surface-soft);
  font-family: var(--font-display);
  font-size: 0.82rem;
}

.comparison-table thead th span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
}

.comparison-table .metric-column {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 126px;
  max-width: 126px;
  background: #f8faf8;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.comparison-table thead .metric-column {
  z-index: 3;
  color: var(--text);
}

.comparison-table .comparison-section-row th {
  position: static;
  max-width: none;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-family: var(--font-display);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.comparison-table td.is-best {
  background: #e8f6ef;
  color: var(--primary-strong);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(11, 107, 88, 0.18);
}

@media (max-width: 760px) {
  .compare-page {
    gap: 20px;
  }

  .section-heading-row,
  .comparison-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .selector-grid {
    grid-template-columns: 1fr;
  }

  .student-selector {
    padding: 14px;
  }

  .add-student-button,
  .comparison-heading .button {
    width: 100%;
  }

  .comparison-table th,
  .comparison-table td {
    min-width: 178px;
    max-width: 210px;
    padding: 10px;
  }

  .comparison-table .metric-column {
    min-width: 108px;
    max-width: 108px;
  }
}
