/* ============================================================
   SCHOOLSYS — Premium School Admin Dashboard
   Theme: Deep Space Navy + Electric Teal
   Fonts: Syne (headings) + DM Sans (body)
   ============================================================ */
   
  

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ─── CSS Variables g ──────────────────────────────────────── */
:root {
  /* Core Backgrounds - Obsidian & Deep Emerald */
  --bg:           #050505; /* Pure Obsidian */
  --bg2:          #0f0f0f; 
  --surface:      #161616; /* Dark Charcoal */
  --surface2:     #1e1e1e; 
  --surface3:     #ffffff; /* Pure Snow for specific panels */

  /* Borders */
  --border:       rgba(255, 255, 255, 0.08);
  --border2:      rgba(16, 185, 129, 0.20); /* Emerald tinted border */

  /* Primary Action - Emerald Green */
  --primary:      #10b981; /* Emerald */
  --primary-dim:  rgba(16, 185, 129, 0.12);
  --primary-glow: rgba(16, 185, 129, 0.30);
  --primary-hover: #34d399;

  /* Status Colors */
  --green:        #10b981;
  --green-dim:    rgba(16, 185, 129, 0.13);
  --yellow:       #fbbf24;
  --yellow-dim:   rgba(251, 191, 36, 0.13);
  --red:          #ef4444;
  --red-dim:      rgba(239, 68, 68, 0.13);
  --purple:       #8b5cf6;
  --purple-dim:   rgba(139, 92, 246, 0.13);
  --orange:       #f59e0b;
  --orange-dim:   rgba(245, 158, 11, 0.13);

  /* Typography */
  --text:         #ffffff; /* Pure White */
  --text2:        #a1a1aa; /* Muted Grey */
  --text3:        #52525b; /* Dark Zinc */

  --sidebar-w:    256px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;
  --shadow:       0 10px 40px rgba(0,0,0,0.8);
  --shadow-sm:    0 4px 20px rgba(0,0,0,0.5);
  --transition:   .2s cubic-bezier(.4, 0, .2, 1);

  --font-head:    'Manrope', 'Segoe UI', Arial, sans-serif;
  --font-body:    'Inter', 'Segoe UI', Arial, sans-serif;
}

/* ─── Light Mode Theme (Matching Reference) ──────────────── */
/* ─── Light Mode Force Override ─────────────────────────── */
body.light-mode {
  --bg: #F3F4F6 !important;
  --bg2: #F8FAFC !important;
  --surface: #FFFFFF !important;
  --surface2: #F9FAFB !important;
  --surface3: #E5E7EB !important;
  --text: #111827 !important;
  --text2: #4B5563 !important;
  --text3: #6B7280 !important;
  --border: rgba(15, 23, 42, 0.10) !important;
  --border2: rgba(16, 185, 129, 0.22) !important;
  --shadow: 0 12px 35px rgba(15, 23, 42, 0.08) !important;
  --shadow-sm: 0 6px 20px rgba(15, 23, 42, 0.06) !important;
}

body.light-mode,
body.light-mode .main-content,
body.light-mode .content-area,
body.light-mode .sidebar,
body.light-mode .topbar,
body.light-mode .stat-card,
body.light-mode .chart-card,
body.light-mode .table-container,
body.light-mode .panel,
body.light-mode .settings-panel,
body.light-mode .modal-content,
body.light-mode .profile-modal-layout,
body.light-mode .calendar-container,
body.light-mode .profile-card,
body.light-mode .card,
body.light-mode .section-card {
  background-color: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

body.light-mode .main-content *,
body.light-mode .sidebar *,
body.light-mode .topbar *,
body.light-mode .panel *,
body.light-mode .stat-card *,
body.light-mode .chart-card *,
body.light-mode .table-container *,
body.light-mode .settings-panel *,
body.light-mode .modal-content *,
body.light-mode .profile-modal-layout *,
body.light-mode .calendar-container * {
  color: inherit;
}

body.light-mode .nav-link,
body.light-mode .nav-link:hover,
body.light-mode .nav-item {
  color: var(--text2) !important;
}

body.light-mode .nav-link.active {
  background: rgba(16, 185, 129, 0.12) !important;
  color: var(--primary) !important;
}

body.light-mode .sb-search-inner,
body.light-mode .toolbar .search-box,
body.light-mode .toolbar .filter-select,
body.light-mode .toolbar input[type="search"],
body.light-mode .toolbar input[type="date"],
body.light-mode .search-box,
body.light-mode .form-input,
body.light-mode .setting-row input,
body.light-mode .setting-row select,
body.light-mode .profile-section input:not([disabled]),
body.light-mode #chartMonth {
  background-color: #FFFFFF !important;
  color: #111827 !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

body.light-mode .sb-search-inner {
  background: var(--bg2) !important;
}

body.light-mode #sidebarSearch,
body.light-mode .search-box input,
body.light-mode .toolbar input::placeholder {
  color: var(--text) !important;
}

body.light-mode .toolbar .search-box svg,
body.light-mode .toolbar .search-box .icon,
body.light-mode #chartMonth::-webkit-calendar-picker-indicator {
  color: var(--text2) !important;
  filter: invert(0) !important;
}

body.light-mode .filter-select,
body.light-mode .setting-row select,
body.light-mode #settingsTimezone,
body.light-mode #settingsLanguage,
body.light-mode #settingsDateFormat {
  background-color: #FFFFFF !important;
  color: #111827 !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  padding: 8px 12px !important;
  border-radius: var(--radius-sm);
  appearance: none !important;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234B5563'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.8rem center !important;
  background-size: 1rem !important;
  padding-right: 2.5rem !important;
}

body.light-mode .panel-actions .btn-secondary,
body.light-mode .btn-secondary {
  background: #F3F4F6 !important;
  color: #374151 !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
}

body.light-mode .panel-actions .btn-secondary:hover,
body.light-mode .btn-secondary:hover {
  background: #E5E7EB !important;
  color: #111827 !important;
}

body.light-mode .btn-primary {
  background: var(--primary) !important;
  color: #FFFFFF !important;
}

body.light-mode .modal-head,
body.light-mode .modal-foot,
body.light-mode .profile-left {
  background-color: #F9FAFB !important;
  border-color: rgba(0, 0, 0, 0.10) !important;
  color: #111827 !important;
}

body.light-mode .modal-content h3,
body.light-mode .modal-content h4,
body.light-mode .profile-section h4,
body.light-mode .setting-row label,
body.light-mode .setting-info h4 {
  color: #111827 !important;
}

body.light-mode .form-input:disabled,
body.light-mode input:disabled {
  background-color: #F3F4F6 !important;
  color: #6B7280 !important;
  border-color: rgba(0, 0, 0, 0.05) !important;
}

body.light-mode .setting-row,
body.light-mode .settings-group,
body.light-mode .table-row {
  border-color: rgba(0, 0, 0, 0.08) !important;
}

body.light-mode .setting-info p,
body.light-mode .setting-row small,
body.light-mode .stat-label,
body.light-mode .empty-title,
body.light-mode .toast-msg {
  color: #4B5563 !important;
}


/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dim); }

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  padding: 24px;
  
}

body.login-page.light-mode {
  background: var(--bg) !important;
  color: var(--text);
  color-scheme: light;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(56,189,248,.06) 0%, transparent 65%);
  top: -200px; right: -200px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(52,211,153,.04) 0%, transparent 65%);
  bottom: -150px; left: -150px;
  pointer-events: none;
}

.login-wrap {
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 44px 40px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  text-align: center;
}
.login-brand-icon {
  width: 200px;
  height: 200px;
  border-radius: 18px;
  display: grid;
  place-items: center;
}

.login-brand-icon img{
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.login-brand-name {
  font-family: var(--font-head);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--primary);
  line-height: 1.1;
}
.login-brand-sub {
  font-size: .72rem;
  color: var(--text2);
  letter-spacing: .2em;
  text-transform: uppercase;
  font-weight: 600;
}

.login-card h2 {
  font-family: var(--font-head);
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card p.sub {
  font-size: .85rem;
  color: var(--text2);
  margin-bottom: 28px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field label { font-size: .78rem; font-weight: 600; color: var(--text2); letter-spacing: .03em; }
.login-field input {
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .88rem;
  transition: var(--transition);
}
.login-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.login-field input::placeholder { color: var(--text3); }

.login-btn {
  margin-top: 6px;
  padding: 13px;
  background: var(--primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-head);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .04em;
  transition: var(--transition);
}
.login-btn:hover {
  background: #60CDFF;
  transform: translateY(-1px);
  box-shadow: 0 4px 24px var(--primary-glow);
}
.forgot-password-btn,
.login-back-btn {
  display: block;
  margin: 14px auto 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--primary);
  font-size: .8rem;
  cursor: pointer;
}
.forgot-password-btn:hover,
.login-back-btn:hover { color: var(--primary-hover); text-decoration: underline; }
.login-back-btn { margin-top: -4px; color: var(--text2); }

#loginStatus {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .83rem;
  text-align: center;
  min-height: 36px;
  display: none;
}
#loginStatus.error   { display: block; background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(248,113,113,.25); }
#loginStatus.success { display: block; background: var(--green-dim); color: var(--green); border: 1px solid rgba(52,211,153,.25); }

/* ═══════════════════════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════════════════════ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  transition: transform var(--transition);
  overflow: hidden;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-brand-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.sb-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.sb-brand-text {
  font-family: var(--font-head);
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary);
  line-height: 1.1;
}
.sb-brand-sub {
  font-size: .66rem;
  color: var(--text2);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}

.sb-search {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
}
.sb-search-inner input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: .82rem;
}
.sb-search-inner input:focus { outline: none; }
.sb-search-inner input::placeholder { color: var(--text3); }
.sb-search-icon { color: var(--text3); font-size: 12px; }

.sb-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .85rem;
  font-weight: 600;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition), color var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.01);
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.nav-link::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(16,185,129,0.22), transparent);
  transition: width var(--transition);
}
.nav-link:hover {
  color: var(--text);
  background: linear-gradient(90deg, rgba(16,185,129,0.08), rgba(255,255,255,0.02));
  border-color: rgba(16,185,129,0.18);
  transform: translateX(3px);
  box-shadow: inset 0 0 0 1px rgba(16,185,129,0.08);
}
.nav-link:hover::before { width: 100%; }
.nav-link.active {
  color: var(--primary);
  background: linear-gradient(90deg, rgba(16,185,129,0.12), rgba(16,185,129,0.05));
  border-color: rgba(16,185,129,0.18);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(16,185,129,0.1);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  margin-left: 0;
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  filter: drop-shadow(0 0 8px rgba(16,185,129,0.28));
}

.nav-link-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.nav-link-copy small {
  color: var(--text3);
  font-size: .65rem;
  font-weight: 500;
  line-height: 1.2;
}

.nav-link.active .nav-link-copy small {
  color: var(--primary);
}

/* ─── Dropdown Menu Styles ─────────────────────────────────── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .85rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 45%;
  text-align: left;
  position: relative;
}

.nav-dropdown-toggle:hover {
  color: var(--text);
  background: var(--surface2);
}

.nav-dropdown-toggle.active {
  color: var(--primary);
  background: var(--primary-dim);
  font-weight: 600;
}

.nav-dropdown-toggle.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  margin-left: -10px;
}

.nav-dropdown-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.nav-dropdown-toggle.active .nav-dropdown-icon {
  transform: rotate(180deg);
}

/* Submenu Container */
.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height var(--transition), opacity var(--transition);
  pointer-events: none;
}

.nav-submenu.open {
  max-height: 500px;
  opacity: 1;
  pointer-events: auto;
}

/* Submenu Items */
.nav-submenu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px 8px 28px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .80rem;
  font-weight: 400;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.nav-submenu-item:hover {
  color: var(--text);
  background: var(--surface2);
  padding-left: 30px;
}

.nav-submenu-item.active {
  color: var(--primary);
  background: var(--primary-dim);
  font-weight: 500;
  padding-left: 26px;
}

.nav-submenu-item.active::before {
  content: '';
  position: absolute;
  left: 10px;
  width: 3px;
  height: 16px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.submenu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.nav-submenu-item:hover .submenu-icon,
.nav-submenu-item.active .submenu-icon {
  opacity: 1;
}

/* Mobile responsive - ensure touch-friendly sizes */
@media (max-width: 768px) {
  .nav-dropdown-toggle,
  .nav-submenu-item {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .nav-submenu-item {
    padding-left: 32px;
  }
}

.nav-badge {
  margin-left: auto;
  background: var(--primary-dim);
  color: var(--primary);
  font-size: .66rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sb-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 8px;
}
.sb-user:hover { background: var(--bg2); }
.sb-avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary-dim);
  border: 1px solid var(--border2);
  display: grid;
  place-items: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .75rem;
  color: var(--primary);
  flex-shrink: 0;
  overflow: hidden;
}
.sb-avatar img, .profile-av-lg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-user-name { font-size: .83rem; font-weight: 600; color: var(--text); }
.sb-user-role { font-size: .68rem; color: var(--text3); }

.btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .82rem;
  transition: var(--transition);
}
.btn-logout:hover { border-color: var(--red); color: var(--red); background: var(--red-dim); }

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-left { min-width: 0; }
.topbar-title {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub { font-size: .78rem; color: var(--text3); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.topbar-search input {
  border: none; background: transparent; color: var(--text);
  font-size: .83rem; width: 160px;
}
.topbar-search input:focus { outline: none; }
.topbar-search input::placeholder { color: var(--text3); }

.topbar-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  position: relative;
  color: var(--text2);
}
.topbar-icon:hover { border-color: var(--border2); color: var(--text); }

.notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}

/* ─── Page Body ───────────────────────────────────────────── */
.page-body {
  flex: 1;
  padding: 26px 28px;
}

.page-body > section {
  max-width: 1200px;
  margin: 0 auto;
}

.hidden { display: none !important; }

/* ─── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.page-header p { font-size: .78rem; color: var(--text3); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.subjects-page-header {
  align-items: center;
  padding: 4px 0 2px;
}

.subjects-page-intro {
  display: grid;
  gap: 4px;
}

.subjects-page-kicker {
  color: var(--primary);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.subjects-page-intro h2 {
  font-size: 1.25rem;
}

.subjects-page-intro p {
  margin: 0;
  color: var(--text3);
  font-size: .82rem;
}

/* ═══════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  place-items: center;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.c-blue::after   { background: var(--primary); }
.stat-card.c-green::after  { background: var(--green); }
.stat-card.c-yellow::after { background: var(--yellow); }
.stat-card.c-red::after    { background: var(--red); }
.stat-card.c-purple::after { background: var(--purple); }
.stat-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }

.c-blue   .stat-icon { background: var(--primary-dim); }
.c-green  .stat-icon { background: var(--green-dim); }
.c-yellow .stat-icon { background: var(--yellow-dim); }
.c-red    .stat-icon { background: var(--red-dim); }
.c-purple .stat-icon { background: var(--purple-dim); }

.stat-change {
  font-size: .68rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
}
.stat-change.up   { background: var(--green-dim);  color: var(--green); }
.stat-change.down { background: var(--red-dim);    color: var(--red); }
.stat-change.flat { background: var(--surface2);   color: var(--text3); }

.stat-value {
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  color: white;
}
.stat-label { font-size: .78rem; color: var(--text2); }

/* ═══════════════════════════════════════════════════════════
   PANELS / CARDS
   ═══════════════════════════════════════════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-padded { padding: 20px 22px; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.panel-body {
  padding: 20px 22px;
}
.panel-title { font-family: var(--font-head); font-size: .92rem; font-weight: 700; color: var(--text); }
.panel-sub   { font-size: .75rem; color: var(--text3); margin-top: 2px; }
.panel-actions { display: flex; gap: 8px; align-items: center; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.info-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.info-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  font-weight: 700;
  margin-bottom: 8px;
}

.info-value {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

/* ─── Chart ───────────────────────────────────────────────── */
.chart-area { padding: 20px 22px 14px; }
canvas { width: 100% !important; height: 200px; display: block; }

.chart-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

/* ═══════════════════════════════════════════════════════════
   CALENDAR
   ═══════════════════════════════════════════════════════════ */
.calendar-container {
  padding: 20px 22px 14px;
  background: var(--surface);
}

.calendar {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: min(100%, 760px);
  margin: 0 auto;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.calendar-weekday {
  text-align: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 0;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.calendar-day {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(145deg, var(--surface2), var(--surface));
  cursor: pointer;
  transition: all var(--transition);
  min-height: 84px;
  outline: none;
}

.calendar-day.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.calendar-day:not(.empty):hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
}

.calendar-day:not(.empty):focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.calendar-day.today {
  border: 2px solid var(--primary);
  background: var(--primary-dim) !important;
  font-weight: 700;
}

.calendar-day.selected {
  border-color: var(--primary) !important;
  box-shadow: inset 0 0 0 1px var(--primary), 0 8px 18px rgba(16, 185, 129, .12);
}

/* Status borders */
.calendar-day.status-full {
  background: var(--surface2);
  border-color: var(--green);
}

.calendar-day.status-good {
  background: var(--surface2);
  border-color: rgba(52, 211, 153, 0.6);
}

.calendar-day.status-medium {
  background: var(--surface2);
  border-color: rgba(251, 191, 36, 0.6);
}

.calendar-day.status-low {
  background: var(--surface2);
  border-color: rgba(239, 68, 68, 0.6);
}

body:not(.light-mode) .calendar-day.status-low {
  border-color: var(--border);
}

.day-number {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 7px;
}

.day-meta {
  color: var(--text3);
  font-size: .66rem;
  font-weight: 600;
  white-space: nowrap;
}

.calendar-legend,
.calendar-detail span {
  color: var(--text3);
  font-size: .68rem;
}

.calendar-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 2px 22px 17px;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.legend-full { background: var(--green); }
.legend-good { background: #34d399; }
.legend-medium { background: var(--yellow); }
.legend-low { background: var(--red); }

.calendar-detail {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 22px 20px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--primary-dim);
}

.calendar-detail > div {
  display: grid;
  gap: 2px;
}

.calendar-detail strong {
  color: var(--text);
  font-size: .76rem;
}

.calendar-detail-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #04120d !important;
  font-size: .72rem !important;
  font-weight: 800;
}

.calendar-detail-icon.muted {
  background: var(--surface2);
  color: var(--text2) !important;
}

.calendar-month-label {
  min-width: 132px;
  text-align: center;
  font-family: var(--font-head);
  font-size: .84rem;
  font-weight: 800;
  color: var(--text);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-dim);
}

.day-stats {
  display: flex;
  gap: 3px;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-badge {
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 20px;
  text-align: center;
  color: white;
}

.stat-badge.present {
  background: var(--green);
  color: white;
}

.stat-badge.absent {
  background: var(--red);
  color: white;
}

.stat-badge.late {
  background: var(--yellow);
  color: #000;
}

/* Light mode calendar fixes */
body.light-mode .calendar-container {
  background: #FFFFFF;
}

body.light-mode .calendar-day {
  background: #F9FAFB;
  border-color: rgba(0, 0, 0, 0.1);
  color: #111827;
}

body.light-mode .calendar-day.empty {
  background: transparent;
}

body.light-mode .calendar-day.status-full {
  background: #F9FAFB;
  border-color: var(--green);
}

body.light-mode .calendar-day.status-good {
  background: #F9FAFB;
  border-color: rgba(52, 211, 153, 0.7);
}

body.light-mode .calendar-day.status-medium {
  background: #F9FAFB;
  border-color: rgba(251, 191, 36, 0.7);
}

body.light-mode .calendar-day.status-low {
  background: #F9FAFB;
}

body.light-mode .calendar-day.today {
  background: rgba(16, 185, 129, 0.16) !important;
}

body.light-mode .day-number {
  color: #111827;
}

body.light-mode .calendar-weekday {
  color: #4B5563;
}

body.light-mode .calendar-day {
  background: linear-gradient(145deg, #ffffff, #f8fafc);
}

body.light-mode .icon-btn {
  background: #f8fafc;
}

@media (max-width: 640px) {
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .panel-actions {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-month-label {
    flex: 1;
  }

  .calendar-container {
    padding: 14px 10px 10px;
  }

  .calendar-days,
  .calendar-weekdays {
    gap: 4px;
  }

  .calendar-day {
    min-height: 58px;
    padding: 7px 2px;
  }

  .day-number {
    font-size: .84rem;
    margin-bottom: 4px;
  }

  .day-meta {
    font-size: .53rem;
  }

  .calendar-weekday {
    font-size: .62rem;
    letter-spacing: 0;
  }

  .calendar-legend {
    gap: 8px;
    justify-content: flex-start;
    padding: 2px 14px 14px;
  }

  .calendar-detail {
    margin: 0 14px 14px;
  }
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .84rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--bg); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: #60CDFF; box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text2); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border2); color: var(--text); }
.btn-danger { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,.3); }
.btn-danger:hover { background: rgba(248,113,113,.22); }
.btn-sm { padding: 5px 11px; font-size: .78rem; }

/* ═══════════════════════════════════════════════════════════
   TOOLBAR (above tables)
   ═══════════════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-box input { border: none; background: transparent; color: var(--text); font-size: .83rem; width: 190px; }
.search-box input:focus { outline: none; }
.search-box input::placeholder { color: var(--text3); }
.search-box svg { color: var(--text3); flex-shrink: 0; }

.filter-select {
  padding: 7px 28px 7px 11px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .82rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%234E6580' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  transition: var(--transition);
}
.filter-select:focus { outline: none; border-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════
   DATA TABLE
   ═══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 650px; }

thead tr { background: var(--surface2); }
th {
  padding: 11px 16px;
  text-align: left;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 13px 16px;
  font-size: .84rem;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }

.cb-cell { width: 42px; }
.cb-cell input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* ─── Table footer ────────────────────────────────────────── */
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.table-count { font-size: .78rem; color: var(--text3); }

.pagination { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: .78rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: var(--bg); border-color: var(--primary); font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
   ENTITY DISPLAY (avatars, names, pills)
   ═══════════════════════════════════════════════════════════ */
.ent-row { display: flex; align-items: center; gap: 10px; }
.ent-name { font-size: .86rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.ent-sub  { font-size: .73rem; color: var(--text3); }

.av {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .72rem;
  flex-shrink: 0;
  text-transform: uppercase;
}
.av-blue   { background: var(--primary-dim); color: var(--primary); }
.av-green  { background: var(--green-dim);   color: var(--green);   }
.av-yellow { background: var(--yellow-dim);  color: var(--yellow);  }
.av-purple { background: var(--purple-dim);  color: var(--purple);  }
.av-red    { background: var(--red-dim);     color: var(--red);     }
.av-orange { background: var(--orange-dim);  color: var(--orange);  }

.pill {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: .71rem; font-weight: 600; letter-spacing: .02em;
}
.pill-green  { background: var(--green-dim);    color: var(--green);   }
.pill-red    { background: var(--red-dim);      color: var(--red);     }
.pill-yellow { background: var(--yellow-dim);   color: var(--yellow);  }
.pill-blue   { background: var(--primary-dim);  color: var(--primary); }
.pill-purple { background: var(--purple-dim);   color: var(--purple);  }
.pill-grey   { background: var(--surface2);     color: var(--text3);   }
.pill-orange { background: var(--orange-dim);   color: var(--orange);  }

.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  padding: 2px 8px; border-radius: 99px;
  background: var(--surface3);
  color: var(--text2);
  font-size: .71rem; font-weight: 500;
}

/* ─── Row actions ─────────────────────────────────────────── */
.row-acts { display: flex; gap: 5px; }
.attendance-status-edit { position: relative; }
.attendance-status-choices { display: none; position: absolute; z-index: 5; right: 0; top: 0; gap: 3px; }
.attendance-status-edit.open .attendance-status-choices { display: flex; }
.attendance-status-edit.open .attendance-edit-btn { visibility: hidden; }
.attendance-status-choice { border: 1px solid var(--border); border-radius: 6px; padding: 6px 7px; background: var(--surface); color: var(--text2); cursor: pointer; font-size: 10px; white-space: nowrap; }
.attendance-status-choice:hover { border-color: var(--primary); background: var(--primary-dim); color: var(--primary); }
.present-choice:hover { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.absent-choice:hover { border-color: var(--red); background: var(--red-dim); color: var(--red); }
.attendance-edit-btn { font-size: 12px; }
.act-btn {
  width: 27px; height: 27px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 11px;
  transition: var(--transition);
}
.act-btn:hover             { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }
.act-btn.danger:hover      { border-color: var(--red);     color: var(--red);     background: var(--red-dim); }

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.user-management-count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text2);
  font-size: .78rem;
  font-weight: 600;
}
.user-management-search input { width: min(320px, 52vw); }
.user-management-table { min-width: 780px; }
.user-management-username {
  font-size: .78rem;
  color: var(--text3);
}
.password-target {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}
.password-rules {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
}
.password-rules span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text3);
  font-size: .76rem;
}
.password-rules span::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
}
.password-rules span.passed {
  color: var(--green);
}
.password-rules span.passed::before {
  background: var(--green);
}
.btn:disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(5px);
  display: grid; place-items: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow);
  animation: mIn .2s cubic-bezier(.34,1.56,.64,1);
}
.modal-box.wide { max-width: 680px; }
.modal-box.x-wide { max-width: 820px; }

.student-name-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.student-name-link:hover { text-decoration: underline; }
.student-profile-body { display: grid; gap: 16px; max-height: 75vh; }
.student-profile-title { margin: 0; color: var(--text); font-size: 1.1rem; }
.student-profile-section { display: grid; gap: 10px; min-width: 0; }
.student-profile-section h3 { margin: 0; color: var(--text); font-size: .92rem; }
.student-profile-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.student-profile-field { display: grid; gap: 3px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; }
.student-profile-field span { color: var(--text3); font-size: .7rem; }
.student-profile-field strong { overflow-wrap: anywhere; color: var(--text); font-size: .82rem; font-weight: 600; }
.student-profile-empty, .student-profile-notice { margin: 0; color: var(--text3); font-size: .8rem; }
.student-profile-notice { color: var(--yellow); }
.student-profile-section .table-wrap { max-width: 100%; }
.student-profile-section table { min-width: 700px; }
.student-portal { width: min(1180px, calc(100% - 32px)); margin: 32px auto; }
.student-portal-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.student-portal-header h1 { margin: 8px 0 4px; color: var(--text); font-family: var(--font-head); font-size: 1.5rem; }
.student-portal-header p { margin: 0; color: var(--text3); font-size: .86rem; }
.student-portal-status { margin: 16px 0; padding: 18px; border: 1px solid var(--border); border-radius: 12px; color: var(--text2); background: var(--surface); }
.student-portal-status p { margin: 0; }
.student-portal-error { color: var(--red); }
.student-portal-content { display: grid; gap: 18px; }
.student-portal-content > .student-profile-section { padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }

@keyframes mIn {
  from { opacity: 0; transform: scale(.93) translateY(12px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.modal-head h2 { font-family: var(--font-head); font-size: 1.05rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text3); cursor: pointer; display: grid; place-items: center;
  font-size: 15px; transition: var(--transition);
}
.modal-close:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }

.modal-body {
  padding: 22px 24px;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--surface);
}

.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
.form-grid   { display: grid; gap: 14px; }
.form-2col   { grid-template-columns: 1fr 1fr; display: grid; gap: 14px; }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.teacher-form-shell {
  max-width: 900px;
  margin: 0 auto;
}

.teacher-form-panel {
  border-radius: 16px;
  overflow: hidden;
}

.teacher-form-inner {
  padding: 18px 22px 22px;
}

.teacher-grade-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 760px;
  margin: 0 auto;
}

.field-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.field label,
.form-label {
  font-size: .77rem;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: .03em;
}
.form-label .req { color: var(--red); margin-left: 2px; }

.form-input, .form-select {
  padding: 9px 13px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .86rem;
  transition: var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-input::placeholder { color: var(--text3); }
.form-input[readonly] { background: var(--surface2); color: var(--text3); cursor: not-allowed; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%234E6580' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-color: var(--bg2);
  padding-right: 30px;
  cursor: pointer;
}

.input-row { display: flex; gap: 8px; }
.input-row .form-input { flex: 1; }

.form-hint { font-size: .73rem; color: var(--text3); margin-top: 2px; }

.school-logo-preview {
  display: block;
  width: 88px;
  height: 88px;
  margin-top: 10px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
}

.system-settings-heading {
  margin-bottom: 18px;
}

.system-settings-heading h2 {
  font-size: 1.25rem;
}

.system-settings-form {
  display: grid;
  gap: 16px;
  max-width: 1080px;
}

.system-settings-card {
  display: grid;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, var(--primary-dim), transparent 34%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.system-settings-card-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.system-settings-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border2);
  border-radius: 11px;
  background: var(--primary-dim);
  color: var(--primary);
}

.system-settings-icon svg {
  width: 18px;
  height: 18px;
}

.system-settings-card-heading h3 {
  margin: 1px 0 3px;
  color: var(--text);
  font-family: var(--font-head);
  font-size: .92rem;
  font-weight: 700;
}

.system-settings-card-heading p {
  margin: 0;
  color: var(--text3);
  font-size: .76rem;
  line-height: 1.5;
}

.system-settings-brand-grid {
  display: grid;
  grid-template-columns: minmax(220px, .9fr) minmax(320px, 1.1fr);
  align-items: center;
  gap: 24px;
}

.system-backup-date-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  max-width: 620px;
}

#backupRecoverySection:not(.hidden) {
  display: grid;
  gap: 16px;
}

#backupRecoverySection .admin-tool-heading {
  margin: 0;
}

#backupRecoverySection .admin-tool-heading p {
  margin: 4px 0 0;
}

#backupRecoverySection .panel-padded {
  padding: 18px 20px;
}

#backupRecoverySection .panel .panel-sub {
  max-width: 820px;
  margin: 5px 0 12px;
  line-height: 1.5;
}

.system-backup-datasets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 12px;
  margin: 10px 0 14px;
}

.system-backup-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text2);
  font-size: .82rem;
}

.system-backup-option input {
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.system-backup-restore-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.system-backup-restore-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.system-backup-status:empty {
  display: none;
}

.system-backup-status:not(:empty) {
  margin: 10px 0 0;
}

.system-backup-preview {
  max-width: 760px;
  margin: 10px 0;
  padding: 12px 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text2);
  font: inherit;
  white-space: pre-wrap;
}

#backupRecoverySection .system-backup-history-header {
  min-height: 0;
  padding: 0 0 12px;
  border: 0;
}

.school-logo-control {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.school-logo-preview-wrap {
  display: grid;
  flex: 0 0 104px;
  width: 104px;
  height: 104px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border2);
  border-radius: 14px;
  background: var(--bg2);
}

.school-logo-preview {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.school-logo-upload {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 7px;
}

.school-logo-file {
  padding: 7px;
  font-size: .78rem;
}

.school-logo-file::file-selector-button {
  margin-right: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.school-logo-file::file-selector-button:hover {
  border-color: var(--border2);
  color: var(--text);
}

.system-settings-input-suffix {
  position: relative;
}

.system-settings-input-suffix .form-input {
  padding-right: 68px;
}

.system-settings-input-suffix > span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--text3);
  font-size: .75rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.system-settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  cursor: pointer;
}

.system-settings-toggle > span {
  display: grid;
  gap: 3px;
}

.system-settings-toggle strong {
  color: var(--text2);
  font-size: .82rem;
}

.system-settings-toggle small {
  color: var(--text3);
  font-size: .73rem;
}

.system-settings-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.system-settings-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .12);
}

.system-settings-save-status {
  color: var(--text3);
  font-size: .78rem;
}

.system-settings-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 150px;
}

.system-settings-save svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 760px) {
  .system-settings-brand-grid {
    grid-template-columns: 1fr;
  }

  .system-backup-date-grid {
    grid-template-columns: 1fr;
  }

  .system-settings-card {
    padding: 18px;
  }
}

@media (max-width: 520px) {
  .school-logo-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .system-settings-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .system-settings-save {
    width: 100%;
  }
}

.form-divider {
  font-size: .71rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin: 4px 0;
}

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
#toastContainer {
  position: fixed;
  bottom: 22px; right: 22px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 270px; max-width: 350px;
  animation: tIn .28s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
}
@keyframes tIn { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }
.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title  { font-size: .84rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.toast-msg    { font-size: .78rem; color: var(--text2); margin-top: 1px; }
.toast-dismiss { color: var(--text3); cursor: pointer; font-size: 14px; flex-shrink: 0; transition: color var(--transition); }
.toast-dismiss:hover { color: var(--text); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--primary); }
.toast.warning { border-left: 3px solid var(--yellow); }

/* ═══════════════════════════════════════════════════════════
   SETTINGS MODAL
   ═══════════════════════════════════════════════════════════ */
.settings-layout {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 26px;
}
.settings-tabs { display: flex; flex-direction: column; gap: 5px; padding-right: 16px; border-right: 1px solid var(--border); }
.tab-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none; background: transparent;
  color: var(--text2);
  font-size: .83rem; cursor: pointer;
  text-align: left; transition: var(--transition);
}
.tab-btn:hover { background: var(--surface2); color: var(--text); }
.tab-btn.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.settings-panel { display: none; }
.settings-panel.active { display: grid; gap: 18px; }
.settings-panel h3 { font-family: var(--font-head); font-size: .95rem; font-weight: 700; margin-bottom: 4px; }

.setting-row { display: grid; gap: 6px; }
.tab-icon { width: 18px; color: var(--text3); font-size: 15px; text-align: center; }
.tab-btn.active .tab-icon { color: var(--primary); }
.settings-modal-subtitle { margin: 3px 0 0; color: var(--text3); font-size: .75rem; font-weight: 400; }
.setting-row label { font-size: .78rem; font-weight: 600; color: var(--text2); }
.settings-panel.active { display: grid; gap: 16px; }
.settings-panel h3 { font-family: var(--font-head); font-size: 1rem; font-weight: 700; margin: 0 0 5px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.setting-row input:focus, .setting-row select:focus { outline: none; border-color: var(--primary); }
.setting-row textarea { resize: vertical; min-height: 90px; }
.setting-hint { font-size: .73rem; color: var(--text3); }
.settings-modal-actions { display: flex; gap: 8px; }
.settings-save-hint { margin-right: auto; align-self: center; color: var(--text3); font-size: .72rem; }

.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.toggle-label { flex: 1; }
.toggle-label span { font-size: .78rem; font-weight: 600; color: var(--text2); display: block; }
.toggle-label small { font-size: .72rem; color: var(--text3); }

.toggle {
  position: relative;
  width: 46px; height: 25px;
  background: var(--surface3);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle input { display: none; }
.toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  background: #fff;
  border-radius: 50%;
  transition: left var(--transition);
}
.toggle input:checked ~ .toggle-knob { left: 24px; }
.toggle:has(input:checked) { background: var(--primary); }

/* ═══════════════════════════════════════════════════════════
   PROFILE MODAL
   ═══════════════════════════════════════════════════════════ */
.profile-modal-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
}
.profile-left {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  border-right: 1px solid var(--border);
  padding-right: 24px;
  background: var(--surface2);
  border-radius: 12px;
  padding: 16px;
}
.profile-av-lg {
  width: 90px; height: 90px;
  border-radius: 18px;
  background: var(--primary-dim);
  border: 2px solid var(--border2);
  display: grid; place-items: center;
  font-family: var(--font-head);
  font-weight: 800; font-size: 1.8rem;
  color: var(--primary);
  overflow: hidden;
}
.profile-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--primary-dim);
  color: var(--primary);
  font-size: .72rem; font-weight: 700;
}
.profile-right { display: grid; gap: 22px; }
.profile-section h4 { font-family: var(--font-head); font-size: .83rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.profile-section { display: grid; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.profile-section:last-child { border-bottom: none; padding-bottom: 0; }

.inline-edit { display: flex; gap: 7px; align-items: center; }
.inline-edit .form-input { flex: 1; }
.edit-btn {
  width: 33px; height: 33px;
  border: 1px solid var(--border); background: var(--surface2);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  cursor: pointer; font-size: 12px;
  transition: var(--transition);
}
.edit-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ═══════════════════════════════════════════════════════════
   GRADES SECTION SPECIFIC
   ═══════════════════════════════════════════════════════════ */
.grade-badge {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-head);
  font-weight: 800; font-size: .9rem;
}
.grade-A  { background: var(--green-dim);  color: var(--green); }
.grade-B  { background: var(--primary-dim); color: var(--primary); }
.grade-C  { background: var(--yellow-dim); color: var(--yellow); }
.grade-D  { background: var(--orange-dim); color: var(--orange); }
.grade-F  { background: var(--red-dim);    color: var(--red); }

.score-bar-wrap { flex: 1; height: 5px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.score-bar { height: 100%; border-radius: 99px; background: var(--green); }

/* ═══════════════════════════════════════════════════════════
   ATTENDANCE SECTION
   ═══════════════════════════════════════════════════════════ */
.att-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.att-mini {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.att-mini-val { font-family: var(--font-head); font-size: 1.4rem; font-weight: 800; }
.att-mini-lbl { font-size: .73rem; color: var(--text3); margin-top: 2px; }

.scanner-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 20px;
  align-items: center;
  margin: 18px 22px;
  padding: 16px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
}
.scanner-panel-copy { min-width: 0; }
.scanner-status {
  margin-top: 8px;
  color: var(--text3);
  font-size: .76rem;
}
.scanner-indicator {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-dim);
}
.scanner-indicator.busy { background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-dim); }
.scanner-indicator.success { background: var(--green); box-shadow: 0 0 0 4px var(--green-dim); }
.scanner-indicator.error,
.scanner-indicator.duplicate { background: var(--red); box-shadow: 0 0 0 4px var(--red-dim); }
.scanner-indicator.idle { background: var(--text3); box-shadow: 0 0 0 4px var(--surface); }
.scanner-result {
  grid-column: 1 / -1;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.scanner-result-title { color: var(--green); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.scanner-student-name { margin-top: 5px; color: var(--text); font-family: var(--font-head); font-size: 1.05rem; font-weight: 700; }
.scanner-detail { margin-top: 3px; color: var(--text2); font-size: .78rem; }
.scanner-result-status { margin-top: 8px; color: var(--green); font-family: var(--font-head); font-size: .95rem; font-weight: 800; }
.scanner-result-error .scanner-result-title,
.scanner-result-error .scanner-result-status { color: var(--red); }
.scanner-result-duplicate .scanner-result-title { color: var(--yellow); }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE / LOADER
   ═══════════════════════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  padding: 56px 20px;
  color: var(--text3);
  text-align: center;
}
.empty-icon { font-size: 2.6rem; opacity: .4; }
.empty-title { font-family: var(--font-head); font-size: .95rem; font-weight: 700; color: var(--text2); }
.empty-sub   { font-size: .8rem; max-width: 260px; line-height: 1.6; }

.loader { display: flex; justify-content: center; padding: 48px; }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   TIME / DATE cells
   ═══════════════════════════════════════════════════════════ */
.time-cell .date { display: block; font-size: .84rem; font-weight: 600; color: var(--text); }
.time-cell .time { font-size: .73rem; color: var(--text3); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .chart-row { grid-template-columns: 1fr; }
  .att-mini-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .scanner-panel { margin: 14px; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 256px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .settings-layout { grid-template-columns: 1fr; gap: 18px; }
  .settings-tabs { flex-direction: row; overflow-x: auto; padding-right: 0; padding-bottom: 8px; border-right: none; border-bottom: 1px solid var(--border); }
  .tab-btn { flex: 0 0 auto; }
  .profile-modal-layout { grid-template-columns: 1fr; }
  .profile-left { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 18px; }
  .form-2col { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .settings-modal-subtitle { max-width: 220px; line-height: 1.4; }
  .settings-save-hint { display: none; }
  .settings-modal-actions { width: 100%; }
  .settings-modal-actions .btn { flex: 1; }
}

/* ─── Month/Date inputs ───────────────────────────────────── */
input[type="month"], input[type="date"], input[type="time"], input[type="number"] {
  padding: 7px 11px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .82rem;
  cursor: pointer;
}
input[type="month"]:focus, input[type="date"]:focus, input[type="time"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ═══════════════════════════════════════════════════════════
   REPORTS & CHARTS
   ═══════════════════════════════════════════════════════════ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.chart-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.1);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.chart-header h3 {
  font-family: var(--font-head);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.chart-loader {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-body {
  position: relative;
  height: 300px;
}

.chart-card[style*="grid-column: 1 / -1"] .chart-body {
  height: 250px;
}

/* Chart.js customization */
canvas {
  max-height: 100%;
}

/* Summary stat cards */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1px solid var(--border2);
  transition: all var(--transition);
}

.stat-card.c-blue {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
  border-color: rgba(59, 130, 246, 0.2);
}

.stat-card.c-green {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
  border-color: rgba(16, 185, 129, 0.2);
}

.stat-card.c-purple {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-color: rgba(139, 92, 246, 0.2);
}

.stat-card.c-orange {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
  border-color: rgba(245, 158, 11, 0.2);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.15);
  border-color: var(--primary);
}

.stat-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.stat-change {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--green-dim);
  color: var(--green);
}

.stat-change.flat {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.stat-value {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-body {
    height: 250px;
  }

  .chart-card[style*="grid-column: 1 / -1"] .chart-body {
    height: 200px;
  }

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

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

  .chart-header h3 {
    font-size: 0.85rem;
  }

  .chart-body {
    height: 200px;
  }

  .stat-value {
    font-size: 24px;
  }
}

/* Print styles */
@media print {
  .page-header-actions,
  .toolbar,
  .pagination,
  .table-footer {
    display: none !important;
  }

  .chart-card,
  .stat-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  body {
    background: white;
    color: black;
  }

  .main-content section {
    background: white;
    color: black;
  }
}

/* Unified dashboard polish for Teacher, School Admin, and Web Admin. */
.admin-layout {
  background:
    radial-gradient(ellipse at 88% 0%, rgba(16, 185, 129, .045), transparent 34%),
    var(--bg);
}

.sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg2) 100%);
  box-shadow: 12px 0 36px rgba(0, 0, 0, .12);
}

.sb-brand {
  min-height: 86px;
  padding: 15px 18px;
}

.sb-brand-icon {
  overflow: hidden;
  border-radius: 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.sb-brand-text {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .06em;
}

.sb-nav {
  gap: 18px;
  padding-top: 18px;
}

.nav-group-label {
  padding: 0 10px;
  margin-bottom: 7px;
  letter-spacing: .13em;
}

.nav-link {
  min-height: 42px;
  border-radius: 10px;
  font-weight: 550;
}

.nav-link.active {
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, .08), 0 5px 14px rgba(0, 0, 0, .08);
}

.nav-icon {
  width: 20px;
  opacity: .86;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.sb-footer {
  padding: 13px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .08));
}

.sb-user {
  border: 1px solid var(--border);
}

.main-content {
  min-width: 0;
}

.dashboard-intro {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 0 0 20px;
  padding: 18px 20px;
  border: 1px solid var(--border2);
  border-radius: 15px;
  background:
    radial-gradient(ellipse at 0 50%, var(--primary-dim), transparent 60%),
    var(--surface);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .06);
}

.dashboard-intro-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border2);
  border-radius: 13px;
  background: var(--primary-dim);
  color: var(--primary);
}

.dashboard-intro-mark svg {
  width: 21px;
  height: 21px;
}

.dashboard-intro h2 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -.02em;
}

.dashboard-intro p {
  margin: 4px 0 0;
  color: var(--text3);
  font-size: .77rem;
  line-height: 1.5;
}

.topbar {
  min-height: 72px;
  padding: 12px 30px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 5px 24px rgba(0, 0, 0, .08);
  backdrop-filter: blur(14px);
}

.topbar-title {
  font-size: 1.06rem;
  letter-spacing: -.025em;
}

.topbar-sub {
  line-height: 1.35;
}

.topbar-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.page-body {
  padding-top: 30px;
  padding-bottom: 40px;
}

.page-header h2 {
  font-size: 1.18rem;
  letter-spacing: -.025em;
}

.page-header p {
  font-size: .8rem;
  line-height: 1.55;
}

.stats-grid {
  gap: 16px;
}

.stat-card {
  min-height: 142px;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
}

.stat-card::after {
  height: 3px;
  opacity: .82;
}

.stat-row {
  min-height: 23px;
}

.stat-value {
  color: var(--text);
  font-size: 1.85rem;
  letter-spacing: -.04em;
}

.stat-label {
  font-size: .75rem;
  letter-spacing: .01em;
}

.stat-change {
  border-radius: 999px;
  padding: 4px 9px;
}

.panel,
.chart-card {
  border-radius: 15px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .075);
}

.panel-header {
  min-height: 68px;
}

.panel-title {
  font-size: .94rem;
  letter-spacing: -.01em;
}

.panel-sub {
  line-height: 1.5;
}

.info-box {
  border-radius: 11px;
  padding: 17px;
}

.toolbar {
  gap: 12px;
}

.search-box,
.filter-select,
.form-input,
.form-select {
  min-height: 40px;
  border-radius: 9px;
}

.filter-select,
.form-input,
.form-select {
  color-scheme: dark;
}

body.light-mode .filter-select,
body.light-mode .form-input,
body.light-mode .form-select {
  color-scheme: light;
}

.btn {
  min-height: 38px;
  border-radius: 9px;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

table {
  border-spacing: 0;
}

thead tr {
  background: color-mix(in srgb, var(--surface2) 82%, var(--primary-dim));
}

th {
  padding-top: 13px;
  padding-bottom: 13px;
  letter-spacing: .075em;
}

td {
  padding-top: 14px;
  padding-bottom: 14px;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--surface2) 80%, var(--primary-dim));
}

.table-footer {
  min-height: 54px;
}

.chart-card {
  padding: 22px;
}

.chart-header {
  margin-bottom: 20px;
}

.chart-header h3 {
  letter-spacing: -.015em;
}

#overviewSection .chart-row,
#overviewSection .chart-card,
#overviewSection .admin-recent-activity {
  margin-bottom: 18px;
}

#overviewSection .stats-grid {
  margin-bottom: 20px;
}

#teacherTopbarTitle {
  color: var(--text);
}

@media (max-width: 860px) {
  .topbar {
    min-height: 64px;
    padding: 10px 18px;
  }

  .page-body {
    padding: 22px 18px 32px;
  }

  .sidebar {
    box-shadow: 18px 0 40px rgba(0, 0, 0, .24);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 9px 14px;
  }

  .page-body {
    padding: 18px 12px 28px;
  }

  .stat-card {
    min-height: 126px;
    padding: 15px;
  }

  .panel-header {
    padding: 15px 16px;
  }

  .panel-body {
    padding: 16px;
  }

  .dashboard-intro {
    align-items: flex-start;
    padding: 15px;
  }
}

@media (max-width: 860px) {
  .user-management-search,
  .user-management-search input,
  .user-management-toolbar .toolbar-left,
  .user-management-toolbar .toolbar-right {
    width: 100%;
  }
  .user-management-toolbar .filter-select {
    flex: 1 1 150px;
  }
}

@media (max-width: 640px) {
  .user-management-table {
    min-width: 0;
  }
  .user-management-table thead {
    display: none;
  }
  .user-management-table,
  .user-management-table tbody,
  .user-management-table tr,
  .user-management-table td {
    display: block;
    width: 100%;
  }
  .user-management-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .user-management-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 8px 0;
    border-bottom: 0;
    text-align: right;
  }
  .user-management-table td::before {
    content: attr(data-label);
    color: var(--text3);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
  }
  .user-management-table td:first-child {
    display: block;
    text-align: left;
  }
  .user-management-table td:first-child::before {
    display: none;
  }
  .table-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

/* ─── Fluid dashboard layout ─────────────────────────────── */
.main-content,
.page-body,
.panel,
.chart-card,
.topbar-left,
.toolbar-left,
.toolbar-right {
  min-width: 0;
}

.sidebar-backdrop,
.mobile-menu-toggle {
  display: none;
}

@media (max-width: 1100px) {
  .page-body { padding: 22px 20px; }
  .topbar { padding-left: 20px; padding-right: 20px; }
  .charts-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}

@media (max-width: 860px) {
  body.nav-open { overflow: hidden; }

  .teacher-grade-form {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .mobile-menu-toggle {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text2);
    font-size: 20px;
    line-height: 1;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    border: 0;
    background: rgba(0, 0, 0, .52);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }
  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar { padding: 13px 16px; }
  .topbar-left { display: flex; align-items: center; gap: 10px; }
  .topbar-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-body { padding: 18px 16px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1 1 150px; justify-content: center; }
  .toolbar { align-items: stretch; padding: 14px 16px; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .search-box, .search-box input { width: 100%; }
  .toolbar-right .filter-select { flex: 1 1 140px; }
  .table-footer { padding-left: 16px; padding-right: 16px; }
  .modal-overlay { padding: 12px; }
  .modal-box { max-height: calc(100vh - 24px); }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-body { padding: 18px 16px; max-height: 60vh; }
  .student-profile-body { max-height: 70vh; }
  .student-profile-fields { grid-template-columns: 1fr; }
  .student-portal-header { align-items: flex-start; }
  .student-portal-header h1 { font-size: 1.2rem; }
}

@media (max-width: 640px) {
  .topbar-title { font-size: 1rem; }
  .topbar-sub { display: none; }
  .topbar-right { margin-left: auto; }
  .page-body { padding: 14px 10px 24px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.55rem; }
  .stat-label { font-size: .7rem; }
  .panel-header { padding: 14px; }
  .panel-actions { flex-wrap: wrap; }
  .panel-actions .btn { flex: 1 1 auto; }
  .scanner-panel { margin: 10px; }
  .table-footer { flex-direction: column; align-items: stretch; gap: 10px; }
  .pagination { justify-content: flex-end; }
  .charts-grid { grid-template-columns: 1fr; gap: 14px; }
  .chart-card { padding: 14px; }
  .chart-header { align-items: flex-start; gap: 8px; }
  .chart-body { height: 220px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 120px; justify-content: center; }
  .input-row { flex-wrap: wrap; }
  .input-row .btn { width: 100%; justify-content: center; }
  .settings-modal-actions { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 0; }
  .calendar-month-label { min-width: 0; font-size: .76rem; }
  .calendar-detail { align-items: flex-start; }
  .calendar-detail > div { min-width: 0; }
  .calendar-detail span { display: block; }
  #toastContainer { right: 10px; bottom: 10px; left: 10px; }
  .toast { min-width: 0; max-width: none; }
}
/* ─── Web Admin system pages ──────────────────────────────── */
.system-maintenance-notice {
  margin: 0 0 18px;
  padding: 14px 18px;
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  background: var(--yellow-dim);
  color: var(--text);
  white-space: pre-wrap;
}
.admin-recent-activity { margin-bottom: 18px; }
.sb-brand-school {
  margin-top: 3px;
  color: var(--text3);
  font-size: .68rem;
  line-height: 1.3;
}
.audit-diff {
  max-width: 480px;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--text2);
  font: .76rem/1.5 var(--font-body);
}
.health-pill,
[data-health-status] {
  text-transform: capitalize;
}
[data-health-status][data-status="healthy"],
.health-pill[data-status="verified"] { color: var(--green); }
[data-health-status][data-status="warning"],
.health-pill[data-status="running"] { color: var(--yellow); }
[data-health-status][data-status="error"],
.health-pill[data-status="failed"] { color: var(--red); }
[data-health-status][data-status="unknown"] { color: var(--text3); }
.security-telemetry-notice p,
#backupRecoverySection .panel p {
  max-width: 900px;
  color: var(--text2);
  line-height: 1.65;
}

.admin-tool-heading {
  align-items: flex-end;
  margin-bottom: 18px;
}

.admin-tool-heading h2 {
  font-size: 1.25rem;
}

.admin-tool-heading p {
  max-width: 720px;
  margin-top: 5px;
  line-height: 1.55;
}

.admin-tool-heading .page-header-actions {
  align-items: center;
}

.admin-tool-count {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text2);
  font-size: .75rem;
  font-weight: 600;
}

.admin-tool-card {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.admin-tool-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.admin-tool-card-heading h3,
.admin-security-guidance h3 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-head);
  font-size: .9rem;
  font-weight: 700;
}

.admin-tool-card-heading p,
.admin-security-guidance p {
  margin: 4px 0 0;
  color: var(--text3);
  font-size: .75rem;
  line-height: 1.55;
}

.admin-audit-toolbar {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.admin-audit-toolbar .toolbar-left {
  width: 100%;
  gap: 9px;
}

.admin-audit-toolbar .filter-select {
  min-width: 145px;
}

.admin-audit-toolbar input[type="search"] {
  flex: 1 1 200px;
  min-width: 190px;
}

.admin-audit-toolbar .filter-date {
  font-size: .72rem;
}

.admin-audit-toolbar .filter-date .filter-select {
  min-width: 130px;
}

.admin-tool-card .table-wrap {
  border-top: 1px solid var(--border);
}

.admin-tool-card-heading + .table-wrap {
  border-top: 1px solid var(--border);
}

.admin-tool-card .table-footer {
  border-top: 1px solid var(--border);
}

.admin-audit-footnote {
  color: var(--text3);
  font-size: .72rem;
}

.admin-health-grid {
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 13px;
}

#systemMonitoringSection .stat-card {
  min-width: 0;
  padding: 17px;
}

.admin-health-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.admin-health-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  box-shadow: 0 0 0 4px var(--surface2);
}

#systemMonitoringSection [data-health-status] {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin: 14px 0 7px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg2);
  font-size: .77rem;
  font-weight: 700;
}

#systemMonitoringSection [data-health-status]::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

#systemMonitoringSection .stat-change {
  max-width: 100%;
  color: var(--text3);
  font-size: .7rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#systemMonitoringSection [data-health-status][data-status="healthy"] {
  border-color: rgba(16, 185, 129, .28);
  background: var(--green-dim);
}

#systemMonitoringSection [data-health-status][data-status="warning"] {
  border-color: rgba(251, 191, 36, .28);
  background: var(--yellow-dim);
}

#systemMonitoringSection [data-health-status][data-status="error"] {
  border-color: rgba(239, 68, 68, .28);
  background: var(--red-dim);
}

#systemMonitoringSection [data-health-status][data-status="unknown"] {
  border-color: var(--border);
  background: var(--bg2);
}

.security-status-card,
.admin-security-guidance {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--primary-dim), transparent 76%), var(--surface);
}

.security-status-icon,
.security-guidance-icon {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--primary-dim);
  color: var(--primary);
}

.security-status-icon svg,
.security-guidance-icon svg {
  width: 19px;
  height: 19px;
}

.security-status-card h3 {
  margin: 1px 0 5px;
  color: var(--text);
  font-family: var(--font-head);
  font-size: .88rem;
}

.security-status-card p {
  margin: 0;
  color: var(--text2);
  font-size: .76rem;
  line-height: 1.55;
}

.security-status-card .security-status-footnote {
  margin-top: 8px;
  color: var(--text3);
  font-size: .71rem;
}

.admin-security-guidance {
  margin-top: 4px;
  margin-bottom: 0;
  border-color: var(--border);
  background: var(--surface);
}

@media (max-width: 760px) {
  .admin-tool-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-tool-heading .page-header-actions {
    width: 100%;
  }

  .admin-audit-toolbar .toolbar-left {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-audit-toolbar .filter-select,
  .admin-audit-toolbar input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  .admin-audit-toolbar .filter-date {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-audit-toolbar .filter-date .filter-select {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .admin-tool-card-heading {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .admin-audit-toolbar {
    padding: 12px;
  }

  .admin-audit-toolbar .toolbar-left {
    grid-template-columns: 1fr;
  }

  .security-status-card,
  .admin-security-guidance {
    padding: 15px;
  }
}
.filter-date {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
  font-size: .8rem;
}
.filter-date .filter-select { min-width: 140px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--text2);
}
.setting-row input[type="checkbox"] { accent-color: var(--primary); }

#overviewSection .dashboard-intro {
  margin-bottom: 14px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

#overviewSection .dashboard-intro h2 {
  font-size: 1.08rem;
}

#overviewSection .dashboard-intro p {
  margin-top: 2px;
}

#overviewSection .dashboard-stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

#overviewSection .dashboard-stats-grid .stat-card {
  min-height: 0;
  padding: 15px 18px;
  text-align: left;
}

#overviewSection .dashboard-stats-grid .stat-value {
  font-size: 1.65rem;
}

#overviewSection .dashboard-chart-row {
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .85fr);
  align-items: start;
  gap: 16px;
}

#overviewSection .dashboard-chart-row > .panel {
  min-width: 0;
  margin-bottom: 0;
}

#overviewSection .calendar {
  width: 100%;
}

#overviewSection .dashboard-insights {
  display: grid;
  min-width: 0;
  gap: 16px;
}

#overviewSection .dashboard-chart-card {
  min-width: 0;
  margin-bottom: 0;
  padding: 18px;
}

#overviewSection .dashboard-chart-card .chart-header {
  margin-bottom: 8px;
}

#overviewSection .dashboard-chart-card .chart-body {
  height: auto;
}

#overviewSection .dashboard-grade-table {
  min-width: 0;
}

#overviewSection .dashboard-grade-table th:last-child,
#overviewSection .dashboard-grade-table td:last-child {
  text-align: right;
}

.dashboard-chart-empty {
  display: grid;
  margin: 0;
  padding: 16px 0;
  place-items: center;
  color: var(--text3);
  font-size: .82rem;
  text-align: center;
}

.dashboard-chart-card canvas[hidden] {
  display: none;
}

.calendar-month-select {
  min-width: 158px;
  max-width: 190px;
}

.calendar-source {
  padding: 0 22px 16px;
  color: var(--text3);
  font-size: .68rem;
  text-align: center;
}

.calendar-source a {
  color: var(--primary);
}

.calendar-day.holiday,
.calendar-day.break {
  border-color: rgba(251, 191, 36, .68);
  background: rgba(251, 191, 36, .12);
}

.calendar-day.past:not(.weekend) {
  border-color: rgba(148, 163, 184, .35);
  background: rgba(100, 116, 139, .14);
  opacity: .62;
}

.calendar-day.outside-school-year {
  background: rgba(100, 116, 139, .1);
  opacity: .58;
}

.calendar-day.weekend {
  border-color: rgba(148, 163, 184, .42);
  background: #374151;
  color: #cbd5e1;
  opacity: .9;
}

.calendar-day.weekend.today,
body.light-mode .calendar-day.weekend.today {
  background: #374151 !important;
}

.calendar-day[aria-disabled="true"] {
  cursor: not-allowed;
}

.calendar-day[aria-disabled="true"]:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}

.legend-weekend { background: #64748b; }
.legend-holiday { background: var(--yellow); }
.legend-past { background: #94a3b8; }

body.light-mode .calendar-day.holiday,
body.light-mode .calendar-day.break {
  background: #fff7df;
}

body.light-mode .calendar-day.past:not(.weekend) {
  background: #e5e7eb;
  opacity: .75;
}

body.light-mode .calendar-day.weekend,
body.light-mode .calendar-day.weekend.today {
  background: #d1d5db !important;
  color: #374151;
}

@media (max-width: 1100px) {
  #overviewSection .dashboard-chart-row {
    grid-template-columns: 1fr;
  }

  #overviewSection .dashboard-insights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  #overviewSection .dashboard-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #overviewSection .dashboard-insights {
    grid-template-columns: 1fr;
  }

  .calendar-month-select {
    min-width: 135px;
    max-width: none;
  }

  .calendar-source {
    padding-right: 14px;
    padding-left: 14px;
  }
}
