/* ── Design tokens (match main app) ───────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-alt: #f6f1ff;
  --ink: #4a4a4a;
  --muted: #6f6f6f;
  --card: #ffffff;
  --accent: #d84b6b;
  --accent-2: #7b5cf6;
  --accent-3: #ffb547;
  --line: #ece7f5;
  --shadow: 0 4px 24px rgba(64, 54, 112, 0.10);
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Nunito", "Segoe UI", sans-serif;
  background: var(--bg-alt);
  color: var(--ink);
  min-height: 100vh;
}

/* ── Login screen ───────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f3edff 0%, #ffe9f2 100%);
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 28px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-2);
  margin-bottom: 6px;
}

.login-card p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-field {
  text-align: left;
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.login-field input:focus {
  border-color: var(--accent-2);
}

.role-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.role-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.role-btn.active {
  border-color: var(--accent-2);
  background: var(--bg-alt);
  color: var(--accent-2);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent-2);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ── Dashboard layout ──────────────────────────────────────── */
#dashboard-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.portal-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(64,54,112,0.06);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--accent-2);
  font-size: 17px;
  text-decoration: none;
}

.portal-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.portal-class-badge {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-2);
}

.portal-header-spacer { flex: 1; }

.refresh-status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-refresh {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-refresh:hover { background: var(--bg-alt); }

.btn-logout {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-logout:hover { background: #fff0f0; color: var(--red); border-color: var(--red); }

/* ── Tabs ──────────────────────────────────────────────────── */
.portal-tabs {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  gap: 4px;
}

.tab-btn {
  padding: 12px 18px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--accent-2); }

.tab-btn.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

/* ── Tab content ───────────────────────────────────────────── */
.portal-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Loading & empty states ────────────────────────────────── */
.loading-state, .empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Back button ────────────────────────────────────────────── */
.btn-back {
  padding: 6px 14px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-2);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-back:hover { background: #ede8ff; }

/* ── Classes screen ─────────────────────────────────────────── */
.classes-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px;
}

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

.classes-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-2);
  margin-bottom: 4px;
}

.classes-sub {
  font-size: 14px;
  color: var(--muted);
}

.btn-new-class {
  padding: 10px 20px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-new-class:hover { opacity: 0.88; }

/* Create class form */
.create-class-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.create-class-form h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--ink);
}

.create-class-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.create-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 180px;
}

.create-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.create-field input,
.create-field select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.create-field input:focus,
.create-field select:focus { outline: none; border-color: var(--accent-2); }

.create-class-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-cancel-create {
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn-create-submit {
  padding: 8px 20px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-create-submit:disabled { opacity: 0.6; cursor: default; }

.create-class-error { font-size: 12px; color: var(--red); margin-top: 8px; }

/* Class cards grid */
.class-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.class-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
}

.class-card:hover {
  box-shadow: 0 8px 28px rgba(123,92,246,0.12);
  transform: translateY(-2px);
}

.class-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.class-card-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  flex: 1;
  line-height: 1.3;
}

.class-card-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-2);
  background: #ede8ff;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  margin-left: 8px;
}

.class-card-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.class-card-arrow {
  font-size: 18px;
  color: var(--accent-2);
  text-align: right;
}

/* ── Class registration banner ─────────────────────────────── */
.class-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.class-banner.registered {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.class-banner.unregistered {
  background: #fffbeb;
  border: 1px solid #fde68a;
  flex-direction: column;
}

.class-banner-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  font-size: 14px;
}

.class-banner-icon { font-size: 20px; line-height: 1.2; }

.register-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.register-input {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  min-width: 160px;
}

.register-input:focus { outline: none; border-color: var(--accent-2); }

.btn-register {
  padding: 7px 18px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-register:disabled { opacity: 0.6; cursor: default; }

.btn-unregister {
  padding: 5px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  align-self: flex-start;
}

.register-error {
  font-size: 12px;
  color: var(--red);
  width: 100%;
}

/* ── Share with parents card ────────────────────────────────── */
.share-card {
  background: linear-gradient(135deg, #f0f7ff 0%, #f6f1ff 100%);
  border: 1px solid #c7d9f8;
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.share-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.share-card-icon { font-size: 24px; line-height: 1; }

.share-card-header strong { font-size: 15px; font-weight: 800; }

.share-card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.share-codes {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.share-code-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
}

.share-code-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.share-code-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-2);
  letter-spacing: 0.05em;
  font-family: monospace;
}

.btn-copy {
  padding: 3px 10px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s;
}
.btn-copy:hover { background: #ede8ff; }

.share-email-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.share-email-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.share-email-input:focus { outline: none; border-color: var(--accent-2); }

.btn-open-email {
  padding: 9px 18px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-open-email:hover { opacity: 0.88; }

.share-email-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Stat cards (Summary tab) ──────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-2);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Module completion bars */
.section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-bars {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.module-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.module-bar-label {
  font-size: 13px;
  font-weight: 700;
  width: 70px;
  flex-shrink: 0;
}

.module-bar-track {
  flex: 1;
  height: 12px;
  background: var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.module-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
  background: var(--accent-2);
}

.module-bar-fill.watch  { background: #3b82f6; }
.module-bar-fill.core   { background: #8b5cf6; }
.module-bar-fill.read   { background: #22c55e; }
.module-bar-fill.speak  { background: #f59e0b; }
.module-bar-fill.game   { background: #ef4444; }

.module-bar-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  width: 36px;
  text-align: right;
}

/* Stuck section */
.stuck-list {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stuck-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.stuck-item:last-child { border-bottom: none; }

.stuck-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #92400e;
  flex-shrink: 0;
}

.stuck-info { flex: 1; }
.stuck-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.stuck-reason { font-size: 12px; color: var(--muted); }

.stuck-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
}

.stuck-badge.low-score {
  background: #fee2e2;
  color: #991b1b;
}

/* ── Progress Grid ─────────────────────────────────────────── */
.grid-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.grid-controls select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: var(--card);
  color: var(--ink);
}

.grid-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.progress-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 600px;
  font-size: 13px;
}

.progress-table th {
  background: var(--bg-alt);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.progress-table th.unit-header {
  text-align: center;
  border-left: 2px solid var(--line);
  font-size: 12px;
}

.progress-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.progress-table tr:last-child td { border-bottom: none; }

.progress-table tr:hover td { background: var(--bg-alt); }

.student-name-cell {
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.student-name-cell:hover { color: var(--accent-2); text-decoration: underline; }

.last-active-cell {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.unit-group-cell.module-col {
  padding: 4px 6px;
  text-align: center;
}

.module-col-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.module-col-header span { font-size: 10px; }

.module-cell {
  min-width: 64px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 2px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.module-cell:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.cell-icon { font-size: 16px; line-height: 1; }
.cell-label { font-size: 10px; font-weight: 700; color: inherit; text-transform: uppercase; letter-spacing: 0.03em; }
.cell-score { font-size: 11px; font-weight: 800; color: inherit; opacity: 0.8; }

.module-cell.completed   { background: #dcfce7; color: #166534; }
.module-cell.in-progress { background: #fef9c3; color: #854d0e; }
.module-cell.not-started { background: var(--line); opacity: 0.35; }
.module-cell.stuck       { background: #fee2e2; color: #991b1b; }

.unit-group-cell {
  border-left: 2px solid var(--line);
  vertical-align: middle;
}

/* ── Timeline ──────────────────────────────────────────────── */
.timeline-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.timeline-controls select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: var(--card);
  color: var(--ink);
}

.timeline-list {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
  cursor: pointer;
}

.timeline-item:last-child { border-bottom: none; }
.timeline-item:hover { background: var(--bg-alt); }

.tl-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
}

.tl-info { flex: 1; min-width: 0; }

.tl-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.tl-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.module-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
}

.module-tag.watch  { background: #dbeafe; color: #1e40af; }
.module-tag.core   { background: #ede9fe; color: #5b21b6; }
.module-tag.read   { background: #dcfce7; color: #166534; }
.module-tag.speak  { background: #fef9c3; color: #92400e; }
.module-tag.game   { background: #fee2e2; color: #991b1b; }

.status-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.status-tag.completed { color: var(--green); }
.status-tag.in_progress { color: var(--yellow); }
.status-tag.started { color: var(--blue); }

/* ── Student detail panel ──────────────────────────────────── */
.student-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}

.student-panel-overlay[hidden],
#login-screen[hidden],
#dashboard-screen[hidden] {
  display: none;
}

.student-panel {
  background: var(--card);
  width: 480px;
  max-width: 95vw;
  height: 100vh;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(64,54,112,0.15);
  display: flex;
  flex-direction: column;
}

.student-panel-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 10;
}

.panel-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.panel-student-info { flex: 1; }
.panel-student-name { font-size: 18px; font-weight: 800; color: var(--ink); }
.panel-student-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn-close-panel {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-top: 2px;
}

.btn-close-panel:hover { color: var(--ink); }

.student-panel-body { padding: 20px 24px; flex: 1; }

.panel-section { margin-bottom: 24px; }

.panel-section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}

.module-detail-card {
  background: var(--bg-alt);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.module-detail-icon {
  font-size: 22px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.module-detail-info { flex: 1; }
.module-detail-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.module-detail-lesson { font-size: 12px; color: var(--muted); }

.module-detail-scores {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.score-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
}

.score-pill.good { background: #dcfce7; color: #166534; }
.score-pill.warn { background: #fef9c3; color: #92400e; }
.score-pill.bad  { background: #fee2e2; color: #991b1b; }

.history-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.history-item:last-child { border-bottom: none; }

.history-time { color: var(--muted); white-space: nowrap; flex-shrink: 0; width: 90px; }
.history-desc { color: var(--ink); }

/* ── Avatar colors by initial ──────────────────────────────── */
.av-a { background: #7b5cf6; } .av-b { background: #3b82f6; }
.av-c { background: #22c55e; } .av-d { background: #f59e0b; }
.av-e { background: #ef4444; } .av-f { background: #ec4899; }
.av-g { background: #14b8a6; } .av-h { background: #8b5cf6; }
.av-i { background: #06b6d4; } .av-j { background: #84cc16; }
.av-k { background: #f97316; } .av-l { background: #6366f1; }
.av-m { background: #d84b6b; } .av-n { background: #0ea5e9; }
.av-o { background: #a855f7; } .av-p { background: #10b981; }
.av-q { background: #f43f5e; } .av-r { background: #fb923c; }
.av-s { background: #4ade80; } .av-t { background: #60a5fa; }
.av-u { background: #c084fc; } .av-v { background: #34d399; }
.av-w { background: #fbbf24; } .av-x { background: #f87171; }
.av-y { background: #a78bfa; } .av-z { background: #2dd4bf; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .portal-header { padding: 10px 16px; }
  .portal-content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .student-panel { width: 100vw; }
}
