:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --border: #dbe3ee;
  --text: #0f172a;
  --muted: #475569;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --alert: #b91c1c;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.toolbar,
.list-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

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

.topbar h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.search-box {
  min-width: 300px;
}

.search-box label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.search-box input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  font-size: 1rem;
}

.toolbar {
  margin-top: 18px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.course-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.course-button {
  border: 1px solid #bfd5d2;
  background: #f0fdfa;
  color: #115e59;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.95rem;
  cursor: pointer;
}

.course-button span {
  display: inline-block;
  margin-left: 6px;
  color: #0f766e;
  font-weight: 700;
}

.course-button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.course-button.is-active span {
  color: #d1fae5;
}

.connection {
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.list-panel,
.detail-panel {
  padding: 22px;
}

.detail-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.panel-header h2,
.detail-panel h2,
.detail-panel h3 {
  margin: 0;
}

#results-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.count-badge {
  min-width: 48px;
  text-align: center;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 700;
}

.panel-message {
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: var(--muted);
}

.panel-message.is-hidden {
  display: none;
}

.student-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}

.student-card {
  width: 100%;
  text-align: left;
  border: 1px solid #dbe3ee;
  background: #fff;
  border-radius: 16px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-self: start;
  min-height: 385px;
}

.student-card:hover {
  border-color: #93c5c1;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.14);
}

.student-photo-wrap {
  background: #eff6ff;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 180px;
  height: 180px;
  margin: 12px auto 0;
  border-radius: 12px;
  overflow: hidden;
}

.student-photo {
  width: 180px;
  height: 180px;
  object-fit: cover;
  display: block;
}

.student-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.student-name {
  font-size: 1rem;
  font-weight: 700;
}

.student-surname {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

.student-meta {
  margin-top: 10px;
  font-size: 0.92rem;
}

.student-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-panel.is-empty {
  color: var(--muted);
}

.detail-loading {
  margin: 0;
  color: var(--muted);
}

.detail-header {
  display: flex;
  gap: 18px;
  align-items: start;
}

.detail-photo-box {
  flex: 0 0 180px;
  width: 180px;
  height: 180px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.detail-photo {
  width: 180px;
  height: 180px;
  object-fit: cover;
}

.detail-identity h2 {
  margin-bottom: 10px;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: #ecfeff;
  color: #155e75;
  font-size: 0.88rem;
}

.detail-badge-alert {
  background: #fee2e2;
  color: var(--alert);
}

.detail-summary {
  margin: 14px 0 0;
  line-height: 1.5;
  color: var(--muted);
}

.detail-quick-grades {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 9pt;
  line-height: 1.3;
}

.detail-quick-title {
  padding: 7px 9px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
}

.detail-quick-head,
.detail-quick-row {
  display: grid;
  grid-template-columns: minmax(82px, 0.8fr) 42px minmax(160px, 2.2fr);
  gap: 8px;
  padding: 6px 9px;
}

.detail-quick-head {
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 700;
}

.detail-quick-row {
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.detail-quick-grade {
  text-align: center;
  font-weight: 700;
}

.detail-quick-empty {
  padding: 8px 9px;
  color: var(--muted);
}

.detail-block {
  margin-top: 22px;
}

.detail-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-cell {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #f8fafc;
}

.detail-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.detail-value {
  line-height: 1.4;
}

.detail-evaluation {
  border-left: 4px solid #99f6e4;
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  line-height: 1.45;
}

.detail-comment {
  margin-top: 6px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
    scrollbar-gutter: auto;
  }

  .detail-photo-box {
    flex-basis: 180px;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 14px;
  }

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

  .search-box {
    min-width: 0;
  }

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

  .detail-quick-head,
  .detail-quick-row {
    grid-template-columns: minmax(72px, 0.8fr) 38px minmax(120px, 2fr);
  }
}
