.dashboard-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 24px;
  align-items: end;
  margin-bottom: 18px;
}

.dashboard-heading {
  display: grid;
  gap: 7px;
}

.dashboard-kicker {
  margin: 0;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.dashboard-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-stat {
  min-width: 92px;
  border-left: 1px solid var(--line);
  padding: 2px 0 2px 16px;
}

.summary-stat span,
.summary-stat strong {
  display: block;
}

.summary-stat span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
}

.summary-stat strong {
  margin-top: 1px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
}

.context-switch {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.context-switch::-webkit-scrollbar {
  display: none;
}

.context-switch a,
.context-switch span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 11px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
}

.context-switch span.is-disabled {
  border-style: dashed;
  background: #f5f7f5;
  color: var(--muted);
  cursor: not-allowed;
}

.context-switch a.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.search-panel {
  position: relative;
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 8px;
}

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

.search-panel-header h2,
.search-panel-header p {
  margin: 0;
}

.search-panel-header h2 {
  font-size: 1.18rem;
}

.search-panel-header p {
  color: var(--muted);
  font-size: 0.78rem;
}

.search-modes {
  width: 220px;
  flex: 0 0 auto;
}

.search-form {
  display: grid;
  gap: 10px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.search-field {
  position: relative;
  min-width: 0;
}

.search-field > .lucide {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 19px;
  height: 19px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 11px 48px 11px 42px;
}

.search-field input::placeholder {
  color: #8b9692;
}

.clear-search {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
  cursor: pointer;
}

.clear-search:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.search-submit {
  min-width: 124px;
}

.search-feedback {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.search-feedback:empty {
  display: none;
}

.search-feedback strong {
  color: var(--text);
}

.rankings-trust {
  margin-bottom: 24px;
}

.podium-section,
.leaderboard-section {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 13px;
  margin-top: 30px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

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

.section-heading p {
  color: var(--muted);
  font-size: 0.84rem;
}

.podium {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 12px;
  padding-top: 30px;
}

.rank-card {
  position: relative;
  min-width: 0;
  min-height: 208px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  border: 2px solid var(--line);
  border-top: 4px solid var(--silver);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  color: var(--text);
  text-decoration: none;
}

.podium-crown {
  position: absolute;
  top: -31px;
  left: 50%;
  width: 62px;
  height: 44px;
  transform: translateX(-50%);
  fill: currentColor;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3px;
  filter: drop-shadow(0 5px 5px rgba(23, 32, 30, 0.18));
}

.rank-card:hover {
  color: var(--text);
  box-shadow: var(--shadow);
}

.rank-card h3,
.rank-card p {
  margin: 0;
}

.rank-card h3 {
  overflow-wrap: anywhere;
  font-size: 1.04rem;
}

.rank-card p {
  color: var(--muted);
  font-size: 0.8rem;
}

.rank-card .rank-number {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.rank-card.rank-1 {
  order: 1;
  border-color: var(--gold);
  background: #fff8df;
  box-shadow: 0 10px 26px rgba(137, 96, 0, 0.14);
}

.rank-card.rank-1 .podium-crown {
  top: -37px;
  width: 76px;
  height: 52px;
  color: #d19a00;
}

.rank-card.rank-1 .rank-number {
  color: #7b5900;
}

.rank-card.rank-2 {
  order: 2;
  border-color: var(--silver);
  background: #f7f9fa;
}

.rank-card.rank-2 .podium-crown {
  color: #8c9ba4;
}

.rank-card.rank-2 .rank-number {
  color: #52616a;
}

.rank-card.rank-3 {
  order: 3;
  border-color: var(--bronze);
  background: #fff6f0;
}

.rank-card.rank-3 .podium-crown {
  color: #aa6235;
}

.rank-card.rank-3 .rank-number {
  color: #7a4324;
}

.rank-card-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.student-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.metric {
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 6px 8px;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 650;
}

.metric strong {
  color: var(--text);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.leaderboard-tools {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-tools h2,
.leaderboard-tools p {
  margin: 0;
}

.leaderboard-note {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.leaderboard-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.leaderboard-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.leaderboard-table td {
  font-size: 0.84rem;
}

.leaderboard-table tr:last-child td {
  border-bottom: 0;
}

.leaderboard-table tbody tr:hover {
  background: #fafcfb;
}

.student-name {
  display: grid;
  gap: 3px;
}

.student-name a {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
}

.student-name a:hover {
  color: var(--primary);
}

.school-link {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.school-link:hover {
  color: var(--primary);
}

.highlight-row,
.highlight-card {
  background: var(--accent-soft) !important;
  box-shadow: inset 4px 0 0 var(--accent);
}

.mobile-leaderboard {
  width: 100%;
  min-width: 0;
  display: none;
}

.mobile-student-row {
  width: 100%;
  min-width: 0;
  min-height: 78px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto 20px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
}

.mobile-student-row:last-child {
  border-bottom: 0;
}

.mobile-rank {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--primary-strong);
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mobile-student-main {
  min-width: 0;
}

.mobile-student-main h3,
.mobile-student-main p {
  margin: 0;
}

.mobile-student-main h3 {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-student-main p {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-score {
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mobile-score strong,
.mobile-score span {
  display: block;
}

.mobile-score strong {
  font-size: 0.82rem;
}

.mobile-score span {
  color: var(--muted);
  font-size: 0.65rem;
}

.mobile-chevron {
  color: var(--muted);
  font-size: 1.1rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.pagination-status {
  min-width: 112px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  text-align: center;
}

@media (max-width: 820px) {
  .dashboard-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .dashboard-summary {
    justify-content: flex-start;
  }

  .summary-stat:first-child {
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 760px) {
  .dashboard-header {
    gap: 13px;
    margin-bottom: 13px;
  }

  .dashboard-kicker {
    font-size: 0.69rem;
  }

  .dashboard-subtitle {
    font-size: 0.82rem;
  }

  .dashboard-summary {
    display: none;
  }

  .context-switch {
    margin-bottom: 12px;
  }

  .search-panel {
    padding: 14px;
  }

  .search-panel-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .search-panel-header h2 {
    font-size: 1.06rem;
  }

  .search-modes {
    width: 100%;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .search-submit {
    width: 48px;
    min-width: 48px;
    padding: 0;
  }

  .search-submit span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .rankings-trust {
    margin-bottom: 20px;
  }

  .podium-section,
  .leaderboard-section {
    margin-top: 24px;
  }

  .section-heading p {
    display: none;
  }

  .podium {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 9px;
    row-gap: 39px;
    padding-top: 33px;
  }

  .rank-card {
    min-height: 158px;
    gap: 8px;
    padding: 13px;
  }

  .rank-card.rank-1 {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    min-height: 150px;
  }

  .rank-card.rank-1 .badge,
  .rank-card.rank-1 .rank-number,
  .rank-card.rank-1 .rank-card-copy {
    grid-column: 1;
  }

  .rank-card.rank-1 .rank-number {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    font-size: 3rem;
    color: #7b5900;
  }

  .rank-card.rank-1 .rank-card-link {
    grid-column: 1 / -1;
  }

  .rank-card.rank-1 .student-metrics {
    grid-column: 1 / -1;
  }

  .rank-card.rank-2 .rank-number,
  .rank-card.rank-3 .rank-number {
    font-size: 1.6rem;
  }

  .rank-card.rank-2 .student-metrics,
  .rank-card.rank-3 .student-metrics {
    display: none;
  }

  .rank-card.rank-2 h3,
  .rank-card.rank-3 h3 {
    font-size: 0.86rem;
  }

  .table-wrap {
    display: none;
  }

  .mobile-leaderboard {
    display: block;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .leaderboard-tools,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

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

  .pagination .button {
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
  }

  .pagination-status {
    grid-row: 1;
    grid-column: 1 / -1;
    justify-self: center;
  }
}

@media (max-width: 360px) {
  .mobile-student-row {
    grid-template-columns: 38px minmax(0, 1fr) auto 14px;
    gap: 8px;
    padding-right: 9px;
    padding-left: 9px;
  }

  .mobile-rank {
    width: 38px;
    height: 38px;
  }

  .mobile-score span {
    display: none;
  }

  .pagination .button {
    min-width: 0;
    padding-right: 9px;
    padding-left: 9px;
    font-size: 0.76rem;
  }

  .pagination-status {
    min-width: 76px;
  }
}
