.grade-stats-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.grade-stats-filters label,
.grade-stat-table-tools label {
  display: grid;
  gap: 4px;
  color: #164266;
  font-size: 11px;
  font-weight: 900;
}

.grade-stats-filters select,
.grade-stat-table-tools select,
.grade-stat-table-tools input {
  min-height: 36px;
  border: 1px solid #98b9d7;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.grade-stat-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.grade-stat-summary-card {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 4px;
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.05);
}

.grade-stat-summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.grade-stat-summary-card strong {
  color: var(--blue);
  font-size: 23px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.grade-stat-summary-card small {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.grade-stat-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.grade-stat-chart,
.grade-stat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.grade-stat-chart h3,
.grade-stat-panel h3 {
  margin: 0;
  color: var(--blue);
  font-size: 16px;
}

.grade-stat-bar-line {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(120px, 1.4fr) 42px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.grade-stat-bar-line > span {
  font-weight: 800;
  color: #344054;
  overflow-wrap: anywhere;
}

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

.grade-stat-bar-track i {
  display: block;
  height: 100%;
}

.grade-stat-bar-line strong {
  color: var(--blue);
  text-align: right;
}

.risk-red {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.risk-orange {
  background: #ffedd5 !important;
  color: #9a3412 !important;
}

.risk-yellow {
  background: #fef9c3 !important;
  color: #854d0e !important;
}

.risk-green {
  background: #dcfce7 !important;
  color: #166534 !important;
}

.risk-none {
  background: #f1f5f9 !important;
  color: #475569 !important;
}

.grade-risk-donut-wrap {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  align-items: center;
}

.grade-risk-donut {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(31, 78, 121, 0.16);
  position: relative;
}

.grade-risk-donut::after {
  content: "";
  position: absolute;
  inset: 31px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 0 1px rgba(31, 78, 121, 0.12);
}

.grade-risk-legend {
  display: grid;
  gap: 7px;
  font-size: 12px;
}

.grade-risk-legend div {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 7px;
  align-items: center;
}

.grade-risk-legend span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.grade-stats-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: auto;
}

.grade-stats-table-wrap.compact {
  max-height: 340px;
}

.grade-stats-heatmap {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 12px;
}

.grade-stats-heatmap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--blue);
  color: white;
  padding: 8px;
  border: 1px solid #1b4267;
  text-align: left;
}

.grade-stats-heatmap td {
  min-width: 86px;
  padding: 8px;
  border: 1px solid var(--line);
  text-align: center;
  font-weight: 900;
}

.grade-stat-table-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.grade-stat-table-tools {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(170px, 220px);
  gap: 8px;
  align-items: center;
}

.grade-stats-risk-table {
  min-width: 1220px;
}

.grade-stats-evaluation-table {
  min-width: 1040px;
}

.grade-risk-pill,
.grade-alert-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.grade-alert-chip {
  margin: 2px 4px 2px 0;
  background: #eef5fb;
  color: var(--blue);
  border: 1px solid #bfd0e2;
}

.grade-stats-detail {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: none;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.62);
  padding: 18px;
}

.grade-stats-detail.active {
  display: flex;
}

.grade-stats-detail-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  background: white;
  padding: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
  display: grid;
  gap: 12px;
  align-content: start;
}

.grade-stats-detail-card .grade-stats-table-wrap.compact {
  max-height: none;
  overflow: visible;
}

.grade-stats-detail-card .grade-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 11px;
}

.grade-stats-detail-card .grade-table th {
  position: static;
  padding: 6px 8px;
  line-height: 1.15;
}

.grade-stats-detail-card .grade-table td {
  padding: 5px 8px;
  line-height: 1.2;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.grade-stats-detail-card header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.grade-stats-detail-card h3,
.grade-stats-detail-card h4,
.grade-stats-detail-card p {
  margin: 0;
}

.grade-stats-detail-card h3 {
  color: var(--blue);
  font-size: 20px;
}

.grade-stats-detail-card h4 {
  color: #344054;
  font-size: 14px;
}

.grade-detail-summary {
  border: 1px solid #bfd0e2;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.grade-detail-subjects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}

.grade-detail-subjects div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
}

.grade-detail-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.grade-detail-evaluations {
  min-width: 0;
}

.grade-detail-evaluations th:nth-child(1),
.grade-detail-evaluations td:nth-child(1) {
  width: 72px;
}

.grade-detail-evaluations th:nth-child(3),
.grade-detail-evaluations td:nth-child(3) {
  width: 64px;
  text-align: center;
}

.grade-detail-evaluations th:nth-child(4),
.grade-detail-evaluations td:nth-child(4) {
  width: 92px;
}

.grade-row-insufficient td {
  background: #fff1f2;
}

@media (max-width: 820px) {
  .grade-stats-filters,
  .grade-stat-table-tools,
  .grade-risk-donut-wrap {
    grid-template-columns: 1fr;
  }

  .grade-stat-bar-line {
    grid-template-columns: minmax(82px, 1fr) minmax(92px, 1fr) 38px;
  }

  .grade-stats-detail {
    justify-content: center;
    padding: 10px;
  }

  .grade-stats-detail-card {
    max-height: calc(100vh - 20px);
  }
}
