/* ============================================================
   ELITE CENTER — DESIGN SYSTEM
   Hybrid: Linear (dark canvas) + Notion (color cards) + Stripe (finance)
   ============================================================ */

/* --- Google Fonts Import Fallback --- */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   THEMES — switch via data-theme on <html>
   Available: dark (default) | light | midnight | forest | sunset
   ============================================================ */

/* 🌑 Modern Obsidian & Indigo (Dark Mode) */
[data-theme="dark"],
:root {
  --canvas:        #090a10;
  --surface-1:     #12141d;
  --surface-2:     #191c28;
  --surface-3:     #222636;
  --surface-4:     #2d324b;
  --surface-glass: rgba(18, 20, 29, 0.85);
  --hairline:      rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.15);
  --hairline-accent: rgba(99, 102, 241, 0.35);
  --primary:       #6366f1;
  --primary-hover: #818cf8;
  --primary-glow:  rgba(99, 102, 241, 0.35);
  --primary-soft:  rgba(99, 102, 241, 0.16);
  --secondary:     #a855f7;
  --secondary-soft: rgba(168, 85, 247, 0.16);
  --ink:           #f8fafc;
  --ink-muted:     #cbd5e1;
  --ink-subtle:    #94a3b8;
  --ink-tertiary:  #64748b;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #f43f5e;
  --info:          #3b82f6;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.5);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:     0 12px 32px rgba(0,0,0,0.5);
  --shadow-glow:   0 0 24px rgba(99, 102, 241, 0.25);
  --shadow-card:   0 4px 20px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ☀️ Apple Studio / Clean Minimal (Light Mode) */
[data-theme="light"] {
  --is-light: 1;
  --canvas:        #f5f7fa;
  --surface-1:     #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #f1f5f9;
  --surface-4:     #e2e8f0;
  --surface-glass: rgba(255, 255, 255, 0.95);
  --hairline:      #e2e8f0;
  --hairline-strong: #cbd5e1;
  --hairline-accent: rgba(79, 70, 229, 0.2);
  --primary:       #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow:  rgba(79, 70, 229, 0.2);
  --primary-soft:  rgba(79, 70, 229, 0.08);
  --secondary:     #7c3aed;
  --secondary-soft: rgba(124, 58, 237, 0.08);
  --ink:           #0f172a;
  --ink-muted:     #334155;
  --ink-subtle:    #64748b;
  --ink-tertiary:  #94a3b8;
  --success:       #059669;
  --warning:       #d97706;
  --danger:        #e11d48;
  --info:          #0284c7;
  --shadow-sm:     0 1px 3px rgba(15,23,42,0.04);
  --shadow-md:     0 4px 12px rgba(15,23,42,0.05);
  --shadow-lg:     0 12px 28px -4px rgba(15,23,42,0.08);
  --shadow-glow:   0 0 20px rgba(79, 70, 229, 0.12);
  --shadow-card:   0 2px 10px rgba(15,23,42,0.04), inset 0 1px 0 #ffffff;
}

/* ── THEME TRANSITION — smooth switching ── */
body,
body * {
  transition:
    background-color 300ms ease,
    border-color     200ms ease,
    color            200ms ease;
}

/* Disable transition on theme switch to avoid flicker on load */
body.no-transition,
body.no-transition * {
  transition: none !important;
}

/* ============================================================
   THEME SWITCHER UI
   ============================================================ */
.theme-switcher-panel {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-3);
  pointer-events: none; /* Let clicks pass through the transparent flex box */
}

.theme-toggle-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--hairline);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 22px;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-fast);
  pointer-events: auto; /* Re-enable clicks for the button */
}
.theme-toggle-btn:hover {
  border-color: var(--primary);
  transform: scale(1.1) rotate(15deg);
  box-shadow: var(--shadow-glow);
}

.theme-options-tray {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-4);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 200px;
  transform: translateY(10px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-base);
}
.theme-options-tray.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

.theme-tray-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  padding: var(--sp-1) var(--sp-2);
  margin-bottom: var(--sp-1);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.theme-option:hover {
  background: var(--surface-2);
  border-color: var(--hairline);
}
.theme-option.active {
  background: var(--primary-soft);
  border-color: var(--hairline-accent);
}

.theme-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}
.theme-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.theme-option-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  flex: 1;
}
.theme-option.active .theme-option-name { color: var(--primary); }

.theme-active-check {
  font-size: 14px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.theme-option.active .theme-active-check { opacity: 1; }

/* --- CSS Custom Properties (Design Tokens) — Shared --- */
:root {
  /* --- Color tokens are defined in [data-theme] blocks above --- */

  /* Notion Pastel Card Tints (Fallback/Base) */
  --tint-peach:     #ff8c42;
  --tint-violet:    #7b3ff2;
  --tint-teal:      #2a9d8f;
  --tint-rose:      #e63b6f;
  --tint-mint:      #27a644;
  --tint-sky:       #0ea5e9;
  --tint-amber:     #f59e0b;

  /* Typography */
  --font-ar: 'Cairo', 'Tajawal', sans-serif;
  --font-en: 'Inter', system-ui, sans-serif;

  /* Spacing (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-24: 96px;

  /* Border Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 20px;
  --r-3xl: 24px;
  --r-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6), 0 4px 8px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px var(--primary-glow), 0 0 40px rgba(94,106,210,0.15);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4,0,0.2,1);
  --transition-base: 250ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 400ms cubic-bezier(0.4,0,0.2,1);

  /* Z-Index Ladder */
  --z-base: 0;
  --z-raised: 10;
  --z-dropdown: 100;
  --z-overlay: 500;
  --z-modal: 1000;
  --z-toast: 2000;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ar);
  background-color: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-1); }
::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* --- Typography Scale --- */
.t-display-xl { font-size: 56px; font-weight: 700; line-height: 1.08; letter-spacing: -1.5px; }
.t-display-lg { font-size: 40px; font-weight: 700; line-height: 1.1; letter-spacing: -1px; }
.t-display-md { font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.5px; }
.t-headline   { font-size: 22px; font-weight: 600; line-height: 1.25; letter-spacing: -0.3px; }
.t-title      { font-size: 18px; font-weight: 600; line-height: 1.3; }
.t-body-lg    { font-size: 16px; font-weight: 400; line-height: 1.6; }
.t-body       { font-size: 14px; font-weight: 400; line-height: 1.5; }
.t-caption    { font-size: 12px; font-weight: 400; line-height: 1.4; }
.t-label      { font-size: 11px; font-weight: 500; line-height: 1.3; letter-spacing: 0.5px; text-transform: uppercase; }

/* --- Colors --- */
.c-primary   { color: var(--primary); }
.c-success   { color: var(--success); }
.c-warning   { color: var(--warning); }
.c-danger    { color: var(--danger); }
.c-muted     { color: var(--ink-muted); }
.c-subtle    { color: var(--ink-subtle); }

/* ============================================================
   LAYOUT — Sidebar + Main Content
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--canvas);
  position: relative;
}

/* --- Ambient Glow Orbs --- */
.ambient-glow {
  display: none !important;
}

.sidebar.glass {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--hairline); /* Only right border */
  border-radius: 0; /* Flush with edge */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-base);
  position: relative;
  z-index: var(--z-raised);
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--hairline);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.sidebar-logo-text .name { font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -0.3px; }
.sidebar-logo-text .sub  { font-size: 10px; color: var(--ink-subtle); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: var(--sp-4) var(--sp-3); }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
  text-decoration: none;
  color: var(--ink-subtle);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink-muted);
  border-color: var(--hairline);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--hairline-accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: var(--r-pill) 0 0 var(--r-pill);
}

.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item .nav-badge {
  margin-right: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--hairline);
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.user-info .user-name  { font-size: 13px; font-weight: 600; color: var(--ink); }
.user-info .user-role  { font-size: 11px; color: var(--ink-subtle); }

/* --- Main Content --- */
.main-content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

/* --- Top Bar --- */
.topbar.glass {
  height: 80px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
  position: relative;
  z-index: var(--z-raised);
}

.topbar-left { display: flex; align-items: center; gap: var(--sp-4); }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -0.3px; }
.topbar-subtitle { font-size: 12px; color: var(--ink-subtle); }

.topbar-right { display: flex; align-items: center; gap: var(--sp-3); }

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--hairline-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
  color: var(--ink-muted);
  position: relative;
}
.topbar-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.topbar-btn .badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-date {
  font-size: 12px;
  color: var(--ink-subtle);
  background: var(--surface-3);
  border: 1px solid var(--hairline-strong);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
}

/* --- Page Content Area --- */
.page-content {
  min-width: 0;
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
}

/* ============================================================
   VIEWS — Hidden/Shown by JS
   ============================================================ */
.view { display: none; }
.view.active { display: block; }

/* --- Bento Box Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}

.stat-card.glass {
  will-change: transform;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.stat-card.glass:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card.glass .stat-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-soft);
  border: 1px solid var(--hairline-accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 16px;
  transition: all 0.25s;
}

.stat-card.glass:hover .stat-icon {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px var(--primary-glow);
}

.stat-card.glass .stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.1;
  margin: 6px 0;
  letter-spacing: -0.5px;
}

.stat-card.glass .stat-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-subtle);
}

.stat-card.glass .stat-sub {
  font-size: 12px;
  color: var(--ink-tertiary);
}

/* Custom stat-icon color badges */
.stat-icon.stat-icon-blue { background: rgba(79, 70, 229, 0.12) !important; color: #4f46e5 !important; border: 1px solid rgba(79, 70, 229, 0.25) !important; }
.stat-icon.stat-icon-purple { background: rgba(168, 85, 247, 0.12) !important; color: #a855f7 !important; border: 1px solid rgba(168, 85, 247, 0.25) !important; }
.stat-icon.stat-icon-emerald { background: rgba(16, 185, 129, 0.12) !important; color: #10b981 !important; border: 1px solid rgba(16, 185, 129, 0.25) !important; }
.stat-icon.stat-icon-rose { background: rgba(244, 63, 94, 0.12) !important; color: #f43f5e !important; border: 1px solid rgba(244, 63, 94, 0.25) !important; }

[data-theme="dark"] .stat-icon.stat-icon-blue { background: rgba(99, 102, 241, 0.16) !important; color: #818cf8 !important; border-color: rgba(99, 102, 241, 0.3) !important; }
[data-theme="dark"] .stat-icon.stat-icon-purple { background: rgba(168, 85, 247, 0.16) !important; color: #c084fc !important; border-color: rgba(168, 85, 247, 0.3) !important; }
[data-theme="dark"] .stat-icon.stat-icon-emerald { background: rgba(16, 185, 129, 0.16) !important; color: #34d399 !important; border-color: rgba(16, 185, 129, 0.3) !important; }
[data-theme="dark"] .stat-icon.stat-icon-rose { background: rgba(244, 63, 94, 0.16) !important; color: #fb7185 !important; border-color: rgba(244, 63, 94, 0.3) !important; }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--ink-subtle); font-weight: 500; margin-bottom: var(--sp-1); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--ink); letter-spacing: -0.5px; line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--ink-subtle); margin-top: var(--sp-1); }

.stat-trend {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 12px;
  font-weight: 600;
}
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================================
   SCANNER — ID Card Attendance System
   ============================================================ */
.scanner-container {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: var(--sp-6);
  min-height: calc(100vh - 140px);
}

.scanner-panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.scanner-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at 50% 30%, rgba(94,106,210,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.scanner-header {
  text-align: center;
  margin-bottom: var(--sp-6);
}
.scanner-header h2 { font-size: 20px; font-weight: 700; color: var(--ink); }
.scanner-header p  { font-size: 13px; color: var(--ink-subtle); margin-top: var(--sp-1); }

.scanner-device {
  width: 200px;
  height: 200px;
  border-radius: var(--r-2xl);
  background: var(--surface-2);
  border: 2px solid var(--hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-6);
  position: relative;
  transition: all var(--transition-base);
}

.scanner-device.scanning {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  animation: scanPulse 1.5s ease-in-out infinite;
}

.scanner-device.success { border-color: var(--success); box-shadow: 0 0 20px rgba(39,166,68,0.3); }
.scanner-device.warning { border-color: var(--warning); box-shadow: 0 0 20px rgba(245,158,11,0.3); }
.scanner-device.error   { border-color: var(--danger);  box-shadow: 0 0 20px rgba(239,68,68,0.3); }

@keyframes scanPulse {
  0%, 100% { box-shadow: 0 0 10px var(--primary-glow); }
  50%       { box-shadow: 0 0 30px var(--primary-glow), 0 0 60px rgba(94,106,210,0.2); }
}

.scanner-icon { font-size: 48px; margin-bottom: var(--sp-3); }
.scanner-status-text { font-size: 14px; color: var(--ink-subtle); font-weight: 500; }

.scan-line {
  position: absolute;
  left: 10px; right: 10px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: scanLine 2s ease-in-out infinite;
  opacity: 0;
}
.scanner-device.scanning .scan-line { opacity: 1; }

@keyframes scanLine {
  0%   { top: 20%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 80%; opacity: 0; }
}

.scanner-input-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.scanner-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 15px;
  text-align: center;
  outline: none;
  transition: all var(--transition-fast);
  letter-spacing: 2px;
}
.scanner-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.scanner-manual-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
  width: 100%;
}

.scanner-result {
  width: 100%;
  margin-top: auto;
}

/* Student Result Card */
.student-result-card {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  display: none;
  flex-direction: column;
  gap: var(--sp-4);
  animation: slideUp 0.3s ease;
  position: relative;
  overflow: hidden;
}
.student-result-card.show { display: flex; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.student-result-header {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.student-big-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(94,106,210,0.4);
}

.student-result-info .student-name   { font-size: 18px; font-weight: 700; color: var(--ink); }
.student-result-info .student-meta   { font-size: 12px; color: var(--ink-subtle); margin-top: 2px; }

.financial-status {
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.financial-status.paid   { background: rgba(39,166,68,0.1); border: 1px solid rgba(39,166,68,0.25); }
.financial-status.unpaid { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); }

.financial-label { font-size: 13px; font-weight: 500; }
.financial-status.paid   .financial-label { color: var(--success); }
.financial-status.unpaid .financial-label { color: var(--danger); }
.financial-amount { font-size: 20px; font-weight: 800; }

.wrong-group-alert {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--warning);
}

/* Live Attendance List */
.attendance-panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  overflow-x: auto; box-shadow: var(--shadow-card);
}

.attendance-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.attendance-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-2); }

.attendance-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  transition: all var(--transition-fast);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.attendance-item:hover { border-color: var(--primary); }

.att-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white; flex-shrink: 0;
}

.att-info { flex: 1; }
.att-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.att-meta { font-size: 11px; color: var(--ink-subtle); }

.att-time { font-size: 12px; color: var(--ink-subtle); font-weight: 500; }

.att-status {
  width: 8px; height: 8px; border-radius: var(--r-pill);
  flex-shrink: 0;
}
.att-status.present { background: var(--success); box-shadow: 0 0 6px rgba(39,166,68,0.5); }
.att-status.absent  { background: var(--danger);  box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.att-status.late    { background: var(--warning); box-shadow: 0 0 6px rgba(245,158,11,0.5); }

.att-paid-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
}
.att-paid-badge.paid   { background: rgba(39,166,68,0.15); color: var(--success); }
.att-paid-badge.unpaid { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ============================================================
   DATA TABLE
   ============================================================ */
.data-table-wrapper {
  -webkit-overflow-scrolling: touch; min-width: 0; width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  overflow-x: auto; box-shadow: var(--shadow-card);
}

.table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--hairline);
}

.search-box {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4);
  transition: all var(--transition-fast);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 14px;
  width: 220px;
}
.search-box input::placeholder { color: var(--ink-tertiary); }

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

thead th {
  background: var(--surface-2);
  padding: var(--sp-3) var(--sp-5);
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-subtle);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--hairline);
  transition: background var(--transition-fast);
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: var(--sp-3) var(--sp-5);
  font-size: 14px;
  color: var(--ink-muted);
  vertical-align: middle;
}

.td-student {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.table-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white; flex-shrink: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
}
.status-badge.present { background: rgba(39,166,68,0.12); color: var(--success); }
.status-badge.absent  { background: rgba(239,68,68,0.12);  color: var(--danger); }
.status-badge.paid    { background: rgba(39,166,68,0.12); color: var(--success); }
.status-badge.unpaid  { background: rgba(239,68,68,0.12);  color: var(--danger); }
.status-badge.partial { background: rgba(245,158,11,0.12); color: var(--warning); }

.table-actions { display: flex; gap: var(--sp-2); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-5);
  border-radius: var(--r-md);
  font-family: var(--font-ar);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--primary-glow); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink-muted);
  border-color: var(--hairline);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--hairline-strong); color: var(--ink); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: #22a83e; transform: translateY(-1px); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--primary); border-color: var(--hairline); }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--r-md);
}

.btn-sm { padding: 6px var(--sp-4); font-size: 12px; }
.btn-lg { padding: 12px var(--sp-6); font-size: 16px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--hairline);
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--ink); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--sp-4); }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-muted); margin-bottom: var(--sp-2); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 10px var(--sp-4);
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--ink-tertiary); }
.form-select { cursor: pointer; }
.form-select option { background: var(--surface-2); }
.form-textarea { resize: vertical; min-height: 100px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  box-shadow: var(--shadow-card);
}

.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); }
.chart-title  { font-size: 15px; font-weight: 700; color: var(--ink); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  height: 160px;
  padding-bottom: var(--sp-6);
  position: relative;
}

.bar-chart::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: var(--sp-6);
  height: 1px;
  background: var(--hairline);
}

.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.bar { width: 100%; border-radius: var(--r-sm) var(--r-sm) 0 0; min-height: 4px; transition: height var(--transition-slow), background var(--transition-fast); position: relative; cursor: pointer; }
.bar:hover { opacity: 0.85; }
.bar-label { font-size: 11px; color: var(--ink-subtle); }
.bar-value { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 600; color: var(--ink-muted); white-space: nowrap; opacity: 0; transition: opacity var(--transition-fast); }
.bar:hover .bar-value { opacity: 1; }

/* ============================================================
   NOTIFICATIONS PANEL
   ============================================================ */
.notifications-panel {
  position: fixed;
  top: 60px;
  left: var(--sp-4);
  width: 360px;
  max-height: 80vh;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(-10px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-base);
}
.notifications-panel.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}

.notif-list { overflow-y: auto; flex: 1; padding: var(--sp-2); }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.notif-item:hover { background: var(--surface-2); border-color: var(--hairline); }
.notif-item.unread { background: var(--primary-soft); border-color: var(--hairline-accent); }

.notif-dot { width: 8px; height: 8px; border-radius: var(--r-pill); flex-shrink: 0; margin-top: 5px; }
.notif-dot.info    { background: var(--info); }
.notif-dot.success { background: var(--success); }
.notif-dot.warning { background: var(--warning); }
.notif-dot.danger  { background: var(--danger); }

.notif-content { flex: 1; }
.notif-title   { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.notif-body    { font-size: 12px; color: var(--ink-subtle); line-height: 1.5; }
.notif-time    { font-size: 11px; color: var(--ink-tertiary); margin-top: 4px; }

/* ============================================================
   PARENT PORTAL — 4-digit PIN
   ============================================================ */
.parent-portal-wrapper {
  min-height: 100vh;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.parent-portal-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(94,106,210,0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(123,63,242,0.08) 0%, transparent 50%);
}

.parent-portal-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3xl);
  padding: var(--sp-10);
  width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.portal-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto var(--sp-6);
  box-shadow: var(--shadow-glow);
}

.portal-title { font-size: 24px; font-weight: 800; color: var(--ink); margin-bottom: var(--sp-2); }
.portal-sub   { font-size: 14px; color: var(--ink-subtle); margin-bottom: var(--sp-8); line-height: 1.5; }

.pin-dots {
  display: flex;
  justify-content: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.pin-dot {
  width: 18px; height: 18px;
  border-radius: var(--r-pill);
  border: 2px solid var(--hairline-strong);
  background: transparent;
  transition: all var(--transition-fast);
}
.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transform: scale(1.1);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  max-width: 280px;
  margin: 0 auto;
}

.pin-key {
  aspect-ratio: 1;
  border-radius: var(--r-xl);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.pin-key:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); transform: scale(1.05); }
.pin-key:active { transform: scale(0.95); }
.pin-key.delete { font-size: 18px; color: var(--ink-subtle); }
.pin-key.zero   { grid-column: 2; }

/* Student Profile (Parent View) */
.student-profile-view {
  display: none;
}
.student-profile-view.show { display: block; }

.profile-hero {
  background: linear-gradient(135deg, var(--surface-1) 0%, var(--surface-2) 100%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  position: relative;
  overflow: hidden;
}

.profile-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at 80% 50%, rgba(94,106,210,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.profile-big-avatar {
  width: 80px; height: 80px;
  border-radius: var(--r-2xl);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: white;
  box-shadow: 0 8px 24px rgba(94,106,210,0.4);
  flex-shrink: 0;
}

/* ============================================================
   FINANCIAL DASHBOARD — Stripe-inspired
   ============================================================ */
.financial-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}

.finance-big-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.finance-amount {
  font-size: 40px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -1.5px;
  line-height: 1;
  font-feature-settings: "tnum";
}

.finance-progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: var(--sp-4);
}
.finance-progress-bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width var(--transition-slow);
}

/* ============================================================
   TABS
   ============================================================ */
.tab-bar {
  display: flex;
  gap: var(--sp-1);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 4px;
  margin-bottom: var(--sp-5);
  overflow-x: auto;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px var(--sp-5);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border: 1px solid transparent;
}
.tab-item:hover { color: var(--ink-muted); background: var(--surface-3); }
.tab-item.active {
  background: var(--surface-1);
  color: var(--primary);
  border-color: var(--hairline);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   GRADES TABLE — Color-coded
   ============================================================ */
.grade-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 28px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 700;
  font-feature-settings: "tnum";
}
.grade-cell.excellent { background: rgba(39,166,68,0.15); color: var(--success); }
.grade-cell.good      { background: rgba(94,106,210,0.15); color: var(--primary); }
.grade-cell.average   { background: rgba(245,158,11,0.15); color: var(--warning); }
.grade-cell.poor      { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ============================================================
   MEDIA LIBRARY — Protected Video Player
   ============================================================ */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.media-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-card);
  cursor: pointer;
}
.media-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow-md); }

.media-thumb {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}

.media-play-btn {
  width: 48px; height: 48px;
  background: rgba(94,106,210,0.9);
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 16px rgba(94,106,210,0.5);
}
.media-card:hover .media-play-btn { transform: scale(1.1); background: var(--primary); }

.media-type-badge {
  position: absolute;
  top: var(--sp-2); right: var(--sp-2);
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  color: var(--ink);
}

.media-info { padding: var(--sp-4); }
.media-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: var(--sp-1); }
.media-meta  { font-size: 12px; color: var(--ink-subtle); }

/* Protected Video Modal */
.video-modal {
  max-width: 800px !important;
}

.video-wrapper {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--r-lg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.video-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 1;
}

.video-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--sp-4);
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  z-index: 2;
}

.video-progress {
  flex: 1; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--r-pill);
  cursor: pointer;
  position: relative;
}
.video-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-pill);
  pointer-events: none;
}

/* ============================================================
   SCHEDULE / NOTIFICATIONS SETTINGS
   ============================================================ */
.schedule-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.schedule-card:hover { border-color: var(--primary); }

.schedule-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-lg);
  background: var(--primary-soft);
  border: 1px solid var(--hairline-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

/* Toggle Switch */
.toggle {
  width: 44px; height: 24px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}
.toggle.on { background: var(--primary); border-color: var(--primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: var(--r-pill);
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle.on::after { transform: translateX(-20px); }

/* ============================================================
   TOP STUDENTS / LEADERBOARD
   ============================================================ */
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-3);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-card);
}
.leaderboard-item:hover { border-color: var(--primary); transform: translateX(-4px); }

.rank-badge {
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; flex-shrink: 0;
}
.rank-badge.gold   { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; box-shadow: 0 2px 8px rgba(245,158,11,0.5); }
.rank-badge.silver { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
.rank-badge.bronze { background: linear-gradient(135deg, #cd7f32, #a0522d); color: white; }
.rank-badge.other  { background: var(--surface-3); color: var(--ink-muted); border: 1px solid var(--hairline); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  left: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--toast-accent, var(--primary));
}

.toast.success { --toast-accent: var(--success); border-color: rgba(39,166,68,0.3); }
.toast.warning { --toast-accent: var(--warning); border-color: rgba(245,158,11,0.3); }
.toast.danger  { --toast-accent: var(--danger);  border-color: rgba(239,68,68,0.3); }
.toast.info    { --toast-accent: var(--info);    border-color: rgba(14,165,233,0.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title   { font-size: 14px; font-weight: 700; color: var(--ink); }
.toast-body    { font-size: 12px; color: var(--ink-subtle); }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }

.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.mt-auto { margin-top: auto; }

.w-full { width: 100%; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.divider {
  height: 1px;
  background: var(--hairline);
  margin: var(--sp-4) 0;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-12);
  color: var(--ink-subtle);
  text-align: center;
  gap: var(--sp-3);
}
.empty-state .empty-icon { font-size: 48px; opacity: 0.4; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--ink-muted); }
.empty-state .empty-sub   { font-size: 13px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}
.section-title { font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -0.3px; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-5); }

/* Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.5s ease-in-out infinite;
  border-radius: var(--r-md);
}
@keyframes skeleton-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scroll snap */
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .media-grid  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-logo-text,
  .nav-section-label,
  .nav-item span:not(.nav-icon):not(.nav-badge),
  .user-info { display: none; }
  .scanner-container { grid-template-columns: 1fr; }
  .financial-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   STUDENT PORTAL — Grade-based Access
   ============================================================ */
.student-portal-wrapper {
  min-height: 100vh;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}
.student-portal-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 10% 20%, rgba(94,106,210,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, rgba(123,63,242,0.10) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.student-portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-8);
  background: rgba(15,16,17,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}
.sp-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.sp-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
}
.sp-logo-name { font-size: 16px; font-weight: 800; color: var(--ink); }
.sp-logo-sub  { font-size: 10px; color: var(--ink-subtle); }

.student-portal-hero {
  padding: var(--sp-12) var(--sp-8) var(--sp-6);
  text-align: center;
  position: relative;
  z-index: 1;
}
.student-portal-hero h1 {
  font-size: 44px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: var(--sp-4);
}
.student-portal-hero h1 .hero-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.student-portal-hero p {
  font-size: 17px;
  color: var(--ink-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

.grade-selection-section {
  flex: 1;
  padding: 0 var(--sp-8) var(--sp-12);
  position: relative;
  z-index: 1;
}
.grade-selection-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: var(--sp-5);
}
.grade-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-5);
  max-width: 960px;
  margin: 0 auto;
}
.grade-entry-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow-x: auto; box-shadow: var(--shadow-card);
}
.grade-entry-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
  opacity: 0;
  transition: opacity var(--transition-base);
}
.grade-entry-card:hover {
  transform: translateY(-10px);
  border-color: var(--card-color, var(--primary));
  box-shadow: var(--shadow-lg), 0 0 40px rgba(94,106,210,0.15);
}
.grade-entry-card:hover::after { opacity: 1; }
.grade-entry-card:active { transform: translateY(-5px) scale(0.98); }

.grade-entry-icon {
  width: 72px; height: 72px;
  border-radius: var(--r-2xl);
  background: var(--card-color, var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto var(--sp-5);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  transition: all var(--transition-base);
}
.grade-entry-card:hover .grade-entry-icon { transform: scale(1.12) rotate(5deg); }

.grade-entry-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: var(--sp-1);
  letter-spacing: -0.3px;
}
.grade-entry-count {
  font-size: 12px;
  color: var(--ink-subtle);
  margin-bottom: var(--sp-5);
}
.grade-entry-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--card-color, var(--primary));
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: var(--r-pill);
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.grade-entry-card:hover .grade-entry-cta { transform: scale(1.05); }

/* PIN Overlay */
.grade-pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeInBg 0.25s ease;
}
@keyframes fadeInBg { from { opacity: 0; } to { opacity: 1; } }

.grade-pin-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3xl);
  padding: var(--sp-10);
  width: 360px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.grade-pin-icon {
  width: 72px; height: 72px;
  border-radius: var(--r-2xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto var(--sp-5);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.grade-pin-title { font-size: 20px; font-weight: 800; color: var(--ink); margin-bottom: var(--sp-1); }
.grade-pin-sub   { font-size: 13px; color: var(--ink-subtle); margin-bottom: var(--sp-6); }

.grade-pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: var(--sp-5);
}
.grade-pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  background: transparent;
  transition: all var(--transition-fast);
}
.grade-pin-dot.filled {
  background: var(--pin-color, var(--primary));
  border-color: var(--pin-color, var(--primary));
  box-shadow: 0 0 12px rgba(94,106,210,0.5);
  transform: scale(1.1);
}

.grade-pin-hint {
  font-size: 11px;
  color: var(--ink-tertiary);
  margin-top: var(--sp-4);
}

/* Student Content View */
.student-content-wrapper {
  min-height: 100vh;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.student-content-header {
  background: rgba(15,16,17,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.student-grade-badge {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-2) var(--sp-4);
}
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.badge-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.badge-count { font-size: 12px; color: var(--ink-subtle); }

.student-content-body { padding: var(--sp-6); }

.content-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.content-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px var(--sp-4);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  color: var(--ink-subtle);
}
.content-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.content-filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 4px 12px var(--primary-glow); }

/* Student Media Card */
.student-media-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: var(--shadow-card);
}
.student-media-card:hover {
  transform: translateY(-6px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg), 0 0 25px rgba(94,106,210,0.15);
}
.student-media-thumb {
  aspect-ratio: 16/9;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.student-thumb-bg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 56px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  transition: transform 0.5s ease;
}
.student-media-card:hover .student-thumb-bg { transform: scale(1.08); }
.student-thumb-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.5));
}
.student-play-btn {
  position: absolute;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(94,106,210,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px rgba(94,106,210,0.5);
  transform: scale(0.9);
  transition: all var(--transition-base);
  z-index: 2;
}
.student-media-card:hover .student-play-btn { transform: scale(1.05); box-shadow: 0 8px 32px rgba(94,106,210,0.6); }

.student-type-tag {
  position: absolute;
  bottom: var(--sp-2); right: var(--sp-2);
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-size: 11px; font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  z-index: 3;
}
.student-media-info { padding: var(--sp-4); }
.student-media-title { font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.4; margin-bottom: var(--sp-2); }
.student-media-meta  { font-size: 11px; color: var(--ink-subtle); display: flex; gap: var(--sp-3); align-items: center; }

/* Protected viewer modal */
.protected-viewer {
  background: #000;
  border-radius: var(--r-xl);
  overflow: hidden;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.protected-viewer::after {
  content: attr(data-watermark);
  position: absolute;
  color: rgba(255,255,255,0.06);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  transform: rotate(-30deg);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}
.video-inner-display {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-5);
  background: linear-gradient(135deg, #0a0b14, #12131f);
}
.viewer-play-circle {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  box-shadow: 0 0 50px var(--primary-glow);
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: pulseGlow 2.5s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 30px var(--primary-glow); }
  50%       { box-shadow: 0 0 60px var(--primary-glow), 0 0 100px rgba(94,106,210,0.3); }
}
.viewer-play-circle:hover { transform: scale(1.1); }
.viewer-lock-notice {
  position: absolute;
  top: var(--sp-3); right: var(--sp-3);
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.5);
  display: flex; align-items: center; gap: 4px;
}

@media (max-width: 900px) {
  .grade-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .student-portal-hero h1 { font-size: 30px; }
  .student-portal-header { padding: var(--sp-3) var(--sp-4); }
}
@media (max-width: 540px) {
  .grade-cards-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .student-portal-hero { padding: var(--sp-6) var(--sp-4) var(--sp-4); }
  .grade-selection-section { padding: 0 var(--sp-4) var(--sp-8); }
  .grade-entry-icon { width: 52px; height: 52px; font-size: 24px; }
  .grade-entry-name { font-size: 14px; }
}

/* ============================================================
   WORLD-CLASS ANIMATIONS � Dashboard
   ============================================================ */

@keyframes staggerIn {
  from { opacity: 0; transform: translateY(28px) scale(0.96); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
.stat-card-anim { animation: staggerIn 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) both; }
.stat-card-anim:nth-child(1) { animation-delay: 0.05s; }
.stat-card-anim:nth-child(2) { animation-delay: 0.15s; }
.stat-card-anim:nth-child(3) { animation-delay: 0.25s; }
.stat-card-anim:nth-child(4) { animation-delay: 0.35s; }

@keyframes rippleExpand { from { transform: scale(0); opacity: 0.4; } to { transform: scale(4); opacity: 0; } }
.ripple-container { position: relative; overflow: hidden; }
.ripple-wave { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.25); width: 60px; height: 60px; margin-left: -30px; margin-top: -30px; pointer-events: none; animation: rippleExpand 0.6s ease-out forwards; }

@keyframes barGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.bar { transform-origin: bottom; animation: barGrow 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both; }
.bar:nth-child(1) { animation-delay: 0.10s; }
.bar:nth-child(2) { animation-delay: 0.18s; }
.bar:nth-child(3) { animation-delay: 0.26s; }
.bar:nth-child(4) { animation-delay: 0.34s; }
.bar:nth-child(5) { animation-delay: 0.42s; }
.bar:nth-child(6) { animation-delay: 0.50s; }
.bar:nth-child(7) { animation-delay: 0.58s; }

@keyframes progressFill { from { width: 0% !important; } }
.finance-progress-bar { animation: progressFill 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.3s both; }

@keyframes pageEnter { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.page-content {
  min-width: 0; flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-6); animation: pageEnter 0.4s ease both; }

.nav-item.active { background: var(--primary-soft) !important; color: var(--primary) !important; border-color: var(--hairline-accent) !important; box-shadow: inset 3px 0 0 var(--primary), 0 0 20px rgba(129,140,248,0.08); }
.nav-item.active .nav-icon { color: var(--primary); filter: drop-shadow(0 0 6px var(--primary)); }

.grade-entry-card { opacity: 0; animation: staggerIn 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

/* Mobile Overlay */
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(4px); z-index: 200; opacity: 0; transition: opacity 0.3s ease; }
.mobile-overlay.active { display: block; opacity: 1; }

/* Drawer */
@keyframes drawerSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.sidebar.drawer-mode { position: fixed !important; top: 0; right: 0; bottom: 0; z-index: 250; display: flex !important; width: 260px !important; animation: drawerSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both; }

/* Hamburger */
.topbar-hamburger { display: none; width: 36px; height: 36px; border-radius: var(--r-md); background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); align-items: center; justify-content: center; cursor: pointer; color: var(--ink-muted); transition: all 0.2s ease; }
.topbar-hamburger:hover { background: rgba(255,255,255,0.1); color: var(--ink); }

/* FAB */
.mobile-fab { display: none; position: fixed; bottom: 90px; left: 20px; z-index: 150; width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); border: none; cursor: pointer; color: white; box-shadow: 0 8px 24px rgba(129,140,248,0.4); transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); align-items: center; justify-content: center; font-size: 20px; }
@keyframes fabEnter { from { transform: scale(0) rotate(-180deg); opacity: 0; } to { transform: scale(1) rotate(0deg); opacity: 1; } }
.mobile-fab.visible { animation: fabEnter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.6s both; }
.mobile-fab:hover { transform: scale(1.12) rotate(10deg); box-shadow: 0 12px 32px rgba(129,140,248,0.6); }

/* Bottom Tab Bar */
.bottom-tab-bar { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 300; background: rgba(8,8,12,0.9); backdrop-filter: blur(10px) saturate(200%); -webkit-backdrop-filter: blur(10px) saturate(200%); border-top: 1px solid rgba(255,255,255,0.08); padding: 6px 4px env(safe-area-inset-bottom, 6px); flex-direction: row; justify-content: space-around; align-items: center; }
.tab-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 10px; border-radius: 10px; cursor: pointer; transition: all 0.2s ease; color: #52525b; min-width: 48px; }
.tab-item svg { width: 20px; height: 20px; }
.tab-item span { font-size: 10px; font-weight: 600; }
.tab-item.active { color: var(--primary); }
.tab-item.active svg { filter: drop-shadow(0 0 5px var(--primary)); }

/* === TABLET (<=1024px) === */
@media (max-width: 1024px) {
  .sidebar.glass { width: 72px; overflow: visible; }
  .sidebar.glass .sidebar-logo-text, .sidebar.glass .nav-section-label, .sidebar.glass .user-info, .sidebar.glass .nav-item span:not(.nav-icon):not(.nav-badge) { display: none; }
  .sidebar.glass .sidebar-logo { justify-content: center; }
  .sidebar.glass .nav-item { justify-content: center; padding: 10px; position: relative; }
  .sidebar.glass .nav-item::after { content: attr(data-label); position: absolute; right: -8px; transform: translateX(100%); background: rgba(15,15,20,0.95); color: white; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 8px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; border: 1px solid rgba(255,255,255,0.1); z-index: 999; }
  .sidebar.glass .nav-item:hover::after { opacity: 1; }
  .sidebar.glass .user-card { justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* === MOBILE (<=768px) === */
@media (max-width: 768px) {
  .theme-switcher-panel { bottom: 90px !important; }
  /* --- Added Mobile Fixes --- */
  .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-date#clockDisplay { display: none; }
  .topbar-right .btn-primary { display: none; }
  .page-title, .section-title { font-size: 1.2rem; }
  .data-table-wrapper {
  -webkit-overflow-scrolling: touch; min-width: 0; width: 100%; border-radius: 8px; }
  th, td { padding: 12px 8px; font-size: 12px; }
  .sidebar.glass { display: none; }
  .topbar-hamburger { display: flex; }
  .mobile-fab { display: flex; }
  .bottom-tab-bar { display: flex; }
  .topbar.glass { height: 60px; padding: 0 16px; }
  .main-content {
  min-width: 0; padding-bottom: 80px; }
  .page-content {
  min-width: 0; padding: var(--sp-3); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: var(--sp-4); }
  .stat-card.glass {
  will-change: transform; padding: 16px; border-radius: 16px; }
  .stat-card.glass .stat-value { font-size: 28px; }
  .chart-container { padding: var(--sp-4); border-radius: var(--r-xl); }
  .scanner-container { grid-template-columns: 1fr; height: auto; }
  .grade-cards-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grade-pin-card { width: calc(100vw - 32px); max-width: 340px; }
  .media-grid { grid-template-columns: 1fr; }
  .financial-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* === SMALL MOBILE (<=480px) === */
@media (max-width: 480px) {
  .stats-grid { gap: var(--sp-2); }
  .stat-card.glass {
  will-change: transform; padding: 14px; border-radius: 14px; }
  .stat-card.glass .stat-value { font-size: 24px; }
  .stat-card.glass .stat-label { font-size: 11px; }
  .grade-cards-grid { grid-template-columns: 1fr; max-width: 280px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .stat-card-anim, .bar, .finance-progress-bar, .grade-entry-card, .mobile-fab, .page-content {
  min-width: 0; animation: none !important; opacity: 1 !important; transform: none !important; }
}

[data-theme="light"] .ambient-glow { display: none !important; }


/* ============================================================
   CHATBOT UI
   ============================================================ */
.chat-widget-btn {
  position: fixed;
  bottom: var(--sp-6);
  left: var(--sp-6);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  cursor: pointer;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-widget-btn:hover {
  transform: scale(1.1);
}
.chat-window {
  position: fixed;
  bottom: 90px;
  left: var(--sp-6);
  width: 350px;
  height: 500px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: bottom left;
}
.chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
.chat-header {
  padding: var(--sp-4);
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: bold; font-size: 18px;
}
.chat-title { font-weight: 700; color: var(--ink); }
.chat-status { font-size: 12px; color: var(--success); display: flex; align-items: center; gap: 4px; }
.chat-status::before { content: ''; width: 8px; height: 8px; background: var(--success); border-radius: 50%; box-shadow: 0 0 8px var(--success); }
.chat-close { cursor: pointer; color: var(--ink-subtle); transition: color 0.2s; }
.chat-close:hover { color: var(--danger); }
.chat-messages {
  flex: 1;
  padding: var(--sp-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: slideUpFade 0.3s ease;
}
.chat-msg.bot {
  background: var(--surface-2);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-right-radius: 4px;
}
.chat-msg.user {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  align-self: flex-end;
  border-bottom-left-radius: 4px;
}
.chat-input-area {
  padding: var(--sp-4);
  border-top: 1px solid var(--hairline);
  display: flex;
  gap: var(--sp-2);
  background: rgba(0,0,0,0.1);
}
.chat-input {
  flex: 1;
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: 100px;
  padding: 0 16px;
  color: var(--ink);
  outline: none;
}
.chat-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chat-send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s;
}
.chat-send-btn:hover { transform: scale(1.05); }

@media (max-width: 768px) {
  .chat-widget-btn { bottom: 90px; left: 16px; width: 50px; height: 50px; }
  .chat-window { bottom: 150px; left: 16px; right: 16px; width: auto; height: 400px; }
}

/* ============================================================
   PORTAL LOGIN PAGES DESIGN SYSTEM (SPLIT SCREEN CLASSIC)
   ============================================================ */
.portal-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  padding: 24px 16px;
  box-sizing: border-box;
  background: #090a14;
}

.portal-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at 80% 20%, rgba(108,99,255,0.15) 0%, transparent 50%),
              radial-gradient(circle at 20% 80%, rgba(245,197,66,0.08) 0%, transparent 50%),
              #090a14;
}

.portal-wrapper-split {
  display: flex;
  flex-direction: row-reverse;
  width: 100%;
  max-width: 900px;
  min-height: 540px;
  border-radius: 28px;
  overflow: hidden;
  background: rgba(16, 16, 32, 0.85);
  backdrop-filter: blur(40px) saturate(1.6);
  -webkit-backdrop-filter: blur(40px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.6);
  position: relative;
  z-index: 10;
  margin: 0 auto;
}

.portal-hero-side {
  flex: 1;
  position: relative;
  background-image: url('/src/teacher.jpg'), url('teacher.jpg');
  background-size: cover;
  background-position: center 15%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px;
  box-sizing: border-box;
  min-height: 280px;
}

.portal-hero-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9,10,20,0.15) 0%, rgba(9,10,20,0.55) 60%, rgba(9,10,20,0.92) 100%);
}

.portal-hero-content {
  position: relative;
  z-index: 2;
  color: #fff;
  padding-top: 12px;
}

.portal-teacher-name {
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.35;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.portal-teacher-title {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  line-height: 1.5;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

.portal-card-side {
  width: 420px;
  padding: 44px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  position: relative;
  background: rgba(18, 18, 36, 0.95);
}

.portal-avatar-thumb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  border: 3px solid rgba(108,99,255,0.6);
  box-shadow: 0 8px 24px rgba(108,99,255,0.3);
  margin: 0 auto 16px;
  display: block;
}

.portal-icon-wrap {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.portal-icon-wrap::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 20px;
  background: inherit;
  opacity: 0.3;
  filter: blur(12px);
}

.portal-icon-main { background: linear-gradient(135deg, #6c63ff, #4834d4); }
.portal-icon-student { background: linear-gradient(135deg, #00b894, #00867a); }
.portal-icon-parent { background: linear-gradient(135deg, #fd7e6b, #e04535); }
.portal-icon-admin { background: linear-gradient(135deg, #6c5ce7, #4834d4); }

.portal-title {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
  text-align: center;
}

.portal-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0;
  line-height: 1.5;
  text-align: center;
}

.portal-sep {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  margin: 24px 0;
}

.portal-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s ease;
  font-family: inherit;
  background: rgba(255,255,255,0.04);
  color: #fff;
  box-sizing: border-box;
}

.portal-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.portal-btn-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.portal-btn-ico-s { background: linear-gradient(135deg, #00b894, #00867a); }
.portal-btn-ico-p { background: linear-gradient(135deg, #fd7e6b, #e04535); }

.portal-btn-text {
  flex: 1;
  text-align: right;
}

.portal-btn-arrow {
  color: rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.portal-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  direction: ltr;
  text-align: left;
  transition: all 0.25s;
  outline: none;
  box-sizing: border-box;
}

.portal-input:focus {
  border-color: rgba(108,99,255,0.5);
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
}

.portal-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.portal-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-align: right;
}

.portal-submit {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  transition: all 0.25s;
  box-sizing: border-box;
  margin-top: 8px;
}

.portal-submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.portal-submit-s { background: linear-gradient(135deg, #00b894, #00867a); }
.portal-submit-p { background: linear-gradient(135deg, #fd7e6b, #e04535); }
.portal-submit-a { background: linear-gradient(135deg, #6c5ce7, #4834d4); }

.portal-back {
  position: absolute;
  top: 16px;
  left: 16px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.portal-back:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
}

.portal-footer {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 20px;
}

@media (max-width: 768px) {
  .portal-wrapper-split {
    flex-direction: column;
    max-width: 420px;
    min-height: auto;
  }
  .portal-hero-side {
    min-height: 200px;
    padding: 24px;
  }
  .portal-card-side {
    width: 100%;
    padding: 32px 24px;
  }
}

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: var(--surface-2);
}
::-webkit-scrollbar-thumb {
  background: var(--ink-muted);
  border-radius: 6px;
  border: 3px solid var(--surface-2);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* --- Table Container & Scroll Fix (Solution for Screenshot 1) --- */
.data-table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 210px);
  border-radius: var(--r-xl);
  border: 1px solid var(--hairline);
  background: var(--surface-1);
}
.data-table-wrapper table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table-wrapper table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  backdrop-filter: blur(10px);
}

/* --- Financial Grid Layout Fix --- */
.financial-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 1024px) {
  .financial-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   THERMAL RECEIPT & CARD PRINT STYLES (Xprinter XP-80 & 80mm)
   ============================================================ */
@media print {
  @page {
    margin: 0 !important;
    size: auto;
  }
  
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  
  /* Hide all UI elements, sidebars, topbars, buttons, chat */
  header, nav, .sidebar, .navbar, .chat-widget-btn, .chat-window, .modal-header, button, .btn, .toast-container, .topbar {
    display: none !important;
  }
  
  .modal-overlay {
    position: static !important;
    background: transparent !important;
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .modal {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  #receiptPrintArea {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 auto !important;
    width: 100% !important;
    display: block !important;
  }
}