/* ============================================================
   LMS Portal styles — layered on top of styles.css (design tokens)
   ============================================================ */

/* v1.9.31 — mobile redesign tokens. Additive only: the brand palette
   (--navy / --gold / --bg / --panel / --border from styles.css) is unchanged.
   v1.9.32 promotes the per-topic card tints to the BASE layer (desktop too) and
   adds the shared elevation / radius scale used across the modernized shell. */
:root {
  --card-fee-bg:     #FBF4E2;  --card-fee-accent:  #B8860B;  --card-fee-ink: #8A6217;
  --card-att-bg:     #E8F5EE;  --card-att-accent:  #2E6B48;
  --card-exam-bg:    #E8F0FA;  --card-exam-accent: #1E5A9E;
  --card-game-bg:    #F0EBF7;  --card-game-accent: #6B4E9E;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  /* Elevation scale — soft, green-tinted, never heavy. */
  --elev-1: 0 1px 2px rgba(18, 61, 49, 0.05), 0 2px 6px rgba(18, 61, 49, 0.05);
  --elev-2: 0 1px 2px rgba(18, 61, 49, 0.04), 0 6px 18px rgba(18, 61, 49, 0.07);
  --elev-3: 0 8px 24px rgba(18, 61, 49, 0.13), 0 2px 6px rgba(18, 61, 49, 0.06);
  --ring-gold: 0 0 0 3px rgba(217, 167, 54, 0.20);
  --surface-2: #FCFBF7;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* CRITICAL: the [hidden] attribute must always win. Elements like
   .portal-login-wrap and .portal-dashboard set display:flex, which would
   otherwise override the browser's default [hidden]{display:none} and keep
   the login screen visible with the dashboard stacked below it. */
[hidden] { display: none !important; }

/* The admin app's styles.css sets html,body { overflow:hidden; height:100% }
   so the SPA can lock to its own scroll area. The portal is a normal
   scrolling page (login screen + dashboard + long tables), so on the portal
   body we must re-enable page scrolling or mobile content gets clipped.
   The :has() scope keeps the admin app completely untouched. */
body:has(.portal-login-wrap),
body:has(.portal-dashboard) {
  overflow: visible !important;
  height: auto !important;
}
html:has(.portal-login-wrap),
html:has(.portal-dashboard) {
  overflow: visible !important;
  height: auto !important;
}

/* v1.9.26: while a full-screen viewer (diary / report card) is open, freeze the
   page behind it so touch devices cannot scroll the dashboard underneath. The
   viewer itself scrolls internally. Declared after the :has() rules above so it
   wins the tie on equal specificity. */
body.portal-modal-open {
  overflow: hidden !important;
  height: 100% !important;
}

/* ---- Login screen ---- */
.portal-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 70%, #0D2B22 100%);
}
.portal-login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}
.portal-login-brand { text-align: center; margin-bottom: 22px; }
.portal-login-logo {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  margin-bottom: 10px;
}
.portal-brand-lms {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--gold);
  margin: 0 0 2px;
  letter-spacing: 2px;
}
.portal-brand-school {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  margin: 0 0 10px;
  letter-spacing: 0.5px;
}
.portal-login-brand p { font-size: 13px; color: var(--muted); margin: 0; }

/* v1.9.28: the Student/Teacher/Parent role tabs were removed — the server derives
   the role from the account, so these styles are intentionally gone. */

.portal-role-hint {
  font-size: 12px;
  color: var(--muted);
  min-height: 17px;
  margin: 2px 0 14px;
  padding: 0 2px;
  text-align: center;
  transition: color 0.15s ease;
}

.portal-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.portal-field .input { width: 100%; }
.portal-error { color: var(--red); font-size: 12.5px; margin: -4px 0 10px; font-weight: 600; }
.portal-login-btn { width: 100%; margin-top: 4px; }
.portal-back { text-align: center; margin: 16px 0 0; font-size: 12.5px; }
.portal-back a { color: var(--navy); text-decoration: none; font-weight: 600; }
.portal-back a:hover { color: var(--navy-light); text-decoration: underline; }

/* ---- Dashboard shell ---- */
.portal-dashboard {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: calc(12px + var(--safe-top)) 24px 12px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 4px 16px rgba(18, 61, 49, 0.16);
}
/* Hairline gold rule under the header — the one signature accent. */
.portal-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 22%, var(--gold-light) 50%, var(--gold) 78%, transparent);
  opacity: 0.55;
}
.portal-header-left { display: flex; align-items: center; gap: 13px; flex: 1; min-width: 0; }
.portal-header-titles { min-width: 0; }
.portal-header-logo {
  width: 42px; height: 42px;
  border-radius: 13px;
  object-fit: cover;
  border: 1.5px solid rgba(232, 200, 136, 0.55);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px;
  flex-shrink: 0;
}
.portal-header-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; line-height: 1.3; letter-spacing: -0.1px; }
.portal-lms { color: var(--gold); }
.portal-school-name { color: #fff; }
.portal-header-sub {
  font-size: 12px; color: var(--gold-light); font-weight: 600;
  letter-spacing: 0.2px; margin-top: 1px;
}
.portal-header-right { display: flex; align-items: center; gap: 10px; }
.portal-header-right .portal-user { order: 3; }
.portal-user { text-align: right; padding-right: 4px; }
.portal-user .name { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.portal-user .role { font-size: 11px; color: var(--gold-light); font-weight: 600; }
.portal-header .btn-danger {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 10px;
  font-weight: 700;
  padding: 8px 15px;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}
.portal-header .btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  transform: translateY(-1px);
}

/* Same element as .portal-main (#portal-main lives inside #portal-dashboard), but
   this selector has higher specificity, so it must agree with .portal-main or it
   silently caps the column. v1.9.32: cap removed for full-bleed on every screen.

   v1.9.32 (mobile gutter fix): this rule carries LAYOUT ONLY (flex/width/max-width)
   and deliberately sets NO padding. It previously repeated `padding: 26px 30px 48px`,
   and because its specificity (0,1,1) beats the `.portal-main` (0,1,0) overrides in
   the @media blocks, every mobile padding rule was silently ignored — the phone
   dashboard kept a fixed 30px dead gutter on BOTH sides at every width (measured
   30px/30px at 320/360/390/414/430px, i.e. the "centred, zoomed-out" look).
   Padding is owned by .portal-main alone so the responsive rules win again. */
.portal-dashboard main { flex: 1; max-width: none; width: 100%; }
.portal-stat-grid { margin-bottom: 22px; }
.portal-class-row { margin-bottom: 18px; }
.portal-class-row .portal-field { min-width: 200px; }
.portal-class-row .input.select { min-width: 220px; }

.portal-msg { font-size: 13px; color: var(--green); font-weight: 600; }
.portal-muted { font-size: 13px; color: var(--muted); }
.portal-footer { text-align: center; padding: 14px; font-size: 12px; color: var(--muted); }

/* ---- Attendance / marks status buttons ---- */
.att-status-btn {
  border: 1.5px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.att-status-btn:hover { border-color: var(--navy-light); color: var(--navy); }
.att-status-btn.selected {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.att-status-btn.selected.present { background: var(--green); border-color: var(--green); }
.att-status-btn.selected.late { background: #C79A3E; border-color: #C79A3E; }
.att-status-btn.selected.absent { background: var(--red); border-color: var(--red); }
.att-status-btn.selected.leave { background: var(--navy-light); border-color: var(--navy-light); }

/* ---- Attendance save row (below the roster table) ---- */
.att-save-row {
  margin-top: 14px;
  justify-content: flex-end;
}
.att-save-row .btn {
  min-width: 170px;
  justify-content: center;
}

/* ---- Result tables ---- */
.exam-block { margin-bottom: 20px; }
.exam-block h4 {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--navy);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.exam-block .exam-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.exam-total { font-weight: 700; color: var(--navy); }

/* ---- Empty states ---- */
.portal-empty { text-align: center; padding: 32px 0; color: var(--muted); font-size: 13.5px; }

/* ---- Reusable card + form markup (replaces scattered inline styles) ---- */
.portal-extras {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 18px;
  box-shadow: var(--shadow-sm);
}
.portal-extras-tall { padding: 16px 18px; }
.portal-extras-btn { flex-shrink: 0; }

.portal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.portal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.portal-card-head > div:first-child { min-width: 0; }
.portal-card-meta { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.portal-item-sep {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.portal-item-sep:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.portal-response {
  margin-top: 8px;
  padding: 8px 10px;
  background: #eef6ff;
  border-left: 3px solid var(--navy-light);
  border-radius: 6px;
  font-size: 13px;
}
.portal-remarks { margin-top: 6px; font-size: 12px; color: var(--muted); }
.portal-keys-table { margin-top: 8px; }
.portal-keys-table th:first-child { width: 40px; }

/* PTM attendance history (v1.8.13) */
.ptm-card { margin-bottom: 14px; }
.ptm-summary {
  display: flex;
  gap: 10px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.ptm-summary-item {
  flex: 1;
  min-width: 72px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.ptm-summary-num { display: block; font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--navy); }
.ptm-summary-label { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; }
.ptm-num-good { color: var(--green); }
.ptm-num-bad { color: var(--red); }
.ptm-summary-num.att-good { color: var(--green); }
.ptm-summary-num.att-warn { color: #C79A3E; }
.ptm-summary-num.att-bad { color: var(--red); }
.ptm-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ptm-row-main { min-width: 0; }
.ptm-row-date { font-weight: 700; color: var(--navy); font-size: 14px; }
.ptm-row-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ptm-status-pill.ptm-att-present { background: var(--green-bg); color: var(--green); }
.ptm-status-pill.ptm-att-absent { background: var(--red-bg); color: var(--red); }
.ptm-status-pill.ptm-att-pending { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
@media (max-width: 700px) {
  .ptm-summary { gap: 8px; }
  .ptm-summary-item { min-width: 60px; padding: 8px 4px; }
  .ptm-summary-num { font-size: 17px; }
}

.portal-inline-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

/* ---- Games & Scores achievement dashboard ---- */
.games-summary-grid { grid-template-columns: repeat(5, 1fr); }
.games-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.games-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.games-tile-icon { font-size: 22px; flex-shrink: 0; }
.games-tile-name { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.points-badge {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}

/* ============================================================
   Student dashboard — identity header, fee summary, attendance,
   results drill-down. Reuses the admin design tokens (styles.css).
   ============================================================ */

/* ---- Student identity header ---- */
.student-identity {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.student-avatar {
  width: 56px; height: 56px;
  border-radius: 12px;
  font-size: 22px; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.student-avatar img { width: 100%; height: 100%; object-fit: cover; }
.student-info { min-width: 0; }
.student-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.student-meta { font-size: 13px; color: var(--muted); }

/* ---- Fee summary + payment progress ---- */
.fee-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.fee-summary-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}
.fee-summary-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.fee-summary-value { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--navy); }
.fee-summary-card.accent-gold .fee-summary-value { color: #9C6F1B; }
.fee-summary-card.accent-green .fee-summary-value { color: var(--green); }
.fee-summary-card.accent-red .fee-summary-value { color: var(--red); }
.fee-progress-wrap { grid-column: 1 / -1; }
.fee-progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fee-progress-track { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.fee-progress-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--green) 0%, #5FA87A 100%);
  transition: width 0.6s ease;
}

/* Fee status banner (top of Fees page) */
.fee-status-banner {
  display: flex; align-items: center; gap: 10px;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--border);
}
.fee-status-banner .banner-ico { font-size: 18px; }
.fee-status-banner.banner-paid { background: #E9F5EE; color: var(--green); border-color: #BFE3CF; }
.fee-status-banner.banner-partial { background: #FCF3E0; color: #9C6F1B; border-color: #EDDCB4; }
.fee-status-banner.banner-due { background: #FCEBE8; color: var(--red); border-color: #F2CCC4; }
.fee-status-banner.banner-nofee { background: var(--bg); color: var(--muted); border-color: var(--border); }

.portal-section-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700; color: var(--navy);
  margin: 22px 0 10px;
}

/* Payment history "View Receipt" button */
.btn-receipt {
  background: var(--navy); color: #fff;
  border: none; border-radius: 6px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.btn-receipt:hover { background: var(--navy-deep); }
.btn-receipt:disabled { opacity: .45; cursor: not-allowed; }

/* ---- Attendance summary ---- */
.att-summary { display: flex; align-items: center; gap: 22px; margin-bottom: 14px; flex-wrap: wrap; }
.att-big-pct { font-family: var(--font-display); font-size: 42px; font-weight: 800; line-height: 1; flex-shrink: 0; }
#att-summary-cards { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }.att-big-pct.att-good { color: var(--green); }
.att-big-pct.att-warn { color: #C79A3E; }
.att-big-pct.att-bad { color: var(--red); }
.att-counts { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.att-counts span { display: flex; align-items: center; gap: 5px; }
.att-count-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.att-count-dot.dot-present { background: var(--green); }
.att-count-dot.dot-late { background: #C79A3E; }
.att-count-dot.dot-absent { background: var(--red); }
.att-count-dot.dot-leave { background: var(--navy-light); }
.att-pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.att-pill.att-present { background: var(--green-bg); color: var(--green); }
.att-pill.att-late { background: #FCF3DF; color: #9C6F1B; }
.att-pill.att-absent { background: var(--red-bg); color: var(--red); }
.att-pill.att-leave { background: #E0F0F8; color: var(--navy-light); }

/* ---- Results: exam cards + popup ---- */
.exam-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.exam-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--navy-light); }
.exam-card-left { min-width: 0; }
.exam-card-name { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.exam-card-date { font-size: 12px; color: var(--muted); }
.exam-card-right { text-align: right; flex-shrink: 0; }
.exam-card-total { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--navy); }
.exam-card-subjects { font-size: 11.5px; color: var(--muted); }
.exam-card-arrow { font-size: 18px; color: var(--muted); flex-shrink: 0; transition: transform 0.12s ease, color 0.12s ease; }
.exam-card:hover .exam-card-arrow { transform: translateX(3px); color: var(--navy); }

/* Grade badge (A+ green / A green / B blue / C gold / D orange / E+F red) */
.exam-card-grade {
  display: inline-block;
  min-width: 30px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  line-height: 1.4;
}
.grade-a-plus, .grade-a { background: var(--green-bg); color: var(--green); }
.grade-b { background: #e3eefb; color: #2b6cb0; }
.grade-c { background: #fcf3df; color: #9c6f1b; }
.grade-d { background: #fdeee0; color: #c2680b; }
.grade-e, .grade-f { background: var(--red-bg); color: var(--red); }

/* Overall percentage on exam cards (clean text, no fat progress bar) */
.exam-card-pct {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--green);
  margin-top: 3px;
}
.exam-card-position { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* v1.9.33 — Upcoming Exams section on the Results page. Reuses .exam-card for
   visual consistency but is not clickable as a whole: the actions are explicit
   buttons so a student can open the date sheet or the syllabus separately. */
.exam-card--upcoming { cursor: default; }
.exam-card--upcoming:hover { transform: none; }
.exam-card--upcoming .exam-card-arrow { display: none; }
.exam-card-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Exam detail viewer (date sheet / syllabus) */
.exam-detail-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.exam-detail-subject {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
.exam-detail-text { font-size: 13.5px; color: var(--text); line-height: 1.6; white-space: normal; }
.exam-detail-file {
  display: inline-block;
  margin-top: 8px;
  margin-right: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.exam-detail-file:hover { color: var(--navy-light); border-bottom-color: var(--navy-light); }
.exam-detail-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.exam-detail-table th,
.exam-detail-table td {
  text-align: left;
  padding: 9px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.exam-detail-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--bg);
}

/* ---- Diary / homework merged card feed (v1.8.0 R1: clickable tiles) ----
   v1.9.26: tapping a date card opens the day's branded LGS diary sheet in a
   FULL-SCREEN viewer (.lgs-diary, defined above) — the old 760px centred
   popup and its admin-style .diary-sheet table are gone. */
.diary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.diary-card:hover, .diary-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--navy-light); }
.diary-card:focus-visible { outline: 2px solid var(--navy-light); outline-offset: 1px; }
/* v1.9.11 — today's diary card stands out: soft green bg, brighter date, pop-in */
.diary-card-today {
  background: linear-gradient(135deg, #eef9ee 0%, #e3f4e0 100%);
  border: 1.5px solid #4caf6e;
  box-shadow: 0 3px 12px rgba(76, 175, 110, 0.18);
  animation: diaryTodayPop 0.5s ease;
}
.diary-card-today:hover, .diary-card-today:focus-visible {
  border-color: #2e8b50;
  box-shadow: 0 5px 16px rgba(76, 175, 110, 0.28);
  transform: translateY(-2px);
}
.diary-card-today .diary-card-date {
  color: #1d6b34;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.today-badge {
  display: inline-block;
  background: #2e8b50;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  animation: todayBadgePulse 2s ease-in-out infinite;
}
@keyframes diaryTodayPop {
  0% { transform: scale(0.94); opacity: 0.4; }
  60% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes todayBadgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 139, 80, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(46, 139, 80, 0); }
}
.diary-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.diary-card-date {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}
.diary-card-meta { font-size: 12px; color: var(--muted); }
.diary-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.diary-chip {
  display: inline-block;
  background: var(--navy-bg, #eef2fb);
  color: var(--navy);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.diary-chip-hw { background: var(--gold); color: #3a2c00; }
.diary-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.diary-card-tap { color: var(--navy-light); font-weight: 600; }
.hw-tag {
  display: inline-block; background: var(--gold); color: #3a2c00;
  font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px;
  margin-right: 4px; vertical-align: middle; text-transform: uppercase; letter-spacing: .3px;
}

/* Diary modal: clean per-entry cards (v1.8.12 — mobile-friendly) */
.diary-card-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.diary-card-row-hw { background: #faf8f3; border-color: #ecdcb5; }
.diary-card-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.diary-card-chip {
  display: inline-block; background: var(--gold); color: #3a2c00;
  font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .3px; flex-shrink: 0;
}
.diary-card-subj { font-weight: 700; color: var(--navy); font-size: 14px; }
.diary-card-row-body { min-width: 0; }
.diary-card-row-title { font-size: 13.5px; font-weight: 700; color: var(--text); line-height: 1.45; }
.diary-card-row-text { font-size: 13.5px; color: var(--text); line-height: 1.55; }
.diary-card-row-desc { font-size: 13px; color: #555; line-height: 1.5; margin-top: 4px; }
.diary-card-row-teacher { font-size: 11.5px; color: var(--muted); margin-top: 6px; font-weight: 600; }

/* ---- Result popup: clean mark-sheet card (v1.8.12) ----
   Removed the fat progress bars; per-subject rows are now a tidy grid:
   subject | marks/out-of | % | grade, with a summary footer. Mobile-first. */
.result-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
.result-card-head,
.result-card-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
}
.result-card-head {
  background: var(--navy);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.result-card-head span:not(:first-child) { text-align: right; }
.result-card-row {
  border-top: 1px solid var(--border);
}
.result-card-subject { font-weight: 700; color: var(--navy); font-size: 13.5px; }
.result-card-marks { font-size: 13.5px; font-weight: 700; color: var(--text); text-align: right; }
.result-card-outof { font-size: 11px; color: var(--muted); font-weight: 600; }
.result-card-pct { font-size: 13px; font-weight: 700; color: var(--navy); text-align: right; }
.result-card-grade { justify-self: end; }
.result-card-row.is-low { background: var(--red-bg); }
.result-card-row.is-low .result-card-subject { color: var(--red); }
.result-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.result-foot-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.result-foot-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.result-foot-total { font-size: 16px; font-weight: 800; color: var(--navy); }
.result-foot-pos { font-size: 12px; color: var(--muted); font-weight: 600; }
.result-foot-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.result-foot-pct { font-size: 18px; font-weight: 800; color: var(--navy); }

/* ---- Teacher marks grid (v1.8.0 R8) ---- */
#teacher-marks-grid-table { font-size: 12.5px; }
#teacher-marks-grid-table th, #teacher-marks-grid-table td {
  padding: 6px 8px;
  white-space: nowrap;
  vertical-align: middle;
}
#teacher-marks-grid-table td input.input-sm { width: 62px; padding: 4px 6px; font-size: 12.5px; }
/* Editable per-subject total-marks row (v1.9.15, matches admin marks grid) */
#teacher-marks-grid-total-row td { color: var(--muted); font-size: 11.5px; font-weight: 700; }
#teacher-marks-grid-total-row td input.teacher-marks-total-input {
  font-weight: 700;
  color: var(--navy);
}

/* Teacher Diary Upload (v1.9.10) — subject label + textarea rows */
.tdiary-subject-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(9, 30, 66, 0.12);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}
.tdiary-subject-row + .tdiary-subject-row { margin-top: 0; }
.tdiary-subject-name {
  flex: 0 0 110px;
  font-weight: 700;
  color: var(--navy);
  padding-top: 8px;
  font-size: 13px;
}
.tdiary-text {
  flex: 1 1 auto;
  resize: vertical;
  min-height: 40px;
}

@media (max-width: 640px) {
  .tdiary-subject-row { flex-direction: column; gap: 6px; }
  .tdiary-subject-name { flex: none; padding-top: 0; }
}

/* Portal tab strips — keep tabs in one scrollable row instead of wrapping */
.tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { flex-shrink: 0; }

/* Exam result popup (portal-scoped modal — avoids clobbering the admin app's .modal state) */
.portal-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15, 24, 48, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.portal-modal {
  background: var(--panel);
  border-radius: 12px;
  width: 520px;
  max-width: 94vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: portalModalIn 0.2s ease;
}
@keyframes portalModalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.portal-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.portal-modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--navy); }
.portal-modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.portal-modal-close {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px; height: 28px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.portal-modal-close:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.portal-modal-body { padding: 16px 22px 22px; overflow-y: auto; }
.portal-modal-body .table { font-size: 13.5px; }

/* ============================================================
   v1.9.26 — FULL-SCREEN VIEWERS (Daily Diary + Report Card)
   The diary and the official report card are documents, not small
   dialogs: on every screen size they take the whole viewport and
   scroll vertically inside themselves. No narrow centred popup, no
   horizontal scrolling, no clipped text.
   ============================================================ */
.portal-modal-overlay.portal-modal-fullscreen {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}
.portal-modal-fullscreen .portal-modal {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border-radius: 0;
  animation: none;
}
.portal-modal-fullscreen .portal-modal-head.portal-fs-head {
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--navy);
  border-bottom: none;
  flex-shrink: 0;
}
.portal-fs-head-text { min-width: 0; }
.portal-modal-fullscreen .portal-fs-head .portal-modal-title { color: #fff; font-size: 16px; }
.portal-modal-fullscreen .portal-fs-head .portal-modal-sub {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.portal-fs-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.portal-fs-print {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.34);
  color: #fff;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}
.portal-fs-print:hover { background: rgba(255, 255, 255, 0.26); }
/* Persistent RED close control — always visible, large touch target,
   pinned to the top-right of the header (never overlaps the status bar
   because the header sits below the device safe-area inset). */
.portal-modal-close.portal-fs-close {
  background: #C0392B;
  border: 1px solid #9E2B1F;
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.portal-modal-close.portal-fs-close:hover,
.portal-modal-close.portal-fs-close:active {
  background: #A32E20;
  color: #fff;
  border-color: #7E2317;
}
.portal-modal-fullscreen .portal-modal-body.portal-fs-body {
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg);
}
/* Respect device safe areas (notch / home indicator) on mobile */
@supports (padding: max(0px)) {
  .portal-modal-fullscreen .portal-modal-head.portal-fs-head {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .portal-modal-fullscreen .portal-modal-body.portal-fs-body {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ============================================================
   v1.9.28 — LGS DAILY DIARY SHEET (green & gold, data-driven)
   Aligned to the school's official Daily Diary reference (the
   supplied PNG): a green/gold double-line frame, branded header
   with logo + school name + Haroonabad line + cell no., a
   Class/Section/Date strip, a bordered table whose column heads
   are English (Subject / Homework) with numbered rows, and a
   Class Teacher's Remarks + Parent's Signature footer.
   Rows come from real LMS data — nothing is hard-coded.
   ============================================================ */
.lgs-diary {
  position: relative;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  background: #fff;
  border: 3px solid var(--navy);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.10);
  padding: 4px;
}
/* v1.9.28 — the reference's double-line frame: the outer green border on
   .lgs-diary, a 4px gap, then an inner gold rule on the sheet. */
.lgsd-sheet {
  position: relative;
  border: 1px solid var(--gold);
  border-radius: 6px;
  overflow: hidden;
}
.lgsd-band {
  height: 8px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-light) 55%, var(--gold) 100%);
}
.lgsd-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 14px;
  background: linear-gradient(135deg, #ffffff 0%, #f4f8f5 100%);
  border-bottom: 3px solid var(--gold);
}
.lgsd-logo { width: 62px; height: 62px; object-fit: contain; flex-shrink: 0; }
.lgsd-school { flex: 1 1 auto; min-width: 0; }
.lgsd-school h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--navy);
  line-height: 1.15;
}
.lgsd-city { margin: 3px 0 0; font-size: 13px; font-weight: 600; color: var(--gold); letter-spacing: 0.4px; }
.lgsd-cell { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.lgsd-badge {
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.4px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 2px solid var(--gold);
  text-align: center;
  line-height: 1.2;
}
.lgsd-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.lgsd-meta-item { background: #fff; padding: 9px 12px; }
.lgsd-meta-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.lgsd-meta-value { font-size: 13.5px; font-weight: 700; color: var(--navy); }
.lgsd-table-wrap { padding: 14px 16px 0; overflow-x: hidden; }
.lgsd-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.lgsd-table th {
  background: var(--navy);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.9px;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--navy);
}
/* Column heads are English (Subject / Homework) — matches the admin diary.
   `.lgsd-urdu` is still applied to CELLS whose text is Urdu (see below). */
.lgsd-th-num { width: 8%; text-align: center; }
.lgsd-th-subject { width: 30%; }
.lgsd-th-hw { width: 62%; }
.lgsd-table td {
  border: 1px solid var(--border);
  padding: 11px 12px;
  vertical-align: top;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.lgsd-row:nth-child(even) td { background: #FAFBF9; }
/* Numbered row gutter — the reference numbers every line 1..n */
.lgsd-num {
  text-align: center;
  font-weight: 800;
  color: var(--navy);
  background: #F4F8F5;
  font-size: 12.5px;
}
.lgsd-subject {
  background: var(--green-bg) !important;
  font-weight: 700;
  color: var(--navy);
}
.lgsd-subject-name { font-size: 13.5px; }
.lgsd-hw { white-space: pre-wrap; }
.lgsd-blank { color: var(--muted); font-style: italic; }
/* Urdu / Arabic script: RTL direction + a Nastaliq-capable font stack so long
   Urdu homework wraps and reads correctly instead of rendering as boxes. */
.lgsd-hw.lgsd-urdu {
  direction: rtl;
  text-align: right;
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', 'Urdu Typesetting', 'Nafees Web Naskh', 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 2;
}
.lgsd-note {
  margin: 14px 16px 0;
  padding: 10px 12px;
  background: #FFF8E6;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #7A5A12;
}
/* v1.9.28 — Class Teacher's Remarks + Parent's Signature strip, as on the
   reference sheet. Two bordered cells with a ruled writing space. */
.lgsd-remarks {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1px;
  margin: 14px 16px 0;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.lgsd-remarks-cell { background: #fff; padding: 10px 12px 14px; }
.lgsd-remarks-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.lgsd-remarks-line {
  display: block;
  min-height: 26px;
  border-bottom: 1px dashed #C9C4B8;
}
.lgsd-sign-line {
  display: block;
  margin-top: 20px;
  border-top: 1px solid var(--navy);
  padding-top: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.lgsd-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 11px 20px;
  background: var(--navy);
  color: rgba(255, 255, 255, 0.92);
  font-size: 11.5px;
  letter-spacing: 0.3px;
}

.portal-modal-body .table th.num, .portal-modal-body .table td.num { text-align: right; }

/* Low marks (<40%) highlighted red in the exam popup */
.portal-modal-body .table tr.is-low td:first-child { color: var(--red); font-weight: 600; }
.portal-modal-body .result-total-row td { font-weight: 700; border-top: 2px solid var(--navy); }

/* Right-aligned money columns in the fee/attendance tables */
#student-fees-table th.num, #student-fees-table td.num,
#student-att-table th.num, #student-att-table td.num { text-align: right; }

/* ============================================================
   v1.9.0 — NEW PORTAL SHELL: sidebar + main + bottom nav
   Desktop: header on top, left sidebar + content beside it.
   Mobile:  sidebar becomes a slide-in drawer; bottom nav shows.
   ============================================================ */

.portal-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---- Desktop sidebar ---- */
.portal-sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 14px 12px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 72px);
  position: sticky;
  top: 72px;
}
.sidebar-section { margin-bottom: 16px; }
.sidebar-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding: 0 12px;
  margin-bottom: 6px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 12px;
  margin-bottom: 2px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
  user-select: none;
}
.sidebar-nav-item:hover {
  background: #fff;
  border-color: var(--border);
  color: var(--navy);
  transform: translateX(2px);
}
.sidebar-nav-item.active {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 90, 74, 0.24);
}
.sidebar-nav-item.active:hover { transform: none; }

/* v1.9.32 — the drawer head markup (logo + brand + close button) lives INSIDE
   .portal-sidebar, and .portal-sidebar is also the desktop rail. v1.9.31 styled
   this head only inside the ≤840px block, so on desktop the logo had no width
   rule and rendered at its natural 1198x1198, blowing the head to ~1264px tall
   and pushing every nav item below the fold (the "giant cropped logo" that
   replaced the sidebar). These base rules keep the head compact on desktop;
   the ≤840px block below re-declares it as the dark-green drawer bar. */
.sidebar-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-drawer-logo {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--gold); flex-shrink: 0;
}
.sidebar-drawer-brand {
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 700; line-height: 1.3; min-width: 0;
}
/* The shared .portal-lms / .portal-school-name colours are tuned for the dark
   header (gold on white would vanish on the white rail), so re-colour here. */
.sidebar-drawer-brand .portal-lms { color: var(--navy); }
.sidebar-drawer-brand .portal-school-name { color: var(--text); }
/* Close button is a mobile-drawer affordance only. */
.sidebar-drawer-close { display: none; }

/* ---- Main content ---- */
.portal-main {
  flex: 1;
  padding: 26px 30px 48px;
  /* v1.9.32: no width ceiling — the dashboard fills the whole space beside the
     sidebar on every screen. The old 1200px cap wasted ~25% of a 1920px viewport
     (234px left + 242px right) and ~44% at 2560px, leaving a wide blank gutter
     next to the boxes. User asked for full-bleed, so the cap is gone entirely. */
  max-width: none;
  min-width: 0;
}
.main-page { width: 100%; }

/* ---- Mobile bottom nav (hidden on desktop) ---- */
.portal-bottom-nav {
  display: none;
}

/* v1.9.22: role-split navs toggle via the [hidden] attribute, but the mobile
   media queries below force display:flex — that would override hidden and show
   BOTH navs to a teacher. This rule keeps the hidden attribute authoritative. */
.portal-sidebar[hidden],
.portal-bottom-nav[hidden] {
  display: none !important;
}

/* ---- Sidebar hamburger (hidden on desktop) ---- */
.portal-sidebar-toggle { display: none; }

/* ---- Notification bell ---- */
.portal-bell-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s ease;
}
.portal-bell-btn:hover { background: rgba(255, 255, 255, 0.24); }
.portal-bell-icon { font-size: 18px; line-height: 1; }
.portal-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--navy-deep);
}

/* ---- Reusable states: loading / empty / error / toast ---- */
.portal-skeleton {
  border-radius: 10px;
  background: linear-gradient(90deg, #efece4 25%, #f8f6f0 50%, #efece4 75%);
  background-size: 200% 100%;
  animation: portalShimmer 1.3s ease infinite;
  min-height: 18px;
}
@keyframes portalShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.portal-error-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.portal-error-box .portal-error-icon { font-size: 40px; }
.portal-error-box .btn { margin-top: 4px; }

.toast-container {
  position: fixed;
  bottom: 84px;
  right: 18px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.toast {
  background: var(--navy-deep);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.25s ease;
}
.toast.toast-error { background: var(--red); }
.toast.toast-success { background: var(--green); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Dashboard page (Phase 4 containers) ---- */
.portal-welcome {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 24px 26px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: 0 10px 26px rgba(18, 61, 49, 0.20);
}
/* Very light depth: a soft gold glow top-right + a green wash bottom-left.
   No logo, no image — just two radial washes that keep the card from reading flat. */
.portal-welcome::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(420px 200px at 100% 0%, rgba(217, 167, 54, 0.16), transparent 70%),
    radial-gradient(360px 220px at 0% 100%, rgba(44, 122, 99, 0.28), transparent 72%);
}
.portal-welcome > * { position: relative; }
/* Gold hairline on the left edge — the card's signature detail. */
.portal-welcome::after {
  content: '';
  position: absolute;
  left: 0; top: 18px; bottom: 18px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  pointer-events: none;
}
.portal-welcome-avatar {
  width: 66px; height: 66px;
  border-radius: 20px;
  object-fit: cover;
  border: 2px solid rgba(232, 200, 136, 0.75);
  background: rgba(255, 255, 255, 0.13);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  overflow: hidden;
  flex-shrink: 0;
}
.portal-welcome-avatar img { width: 100%; height: 100%; object-fit: cover; }
.portal-welcome-name {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800; line-height: 1.2;
  letter-spacing: -0.3px; margin-bottom: 5px;
}
.portal-welcome-greet {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.9px; text-transform: uppercase;
  color: var(--gold-light); opacity: 0.95; margin-bottom: 3px;
}
.portal-welcome-meta {
  font-size: 13px; color: rgba(255, 255, 255, 0.86);
  line-height: 1.55; font-weight: 500;
  padding-top: 6px; margin-top: 2px;
  border-top: 1px solid rgba(232, 200, 136, 0.22);
}
.portal-welcome-date {
  font-size: 12px; color: var(--gold-light);
  margin-top: 4px; font-weight: 600;
}

/* Parent child-switch dropdown (dashboard welcome) */
.portal-child-switch {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.portal-child-switch label { color: var(--gold-light); white-space: nowrap; }
.portal-child-select {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--gold-light);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  max-width: 100%;
  outline: none;
}
.portal-child-select:focus { border-color: var(--gold); }

.portal-dash-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.dash-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--elev-1);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--elev-3);
  border-color: transparent;
}
/* Icon sits in a soft rounded tile so the card reads as a component, not a box. */
.dash-card-icon {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(18, 61, 49, 0.07);
}
.dash-card-icon svg { width: 22px; height: 22px; }
.dash-card-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 800;
}
.dash-card-value {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 800; line-height: 1.15;
  color: var(--navy); margin-top: 5px; letter-spacing: -0.4px;
}
.dash-card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }
/* v1.9.32: status chip is now shown on every layout (desktop included). */
.dash-card-chip {
  display: inline-block;
  position: absolute;
  top: 13px; right: 13px;
  font-size: 9.5px; font-weight: 800;
  letter-spacing: 0.4px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--navy);
}
/* v1.9.31: announcement thumbnail — rendered only when real image data exists */
.dash-item-icon--img { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; display: block; }
.dash-item-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }

/* v1.9.32 — per-topic pastel tints now apply on desktop too. Each summary card
   carries its own soft background + accent value colour + tinted chip. */
.dash-card--fee  { background: var(--card-fee-bg);  border-color: #EADCB8; }
.dash-card--fee  .dash-card-value { color: var(--card-fee-accent); }
.dash-card--fee  .dash-card-chip  { background: rgba(184, 134, 11, 0.16); color: var(--card-fee-ink); }
.dash-card--att  { background: var(--card-att-bg);  border-color: #CBE7D8; }
.dash-card--att  .dash-card-value { color: var(--card-att-accent); }
.dash-card--att  .dash-card-chip  { background: rgba(46, 107, 72, 0.14); color: var(--card-att-accent); }
.dash-card--exam { background: var(--card-exam-bg); border-color: #CFE0F4; }
.dash-card--exam .dash-card-value { color: var(--card-exam-accent); }
.dash-card--exam .dash-card-chip  { background: rgba(30, 90, 158, 0.14); color: var(--card-exam-accent); }
.dash-card--game { background: var(--card-game-bg); border-color: #DFD4EE; }
.dash-card--game .dash-card-value { color: var(--card-game-accent); }
.dash-card--game .dash-card-chip  { background: rgba(107, 78, 158, 0.14); color: var(--card-game-accent); }

/* Dashboard card status — the live fee/attendance state is layered ON TOP of the
   topic tint, never replacing it: a coloured left rail + a matching status chip.
   The topic class keeps ownership of the pastel background + value colour, so the
   Fee card always reads gold and Attendance always reads mint (per the spec). */
.dash-card-green { --card-status: var(--green);  --card-status-chip-bg: #D8EEDF; --card-status-chip-ink: #2E6B48; }
.dash-card-amber { --card-status: #9C6F1B;       --card-status-chip-bg: #F6E6C2; --card-status-chip-ink: #8A6217; }
.dash-card-red   { --card-status: var(--red);    --card-status-chip-bg: #F6D6D0; --card-status-chip-ink: var(--red); }
.dash-card-green::before,
.dash-card-amber::before,
.dash-card-red::before {
  content: ''; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--card-status);
}
/* Higher specificity than the topic chip rule, so the live status colour wins
   the chip while the card background stays the topic tint. */
.dash-card.dash-card-green .dash-card-chip,
.dash-card.dash-card-amber .dash-card-chip,
.dash-card.dash-card-red   .dash-card-chip {
  background: var(--card-status-chip-bg); color: var(--card-status-chip-ink);
}

.portal-quick-actions {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--elev-1);
}
.portal-quick-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  letter-spacing: -0.1px;
}
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 13px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.quick-action:hover {
  transform: translateY(-3px);
  box-shadow: var(--elev-2);
  border-color: var(--navy-light);
  background: #fff;
}
.quick-action-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: #fff;
  font-size: 20px;
  box-shadow: 0 1px 3px rgba(18, 61, 49, 0.08);
}
.quick-action:hover .quick-action-icon { background: var(--card-att-bg); }

/* ---- Teacher dashboard (Phase 3, v1.9.20) ---- */
.teacher-dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.teacher-dash-grid .portal-dash-section { margin-bottom: 0; }
.teacher-dash-details {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 0;
}
.teacher-dash-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.teacher-dash-row:last-child { border-bottom: none; }
.teacher-dash-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  flex-shrink: 0;
}
.teacher-dash-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}
.teacher-att-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.teacher-att-stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.teacher-att-stat-count {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
}
.teacher-att-stat-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  margin-top: 2px;
}
.teacher-att-stat-box.green .teacher-att-stat-count { color: var(--green); }
.teacher-att-stat-box.amber .teacher-att-stat-count { color: #9C6F1B; }
.teacher-att-stat-box.red .teacher-att-stat-count { color: var(--red); }
.teacher-att-stat-box.blue .teacher-att-stat-count { color: #1E5A9E; }
.teacher-att-stat-box.muted .teacher-att-stat-count { color: var(--muted); }

/* ---- Dashboard announcements + notifications previews ---- */
.portal-dash-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--elev-1);
}
/* v1.9.32 — Announcements + Notifications sit side-by-side on desktop and stack
   on mobile (this grid collapses to one column under 840px). */
.portal-dash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.portal-dash-columns .portal-dash-section { margin-bottom: 20px; }
/* Designed empty state — a centred icon chip + copy, never a bare line of text. */
.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 12px 22px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.dash-empty::before {
  content: '📭';
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px;
  border-radius: 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 21px;
}
.dash-empty--ann::before { content: '📢'; background: var(--card-exam-bg); border-color: #CFE0F4; }
.dash-empty--notif::before { content: '🔔'; background: var(--card-att-bg); border-color: #CBE7D8; }
.portal-dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 12px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.portal-dash-section-head h4 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
  letter-spacing: -0.1px;
}
.dash-view-all {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  text-decoration: none;
  background: var(--card-att-bg);
  border: 1px solid #CBE7D8;
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  transition: background 0.14s ease, transform 0.14s ease;
}
.dash-view-all:hover { background: #D8EEDF; transform: translateX(1px); text-decoration: none; }
.portal-dash-list-item {
  display: flex;
  gap: 11px;
  padding: 11px 8px;
  border-top: 1px solid var(--border);
  align-items: flex-start;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.14s ease;
}
.portal-dash-list-item:first-child { border-top: none; }
.portal-dash-list-item:hover { background: var(--surface-2); }
.dash-item-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--card-att-bg);
  font-size: 16px;
}
.dash-item-body { min-width: 0; }
.dash-item-title { font-size: 13px; font-weight: 700; color: var(--text); }
.dash-item-meta { font-size: 11.5px; color: var(--muted); }
.dash-new-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: 1px;
  text-transform: uppercase;
}

/* ---- Announcements + Notifications + Profile pages ---- */
.notif-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.notif-header h3 { margin: 0; }
.ann-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.ann-card.ann-pinned { border-left: 4px solid var(--gold); }
.ann-card.ann-important { border-left: 4px solid var(--red); }
.ann-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 6px;
}
.ann-pill-pinned { background: #fcf3df; color: #9c6f1b; }
.ann-pill-important { background: var(--red-bg); color: var(--red); }
.notif-card {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  align-items: flex-start;
}
.notif-card.unread { background: #f3f9ff; border-color: var(--navy-light); }
.notif-card-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--navy-light); flex-shrink: 0; margin-top: 5px; }
.notif-card-body { min-width: 0; }
.notif-card-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.notif-card-message { font-size: 13px; color: #555; line-height: 1.5; margin-top: 2px; }
.notif-card-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---- Profile page ---- */
.profile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  max-width: 520px;
}
.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--navy); }
.profile-role { font-size: 13px; color: var(--muted); }
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.profile-field { padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.profile-field-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; margin-bottom: 2px; }
.profile-field-value { font-size: 14px; font-weight: 600; color: var(--text); }
.profile-note { margin-top: 16px; font-size: 12.5px; color: var(--muted); }

/* Profile page action buttons (Change Password + Logout) */
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.profile-actions .btn { flex: 1 1 160px; justify-content: center; }

/* ---- btn-danger (used by logout confirm) ---- */
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover { background: #a03d31; }

/* ============================================================
   Responsive — phone-first design (≤640px) and small tablets.
   Tables become card rows; everything stacks; touch targets grow.
   ============================================================ */

/* ---- Small tablets & large phones (601–840px) ---- */
@media (max-width: 840px) {
  .portal-main { padding: 18px 16px; }
  /* Sidebar collapses to a drawer on tablets too; bottom nav takes over */
  .portal-sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 11px;
    width: 38px; height: 38px;
    font-size: 17px; color: #fff; cursor: pointer;
    transition: background 0.14s ease, transform 0.14s ease;
  }
  .portal-sidebar-toggle:hover { background: rgba(255, 255, 255, 0.26); }
  .portal-sidebar-toggle:active { transform: scale(0.94); }
  .portal-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 264px;
    max-height: none;
    z-index: 300;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding-top: 18px;
  }
  .portal-sidebar.open { transform: translateX(0); }
  .portal-sidebar-overlay { position: fixed; inset: 0; background: rgba(15, 24, 48, 0.45); z-index: 290; }
  .portal-bottom-nav {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 22px rgba(18, 61, 49, 0.13);
    z-index: 280;
    padding: 8px 6px calc(8px + var(--safe-bottom));
  }
  .bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: none;
    background: transparent;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    padding: 7px 4px;
    border-radius: 12px;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
  }
  .bnav-item .bnav-icon { display: flex; align-items: center; justify-content: center; }
  .bnav-item .bnav-icon svg { width: 22px; height: 22px; display: block; }
  .bnav-item.active {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(30, 90, 74, 0.28);
    transform: translateY(-1px);
  }
  .portal-dash-cards { grid-template-columns: repeat(2, 1fr); }
  .portal-dash-columns { grid-template-columns: 1fr; gap: 0; }
  .quick-actions-grid { grid-template-columns: repeat(3, 1fr); }
  .portal-main { padding-bottom: 88px; }
  .toast-container { bottom: 80px; left: 12px; right: 12px; max-width: none; }
  /* Teacher dashboard: side-by-side sections stack below 840px */
  .teacher-dash-grid { grid-template-columns: 1fr; }
  .teacher-att-stats-grid { grid-template-columns: repeat(3, 1fr); }

  /* ============================================================
     v1.9.31 — mobile redesign (drawer head, cards, banner, nav polish)
     Scoped to ≤840px so the desktop portal keeps its exact layout.
     ============================================================ */

  /* Drawer head: dark-green brand bar with a real close button */
  .portal-sidebar { padding-top: 0; }
  .sidebar-drawer-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(14px + var(--safe-top)) 14px 14px;
    margin-bottom: 8px;
    border-bottom: none;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
    color: #fff;
  }
  .sidebar-drawer-logo {
    width: 32px; height: 32px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--gold); flex-shrink: 0;
  }
  .sidebar-drawer-brand { font-family: var(--font-display); font-size: 12.5px; font-weight: 700; line-height: 1.3; min-width: 0; }
  .sidebar-drawer-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.14);
    border: none; border-radius: 9px;
    width: 34px; height: 34px;
    font-size: 22px; line-height: 1;
    color: #fff; cursor: pointer; flex-shrink: 0;
  }
  .sidebar-drawer-close:hover { background: rgba(255, 255, 255, 0.26); }
  /* Re-assert the mobile-drawer overrides the new base rules replaced. */
  .sidebar-drawer-close { display: block; }
  .sidebar-drawer-brand .portal-lms { color: var(--gold); }
  .sidebar-drawer-brand .portal-school-name { color: #fff; }

  /* Summary cards — equal-height 2-col grid with per-topic tints */
  .portal-dash-cards { gap: 12px; grid-auto-rows: 1fr; }
  .dash-card { position: relative; border-radius: var(--radius-lg); padding: 15px; }
  .dash-card-label { font-size: 11px; letter-spacing: 0.5px; }
  .dash-card-value { font-size: clamp(18px, 5.4vw, 22px); }
  .dash-card--fee  { background: var(--card-fee-bg);  border-color: #EADCB8; }
  .dash-card--fee  .dash-card-value { color: var(--card-fee-accent); }
  .dash-card--att  { background: var(--card-att-bg);  border-color: #CBE7D8; }
  .dash-card--att  .dash-card-value { color: var(--card-att-accent); }
  .dash-card--exam { background: var(--card-exam-bg); border-color: #CFE0F4; }
  .dash-card--exam .dash-card-value { color: var(--card-exam-accent); }
  .dash-card--game { background: var(--card-game-bg); border-color: #DFD4EE; }
  .dash-card--game .dash-card-value { color: var(--card-game-accent); }
  /* Status chip (top-right) — the live fee/attendance state, on top of the tint */
  .dash-card-chip {
    display: inline-block;
    position: absolute;
    top: 11px; right: 11px;
    font-size: 9.5px; font-weight: 800;
    letter-spacing: 0.3px; text-transform: uppercase;
    padding: 3px 8px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--navy);
  }
  .dash-card-green  .dash-card-chip { background: #D8EEDF; color: var(--card-att-accent); }
  .dash-card-amber  .dash-card-chip { background: #F6E6C2; color: #8A6217; }
  .dash-card-red    .dash-card-chip { background: #F6D6D0; color: var(--red); }
  .dash-card--fee   .dash-card-chip { background: rgba(184, 134, 11, 0.16); color: var(--card-fee-accent); }
  .dash-card--att   .dash-card-chip { background: rgba(46, 107, 72, 0.14); color: var(--card-att-accent); }
  .dash-card--exam  .dash-card-chip { background: rgba(30, 90, 158, 0.14); color: var(--card-exam-accent); }
  .dash-card--game  .dash-card-chip { background: rgba(107, 78, 158, 0.14); color: var(--card-game-accent); }

  /* Welcome banner — date line + slightly tighter rhythm */
  .portal-welcome { border-radius: var(--radius-lg); }
  .portal-welcome-body { min-width: 0; }
  .portal-welcome-date { font-size: 11.5px; }

  /* Quick actions + section cards: match the new radius */
  .portal-quick-actions { border-radius: var(--radius-lg); }
  .quick-action { border-radius: var(--radius-md); }
  .portal-dash-section { border-radius: var(--radius-lg); }
}

/* ---- Phones (≤640px) ---- */
@media (max-width: 640px) {
  .portal-main { padding: 14px 12px 84px; }

  /* Header: compact single dark-green row (logo + LMS + school + role, bell + menu).
     v1.9.31: the inline user name + logout move into the drawer on phones, so the
     header stays one tight bar; they remain in the DOM for the desktop header. */
  .portal-header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: calc(9px + var(--safe-top)) 12px 9px;
  }
  .portal-header-left { gap: 9px; }
  .portal-header-logo { width: 34px; height: 34px; border-radius: 11px; }
  .portal-header-title { font-size: 13px; line-height: 1.25; }
  .portal-header-sub { font-size: 11px; }
  .portal-header-right { gap: 6px; }
  .portal-header-right .portal-user,
  .portal-header-right #btn-logout-header { display: none; }
  .portal-header-right .portal-bell-btn { margin-left: auto; }

  /* Hamburger + drawer sidebar — base rules live in the ≤840px block above.
     v1.9.31 de-duplication: phones only need the flex-shrink guard here. */
  .portal-sidebar-toggle { flex-shrink: 0; }

  /* Bottom navigation — base rules live in the ≤840px block; phones only
     refine the label/icon size (see below). v1.9.31 de-duplication. */
  .bnav-item { font-size: 9.5px; }
  .bnav-item .bnav-icon svg { width: 21px; height: 21px; }

  /* Toast sits above the bottom nav on mobile */
  .toast-container { bottom: 76px; left: 12px; right: 12px; max-width: none; }

  /* Dashboard cards: 2×2 grid on phones */
  .portal-dash-cards { grid-template-columns: 1fr 1fr; gap: 11px; }
  .dash-card { padding: 14px; }
  .dash-card-icon { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; margin-bottom: 9px; }
  .dash-card-value { font-size: 20px; }
  .quick-actions-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .quick-action { padding: 12px 6px 11px; }
  .quick-action-icon { width: 36px; height: 36px; font-size: 18px; }
  .portal-welcome { padding: 18px; gap: 13px; border-radius: var(--radius-lg); }
  .portal-welcome-avatar { width: 52px; height: 52px; border-radius: 16px; font-size: 21px; }
  .portal-welcome-name { font-size: 18px; }
  .portal-welcome-greet { font-size: 11px; letter-spacing: 0.7px; }
  .portal-dash-section { padding: 15px; }
  .portal-quick-actions { padding: 15px; }
  .portal-child-switch { flex-direction: column; align-items: flex-start; gap: 4px; }
  .portal-child-select { max-width: 100%; }
  .profile-grid { grid-template-columns: 1fr; }

  /* Teacher dashboard mobile: stat boxes 3 columns, grid single column */
  .teacher-dash-grid { grid-template-columns: 1fr; }
  .teacher-att-stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .teacher-att-stat-box { padding: 8px 6px; }
  .teacher-att-stat-count { font-size: 17px; }

  /* Stat cards: 2×2 grid instead of 4-in-a-row */
  .portal-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .portal-stat-grid .stat-card { padding: 14px 12px; }
  .portal-stat-grid .stat-value { font-size: 20px; }

  /* Panels & tabs */
  .panel { padding: 14px 14px; }
  .panel h3 { font-size: 14px; margin-bottom: 8px; }
  .tabs { gap: 6px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex: 0 0 auto; justify-content: center; padding: 10px 6px; font-size: 12.5px; white-space: nowrap; }

  /* Class/subject controls stack */
  .portal-class-row { flex-direction: column; gap: 0; }
  .portal-class-row .portal-field,
  .portal-class-row .input.select { width: 100%; min-width: 0; }

  /* Form rows wrap the button under the fields */
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row .portal-field { width: 100%; }
  .form-row .input { width: 100%; }
  .form-row .btn { align-self: flex-start; }
  .form-row .portal-msg { align-self: flex-start; }

  /* Student identity card */
  .student-identity { padding: 14px 16px; gap: 12px; }
  .student-avatar { width: 48px; height: 48px; font-size: 19px; }
  .student-name { font-size: 16px; }
  .student-meta { font-size: 12.5px; line-height: 1.45; }

  /* Fee summary: vertical stack */
  .fee-summary { grid-template-columns: 1fr; gap: 8px; }
  .fee-summary-card { padding: 10px 14px; }
  .fee-summary-value { font-size: 16px; }

  /* Tables: card rows — the mobile-friendly replacement for
     squeezing a 7-column grid into 375px. */
  .table-panel { overflow: visible; }
  .table,
  .table thead,
  .table tbody,
  .table tr,
  .table td { display: block; width: 100%; }
  .table thead { display: none; }               /* hide the header row */
  .table tbody tr {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
  }
  .table tbody tr:hover { background: var(--panel); }
  .table tbody tr.is-low { border-left: 3px solid var(--red); }
  .table td {
    display: grid;
    grid-template-columns: 42% 58%;
    align-items: baseline;
    padding: 5px 0;
    border-bottom: none;
    font-size: 13px;
  }
  .table td.num { text-align: left; }
  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  /* Money/pill cells: right side keeps its emphasis */
  .table td.num::before { text-align: left; }
  .table td .pill,
  .table td .att-pill { justify-self: start; }

  /* Attendance summary */
  .att-big-pct { font-size: 32px; }
  .att-counts { gap: 8px 12px; font-size: 12.5px; }

  /* Teacher attendance status buttons: label on its own line, then a
     wrap row of equal-width touch buttons */
  .att-status-cell {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
  }
  .att-status-cell::before {
    flex-basis: 100%;
    margin-bottom: 2px;
  }
  .att-status-cell .att-status-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 4px;
    font-size: 11.5px;
    border-radius: 8px;
  }
  /* Marks input inside a card row stretches full width */
  .table td .input { width: 100%; }

  /* Exam cards */
  .exam-card { flex-wrap: wrap; padding: 13px 16px; gap: 8px 12px; }
  .exam-card-right { text-align: left; }
  .exam-card-arrow { display: none; }
  .exam-card .exam-card-pct { margin-top: 4px; font-size: 14px; }

  /* v1.9.33 — Upcoming exams: actions drop to their own full-width row so the
     two buttons never squeeze the exam name on a 375px screen. */
  .exam-card-actions { width: 100%; }
  .exam-card-actions .btn { flex: 1 1 0; justify-content: center; }
  .exam-detail-table th, .exam-detail-table td { padding: 8px 6px; font-size: 12.5px; }

  /* Diary cards on mobile */
  .diary-card { padding: 12px 14px; }
  .diary-card-top { flex-direction: column; align-items: flex-start; gap: 2px; }
  .diary-card-tap { display: none; }

  /* Diary modal: bottom-sheet with subject rows stacked */
  .diary-card-row { padding: 11px 13px; }
  .diary-card-row-top { margin-bottom: 5px; }
  .diary-card-row-body { font-size: 13px; }

  /* Result popup: card grid collapses to stacked on mobile */
  .result-card-head { display: none; }
  .result-card-row {
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    padding: 10px 14px;
  }
  .result-card-subject { grid-column: 1; grid-row: 1; }
  .result-card-marks { grid-column: 2; grid-row: 1; }
  .result-card-pct { grid-column: 2; grid-row: 2; }
  .result-card-grade { grid-column: 1; grid-row: 2; justify-self: start; }
  .result-card-foot { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Games dashboard: stat cards 2-col, launch button full-width */
  .games-summary-grid { grid-template-columns: 1fr 1fr; }
  .games-tile-grid { grid-template-columns: 1fr; gap: 8px; }
  .portal-extras { flex-direction: column; align-items: stretch; }
  .portal-extras-btn { text-align: center; }

  /* Small dialogs (leave / advance / password): bottom sheet on phones.
     The full-screen viewers are excluded — they already fill the viewport. */
  .portal-modal-overlay:not(.portal-modal-fullscreen) { padding: 10px; align-items: flex-end; }
  .portal-modal-overlay:not(.portal-modal-fullscreen) .portal-modal {
    width: 100%;
    max-width: none;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
  }
  .portal-modal-overlay:not(.portal-modal-fullscreen) .portal-modal-head { padding: 16px 16px 12px; }
  .portal-modal-overlay:not(.portal-modal-fullscreen) .portal-modal-body { padding: 12px 16px 18px; }

  /* Logout confirm popup always stays centered in the screen */
  .portal-modal-overlay#logout-modal { align-items: center; }
  #logout-modal .portal-modal {
    width: auto;
    min-width: 280px;
    max-width: 94vw;
    border-radius: 12px;
    text-align: center;
  }
}

/* ---- Popup-markup table on mobile: since .table becomes cards, make
   sure the exam-popup subject table (which reuses .table) also gets the
   card treatment with proper labels. ---- */
@media (max-width: 640px) {
  .portal-modal-body .table tbody tr { margin-bottom: 6px; }
  .portal-modal-body .table td { grid-template-columns: 50% 25% 25%; }
}

/* ---- Teacher marks grid stays tabular on mobile: it is marks-entry UI,
   so it must NOT become the card transform — it scrolls horizontally
   inside its wrapper instead. Must restore a REAL table (v1.9.16): the
   earlier version set even the .table element to table-cell, so the
   thead (Roll No | Name | subject | Total Marks) sized its columns in its
   own anonymous table and got pushed far off while the body looked fine.
   Width is max-content (not a forced min-width) so Roll No | Name |
   subject sit close together with no big horizontal gaps; the wrapper
   only scrolls when there are many subjects. ---- */
#teacher-marks-grid-wrap { -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  #teacher-marks-grid-wrap .table { display: table; width: max-content; }
  #teacher-marks-grid-wrap .table thead { display: table-header-group; }
  #teacher-marks-grid-wrap .table tbody { display: table-row-group; }
  #teacher-marks-grid-wrap .table tr { display: table-row; }
  #teacher-marks-grid-wrap .table th,
  #teacher-marks-grid-wrap .table td { display: table-cell; width: auto; }
  #teacher-marks-grid-wrap .table td::before { content: none; }
  #teacher-marks-grid-wrap .table tbody tr {
    border: none; border-radius: 0; padding: 0; margin: 0;
    background: transparent; box-shadow: none;
  }
  #teacher-marks-grid-wrap .table th,
  #teacher-marks-grid-wrap .table td { padding: 4px 6px; }
}

/* ---- v1.9.26 — LGS diary sheet on phones: stays a real two-column table
   (Subject | Diary / Homework) so it keeps the official grid look, but the
   columns are sized to the screen — NO min-width, NO horizontal scrolling.
   Long homework and Urdu text wrap inside the cell instead. ---- */
@media (max-width: 640px) {
  .portal-modal-fullscreen .portal-modal-body.portal-fs-body { padding: 10px; }
  .lgs-diary { max-width: 100%; border-radius: 8px; }
  .lgsd-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .lgsd-logo { width: 46px; height: 46px; }
  .lgsd-school h1 { font-size: 16px; letter-spacing: 0.3px; }
  .lgsd-city { font-size: 11.5px; }
  .lgsd-cell { font-size: 10.5px; }
  .lgsd-badge { font-size: 10.5px; padding: 6px 9px; letter-spacing: 1px; }
  .lgsd-meta { grid-template-columns: repeat(2, 1fr); }
  .lgsd-meta-item { padding: 7px 10px; }
  .lgsd-meta-value { font-size: 12.5px; }
  .lgsd-table-wrap { padding: 10px 10px 0; }
  .lgsd-table { table-layout: fixed; }
  .lgsd-th-num { width: 10%; }
  .lgsd-th-subject { width: 32%; }
  .lgsd-th-hw { width: 58%; }
  .lgsd-table th { padding: 8px 8px; font-size: 11.5px; letter-spacing: 0.5px; }
  .lgsd-table td { padding: 8px 8px; font-size: 12.5px; }
  .lgsd-num { font-size: 11.5px; }
  .lgsd-subject-name { font-size: 12.5px; }
  .lgsd-hw.lgsd-urdu { font-size: 14px; line-height: 1.9; }
  .lgsd-note { margin: 10px 10px 0; font-size: 11.5px; padding: 8px 10px; }
  .lgsd-remarks { grid-template-columns: 1fr; margin: 10px 10px 0; }
  .lgsd-remarks-cell { padding: 8px 10px 12px; }
  .lgsd-footer { padding: 10px 14px; font-size: 10.5px; }
}

/* ================= Fee Receipt (official — identical to admin) ================= */
.doc-logo {
  display: block;
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--gold);
  margin: 0 auto 6px;
}
.receipt-header-brand { display: flex; align-items: center; gap: 12px; }
.receipt-header-brand .doc-logo { margin: 0; }

.receipt {
  border: 2px solid var(--navy);
  border-radius: 10px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.receipt::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 300px; height: 300px;
  background: url('assets/logo.png') center / contain no-repeat;
  opacity: 0.06;
  pointer-events: none;
}
.receipt > * { position: relative; }
.receipt-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 14px; margin-bottom: 16px;
}
.receipt-header h2 { font-family: var(--font-display); color: var(--navy); margin: 0 0 2px; }
.receipt-header p { margin: 0; color: var(--muted); font-size: 12.5px; }
.receipt-no { text-align: right; font-size: 12.5px; color: var(--muted); }
.receipt-no b { color: var(--navy); font-family: var(--font-display); }
.receipt-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin-bottom: 18px; font-size: 13.5px; }
.receipt-meta b { color: var(--navy); }
.receipt-amount-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.receipt-amount-table th { background: var(--navy); color: #fff; padding: 9px 12px; font-size: 12.5px; text-align: left; }
.receipt-amount-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.receipt-amount-table tr.total-row td { font-weight: 700; color: var(--navy); border-top: 2px solid var(--navy); border-bottom: none; }
.receipt-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 30px; }
.receipt-footer .stamp { text-align: center; font-size: 11px; color: var(--muted); }
.receipt-footer .stamp .line { width: 140px; border-top: 1px solid var(--border); margin-bottom: 4px; }

/* Receipt modal footer (portal-only; admin prints via its own modal) */
.portal-modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ---- Official Report Card (v1.9.0) ----
   The portal's own .result-card is the compact mark-sheet card, so the admin
   app's official A4 report card (styles.css) must be restored inside the
   report-card modal via #report-card-modal scoping. Everything else
   (.result-card-header, .result-logo, .result-info-table, .result-marks-table,
   .result-remarks, .result-signatures) already comes from styles.css. */
#report-card-modal .result-card {
  background: #fff;
  color: #000;
  border: 2.5px solid #000;
  padding: 22px 26px;
  border-radius: 0;
  overflow: visible;
  font-family: var(--font-body);
  page: result-portrait;
}
/* v1.9.26: the report card is a full-screen viewer, so the modal fills the
   viewport and the BODY scrolls — the A4 sheet is never clipped. */
#report-card-modal .portal-modal-report {
  max-height: none;
  height: 100%;
}
#report-card-modal .result-card * { border-color: #000; color: #000; }
#report-card-modal .result-card-title {
  border: 1.5px solid #000;
  padding: 7px;
  margin-bottom: 14px;
}
#report-card-modal .result-total-row td { border-top: 1px solid #000; }
#report-card-modal .result-marks-table td,
#report-card-modal .result-marks-table th { border-color: #000; }

/* Receipt print: overlay is reflowed to normal flow so ONLY the receipt
   prints (same approach as the admin app's .modal-overlay print rule). */
@media print {
  html, body, .portal-dashboard, .portal-main, .main-page {
    height: auto !important; overflow: visible !important;
  }
  /* Hide all shell chrome */
  .portal-header, .portal-sidebar, .portal-bottom-nav, .portal-sidebar-overlay,
  .portal-sidebar-toggle { display: none !important; }
  body.portal-modal-open { overflow: visible !important; height: auto !important; }
  .portal-modal-overlay {
    position: static !important;
    background: none !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  #receipt-modal .portal-modal,
  #report-card-modal .portal-modal-report {
    box-shadow: none; width: 100%; max-width: none;
    max-height: none !important; height: auto !important;
    overflow: visible !important;
    border-radius: 0;
  }
  #receipt-modal .portal-modal-head,
  #receipt-modal .portal-modal-foot { display: none !important; }
  #report-card-modal .portal-modal-head,
  #report-card-modal .portal-modal-foot { display: none !important; }
  /* Diary: print the sheet in full, hide the viewer header */
  #diary-modal .portal-modal-head { display: none !important; }
  #diary-modal .portal-modal-body.portal-fs-body {
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    height: auto !important;
  }
  .lgs-diary {
    max-width: none;
    border: 2px solid #1E5A4A;
    box-shadow: none;
    page-break-inside: avoid;
  }
  .lgsd-table { page-break-inside: auto; }
  .lgsd-row { page-break-inside: avoid; page-break-after: auto; }
  .lgsd-table thead { display: table-header-group; }
  .lgsd-table tfoot { display: table-footer-group; }
  .lgsd-band, .lgsd-badge, .lgsd-footer, .lgsd-table th, .lgsd-subject, .lgsd-note,
  .lgsd-num, .lgsd-remarks, .lgsd-remarks-cell, .lgsd-sheet {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .lgsd-footer { page-break-inside: avoid; }
  .lgsd-remarks { page-break-inside: avoid; }
  @page diary-portrait { size: A4 portrait; margin: 10mm; }
  .lgs-diary { page: diary-portrait; }
  .receipt { border: 2px solid #1E5A4A; }
  .receipt-amount-table th,
  .receipt-amount-table td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Report card: force black & white, same as admin */
  #report-card-modal .result-card,
  #report-card-modal .result-card * {
    color: #000 !important;
    background: #fff !important;
    border-color: #000 !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #report-card-modal .result-logo { filter: grayscale(1) contrast(1.15) !important; }
  #report-card-modal .result-card { aspect-ratio: auto; width: 100%; }
}

/* ============================================================
   v1.9.8 — Official Report Card + Fee Receipt on phones
   Both sheets now "zoom-out" to fit the screen width perfectly
   (no horizontal scroll). Tables, fonts, and padding shrink so
   everything is visible at a glance — like a printed page
   auto-scaled to the phone.
   ============================================================ */
@media (max-width: 640px) {
  /* ---- Report Card ---- */
  /* v1.9.26: the viewer body scrolls vertically (the sheet is tall); it must
     NOT be overflow:visible or the whole page would scroll behind it. */
  #report-card-modal .portal-modal-body { overflow-y: auto; overflow-x: hidden; }
  #report-card-modal .result-card {
    padding: 10px 8px;
    border-width: 1.5px;
  }
  #report-card-modal .result-card-header {
    flex-direction: column;
    gap: 4px;
    padding-bottom: 6px;
    margin-bottom: 6px;
    text-align: center;
  }
  #report-card-modal .result-logo { width: 32px; height: 32px; }
  #report-card-modal .result-header-text h1 { font-size: 13px; letter-spacing: 0; }
  #report-card-modal .result-header-text p { font-size: 9px; }
  #report-card-modal .result-card-title { font-size: 10px; padding: 4px 6px; margin-bottom: 6px; }
  /* Tables fit within screen width — no min-width, no scroll */
  #report-card-modal .result-info-table,
  #report-card-modal .result-marks-table { width: 100%; font-size: 9.5px; }
  #report-card-modal .result-info-table td,
  #report-card-modal .result-marks-table th,
  #report-card-modal .result-marks-table td { padding: 3px 4px; }
  #report-card-modal .result-remarks { font-size: 9.5px; min-height: 30px; padding: 6px 8px; margin-bottom: 12px; }
  #report-card-modal .result-signatures { padding: 0 4px; }
  #report-card-modal .result-signatures .sig { font-size: 9px; }
  #report-card-modal .result-signatures .sig .line { width: 80px; }

  /* ---- Fee Receipt ---- */
  #receipt-modal .portal-modal-body { overflow: visible; }
  #receipt-modal .receipt { padding: 10px 8px; }
  #receipt-modal .receipt-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding-bottom: 6px;
    margin-bottom: 8px;
  }
  #receipt-modal .receipt-header-brand { gap: 6px; }
  #receipt-modal .doc-logo { width: 30px; height: 30px; }
  #receipt-modal .receipt-header h2 { font-size: 12px; }
  #receipt-modal .receipt-header p { font-size: 9px; }
  #receipt-modal .receipt-no { text-align: left; font-size: 9px; }
  #receipt-modal .receipt-meta { grid-template-columns: 1fr; gap: 4px; font-size: 9.5px; }
  /* 5-column amount table fits full width — no min-width, no scroll */
  #receipt-modal .receipt-amount-table { width: 100%; font-size: 9.5px; }
  #receipt-modal .receipt-amount-table th,
  #receipt-modal .receipt-amount-table td { padding: 4px 5px; }
  #receipt-modal .receipt-footer { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ============ Teacher Timetable (Phase 4, v1.9.21) ============ */
.tt-teacher-grid {
  display: flex; flex-direction: column; gap: 6px; margin-top: 10px;
}
.tt-teacher-row {
  display: flex; align-items: stretch; gap: 8px;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--panel);
}
.tt-teacher-time {
  flex: 0 0 110px; padding: 8px 10px; font-weight: 600; font-size: 12px;
  background: #f4f6f8; border-right: 1px solid var(--border);
  display: flex; align-items: center;
}
.tt-teacher-label {
  flex: 1; padding: 8px 10px; font-weight: 600; font-size: 12.5px;
  display: flex; align-items: center;
}
.tt-teacher-assembly { background: #fff8e1; }
.tt-teacher-assembly .tt-teacher-label { color: #e65100; }
.tt-teacher-break { background: #e3f2fd; }
.tt-teacher-break .tt-teacher-label { color: #1565c0; }
.tt-teacher-period { }
.tt-teacher-cells {
  flex: 1; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px;
}
.tt-teacher-cell {
  display: flex; flex-direction: column; gap: 1px;
  background: #f0f6f3; border: 1px solid #d7e6dd; border-radius: 6px;
  padding: 5px 9px;
}
.tt-teacher-subject { font-weight: 600; font-size: 12px; color: var(--navy); }
.tt-teacher-class { font-size: 11px; color: var(--muted); }

@media (max-width: 640px) {
  .tt-teacher-row { flex-direction: column; gap: 0; }
  .tt-teacher-time { flex: none; border-right: none; border-bottom: 1px solid var(--border); }
  .tt-teacher-cells { flex-direction: column; }
}

/* ============ Teacher HR & Finance (v1.9.23) ============ */

/* Payslip / advance / leave cards */
.portal-card { margin-bottom: 12px; }
.portal-card-head strong { font-size: 14px; color: var(--navy); }
.portal-card-body { margin-top: 10px; }
.payslip-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.payslip-row:last-child { border-bottom: none; }
.payslip-row span:first-child { color: var(--muted); }
.payslip-row span:last-child { font-weight: 600; color: var(--text); text-align: right; }
.payslip-row .num { font-variant-numeric: tabular-nums; }

/* Status badges */
.status-approved { color: var(--green); font-weight: 700; text-transform: capitalize; }
.status-pending  { color: #b8860b; font-weight: 700; text-transform: capitalize; }
.status-rejected { color: var(--red);  font-weight: 700; text-transform: capitalize; }

/* Staff attendance table badge */
.staffatt-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 700; text-transform: capitalize;
  background: #eceff1; color: #546e7a;
}
.staffatt-badge.present  { background: #e6f4ea; color: #1e7e34; }
.staffatt-badge.late     { background: #fdf3dc; color: #9a6700; }
.staffatt-badge.absent   { background: #fdeaea; color: #c5221f; }
.staffatt-badge.leave    { background: #e3f0fd; color: #1967d2; }
.staffatt-badge.half_day { background: #f3e8fd; color: #7b1fa2; }

/* v1.9.23 modal buttons row */
.portal-modal-body .form-row { gap: 10px; }
.portal-modal-body textarea.input { resize: vertical; }
.portal-modal-body .btn { margin-top: 4px; }

/* ============================================================
   v1.9.30 — "Install as App" (PWA) affordance
   The buttons carry the `hidden` attribute and are only revealed when the
   browser fires beforeinstallprompt (Chrome/Edge, installable, not yet
   installed). Safari/Firefox never fire it, so nothing shows there.
   ============================================================ */

/* Login screen — full-width button under the Sign In form */
.portal-install-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  background: transparent;
  border: 1.5px dashed var(--navy-light, var(--navy));
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.portal-install-btn:hover {
  background: rgba(30, 90, 74, 0.07);
  border-style: solid;
}
.portal-install-btn:active { transform: scale(0.99); }
.portal-install-ico { margin-right: 6px; }

.portal-install-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* Header — compact icon button, sits with the bell / user chip */
.portal-install-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--navy);
  background: rgba(30, 90, 74, 0.09);
  border: 1px solid rgba(30, 90, 74, 0.22);
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.portal-install-btn-icon:hover { background: rgba(30, 90, 74, 0.18); }
.portal-install-btn-icon:active { transform: scale(0.94); }

/* Sidebar row (student + teacher) — inherits .sidebar-nav-item, just tints it */
.portal-install-row { color: var(--navy); font-weight: 700; }

/* `hidden` must beat the display rules above (global [hidden] fix pattern) */
.portal-install-btn[hidden],
.portal-install-btn-icon[hidden],
.portal-install-hint[hidden],
.portal-install-row[hidden] { display: none !important; }

/* ============================================================
   v1.9.31 — small-phone fine-tune (≤380px: 320 / 360 / 375 class).
   Prevents overflow with long names + large amounts and keeps the
   compact header readable. Scoped to ≤380px only.
   ============================================================ */
@media (max-width: 380px) {
  .portal-header-title { font-size: 12px; }
  .portal-header-sub { font-size: 10.5px; }
  .portal-header-logo { width: 30px; height: 30px; }
  .portal-main { padding-left: 10px; padding-right: 10px; }
  .dash-card { padding: 12px; }
  .dash-card-value { font-size: 17px; }
  .dash-card-chip { font-size: 9px; padding: 2px 6px; top: 9px; right: 9px; }
  .quick-actions-grid { gap: 6px; }
  .quick-action { padding: 10px 4px; font-size: 11px; }
  .quick-action-icon { font-size: 19px; }
  .portal-welcome { padding: 14px; gap: 10px; }
  .portal-welcome-avatar { width: 42px; height: 42px; font-size: 18px; }
  .portal-welcome-name { font-size: 16px; }
  .portal-welcome-meta { font-size: 12px; }
  .bnav-item { font-size: 9px; }
  .bnav-item .bnav-icon svg { width: 20px; height: 20px; }
}

/* ============================================================
   v1.9.33 — LEARNING ARENA
   Games page, game cards, the round player, leaderboards and badges.
   Built entirely from the existing LGS tokens (green / cream / gold) so the
   Arena reads as part of the portal rather than a bolted-on arcade. All
   artwork is emoji + CSS — no external image can 404.
   ============================================================ */

/* ---- hero ---- */
.arena-hero {
  background: linear-gradient(135deg, var(--navy-deep, #1a4a3f) 0%, var(--navy) 60%, var(--navy-light, #338866) 100%);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  color: #fff;
  margin-bottom: 18px;
  box-shadow: var(--elev-2);
}
.arena-hero-title { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.2px; }
.arena-hero-tag { font-size: 13px; opacity: 0.9; margin-top: 3px; }
.arena-hero-stats { display: flex; gap: 22px; margin-top: 16px; flex-wrap: wrap; }
.arena-hero-stat { min-width: 74px; }
.arena-hero-stat-value { font-family: var(--font-display); font-size: 21px; font-weight: 800; line-height: 1.1; }
.arena-hero-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; opacity: 0.85; margin-top: 2px; }

/* ---- section headings ---- */
.arena-section { margin-bottom: 22px; }
.arena-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.arena-section-head h4 { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--navy); margin: 0; }
.arena-section-note { font-size: 12px; color: var(--muted); }

/* ---- game cards ---- */
.arena-games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.arena-game-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--elev-1);
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex; flex-direction: column; gap: 8px;
  font: inherit;
}
.arena-game-card:hover { transform: translateY(-2px); box-shadow: var(--elev-2); border-color: var(--navy-light, #338866); }
.arena-game-card:focus-visible { outline: none; box-shadow: var(--ring-gold); }
.arena-game-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
  background: var(--card-game-bg); border: 1px solid rgba(107, 78, 158, 0.16);
}
.arena-game-card[data-cat="math"] .arena-game-icon { background: var(--card-exam-bg); border-color: rgba(30, 90, 158, 0.16); }
.arena-game-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--navy); }
.arena-game-blurb { font-size: 12px; color: var(--muted); line-height: 1.45; }
.arena-game-meta { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.arena-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
  background: var(--card-game-bg); color: var(--card-game-accent);
}
.arena-tag--math { background: var(--card-exam-bg); color: var(--card-exam-accent); }
.arena-tag--easy { background: var(--card-att-bg); color: var(--card-att-accent); }
.arena-tag--medium { background: var(--card-fee-bg); color: var(--card-fee-ink); }
.arena-tag--hard { background: #FBE9E7; color: #B3452F; }
.arena-tag--advanced { background: #EDE7F6; color: #5B3FA0; }

/* ---- category tabs ---- */
.arena-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.arena-tab {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border);
}
.arena-tab[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- top-3 winner cards ---- */
.arena-podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.arena-winner {
  border-radius: var(--radius-md); padding: 14px 12px; text-align: center;
  border: 1px solid var(--border); background: var(--panel);
  box-shadow: var(--elev-1);
}
.arena-winner--1 { background: linear-gradient(180deg, #FFF8E1, #FDF3D4); border-color: #E8C86A; }
.arena-winner--2 { background: linear-gradient(180deg, #F7F8FA, #EDEFF3); border-color: #C8CDD6; }
.arena-winner--3 { background: linear-gradient(180deg, #FDF2E8, #F8E7D5); border-color: #DFB98C; }
.arena-winner-crown { font-size: 20px; line-height: 1; }
.arena-winner-avatar {
  width: 46px; height: 46px; border-radius: 50%; margin: 6px auto 8px;
  overflow: hidden; background: var(--card-att-bg); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 19px;
  border: 2px solid rgba(255, 255, 255, 0.9);
}
.arena-winner-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.arena-winner-name { font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--navy);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arena-winner-class { font-size: 11px; color: var(--muted); margin-top: 1px; }
.arena-winner-points { font-family: var(--font-display); font-size: 16px; font-weight: 800; color: var(--card-fee-ink); margin-top: 5px; }

/* ---- leaderboard table ---- */
.arena-board { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--elev-1); }
.arena-board-row {
  display: grid; grid-template-columns: 34px 38px 1fr auto;
  align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.arena-board-row:last-child { border-bottom: 0; }
.arena-board-row--me { background: var(--card-att-bg); }
.arena-board-rank { font-family: var(--font-display); font-size: 14px; font-weight: 800; color: var(--muted); text-align: center; }
.arena-board-row--1 .arena-board-rank { color: #B8860B; }
.arena-board-row--2 .arena-board-rank { color: #7A828E; }
.arena-board-row--3 .arena-board-rank { color: #B5713A; }
.arena-board-avatar {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  background: var(--card-att-bg); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
}
.arena-board-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.arena-board-name { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arena-board-sub { font-size: 11.5px; color: var(--muted); }
.arena-board-points { font-family: var(--font-display); font-size: 14px; font-weight: 800; color: var(--navy); white-space: nowrap; }
.arena-board-points span { font-size: 10.5px; font-weight: 600; color: var(--muted); display: block; text-align: right; }

/* ---- badges ---- */
.arena-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.arena-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--card-fee-bg); color: var(--card-fee-ink); border: 1px solid rgba(184, 134, 11, 0.22);
}
.arena-badge-icon { font-size: 14px; }

/* ---- the round player ---- */
.arena-play-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.arena-play-progress { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.arena-play-timer {
  font-family: var(--font-display); font-size: 15px; font-weight: 800; color: var(--navy);
  background: var(--card-exam-bg); border-radius: 999px; padding: 5px 14px;
}
.arena-play-timer--low { background: #FBE9E7; color: #B3452F; }
.arena-play-bar { height: 5px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: 18px; }
.arena-play-bar-fill { height: 100%; background: var(--navy-light, #338866); border-radius: 999px; transition: width 0.25s ease; }
.arena-play-prompt {
  font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--navy);
  line-height: 1.35; margin-bottom: 18px; word-break: break-word;
}
.arena-play-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.arena-option {
  font: inherit; font-size: 16px; font-weight: 700; color: var(--navy);
  padding: 15px 12px; border-radius: var(--radius-md); cursor: pointer;
  background: var(--panel); border: 1.5px solid var(--border);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease;
  min-height: 54px;
}
.arena-option:hover { border-color: var(--navy-light, #338866); background: var(--surface-2, #FCFBF7); }
.arena-option[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.arena-option:focus-visible { outline: none; box-shadow: var(--ring-gold); }
.arena-play-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.arena-memory-reveal {
  font-family: var(--font-display); font-size: 30px; letter-spacing: 10px;
  text-align: center; padding: 22px 10px; border-radius: var(--radius-md);
  background: var(--card-game-bg); color: var(--card-game-accent); margin-bottom: 16px;
}

/* ---- results screen ---- */
.arena-result { text-align: center; padding: 8px 0 4px; }
.arena-result-ring {
  width: 108px; height: 108px; border-radius: 50%; margin: 0 auto 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--card-att-bg); border: 4px solid var(--card-att-accent); color: var(--navy);
}
.arena-result-score { font-family: var(--font-display); font-size: 30px; font-weight: 800; line-height: 1; }
.arena-result-outof { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.arena-result-title { font-family: var(--font-display); font-size: 19px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.arena-result-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.arena-result-points {
  display: inline-block; font-family: var(--font-display); font-size: 15px; font-weight: 800;
  padding: 8px 18px; border-radius: 999px; margin-bottom: 14px;
  background: var(--card-fee-bg); color: var(--card-fee-ink); border: 1px solid rgba(184, 134, 11, 0.25);
}
.arena-result-bonuses { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ---- empty state ---- */
.arena-empty {
  text-align: center; padding: 26px 16px; color: var(--muted); font-size: 13.5px;
  background: var(--surface-2, #FCFBF7); border: 1px dashed var(--border); border-radius: var(--radius-md);
}
.arena-privacy { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* ---- standings teaser → opens the Leaderboard tab (v1.9.34) ---- */
.arena-board-link {
  width: 100%; display: grid; grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center; gap: 12px; padding: 12px 15px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--elev-1); font: inherit; color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.arena-board-link:hover { border-color: var(--navy-light, #2C7A63); box-shadow: var(--elev-2); }
.arena-board-link:active { transform: translateY(1px); }
.arena-board-link-avatar { display: flex; }
.arena-board-link-text { min-width: 0; }
.arena-board-link-name {
  display: block; font-size: 13.5px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.arena-board-link-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.arena-board-link-go { font-size: 12px; font-weight: 700; color: var(--navy); white-space: nowrap; }

/* ============================================================
   v1.9.34 — LEADERBOARD (its own tab)
   A dedicated, professional standings surface: my-position card,
   segmented scope control, raised podium and a clean ranked table.
   Same palette as the Arena so it reads as one product.
   ============================================================ */

/* ---- my position card ---- */
.lb-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--navy-deep, #123D31) 0%, var(--navy) 55%, var(--navy-light, #2C7A63) 100%);
  border-radius: var(--radius-lg);
  padding: 20px 22px; color: #fff; margin-bottom: 16px;
  box-shadow: var(--elev-2);
  display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center;
}
.lb-hero::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(217,167,54,0.30), transparent 70%);
  pointer-events: none;
}
.lb-hero-rank { text-align: center; min-width: 84px; }
.lb-hero-rank-num {
  font-family: var(--font-display); font-size: 40px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
}
.lb-hero-rank-num small { font-size: 20px; font-weight: 700; opacity: 0.7; }
.lb-hero-rank-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px;
  opacity: 0.82; margin-top: 4px;
}
.lb-hero-main { min-width: 0; }
.lb-hero-name {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-hero-meta { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.lb-hero-stats { display: flex; gap: 20px; margin-top: 14px; flex-wrap: wrap; }
.lb-hero-stat-value {
  font-family: var(--font-display); font-size: 18px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.lb-hero-stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; opacity: 0.8; margin-top: 2px; }
.lb-hero-gap {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.20);
}
.lb-hero-gap b { font-variant-numeric: tabular-nums; }

/* ---- segmented scope control ---- */
.lb-seg {
  display: inline-flex; gap: 3px; padding: 3px; margin-bottom: 16px;
  background: var(--surface-2, #FCFBF7); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: inset 0 1px 2px rgba(18,61,49,0.04);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.lb-seg::-webkit-scrollbar { display: none; }
.lb-seg-btn {
  font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  padding: 7px 15px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted); border: 0;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.lb-seg-btn:hover { color: var(--navy); }
.lb-seg-btn[aria-selected="true"] {
  background: var(--navy); color: #fff; box-shadow: 0 1px 3px rgba(18,61,49,0.28);
}
.lb-seg-btn .lb-seg-count {
  font-size: 10.5px; font-weight: 700; opacity: 0.7; margin-left: 5px;
  font-variant-numeric: tabular-nums;
}

/* ---- podium (2nd · 1st · 3rd) ---- */
.lb-podium {
  display: grid; grid-template-columns: 1fr 1.14fr 1fr; gap: 10px;
  align-items: end; margin-bottom: 16px;
}
.lb-pod {
  position: relative; text-align: center; padding: 16px 12px 14px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--panel); box-shadow: var(--elev-1);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.lb-pod::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.lb-pod--1 { order: 2; padding-top: 20px; padding-bottom: 18px; }
.lb-pod--2 { order: 1; }
.lb-pod--3 { order: 3; }
.lb-pod--1 { background: linear-gradient(180deg, #FFFCF2, #FBF3DC); border-color: #E8C86A; box-shadow: var(--elev-2); }
.lb-pod--1::before { background: linear-gradient(90deg, #E8C86A, #D9A736, #E8C86A); }
.lb-pod--2 { background: linear-gradient(180deg, #FBFCFD, #EFF1F5); border-color: #C8CDD6; }
.lb-pod--2::before { background: linear-gradient(90deg, #C8CDD6, #9AA2AE, #C8CDD6); }
.lb-pod--3 { background: linear-gradient(180deg, #FEFAF6, #F7E9DA); border-color: #DFB98C; }
.lb-pod--3::before { background: linear-gradient(90deg, #DFB98C, #C08552, #DFB98C); }
.lb-pod-medal { font-size: 17px; line-height: 1; }
.lb-pod-avatar {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-att-bg); color: var(--navy);
  font-family: var(--font-display); font-weight: 800; font-size: 20px;
  border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(18,61,49,0.06);
}
.lb-pod--1 .lb-pod-avatar { width: 62px; height: 62px; font-size: 24px; box-shadow: 0 0 0 2px #D9A736; }
.lb-pod-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-pod-name {
  font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--navy);
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-pod-class { font-size: 10.5px; color: var(--muted); }
.lb-pod-pts {
  font-family: var(--font-display); font-size: 16px; font-weight: 800; color: var(--card-fee-ink);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.lb-pod-pts span { font-size: 10px; font-weight: 600; color: var(--muted); }
.lb-pod-me {
  position: absolute; top: 7px; right: 8px; font-size: 9.5px; font-weight: 800;
  letter-spacing: 0.4px; text-transform: uppercase; padding: 2px 6px; border-radius: 999px;
  background: var(--navy); color: #fff;
}

/* ---- ranked table ---- */
.lb-table {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--elev-1);
}
.lb-row {
  display: grid; grid-template-columns: 40px 40px minmax(0,1fr) 74px auto;
  align-items: center; gap: 12px; padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}
.lb-row:last-child { border-bottom: 0; }
.lb-row:hover { background: var(--surface-2, #FCFBF7); }
.lb-row--me { background: var(--card-att-bg); }
.lb-row--me:hover { background: var(--card-att-bg); }
.lb-row--me::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--navy-light, #2C7A63);
}
.lb-row { position: relative; }
.lb-rank {
  font-family: var(--font-display); font-size: 14px; font-weight: 800; text-align: center;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.lb-rank--1 { color: #B8860B; }
.lb-rank--2 { color: #7A828E; }
.lb-rank--3 { color: #B5713A; }
.lb-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-att-bg); color: var(--navy);
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
}
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-who { min-width: 0; }
.lb-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.lb-you {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px; background: var(--navy); color: #fff; flex-shrink: 0;
}
.lb-sub { font-size: 11.5px; color: var(--muted); }
.lb-acc { min-width: 0; }
.lb-acc-bar { height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.lb-acc-fill { height: 100%; border-radius: 999px; background: var(--navy-light, #2C7A63); }
.lb-acc-txt { font-size: 10px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.lb-pts {
  font-family: var(--font-display); font-size: 15px; font-weight: 800; color: var(--navy);
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.lb-pts span { display: block; font-size: 10px; font-weight: 600; color: var(--muted); }
.lb-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.lb-empty {
  text-align: center; padding: 30px 16px; color: var(--muted); font-size: 13.5px;
  background: var(--surface-2, #FCFBF7); border: 1px dashed var(--border); border-radius: var(--radius-md);
}
.lb-empty strong { display: block; color: var(--navy); font-family: var(--font-display); font-size: 15px; margin-bottom: 4px; }

/* ---- leaderboard on phones ---- */
@media (max-width: 640px) {
  .lb-hero { grid-template-columns: 1fr; gap: 14px; padding: 18px; text-align: left; }
  .lb-hero-rank { text-align: left; }
  .lb-hero-rank-num { font-size: 34px; }
  .lb-podium { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .lb-pod--1 { order: 0; grid-column: 1 / -1; }
  .lb-pod--2 { order: 1; }
  .lb-pod--3 { order: 2; }
  .lb-pod--1 .lb-pod-avatar { width: 56px; height: 56px; }
  .lb-row { grid-template-columns: 32px 34px minmax(0,1fr) auto; gap: 10px; padding: 10px 12px; }
  .lb-acc { display: none; }
  .lb-avatar { width: 32px; height: 32px; }
}

/* ---- phone ---- */
@media (max-width: 640px) {
  .arena-hero { padding: 17px; }
  .arena-hero-title { font-size: 19px; }
  .arena-hero-stats { gap: 16px; }
  .arena-hero-stat-value { font-size: 18px; }
  .arena-games-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .arena-game-card { padding: 12px; }
  .arena-game-icon { width: 36px; height: 36px; font-size: 19px; }
  .arena-game-blurb { display: none; }
  .arena-podium { grid-template-columns: 1fr; }
  .arena-winner { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; }
  .arena-winner-avatar { margin: 0; flex-shrink: 0; }
  .arena-winner-crown { font-size: 17px; }
  .arena-winner-points { margin-top: 0; margin-left: auto; }
  .arena-board-row { grid-template-columns: 28px 32px 1fr auto; gap: 8px; padding: 9px 11px; }
  .arena-board-avatar { width: 30px; height: 30px; font-size: 13px; }
  .arena-play-prompt { font-size: 18px; }
  .arena-play-options { grid-template-columns: 1fr; }
  .arena-option { padding: 14px 12px; font-size: 15.5px; }
  .arena-play-actions .btn { flex: 1 1 0; justify-content: center; }
  .arena-memory-reveal { font-size: 24px; letter-spacing: 7px; }
}

@media (max-width: 380px) {
  .arena-games-grid { grid-template-columns: 1fr 1fr; }
  .arena-game-title { font-size: 13px; }
  .arena-hero-stat-value { font-size: 16px; }
  .arena-play-prompt { font-size: 16.5px; }
}

/* ============================================================
   v1.9.36 — My Check-In (teacher self check-in, geo-fence verified)
   Uses the established LGS tokens only: green/navy surfaces, gold
   accent, cream panel. One "status card" is the memorable element;
   everything around it stays quiet.
   ============================================================ */
.geo-checkin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--elev-1);
}
/* v1.9.43 — Pakistan GMT+5 clock line above the check-in card. */
.geo-checkin-tzline {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  display: inline-block;
  line-height: 1.5;
}
.geo-checkin-tzline b { color: var(--navy); font-variant-numeric: tabular-nums; }
.geo-checkin-top { display: flex; align-items: flex-start; gap: 14px; }
.geo-checkin-icon {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--card-att-bg), #ffffff);
  border: 1px solid var(--border);
}
.geo-checkin-text { min-width: 0; }
.geo-checkin-title { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.25; }
.geo-checkin-sub { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

.geo-checkin-meta {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.geo-meta-item {
  font-size: 12px; color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
  line-height: 1.4;
}
.geo-meta-item b { color: var(--navy); }
.geo-meta-item.geo-meta-strict { background: #fdf3dc; border-color: #f0d9a8; color: #8a5a00; }

.geo-checkin-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.geo-checkin-actions .btn { flex: 0 0 auto; }
.geo-checkin-actions #geocheck-btn { min-width: 150px; }

.geo-checkin-msg {
  margin-top: 12px; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; line-height: 1.45;
}
.geo-checkin-msg.is-ok  { background: #e7f6ec; color: #17683a; border: 1px solid #b6e2c4; }
.geo-checkin-msg.is-bad { background: #fdecec; color: #8f2222; border: 1px solid #f2c3c3; }

.geo-today-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 16px;
  box-shadow: var(--elev-1);
}
.geo-today-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text);
}
.geo-today-row:last-child { border-bottom: none; }
.geo-today-label { color: var(--muted); font-weight: 600; }

/* Verdict pills reused from the admin panel's visual language */
.geo-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.geo-badge.is-in   { background: #e7f6ec; color: #17683a; }
.geo-badge.is-out  { background: #fdecec; color: #8f2222; }
.geo-badge.is-weak { background: #fff6e5; color: #8a5a00; }
.geo-badge.is-off  { background: var(--bg); color: var(--muted); }

@media (max-width: 560px) {
  .geo-checkin-card { padding: 15px; }
  .geo-checkin-icon { width: 44px; height: 44px; font-size: 20px; }
  .geo-checkin-actions { flex-direction: column; }
  .geo-checkin-actions .btn,
  .geo-checkin-actions #geocheck-btn { width: 100%; min-width: 0; justify-content: center; }
  .geo-today-row { font-size: 13px; }
}

/* v1.9.37 — auto "Mark Your Attendance" prompt. Same modal language as the
   rest of the portal; the icon is the single focal element. */
.attn-prompt-icon {
  width: 60px; height: 60px; margin: 4px auto 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--card-att-bg), #ffffff);
  border: 1px solid var(--border);
}
.attn-prompt-text {
  text-align: center; font-size: 14px; line-height: 1.5;
  color: var(--text); margin: 14px 0 4px;
}
.attn-prompt-actions { display: flex; gap: 10px; margin-top: 16px; }
.attn-prompt-actions .btn { flex: 1 1 auto; justify-content: center; }
#attn-prompt-modal .geo-checkin-msg { margin-top: 12px; text-align: left; }
@media (max-width: 560px) {
  .attn-prompt-actions { flex-direction: column-reverse; }
}
