.student-roster-page {
  --student-accent: #1690a0;
  --roster-card-padding: 24px;
  --student-accent-ring: rgba(22, 144, 160, 0.16);
  --student-accent-soft-bg: rgba(53, 219, 155, 0.12);
  --student-control-border-hover: #b7d6da;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  background: #f8fafc;
}

.student-roster-page:not(.classroom-hub-page) {
  height: 100%;
  min-height: 0;
  overflow: visible;
}

.roster-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: auto;
  min-width: 0;
  max-width: 100%;
  align-self: stretch;
  position: relative;
}

.student-roster-page:not(.classroom-hub-page) .roster-card {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.student-roster-page:not(.classroom-hub-page) .roster-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding: 0;
}

.student-roster-page:not(.classroom-hub-page) .roster-footer {
  margin-top: auto;
}

.roster-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: calc(var(--roster-card-padding) * -1) calc(var(--roster-card-padding) * -1) 1.25rem;
  padding: 1.25rem var(--roster-card-padding);
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.roster-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.roster-control {
  min-width: 170px;
}

.roster-title h1 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
}

.roster-title .text-muted {
  font-size: 0.95rem;
  color: #64748b;
  line-height: 1.25;
}

.roster-table-wrap {
  margin-top: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: clamp(360px, 60vh, 720px);
  background: rgba(248, 250, 252, 0.7);
  position: relative;
  padding: 0;
}


/* Dimm only the table content, not the overlay that sits inside the same wrapper */
.roster-table-wrap.loading .roster-table {
  opacity: 0.6;
}

.roster-loading-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(248, 250, 252, 0.76);
  z-index: 8;
  pointer-events: all;
}

.roster-table-wrap.loading .roster-loading-overlay {
  display: flex;
}

.roster-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.roster-loading-text {
  font-size: 0.92rem;
  color: #334155;
  font-weight: 500;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.roster-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  min-width: 1050px;
}

.roster-table col[data-col="student_avatar"] {
  width: 48px;
}

.roster-table col[data-col="student_name"] {
  width: 180px;
}

.roster-table col[data-col="grade_level"] {
  width: 70px;
}

.roster-table col[data-col="math_lg"],
.roster-table col[data-col="ela_lg"],
.roster-table col[data-col="math_ach"],
.roster-table col[data-col="ela_ach"],
.roster-table col[data-col="math_lq"],
.roster-table col[data-col="ela_lq"] {
  width: 110px;
}

.roster-table thead th {
  box-sizing: border-box;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.roster-table thead {
  background: #f1f5f9;
}

.roster-table thead tr.roster-header-group th {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 14px;
}

.roster-table thead tr.roster-header-columns th,
.roster-table thead th.roster-column-header {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
}

.roster-table thead th.roster-column-header[rowspan] {
  vertical-align: middle;
}

/* thead math cols redefined below with 2px separator; keep only math_prior_score */
.roster-table thead th[data-col="math_prior_score"],
.roster-table tbody td[data-col="math_prior_score"] {
  border-left: 1px solid #e2e8f0;
}

.roster-table thead th[data-col="student_name"] {
  text-align: left;
}

.roster-table thead th[data-col="grade_level"] {
  color: #475569;
}

.roster-table thead th[data-col="student_avatar"] {
  color: #94a3b8;
  font-weight: 500;
  background: #f8fafc;
}

.roster-group-info {
  margin-left: 6px;
  font-size: 0.85rem;
  color: #94a3b8;
  cursor: help;
}

.roster-table tbody td {
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: #1f2937;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
  white-space: nowrap;
  background: transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.roster-table tbody td[data-col="student_name"] {
  font-weight: 600;
  color: #0f172a;
  font-size: 1.05rem;
  text-align: left;
  /* max-width ignored with table-layout: fixed — width controlled by <col> */
}

.roster-row-link {
  display: block;
  width: 100%;
  color: inherit;
  text-decoration: none;
}

.roster-row-link:hover,
.roster-row-link:active,
.roster-row-link:visited {
  color: inherit;
  text-decoration: none;
}

.roster-row-link:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 4px;
}

.roster-row-link--name {
  font-weight: inherit;
  color: inherit;
}

.roster-table tbody td[data-col="student_avatar"] {
  text-align: center;
}

.roster-table tbody td[data-col="grade_level"] {
  color: #475569;
  font-size: 0.95rem;
}

.roster-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.student-roster-page .roster-avatar {
  width: 32px;
  height: 32px;
}

.roster-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.roster-table tbody tr:nth-child(odd) td {
  background: #ffffff;
}

.roster-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}

.roster-table tbody tr {
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.roster-table tbody tr:hover td {
  background: #f0f9ff !important;
}

.roster-table tbody tr:hover td[data-col="student_name"] {
  color: #1e40af !important;
  font-weight: 600;
}

.roster-table tbody td.roster-message-cell {
  text-align: center;
  font-weight: 600;
  padding: 16px 14px;
  background: #f8fafc !important;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}

.roster-table tbody td.roster-message-cell[data-kind="error"] {
  background: #fef2f2 !important;
  color: #991b1b;
  border-bottom-color: #fecaca;
}

.roster-table tbody tr:hover td.roster-status-cell[data-status="on-track"] {
  background: #d1fae5 !important;
}

.roster-table tbody tr:hover td.roster-status-cell[data-status="monitor"] {
  background: #fef3c7 !important;
}

.roster-table tbody tr:hover td.roster-status-cell[data-status="off-track"] {
  background: #fee2e2 !important;
}

.roster-table tbody tr:hover td.roster-status-cell[data-status="no-data"] {
  background: #f1f5f9 !important;
}

.roster-table tbody td.roster-status-cell {
  padding: 10px 14px;
  text-align: center;
  vertical-align: middle;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 500;
  color: #64748b;
}

.roster-table tbody td.roster-status-cell[data-status="on-track"] {
  background: #d1fae5;
  color: #065f46;
}

.roster-table tbody td.roster-status-cell[data-status="monitor"] {
  background: #fef3c7;
  color: #92400e;
}

.roster-table tbody td.roster-status-cell[data-status="no-data"] {
  background: #f1f5f9;
  color: #64748b;
}

.roster-table tbody td.roster-status-cell[data-status="no-data"][data-col="math_lq"],
.roster-table tbody td.roster-status-cell[data-status="no-data"][data-col="ela_lq"] {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.8rem;
}

.roster-table tbody tr:hover td.roster-status-cell[data-status="no-data"][data-col="math_lq"],
.roster-table tbody tr:hover td.roster-status-cell[data-status="no-data"][data-col="ela_lq"] {
  background: #f1f5f9 !important;
  color: #64748b;
}

.roster-table tbody td.roster-status-cell[data-status="off-track"] {
  background: #fee2e2;
  color: #991b1b;
}

.roster-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.roster-table thead th.sortable:hover {
  background: #e2e8f0;
}

.roster-table thead th.sortable::after {
  content: '\25BE';
  font-size: 0.7rem;
  margin-left: 6px;
  opacity: 0.25;
  transition: opacity 0.15s ease;
}

.roster-table thead th.sortable:hover::after {
  opacity: 0.5;
}

.roster-table thead th.sortable.sort-asc::after {
  content: '\25B2';
  opacity: 0.85;
}

.roster-table thead th.sortable.sort-desc::after {
  content: '\25BC';
  opacity: 0.85;
}

.roster-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  padding-bottom: 0.5rem;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 0.95rem;
}

.roster-pagination {
  display: flex;
  align-items: center;
  gap: 14px;
}

.roster-view-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: #64748b;
}

.roster-view-meta-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 600;
}

.roster-view-meta-value {
  color: #0f172a;
  font-weight: 700;
  font-size: 1.05rem;
}

.student-roster-page .roster-pagination .btn-outline-secondary {
  color: #64748b;
  border-color: #cbd5e1;
  background-color: #fff;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.student-roster-page .roster-pagination .btn-outline-secondary:hover,
.student-roster-page .roster-pagination .btn-outline-secondary:focus-visible {
  color: var(--student-accent);
  border-color: var(--student-accent);
  background-color: var(--student-accent-soft-bg);
}

.student-roster-page .roster-pagination .btn-outline-secondary:focus-visible {
  box-shadow: 0 0 0 3px var(--student-accent-ring);
  outline: none;
}

.student-roster-page .roster-pagination .btn-outline-secondary:disabled {
  color: #94a3b8;
  border-color: #e2e8f0;
  background-color: #f8fafc;
}

@media (max-width: 768px) {
  .roster-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .roster-control {
    width: 100%;
  }

  .roster-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Fixed column widths */
.roster-table thead th[data-col="student_name"],
.roster-table tbody td[data-col="student_name"] {
  width: 180px;
  min-width: 180px;
  max-width: 180px;
}

.roster-table thead th[data-col="grade_level"],
.roster-table tbody td[data-col="grade_level"] {
  width: 70px;
  min-width: 70px;
  max-width: 70px;
}

.roster-table thead th[data-col="student_avatar"],
.roster-table tbody td[data-col="student_avatar"] {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  padding: 10px 8px;
}

.roster-table thead th[data-col="math_lg"],
.roster-table thead th[data-col="ela_lg"],
.roster-table thead th[data-col="math_ach"],
.roster-table thead th[data-col="ela_ach"],
.roster-table thead th[data-col="math_lq"],
.roster-table thead th[data-col="ela_lq"],
.roster-table tbody td[data-col="math_lg"],
.roster-table tbody td[data-col="ela_lg"],
.roster-table tbody td[data-col="math_ach"],
.roster-table tbody td[data-col="ela_ach"],
.roster-table tbody td[data-col="math_lq"],
.roster-table tbody td[data-col="ela_lq"] {
  width: 110px;
  min-width: 110px;
  max-width: 110px;
}

/* Vertical separators between column groups */
.roster-table thead th[data-col="math_lg"],
.roster-table thead th[data-col="math_ach"],
.roster-table thead th[data-col="math_lq"] {
  border-left: 2px solid #cbd5e1;
}

.roster-table tbody td[data-col="math_lg"],
.roster-table tbody td[data-col="math_ach"],
.roster-table tbody td[data-col="math_lq"] {
  border-left: 1px solid #e2e8f0;
}

/* Group header cells with distinct background */
.roster-table thead tr.roster-header-group th.roster-header-group {
  background: #e2e8f0;
  font-weight: 600;
  border-left: 2px solid #cbd5e1;
}

/* ============================================
   CONTROLS SECTION - Filter and Period Controls
   ============================================ */
.roster-controls-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 24px;
}

.roster-controls-left {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.roster-controls-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.roster-controls-right label {
    width: 100%;
    text-align: center;
}

.roster-control label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.roster-control select,
.roster-control input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.roster-control select:hover,
.roster-control input:hover {
  border-color: var(--student-control-border-hover);
}

.roster-control select:focus,
.roster-control input:focus {
  outline: none;
  border-color: var(--student-accent);
  box-shadow: 0 0 0 3px var(--student-accent-ring);
}

.roster-control.teacher-control select {
  font-weight: 500;
}

.roster-pm-control {
  min-width: 0;
}

.roster-pm-control .subject-carousel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 0;
}

.roster-pm-control .subject-toggle {
  border: 0;
  background: transparent;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #64748b;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.roster-pm-control .subject-toggle:hover,
.roster-pm-control .subject-toggle:focus-visible {
  color: var(--student-accent);
  background-color: var(--student-accent-soft-bg);
  outline: none;
}

.roster-pm-control .subject-toggle:disabled,
.roster-pm-control .subject-toggle[aria-disabled="true"] {
  opacity: 0.38;
  pointer-events: none;
}

.roster-pm-control .subject-toggle .bi {
  font-size: 1.3rem;
}

#roster-pm-value {
  min-width: 48px;
  text-align: center;
  color: #0f172a;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  user-select: none;
}

/* ============================================
   SUMMARY CARDS - Status Summary Cards
   ============================================ */
.roster-summary {
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.summary-meta {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 600;
  width: 100%;
}

.summary-meta-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.summary-meta-value {
  color: #0f172a;
  font-weight: 700;
  font-size: 1.05rem;
}

.roster-summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.summary-group {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.summary-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.summary-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

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

.summary-mini-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.summary-mini-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary-mini-list {
  display: grid;
  gap: 6px;
}

.summary-filter {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #fff;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.summary-filter::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--status-color, #94a3b8);
  flex: 0 0 auto;
}

.summary-filter[data-status="on-track"] {
  --status-color: #16a34a;
}

.summary-filter[data-status="off-track"] {
  --status-color: #dc2626;
}

.summary-filter[data-status="monitor"] {
  --status-color: #d97706;
}

.summary-filter:hover {
  border-color: var(--student-control-border-hover);
  transform: translateY(-1px);
}

.summary-filter:focus-visible {
  outline: 2px solid var(--student-accent);
  outline-offset: 2px;
}

.summary-filter[data-active="true"] {
  border-color: var(--student-accent);
  box-shadow: 0 0 0 2px var(--student-accent-ring);
}

.summary-filter-count {
  font-weight: 700;
  color: #0f172a;
  margin-left: auto;
}

.summary-filter-count.is-loading {
  color: transparent;
  position: relative;
  min-width: 0.95rem;
}

.summary-filter-count.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  border-top-color: #64748b;
  transform: translateY(-50%);
  animation: summary-count-spin 0.75s linear infinite;
}

@keyframes summary-count-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.summary-muted {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ============================================
   RESPONSIVE - Mobile Adaptation
   ============================================ */
@media (max-width: 1199.98px) {
  .roster-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  .summary-mini-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  .roster-summary-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

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

  .roster-controls-section {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .roster-controls-left {
    flex-direction: column;
    align-items: stretch;
  }

  .roster-controls-right {
    align-items: flex-start;
  }

  .roster-view-meta {
    width: 100%;
    justify-content: space-between;
  }

  .roster-summary {
    padding: 16px;
  }

  .roster-pm-control .subject-carousel {
    min-width: 0;
    width: auto;
    justify-content: center;
  }

  .roster-control {
    min-width: 100%;
  }

  .roster-table-wrap {
    padding: 0 0.5rem 0.25rem 0.25rem;
  }

  .roster-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    padding-bottom: 0.35rem;
  }
}

/* ============================================
   RESPONSIVE - Medium Desktop (1280–1440px)
   Compact notebooks: fixes controls and summary
   overflowing the available content area
   ============================================ */
@media (min-width: 721px) and (max-width: 1708px) {

  .roster-table col[data-col="student_avatar"] {
    width: 18px;
  }

  .roster-table col[data-col="student_name"] {
    width: 180px;
  }

  .roster-table col[data-col="grade_level"] {
    width: 70px;
  }

  .roster-table col[data-col="math_lg"],
  .roster-table col[data-col="ela_lg"],
  .roster-table col[data-col="math_ach"],
  .roster-table col[data-col="ela_ach"],
  .roster-table col[data-col="math_lq"],
  .roster-table col[data-col="ela_lq"] {
    width: 110px;
  }

  /* Page-scroll approach (same as demographics): #content-container has only flex-grow:1,
     no concrete height, so height:100% on children collapses to 0. Instead of fighting
     the flex chain, let the card grow to natural height and let the page scroll. */
  #content-container.student-roster-page {
    height: auto;
    min-width: 0;
    overflow: visible;
    padding: 0.5rem;
  }

  /* Card: flex:0 0 auto — ROOT CAUSE FIX.
     Base rule has flex:1 1 auto which makes the card FILL the container's concrete
     height (~100vh - navbar via flex-grow:1 on #content-container). Any content beyond
     that height overflows visually outside the card border (footer hidden below border).
     flex:0 0 auto makes the card size to its CONTENT instead of filling the container. */
  .roster-card,
  .student-roster-page:not(.classroom-hub-page) .roster-card {
    flex: 0 0 auto;
    height: auto;
    max-height: none;
    min-width: 0;
    overflow: visible;
  }

  /* Controls: compact, fixed size */
  .roster-controls-section {
    flex: 0 0 auto;
    padding: 10px 16px;
    gap: 12px;
    flex-wrap: nowrap;
    align-items: center;
  }

  /* Left side: 2 controls per row */
  .roster-controls-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Right side: period carousel */
  .roster-controls-right {
    flex: 0 0 16.667%;
    min-width: 0;
    align-items: center;
  }

  .roster-controls-right label {
    width: 100%;
    text-align: center;
  }

  /* Each control: half width → 2 per row */
  .roster-control {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  /* Summary: compact, fixed size */
  .roster-summary {
    flex: 0 0 auto;
    padding: 8px 16px;
  }

  .roster-summary-grid {
    gap: 8px;
  }

  .summary-group {
    padding: 8px;
    gap: 6px;
  }

  .summary-mini-card {
    padding: 6px 8px;
    gap: 4px;
  }

  /* table-wrap: flex child of the card (display:flex flex-col).
     min-width:0 is the key — without it the flex item expands to accommodate
     the table (1050px) and overflow-x:auto never triggers.
     Do NOT use display:block: it breaks the card's flex layout. */
  .roster-table-wrap, 
  .student-roster-page:not(.classroom-hub-page) .roster-table-wrap {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    height: auto;
    max-height: none;
  }

  /* Table keeps its natural width — the wrapper scrolls horizontally when content overflows. */
  .roster-table {
    min-width: 1050px;
  }

  /* Footer: no auto margin — would steal space from table-wrap */
  .roster-footer,
  .student-roster-page:not(.classroom-hub-page) .roster-footer {
    margin: 0;
    padding: 1rem 1rem 0;
  }

  .summary-filter {
    font-size: 0.78rem;
    padding: 4px 6px;
  }
}

/* ============================================
   CLASSROOM HUB PAGE — Teacher Hub Table
   Overrides/additions for columns that differ
   from the student roster (teacher_name, etc.)
   ============================================ */

/* Period value label — classroom hub uses its own ID */
#teacher-hub-pm-value {
  min-width: 48px;
  text-align: center;
  color: #0f172a;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  user-select: none;
}

/* Controls: keep all 3 search inputs in a single row, no wrap */
.classroom-hub-page .roster-controls-left {
  flex-wrap: nowrap;
  align-items: flex-end;
}

.classroom-hub-page .roster-controls-left .roster-control {
  flex: 1 1 0;
  min-width: 0;
}

/* Table is wider than student roster (12 cols vs 11) */
.classroom-hub-page .roster-table {
  min-width: 1480px;
}

/* teacher_name mirrors student_name: left-aligned, heavy weight */
.classroom-hub-page .roster-table thead th[data-col="teacher_name"] {
  text-align: left;
}

.classroom-hub-page .roster-table tbody td[data-col="teacher_name"] {
  text-align: left;
  font-weight: 600;
  color: #0f172a;
  font-size: 1.05rem;
}

/* teacher_avatar mirrors student_avatar */
.classroom-hub-page .roster-table thead th[data-col="teacher_avatar"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_avatar"] {
  text-align: center;
  padding: 10px 8px;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

/* teacher_subjects, teacher_school, teacher_grade_band, teacher_students */
.classroom-hub-page .roster-table thead th[data-col="teacher_subjects"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_subjects"],
.classroom-hub-page .roster-table thead th[data-col="teacher_school"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_school"],
.classroom-hub-page .roster-table thead th[data-col="teacher_grade_band"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_grade_band"],
.classroom-hub-page .roster-table thead th[data-col="teacher_students"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_students"] {
  text-align: center;
}

/* Hover: teacher_name turns accent-blue, mirroring student_name behaviour */
.classroom-hub-page .roster-table tbody tr:hover td[data-col="teacher_name"] {
  color: #1e40af !important;
  font-weight: 600;
}

/* Fixed column widths for teacher hub (table-layout: fixed) */
.classroom-hub-page .roster-table thead th[data-col="teacher_name"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_name"] {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
}

.classroom-hub-page .roster-table thead th[data-col="teacher_subjects"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_subjects"] {
  width: 180px;
  min-width: 180px;
  max-width: 180px;
}

.classroom-hub-page .roster-table thead th[data-col="teacher_school"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_school"] {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
}

.classroom-hub-page .roster-table thead th[data-col="teacher_grade_band"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_grade_band"] {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.classroom-hub-page .roster-table thead th[data-col="teacher_students"],
.classroom-hub-page .roster-table tbody td[data-col="teacher_students"] {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

/* 4K / large desktop: prevent the card from stretching and leaving empty space */
@media (min-width: 1920px) {
  #content-container.classroom-hub-page .roster-card,
  #content-container.classroom-hub-page .classroom-hub-card {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  #content-container.classroom-hub-page .roster-table-wrap {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    max-height: calc(100vh - 360px);
    overflow-y: auto;
  }

  #content-container.classroom-hub-page .roster-footer {
    margin-top: 0;
  }
}
