:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #eef3f5;
  --ink: #172026;
  --muted: #64717a;
  --line: #d8e0df;
  --accent: #126b72;
  --accent-2: #b3432f;
  --accent-soft: #d9ecee;
  --ok: #197245;
  --warn: #9a5b08;
  --danger: #a33a32;
  --shadow: 0 16px 50px rgba(23, 32, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 4px 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.stats span {
  min-width: 132px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.35rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 144px);
}

.sidebar,
.detail {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-panel,
.detail,
.student-card,
.info-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-panel {
  padding: 16px;
  box-shadow: var(--shadow);
}

.search-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
}

input,
select {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
  color: var(--ink);
  outline: none;
}

input {
  width: 100%;
  padding: 0 12px;
}

select {
  width: 100%;
  padding: 0 34px 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#clearSearch {
  display: grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 8px;
  margin-top: 10px;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.student-list {
  display: flex;
  flex: 1;
  min-height: 300px;
  max-height: calc(100vh - 258px);
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.student-card {
  width: 100%;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.student-card:hover,
.student-card.active {
  border-color: var(--accent);
  background: #f8fbfb;
}

.student-card:hover {
  transform: translateY(-1px);
}

.student-card strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.25;
}

.student-card span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.detail {
  min-width: 0;
  padding: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.empty-state {
  display: grid;
  min-height: 420px;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin-bottom: 8px;
  color: var(--ink);
}

.hidden {
  display: none;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin-bottom: 8px;
  font-size: clamp(1.5rem, 3vw, 2.6rem);
  line-height: 1;
}

.program-line {
  max-width: 900px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.35;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 180px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.info-grid > div {
  min-height: 82px;
  padding: 14px;
  background: #fbfcfc;
}

.info-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.info-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.grades-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.grades-toolbar h3 {
  margin: 0;
  font-size: 1.1rem;
}

.grades-toolbar select {
  max-width: 360px;
}

.grades-wrap {
  max-height: calc(100vh - 390px);
  min-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f5;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

.number {
  text-align: right;
}

.grade-ok {
  color: var(--ok);
  font-weight: 800;
}

.grade-warn {
  color: var(--warn);
  font-weight: 800;
}

.grade-danger {
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .detail-header,
  .grades-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    justify-content: stretch;
  }

  .stats span {
    flex: 1;
  }

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

  .student-list,
  .grades-wrap {
    max-height: none;
  }

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

@media (max-width: 560px) {
  .filter-row,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .detail {
    padding: 16px;
  }

  th,
  td {
    padding: 10px 8px;
  }
}
