/* ============================================================
   ElimuSaaS — Design System v7
   Blue Brand · Light Default · Mobile-First · Zeraki-inspired
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:          #1565C0;
  --brand-light:    #1976D2;
  --brand-dark:     #0D47A1;
  --brand-subtle:   #E3F2FD;
  --brand-glow:     rgba(21,101,192,0.15);

  /* Semantic colors */
  --green:       #2E7D32; --green-bg:    #E8F5E9;
  --red:         #C62828; --red-bg:      #FFEBEE;
  --amber:       #E65100; --amber-bg:    #FFF3E0;
  --purple:      #6A1B9A; --purple-bg:   #F3E5F5;
  --cyan:        #00695C; --cyan-bg:     #E0F2F1;
  --teal:        #00796B; --teal-bg:     #E0F2F1;

  /* Light theme (default) */
  --bg-base:       #F5F7FA;
  --bg-card:       #FFFFFF;
  --bg-elevated:   #F0F4F8;
  --bg-hover:      #E8EDF2;
  --border:        #DDE3EA;
  --border-subtle: #EEF1F5;
  --text-primary:  #0D1117;
  --text-secondary:#374151;
  --text-muted:    #6B7280;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 56px;
  --bottom-nav-h:  64px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  /* Typography */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition:    0.15s ease;
}

/* Dark mode override */
[data-theme="dark"] {
  --bg-base:       #0A0F1E;
  --bg-card:       #111827;
  --bg-elevated:   #1A2035;
  --bg-hover:      #1E2A40;
  --border:        #2D3748;
  --border-subtle: #1E2A40;
  --text-primary:  #F9FAFB;
  --text-secondary:#CBD5E1;
  --text-muted:    #64748B;
  --brand-subtle:  rgba(21,101,192,0.15);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── SIDEBAR (Desktop only) ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  transition: width var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.brand-name { font-weight: 800; font-size: 16px; color: var(--text-primary); }
.brand-tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-school {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--brand-subtle);
}
.sidebar-school-name { font-weight: 700; font-size: 13px; color: var(--brand); }
.sidebar-school-code { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 1px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--brand-subtle);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--brand); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOP HEADER ────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 50;
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1;
  max-width: 320px;
}
.header-search input {
  border: none; background: none; outline: none;
  font-size: 13px; color: var(--text-primary); width: 100%;
}
.header-search input::placeholder { color: var(--text-muted); }
.search-icon { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 36px; height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.header-btn:hover { background: var(--bg-hover); color: var(--brand); }
.header-btn svg { width: 17px; height: 17px; }

.header-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--transition);
}
.header-user:hover { background: var(--bg-hover); }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.notif-dot {
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  position: absolute;
  top: 6px; right: 6px;
  border: 1.5px solid var(--bg-card);
}

/* ── PAGE AREA ─────────────────────────────────────────────── */
.page-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.page-view {
  display: none;
  padding: 20px;
  min-height: calc(100vh - var(--header-height));
  animation: pageFadeIn 0.18s ease;
}
.page-view.active { display: block; }
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ── BOTTOM NAVIGATION (Mobile) ────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.bottom-nav-items {
  display: flex;
  height: 100%;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
  padding: 4px 0;
  user-select: none;
  position: relative;
}
.bottom-nav-item .bn-icon { font-size: 22px; line-height: 1; }
.bottom-nav-item .bn-label { font-size: 10px; }
.bottom-nav-item.active { color: var(--brand); }
.bottom-nav-item.active .bn-icon { transform: translateY(-2px); }
.bottom-nav-item .bn-badge {
  position: absolute; top: 6px; right: 50%; margin-right: -18px;
  background: var(--red); color: white;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--bg-card);
}

/* More drawer (slides up) */
.more-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  z-index: 300;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.more-drawer.open { transform: translateY(0); }
.more-drawer-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 12px auto;
}
.more-drawer-title {
  padding: 0 20px 12px;
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
}
.more-drawer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 12px 20px;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
  text-align: center;
}
.more-item:hover, .more-item:active { background: var(--bg-hover); }
.more-item-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--brand-subtle);
}
.more-item-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 299;
  display: none;
}
.drawer-overlay.open { display: block; }

/* ── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-header-left { flex: 1; min-width: 0; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── STATS GRID ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--stat-bg, var(--brand-subtle));
  color: var(--stat-color, var(--brand));
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat-change { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── WELCOME CARD ──────────────────────────────────────────── */
.welcome-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  border-radius: var(--radius-xl);
  padding: 24px;
  color: white;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.welcome-card::after {
  content: '';
  position: absolute;
  bottom: -30px; right: 60px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.welcome-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.4);
  overflow: hidden;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: white;
}
.welcome-title { font-size: 20px; font-weight: 700; position: relative; z-index: 1; }
.welcome-sub { font-size: 13px; opacity: 0.85; margin-top: 4px; position: relative; z-index: 1; }
.welcome-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.welcome-stat {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition);
}
.welcome-stat:hover { background: rgba(255,255,255,0.2); }
.welcome-stat-val { font-size: 22px; font-weight: 800; }
.welcome-stat-lbl { font-size: 10px; opacity: 0.8; margin-top: 2px; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 18px; }

/* ── SUBJECT CARD (Zeraki teacher view) ────────────────────── */
.subject-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.subject-card:hover { box-shadow: var(--shadow-md); }
.subject-card-header {
  background: var(--brand);
  padding: 14px 16px;
  color: white;
}
.subject-card-name { font-weight: 700; font-size: 15px; }
.subject-card-class { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.subject-card-exam { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.subject-card-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0;
}
.subject-stat {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.subject-stat:nth-child(even) { border-right: none; }
.subject-stat:nth-child(n+3) { border-bottom: none; }
.subject-stat-val { font-size: 20px; font-weight: 800; color: var(--brand); }
.subject-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.subject-stat-change { font-size: 11px; margin-top: 2px; }
.subject-stat-change.up { color: var(--green); }
.subject-stat-change.down { color: var(--red); }
.subject-card-action {
  width: 100%; padding: 12px;
  background: var(--brand);
  color: white; border: none;
  font-weight: 700; font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.subject-card-action:hover { background: var(--brand-dark); }

/* ── STUDENT ANALYSIS CARD ─────────────────────────────────── */
.analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.analysis-header {
  background: var(--brand);
  padding: 12px 16px;
  color: white;
  display: flex; align-items: center; gap: 8px;
  font-weight: 700;
}
.analysis-student {
  text-align: center;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.analysis-photo {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 3px solid var(--brand-subtle);
  object-fit: cover;
  margin: 0 auto 10px;
  background: var(--brand-subtle);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: var(--brand);
  overflow: hidden;
}
.analysis-name { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.analysis-class { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.analysis-actions {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
}
.analysis-action-btn {
  flex: 1; padding: 10px;
  background: none; border: none;
  color: var(--brand); font-size: 13px; font-weight: 600;
  cursor: pointer;
  border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--transition);
}
.analysis-action-btn:last-child { border-right: none; }
.analysis-action-btn:hover { background: var(--brand-subtle); }
.analysis-metrics {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0;
}
.analysis-metric {
  padding: 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.analysis-metric:nth-child(even) { border-right: none; }
.analysis-metric:nth-child(n+5) { border-bottom: none; }
.analysis-metric-val { font-size: 28px; font-weight: 800; color: var(--brand); }
.analysis-metric-val.green { color: var(--green); }
.analysis-metric-val.red { color: var(--red); }
.analysis-metric-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.analysis-metric-change { font-size: 11px; margin-top: 4px; font-weight: 600; }
.change-up { color: var(--green); }
.change-down { color: var(--red); }

/* ── GRADE BREAKDOWN TABLE ─────────────────────────────────── */
.grade-breakdown { overflow-x: auto; }
.grade-breakdown table { font-size: 12px; min-width: 500px; }
.grade-breakdown th { background: var(--brand); color: white; text-align: center; padding: 8px; }
.grade-breakdown td { text-align: center; padding: 8px; border-bottom: 1px solid var(--border-subtle); }
.grade-breakdown tr:hover td { background: var(--bg-hover); }

/* ── TABLES ────────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-elevated);
}
.table-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1; min-width: 200px;
}
.table-search input { border: none; background: none; outline: none; font-size: 13px; color: var(--text-primary); width: 100%; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-elevated);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 10px 14px;
  text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 14px; font-size: 13px; color: var(--text-primary); }
.table-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elevated); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); box-shadow: 0 4px 12px var(--brand-glow); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: white; }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.btn-success:hover:not(:disabled) { background: var(--green); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }
.btn-xl { padding: 15px 28px; font-size: 16px; border-radius: 12px; }
.w-full { width: 100%; }
.btn.loading::after {
  content: '';
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px; color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-card);
}
select { appearance: none; cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.badge-blue    { background: var(--brand-subtle); color: var(--brand); }
.badge-green   { background: var(--green-bg); color: var(--green); }
.badge-red     { background: var(--red-bg); color: var(--red); }
.badge-amber   { background: var(--amber-bg); color: var(--amber); }
.badge-purple  { background: var(--purple-bg); color: var(--purple); }
.badge-cyan    { background: var(--cyan-bg); color: var(--cyan); }
.badge-gray    { background: var(--bg-elevated); color: var(--text-muted); }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 18px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

/* ── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px; border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red-bg); color: var(--red); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--bg-card);
}

/* ── TOAST ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 8px);
  left: 50%; transform: translateX(-50%);
  z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.toast-success { border-left: 4px solid var(--green); }
.toast-error   { border-left: 4px solid var(--red); }
.toast-info    { border-left: 4px solid var(--brand); }
.toast-warning { border-left: 4px solid var(--amber); }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.alert-info    { background: var(--brand-subtle); color: var(--brand); border: 1px solid var(--brand); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }

/* ── GRID LAYOUTS ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── LOADING / SKELETON ────────────────────────────────────── */
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full { width: 100%; }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-desc { font-size: 13px; margin-bottom: 20px; }

/* ── ERROR STATE ───────────────────────────────────────────── */
.error-state { text-align: center; padding: 40px 20px; }
.error-icon { font-size: 48px; margin-bottom: 12px; }

/* ── AVATAR ────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* ── PROGRESS ──────────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: 99px; transition: width 0.5s ease; }

/* ── OFFLINE BANNER ────────────────────────────────────────── */
#offline-banner {
  display: none; position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--amber); color: #000;
  text-align: center; padding: 8px 16px;
  font-size: 13px; font-weight: 600;
  z-index: 9999;
}
body.offline #offline-banner { display: block; }
body.offline .app-shell, body.offline #page-login { padding-top: 36px; }

/* ── LOGIN PAGE ────────────────────────────────────────────── */
#page-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EBF4FF 0%, #F0F7FF 50%, #E8F0FE 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(21,101,192,0.12);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  padding: 32px 24px;
  text-align: center;
  color: white;
}
.login-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.2);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 28px; color: white;
  margin: 0 auto 12px;
  border: 2px solid rgba(255,255,255,0.3);
}
.login-app-name { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; }
.login-tagline { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.login-body { padding: 28px 24px; }
.login-welcome { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* ── CALENDAR ──────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day-header { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 6px 0; }
.calendar-day {
  min-height: 60px; padding: 4px;
  border-radius: 6px; cursor: pointer;
  transition: background var(--transition);
  font-size: 12px;
}
.calendar-day:hover { background: var(--bg-hover); }
.calendar-day.today { background: var(--brand-subtle); font-weight: 700; color: var(--brand); }
.calendar-day.other-month { opacity: 0.4; }
.calendar-event {
  background: var(--brand); color: white;
  border-radius: 3px; padding: 2px 4px;
  font-size: 10px; margin-top: 2px; truncate;
}

/* ── MISC ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.font-mono { font-family: var(--font-mono); }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  .sidebar { display: flex !important; }
  .page-view { padding: 24px; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .page-area { padding-bottom: var(--bottom-nav-h); }
  .page-view { padding: 16px; min-height: calc(100vh - var(--header-height) - var(--bottom-nav-h)); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .welcome-stats-row { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; gap: 10px; }
  .page-header-actions { width: 100%; flex-wrap: wrap; }
  .page-header-actions .btn { flex: 1; min-width: 100px; }
  .header-search { display: none; }
  .modal { max-width: 100%; max-height: 95vh; border-radius: 20px 20px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .form-row { grid-template-columns: 1fr; }
  .more-drawer-grid { grid-template-columns: repeat(3, 1fr); }
  .top-header { padding: 0 14px; }
  .toast-container { bottom: calc(var(--bottom-nav-h) + 10px); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .page-title { font-size: 18px; }
  .more-drawer-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media print {
  .sidebar, .top-header, .bottom-nav, .page-header-actions { display: none !important; }
  .page-view { padding: 0; }
}

/* Landing page — full width, no inner padding */
#page-landing.page-view {
  padding: 0 !important;
  min-height: 100vh !important;
  background: #F8FAFF !important;
}
#page-landing.page-view.active {
  display: block !important;
}
/* Login page — flex layout override */
#page-login.page-view {
  padding: 0 !important;
  display: none;
  min-height: 100vh;
}
#page-login.page-view.active {
  display: flex !important;
  align-items: stretch;
}
/* ============================================================
   ElimuSaaS — Design System v7
   Blue Brand · Light Default · Mobile-First · Zeraki-inspired
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:          #1565C0;
  --brand-light:    #1976D2;
  --brand-dark:     #0D47A1;
  --brand-subtle:   #E3F2FD;
  --brand-glow:     rgba(21,101,192,0.15);

  /* Semantic colors */
  --green:       #2E7D32; --green-bg:    #E8F5E9;
  --red:         #C62828; --red-bg:      #FFEBEE;
  --amber:       #E65100; --amber-bg:    #FFF3E0;
  --purple:      #6A1B9A; --purple-bg:   #F3E5F5;
  --cyan:        #00695C; --cyan-bg:     #E0F2F1;
  --teal:        #00796B; --teal-bg:     #E0F2F1;

  /* Light theme (default) */
  --bg-base:       #F5F7FA;
  --bg-card:       #FFFFFF;
  --bg-elevated:   #F0F4F8;
  --bg-hover:      #E8EDF2;
  --border:        #DDE3EA;
  --border-subtle: #EEF1F5;
  --text-primary:  #0D1117;
  --text-secondary:#374151;
  --text-muted:    #6B7280;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 56px;
  --bottom-nav-h:  64px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  /* Typography */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition:    0.15s ease;
}

/* Dark mode override */
[data-theme="dark"] {
  --bg-base:       #0A0F1E;
  --bg-card:       #111827;
  --bg-elevated:   #1A2035;
  --bg-hover:      #1E2A40;
  --border:        #2D3748;
  --border-subtle: #1E2A40;
  --text-primary:  #F9FAFB;
  --text-secondary:#CBD5E1;
  --text-muted:    #64748B;
  --brand-subtle:  rgba(21,101,192,0.15);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── SIDEBAR (Desktop only) ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  transition: width var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.brand-name { font-weight: 800; font-size: 16px; color: var(--text-primary); }
.brand-tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-school {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--brand-subtle);
}
.sidebar-school-name { font-weight: 700; font-size: 13px; color: var(--brand); }
.sidebar-school-code { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 1px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--brand-subtle);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--brand); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOP HEADER ────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 50;
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1;
  max-width: 320px;
}
.header-search input {
  border: none; background: none; outline: none;
  font-size: 13px; color: var(--text-primary); width: 100%;
}
.header-search input::placeholder { color: var(--text-muted); }
.search-icon { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 36px; height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.header-btn:hover { background: var(--bg-hover); color: var(--brand); }
.header-btn svg { width: 17px; height: 17px; }

.header-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--transition);
}
.header-user:hover { background: var(--bg-hover); }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.notif-dot {
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  position: absolute;
  top: 6px; right: 6px;
  border: 1.5px solid var(--bg-card);
}

/* ── PAGE AREA ─────────────────────────────────────────────── */
.page-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.page-view {
  display: none;
  padding: 20px;
  min-height: calc(100vh - var(--header-height));
  animation: pageFadeIn 0.18s ease;
}
.page-view.active { display: block; }
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ── BOTTOM NAVIGATION (Mobile) ────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.bottom-nav-items {
  display: flex;
  height: 100%;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
  padding: 4px 0;
  user-select: none;
  position: relative;
}
.bottom-nav-item .bn-icon { font-size: 22px; line-height: 1; }
.bottom-nav-item .bn-label { font-size: 10px; }
.bottom-nav-item.active { color: var(--brand); }
.bottom-nav-item.active .bn-icon { transform: translateY(-2px); }
.bottom-nav-item .bn-badge {
  position: absolute; top: 6px; right: 50%; margin-right: -18px;
  background: var(--red); color: white;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--bg-card);
}

/* More drawer (slides up) */
.more-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  z-index: 300;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.more-drawer.open { transform: translateY(0); }
.more-drawer-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 12px auto;
}
.more-drawer-title {
  padding: 0 20px 12px;
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
}
.more-drawer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 12px 20px;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
  text-align: center;
}
.more-item:hover, .more-item:active { background: var(--bg-hover); }
.more-item-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--brand-subtle);
}
.more-item-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 299;
  display: none;
}
.drawer-overlay.open { display: block; }

/* ── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-header-left { flex: 1; min-width: 0; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── STATS GRID ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--stat-bg, var(--brand-subtle));
  color: var(--stat-color, var(--brand));
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat-change { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── WELCOME CARD ──────────────────────────────────────────── */
.welcome-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  border-radius: var(--radius-xl);
  padding: 24px;
  color: white;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.welcome-card::after {
  content: '';
  position: absolute;
  bottom: -30px; right: 60px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.welcome-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.4);
  overflow: hidden;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: white;
}
.welcome-title { font-size: 20px; font-weight: 700; position: relative; z-index: 1; }
.welcome-sub { font-size: 13px; opacity: 0.85; margin-top: 4px; position: relative; z-index: 1; }
.welcome-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.welcome-stat {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition);
}
.welcome-stat:hover { background: rgba(255,255,255,0.2); }
.welcome-stat-val { font-size: 22px; font-weight: 800; }
.welcome-stat-lbl { font-size: 10px; opacity: 0.8; margin-top: 2px; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 18px; }

/* ── SUBJECT CARD (Zeraki teacher view) ────────────────────── */
.subject-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.subject-card:hover { box-shadow: var(--shadow-md); }
.subject-card-header {
  background: var(--brand);
  padding: 14px 16px;
  color: white;
}
.subject-card-name { font-weight: 700; font-size: 15px; }
.subject-card-class { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.subject-card-exam { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.subject-card-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0;
}
.subject-stat {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.subject-stat:nth-child(even) { border-right: none; }
.subject-stat:nth-child(n+3) { border-bottom: none; }
.subject-stat-val { font-size: 20px; font-weight: 800; color: var(--brand); }
.subject-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.subject-stat-change { font-size: 11px; margin-top: 2px; }
.subject-stat-change.up { color: var(--green); }
.subject-stat-change.down { color: var(--red); }
.subject-card-action {
  width: 100%; padding: 12px;
  background: var(--brand);
  color: white; border: none;
  font-weight: 700; font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.subject-card-action:hover { background: var(--brand-dark); }

/* ── STUDENT ANALYSIS CARD ─────────────────────────────────── */
.analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.analysis-header {
  background: var(--brand);
  padding: 12px 16px;
  color: white;
  display: flex; align-items: center; gap: 8px;
  font-weight: 700;
}
.analysis-student {
  text-align: center;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.analysis-photo {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 3px solid var(--brand-subtle);
  object-fit: cover;
  margin: 0 auto 10px;
  background: var(--brand-subtle);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: var(--brand);
  overflow: hidden;
}
.analysis-name { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.analysis-class { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.analysis-actions {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
}
.analysis-action-btn {
  flex: 1; padding: 10px;
  background: none; border: none;
  color: var(--brand); font-size: 13px; font-weight: 600;
  cursor: pointer;
  border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--transition);
}
.analysis-action-btn:last-child { border-right: none; }
.analysis-action-btn:hover { background: var(--brand-subtle); }
.analysis-metrics {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0;
}
.analysis-metric {
  padding: 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.analysis-metric:nth-child(even) { border-right: none; }
.analysis-metric:nth-child(n+5) { border-bottom: none; }
.analysis-metric-val { font-size: 28px; font-weight: 800; color: var(--brand); }
.analysis-metric-val.green { color: var(--green); }
.analysis-metric-val.red { color: var(--red); }
.analysis-metric-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.analysis-metric-change { font-size: 11px; margin-top: 4px; font-weight: 600; }
.change-up { color: var(--green); }
.change-down { color: var(--red); }

/* ── GRADE BREAKDOWN TABLE ─────────────────────────────────── */
.grade-breakdown { overflow-x: auto; }
.grade-breakdown table { font-size: 12px; min-width: 500px; }
.grade-breakdown th { background: var(--brand); color: white; text-align: center; padding: 8px; }
.grade-breakdown td { text-align: center; padding: 8px; border-bottom: 1px solid var(--border-subtle); }
.grade-breakdown tr:hover td { background: var(--bg-hover); }

/* ── TABLES ────────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-elevated);
}
.table-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1; min-width: 200px;
}
.table-search input { border: none; background: none; outline: none; font-size: 13px; color: var(--text-primary); width: 100%; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-elevated);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 10px 14px;
  text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 14px; font-size: 13px; color: var(--text-primary); }
.table-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elevated); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); box-shadow: 0 4px 12px var(--brand-glow); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: white; }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.btn-success:hover:not(:disabled) { background: var(--green); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }
.btn-xl { padding: 15px 28px; font-size: 16px; border-radius: 12px; }
.w-full { width: 100%; }
.btn.loading::after {
  content: '';
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px; color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-card);
}
select { appearance: none; cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.badge-blue    { background: var(--brand-subtle); color: var(--brand); }
.badge-green   { background: var(--green-bg); color: var(--green); }
.badge-red     { background: var(--red-bg); color: var(--red); }
.badge-amber   { background: var(--amber-bg); color: var(--amber); }
.badge-purple  { background: var(--purple-bg); color: var(--purple); }
.badge-cyan    { background: var(--cyan-bg); color: var(--cyan); }
.badge-gray    { background: var(--bg-elevated); color: var(--text-muted); }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 18px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

/* ── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px; border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red-bg); color: var(--red); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--bg-card);
}

/* ── TOAST ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 8px);
  left: 50%; transform: translateX(-50%);
  z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.toast-success { border-left: 4px solid var(--green); }
.toast-error   { border-left: 4px solid var(--red); }
.toast-info    { border-left: 4px solid var(--brand); }
.toast-warning { border-left: 4px solid var(--amber); }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.alert-info    { background: var(--brand-subtle); color: var(--brand); border: 1px solid var(--brand); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }

/* ── GRID LAYOUTS ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── LOADING / SKELETON ────────────────────────────────────── */
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full { width: 100%; }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-desc { font-size: 13px; margin-bottom: 20px; }

/* ── ERROR STATE ───────────────────────────────────────────── */
.error-state { text-align: center; padding: 40px 20px; }
.error-icon { font-size: 48px; margin-bottom: 12px; }

/* ── AVATAR ────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* ── PROGRESS ──────────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: 99px; transition: width 0.5s ease; }

/* ── OFFLINE BANNER ────────────────────────────────────────── */
#offline-banner {
  display: none; position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--amber); color: #000;
  text-align: center; padding: 8px 16px;
  font-size: 13px; font-weight: 600;
  z-index: 9999;
}
body.offline #offline-banner { display: block; }
body.offline .app-shell, body.offline #page-login { padding-top: 36px; }

/* ── LOGIN PAGE ────────────────────────────────────────────── */
#page-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EBF4FF 0%, #F0F7FF 50%, #E8F0FE 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(21,101,192,0.12);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  padding: 32px 24px;
  text-align: center;
  color: white;
}
.login-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.2);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 28px; color: white;
  margin: 0 auto 12px;
  border: 2px solid rgba(255,255,255,0.3);
}
.login-app-name { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; }
.login-tagline { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.login-body { padding: 28px 24px; }
.login-welcome { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* ── CALENDAR ──────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day-header { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 6px 0; }
.calendar-day {
  min-height: 60px; padding: 4px;
  border-radius: 6px; cursor: pointer;
  transition: background var(--transition);
  font-size: 12px;
}
.calendar-day:hover { background: var(--bg-hover); }
.calendar-day.today { background: var(--brand-subtle); font-weight: 700; color: var(--brand); }
.calendar-day.other-month { opacity: 0.4; }
.calendar-event {
  background: var(--brand); color: white;
  border-radius: 3px; padding: 2px 4px;
  font-size: 10px; margin-top: 2px; truncate;
}

/* ── MISC ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.font-mono { font-family: var(--font-mono); }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  .sidebar { display: flex !important; }
  .page-view { padding: 24px; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .page-area { padding-bottom: var(--bottom-nav-h); }
  .page-view { padding: 16px; min-height: calc(100vh - var(--header-height) - var(--bottom-nav-h)); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .welcome-stats-row { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; gap: 10px; }
  .page-header-actions { width: 100%; flex-wrap: wrap; }
  .page-header-actions .btn { flex: 1; min-width: 100px; }
  .header-search { display: none; }
  .modal { max-width: 100%; max-height: 95vh; border-radius: 20px 20px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .form-row { grid-template-columns: 1fr; }
  .more-drawer-grid { grid-template-columns: repeat(3, 1fr); }
  .top-header { padding: 0 14px; }
  .toast-container { bottom: calc(var(--bottom-nav-h) + 10px); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .page-title { font-size: 18px; }
  .more-drawer-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media print {
  .sidebar, .top-header, .bottom-nav, .page-header-actions { display: none !important; }
  .page-view { padding: 0; }
}

/* Landing page — full width, no inner padding */
#page-landing.page-view {
  padding: 0 !important;
  min-height: 100vh !important;
  background: #F8FAFF !important;
}
#page-landing.page-view.active {
  display: block !important;
}
/* Login page — flex layout override */
#page-login.page-view {
  padding: 0 !important;
  display: none;
  min-height: 100vh;
}
#page-login.page-view.active {
  display: flex !important;
  align-items: stretch;
}

/* ── Multipage shell view switching ──────────────────────────── */
body[data-view="app"]     #page-landing,
body[data-view="app"]     #page-login     { display: none !important; }
body[data-view="app"]     .app-shell      { display: flex !important; }

body[data-view="landing"] .app-shell      { display: none !important; }
body[data-view="landing"] #page-landing   { display: flex !important; flex-direction: column; }
body[data-view="landing"] #page-login     { display: none !important; }

body[data-view="login"]   .app-shell      { display: none !important; }
body[data-view="login"]   #page-login     { display: flex !important; }
body[data-view="login"]   #page-landing   { display: none !important; }

/* Default: show landing */
.app-shell    { display: none; }
#page-landing { display: none; }
#page-login   { display: none; }

/* More drawer item */
.more-item {
  display:flex; flex-direction:column; align-items:center;
  gap:6px; cursor:pointer; padding:12px 4px; border-radius:10px;
  transition:background 0.15s;
}
.more-item:hover { background: var(--bg-elevated); }
.more-item-icon {
  width:44px; height:44px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-size:22px;
}
.more-item-label {
  font-size:10px; font-weight:600; color:var(--text-secondary);
  text-align:center; line-height:1.3;
}
/* ============================================================
   ElimuSaaS — Design System v7
   Blue Brand · Light Default · Mobile-First · Zeraki-inspired
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:          #1565C0;
  --brand-light:    #1976D2;
  --brand-dark:     #0D47A1;
  --brand-subtle:   #E3F2FD;
  --brand-glow:     rgba(21,101,192,0.15);

  /* Semantic colors */
  --green:       #2E7D32; --green-bg:    #E8F5E9;
  --red:         #C62828; --red-bg:      #FFEBEE;
  --amber:       #E65100; --amber-bg:    #FFF3E0;
  --purple:      #6A1B9A; --purple-bg:   #F3E5F5;
  --cyan:        #00695C; --cyan-bg:     #E0F2F1;
  --teal:        #00796B; --teal-bg:     #E0F2F1;

  /* Light theme (default) */
  --bg-base:       #F5F7FA;
  --bg-card:       #FFFFFF;
  --bg-elevated:   #F0F4F8;
  --bg-hover:      #E8EDF2;
  --border:        #DDE3EA;
  --border-subtle: #EEF1F5;
  --text-primary:  #0D1117;
  --text-secondary:#374151;
  --text-muted:    #6B7280;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 56px;
  --bottom-nav-h:  64px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  /* Typography */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition:    0.15s ease;
}

/* Dark mode override */
[data-theme="dark"] {
  --bg-base:       #0A0F1E;
  --bg-card:       #111827;
  --bg-elevated:   #1A2035;
  --bg-hover:      #1E2A40;
  --border:        #2D3748;
  --border-subtle: #1E2A40;
  --text-primary:  #F9FAFB;
  --text-secondary:#CBD5E1;
  --text-muted:    #64748B;
  --brand-subtle:  rgba(21,101,192,0.15);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── SIDEBAR (Desktop only) ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  transition: width var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.brand-name { font-weight: 800; font-size: 16px; color: var(--text-primary); }
.brand-tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-school {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--brand-subtle);
}
.sidebar-school-name { font-weight: 700; font-size: 13px; color: var(--brand); }
.sidebar-school-code { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 1px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--brand-subtle);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--brand); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOP HEADER ────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 50;
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1;
  max-width: 320px;
}
.header-search input {
  border: none; background: none; outline: none;
  font-size: 13px; color: var(--text-primary); width: 100%;
}
.header-search input::placeholder { color: var(--text-muted); }
.search-icon { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 36px; height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.header-btn:hover { background: var(--bg-hover); color: var(--brand); }
.header-btn svg { width: 17px; height: 17px; }

.header-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--transition);
}
.header-user:hover { background: var(--bg-hover); }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.notif-dot {
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  position: absolute;
  top: 6px; right: 6px;
  border: 1.5px solid var(--bg-card);
}

/* ── PAGE AREA ─────────────────────────────────────────────── */
.page-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.page-view {
  display: none;
  padding: 20px;
  min-height: calc(100vh - var(--header-height));
  animation: pageFadeIn 0.18s ease;
}
.page-view.active { display: block; }
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ── BOTTOM NAVIGATION (Mobile) ────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.bottom-nav-items {
  display: flex;
  height: 100%;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
  padding: 4px 0;
  user-select: none;
  position: relative;
}
.bottom-nav-item .bn-icon { font-size: 22px; line-height: 1; }
.bottom-nav-item .bn-label { font-size: 10px; }
.bottom-nav-item.active { color: var(--brand); }
.bottom-nav-item.active .bn-icon { transform: translateY(-2px); }
.bottom-nav-item .bn-badge {
  position: absolute; top: 6px; right: 50%; margin-right: -18px;
  background: var(--red); color: white;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--bg-card);
}

/* More drawer (slides up) */
.more-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  z-index: 300;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.more-drawer.open { transform: translateY(0); }
.more-drawer-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 12px auto;
}
.more-drawer-title {
  padding: 0 20px 12px;
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
}
.more-drawer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 12px 20px;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
  text-align: center;
}
.more-item:hover, .more-item:active { background: var(--bg-hover); }
.more-item-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--brand-subtle);
}
.more-item-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 299;
  display: none;
}
.drawer-overlay.open { display: block; }

/* ── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-header-left { flex: 1; min-width: 0; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── STATS GRID ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--stat-bg, var(--brand-subtle));
  color: var(--stat-color, var(--brand));
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat-change { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── WELCOME CARD ──────────────────────────────────────────── */
.welcome-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  border-radius: var(--radius-xl);
  padding: 24px;
  color: white;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.welcome-card::after {
  content: '';
  position: absolute;
  bottom: -30px; right: 60px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.welcome-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.4);
  overflow: hidden;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: white;
}
.welcome-title { font-size: 20px; font-weight: 700; position: relative; z-index: 1; }
.welcome-sub { font-size: 13px; opacity: 0.85; margin-top: 4px; position: relative; z-index: 1; }
.welcome-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.welcome-stat {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition);
}
.welcome-stat:hover { background: rgba(255,255,255,0.2); }
.welcome-stat-val { font-size: 22px; font-weight: 800; }
.welcome-stat-lbl { font-size: 10px; opacity: 0.8; margin-top: 2px; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 18px; }

/* ── SUBJECT CARD (Zeraki teacher view) ────────────────────── */
.subject-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.subject-card:hover { box-shadow: var(--shadow-md); }
.subject-card-header {
  background: var(--brand);
  padding: 14px 16px;
  color: white;
}
.subject-card-name { font-weight: 700; font-size: 15px; }
.subject-card-class { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.subject-card-exam { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.subject-card-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0;
}
.subject-stat {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.subject-stat:nth-child(even) { border-right: none; }
.subject-stat:nth-child(n+3) { border-bottom: none; }
.subject-stat-val { font-size: 20px; font-weight: 800; color: var(--brand); }
.subject-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.subject-stat-change { font-size: 11px; margin-top: 2px; }
.subject-stat-change.up { color: var(--green); }
.subject-stat-change.down { color: var(--red); }
.subject-card-action {
  width: 100%; padding: 12px;
  background: var(--brand);
  color: white; border: none;
  font-weight: 700; font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.subject-card-action:hover { background: var(--brand-dark); }

/* ── STUDENT ANALYSIS CARD ─────────────────────────────────── */
.analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.analysis-header {
  background: var(--brand);
  padding: 12px 16px;
  color: white;
  display: flex; align-items: center; gap: 8px;
  font-weight: 700;
}
.analysis-student {
  text-align: center;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.analysis-photo {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 3px solid var(--brand-subtle);
  object-fit: cover;
  margin: 0 auto 10px;
  background: var(--brand-subtle);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: var(--brand);
  overflow: hidden;
}
.analysis-name { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.analysis-class { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.analysis-actions {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
}
.analysis-action-btn {
  flex: 1; padding: 10px;
  background: none; border: none;
  color: var(--brand); font-size: 13px; font-weight: 600;
  cursor: pointer;
  border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--transition);
}
.analysis-action-btn:last-child { border-right: none; }
.analysis-action-btn:hover { background: var(--brand-subtle); }
.analysis-metrics {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0;
}
.analysis-metric {
  padding: 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.analysis-metric:nth-child(even) { border-right: none; }
.analysis-metric:nth-child(n+5) { border-bottom: none; }
.analysis-metric-val { font-size: 28px; font-weight: 800; color: var(--brand); }
.analysis-metric-val.green { color: var(--green); }
.analysis-metric-val.red { color: var(--red); }
.analysis-metric-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.analysis-metric-change { font-size: 11px; margin-top: 4px; font-weight: 600; }
.change-up { color: var(--green); }
.change-down { color: var(--red); }

/* ── GRADE BREAKDOWN TABLE ─────────────────────────────────── */
.grade-breakdown { overflow-x: auto; }
.grade-breakdown table { font-size: 12px; min-width: 500px; }
.grade-breakdown th { background: var(--brand); color: white; text-align: center; padding: 8px; }
.grade-breakdown td { text-align: center; padding: 8px; border-bottom: 1px solid var(--border-subtle); }
.grade-breakdown tr:hover td { background: var(--bg-hover); }

/* ── TABLES ────────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-elevated);
}
.table-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1; min-width: 200px;
}
.table-search input { border: none; background: none; outline: none; font-size: 13px; color: var(--text-primary); width: 100%; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-elevated);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 10px 14px;
  text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 14px; font-size: 13px; color: var(--text-primary); }
.table-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elevated); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); box-shadow: 0 4px 12px var(--brand-glow); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: white; }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.btn-success:hover:not(:disabled) { background: var(--green); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }
.btn-xl { padding: 15px 28px; font-size: 16px; border-radius: 12px; }
.w-full { width: 100%; }
.btn.loading::after {
  content: '';
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px; color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-card);
}
select { appearance: none; cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.badge-blue    { background: var(--brand-subtle); color: var(--brand); }
.badge-green   { background: var(--green-bg); color: var(--green); }
.badge-red     { background: var(--red-bg); color: var(--red); }
.badge-amber   { background: var(--amber-bg); color: var(--amber); }
.badge-purple  { background: var(--purple-bg); color: var(--purple); }
.badge-cyan    { background: var(--cyan-bg); color: var(--cyan); }
.badge-gray    { background: var(--bg-elevated); color: var(--text-muted); }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 18px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

/* ── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px; border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red-bg); color: var(--red); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--bg-card);
}

/* ── TOAST ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 8px);
  left: 50%; transform: translateX(-50%);
  z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.toast-success { border-left: 4px solid var(--green); }
.toast-error   { border-left: 4px solid var(--red); }
.toast-info    { border-left: 4px solid var(--brand); }
.toast-warning { border-left: 4px solid var(--amber); }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.alert-info    { background: var(--brand-subtle); color: var(--brand); border: 1px solid var(--brand); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }

/* ── GRID LAYOUTS ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── LOADING / SKELETON ────────────────────────────────────── */
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full { width: 100%; }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-desc { font-size: 13px; margin-bottom: 20px; }

/* ── ERROR STATE ───────────────────────────────────────────── */
.error-state { text-align: center; padding: 40px 20px; }
.error-icon { font-size: 48px; margin-bottom: 12px; }

/* ── AVATAR ────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* ── PROGRESS ──────────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: 99px; transition: width 0.5s ease; }

/* ── OFFLINE BANNER ────────────────────────────────────────── */
#offline-banner {
  display: none; position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--amber); color: #000;
  text-align: center; padding: 8px 16px;
  font-size: 13px; font-weight: 600;
  z-index: 9999;
}
body.offline #offline-banner { display: block; }
body.offline .app-shell, body.offline #page-login { padding-top: 36px; }

/* ── LOGIN PAGE ────────────────────────────────────────────── */
#page-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EBF4FF 0%, #F0F7FF 50%, #E8F0FE 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(21,101,192,0.12);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  padding: 32px 24px;
  text-align: center;
  color: white;
}
.login-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.2);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 28px; color: white;
  margin: 0 auto 12px;
  border: 2px solid rgba(255,255,255,0.3);
}
.login-app-name { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; }
.login-tagline { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.login-body { padding: 28px 24px; }
.login-welcome { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* ── CALENDAR ──────────────────────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day-header { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 6px 0; }
.calendar-day {
  min-height: 60px; padding: 4px;
  border-radius: 6px; cursor: pointer;
  transition: background var(--transition);
  font-size: 12px;
}
.calendar-day:hover { background: var(--bg-hover); }
.calendar-day.today { background: var(--brand-subtle); font-weight: 700; color: var(--brand); }
.calendar-day.other-month { opacity: 0.4; }
.calendar-event {
  background: var(--brand); color: white;
  border-radius: 3px; padding: 2px 4px;
  font-size: 10px; margin-top: 2px; truncate;
}

/* ── MISC ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.font-mono { font-family: var(--font-mono); }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  .sidebar { display: flex !important; }
  .page-view { padding: 24px; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .page-area { padding-bottom: var(--bottom-nav-h); }
  .page-view { padding: 16px; min-height: calc(100vh - var(--header-height) - var(--bottom-nav-h)); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .welcome-stats-row { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; gap: 10px; }
  .page-header-actions { width: 100%; flex-wrap: wrap; }
  .page-header-actions .btn { flex: 1; min-width: 100px; }
  .header-search { display: none; }
  .modal { max-width: 100%; max-height: 95vh; border-radius: 20px 20px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .form-row { grid-template-columns: 1fr; }
  .more-drawer-grid { grid-template-columns: repeat(3, 1fr); }
  .top-header { padding: 0 14px; }
  .toast-container { bottom: calc(var(--bottom-nav-h) + 10px); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .page-title { font-size: 18px; }
  .more-drawer-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media print {
  .sidebar, .top-header, .bottom-nav, .page-header-actions { display: none !important; }
  .page-view { padding: 0; }
}

/* Landing page — full width, no inner padding */
#page-landing.page-view {
  padding: 0 !important;
  min-height: 100vh !important;
  background: #F8FAFF !important;
}
#page-landing.page-view.active {
  display: block !important;
}
/* Login page — flex layout override */
#page-login.page-view {
  padding: 0 !important;
  display: none;
  min-height: 100vh;
}
#page-login.page-view.active {
  display: flex !important;
  align-items: stretch;
}

/* ── Multipage shell view switching ──────────────────────────── */
body[data-view="app"]     #page-landing,
body[data-view="app"]     #page-login     { display: none !important; }
body[data-view="app"]     .app-shell      { display: flex !important; }

body[data-view="landing"] .app-shell      { display: none !important; }
body[data-view="landing"] #page-landing   { display: flex !important; flex-direction: column; }
body[data-view="landing"] #page-login     { display: none !important; }

body[data-view="login"]   .app-shell      { display: none !important; }
body[data-view="login"]   #page-login     { display: flex !important; }
body[data-view="login"]   #page-landing   { display: none !important; }

/* Default: show landing */
.app-shell    { display: none; }
#page-landing { display: none; }
#page-login   { display: none; }

/* More drawer item */
.more-item {
  display:flex; flex-direction:column; align-items:center;
  gap:6px; cursor:pointer; padding:12px 4px; border-radius:10px;
  transition:background 0.15s;
}
.more-item:hover { background: var(--bg-elevated); }
.more-item-icon {
  width:44px; height:44px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-size:22px;
}
.more-item-label {
  font-size:10px; font-weight:600; color:var(--text-secondary);
  text-align:center; line-height:1.3;
}
