
/* =========================
   CSS VARIABLES
   ========================= */
:root {
  --primary: #4F46E5;
  --primary-light: #6366F1;
  --accent: #06B6D4;
  --danger: #EF4444;
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  
  --header-height: 70px;
  --sidebar-width: 300px;
  --border-radius: 14px;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  --bg-body: #F7F8FA;
  --bg-card: #FFFFFF;
  --sidebar-bg: #F3F4F6;
  --sidebar-divider: #E5E7EB;
  --sidebar-text: #374151;
  --sidebar-text-dim: #6B7280;
  --sidebar-hover: rgba(55, 65, 81, 0.06);
  --sidebar-active: rgba(99, 102, 241, 0.10);
  --sidebar-active-border: #4F46E5;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.08);
  --transition: 0.25s ease;
  
  --z-sidebar: 1000;
  --z-backdrop: 1010;
  --z-header: 1020;
  --z-flyout: 1030;
  --z-mobile-menu: 1040;
  --z-modal: 2000;
  --z-overlay: 9000;
}

[data-theme="dark"] {
  --bg-body: #0F172A;
  --bg-card: #111827;
  --sidebar-bg: #1F2937;
  --sidebar-divider: #2B3340;
  --sidebar-text: #E5E7EB;
  --sidebar-text-dim: #A7AFBD;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.09);
  --sidebar-active-border: #6366F1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif !important;
  background: var(--bg-body);
  color: #111827;
  line-height: 1.6;
}

[data-theme="dark"] body {
  color: #E5E7EB;
}

html, body {
  overscroll-behavior: none;
}

html.menu-open,
body.menu-open {
  overflow: hidden;
}

/* =========================
   HEADER
   ========================= */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid rgba(17, 24, 39, 0.06);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0 1.1rem;
  z-index: var(--z-header);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .app-header {
  background: var(--bg-card);
  border-color: #1f2530;
  color: #E5E7EB;
}

.app-title {
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  margin: 0;
}

.page-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
  padding: 0.35rem 0.55rem;
  border-radius: 14px;
  background: rgba(79, 70, 229, 0.06);
  border: 1px solid rgba(79, 70, 229, 0.10);
}

.page-indicator .page-home {
  border: 0;
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.page-indicator .page-home:hover {
  background: var(--gray-200);
}

[data-theme="dark"] .page-indicator .page-home {
  background: rgba(255, 255, 255, 0.08);
  color: #E5E7EB;
}

[data-theme="dark"] .page-indicator .page-home:hover {
  background: rgba(255, 255, 255, 0.14);
}

.page-indicator .page-title {
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .page-indicator .page-title {
  color: #E5E7EB;
}

.page-indicator .page-subtitle {
  font-size: 0.82rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .page-indicator .page-subtitle {
  color: #A7AFBD;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6B7280;
  cursor: pointer;
  background: none;
  border: none;
  transition: background 0.2s ease;
}

.menu-toggle:hover {
  background: var(--gray-100);
}

[data-theme="dark"] .menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-info {
  line-height: 1.15;
}

#user-info small {
  font-size: 0.78rem;
}

#user-info strong {
  font-size: 0.98rem;
  font-weight: 700;
}

@media (max-width: 992px) {
  .page-indicator {
    padding: 0.25rem 0.4rem;
    border-radius: 12px;
    background: transparent;
    border-color: transparent;
  }

  .page-indicator .page-subtitle {
    display: none;
  }

  .page-indicator .page-home {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
}

.header-link {
  background: none;
  border: 0;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.header-link:hover {
  background: var(--gray-100);
}

.header-link.danger {
  color: var(--danger);
}

[data-theme="dark"] .header-link {
  color: #E5E7EB;
}

[data-theme="dark"] .header-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* =========================
   SIDEBAR
   ========================= */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  height: calc(100vh - var(--header-height));
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-divider);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  transition: transform 0.3s ease;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-search {
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  z-index: 2;
  border-bottom: 1px solid var(--sidebar-divider);
  padding: 0.8rem var(--spacing-md);
}

.sidebar-search .search-input {
  position: relative;
}

.sidebar-search input {
  width: 100%;
  border-radius: 10px;
  padding: 0.6rem 0.9rem 0.6rem 2.25rem;
  outline: none;
  background: var(--bg-card);
  color: var(--sidebar-text);
  border: 1px solid var(--sidebar-divider);
  font-size: 0.95rem;
  font-family: inherit;
}

.sidebar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.sidebar-search i {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sidebar-text-dim);
  pointer-events: none;
}

.sidebar-search .search-clear {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--sidebar-text-dim);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar.searching .sidebar-search .search-clear {
  display: inline-flex;
}

.sidebar-search .search-clear:hover {
  background: var(--sidebar-hover);
}

.nav-label mark {
  padding: 0 0.15em;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.18);
  color: inherit;
}

.fav-toggle {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--sidebar-text-dim);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.fav-toggle:hover {
  background: var(--sidebar-hover);
}

.fav-toggle.active {
  color: #F59E0B;
}

.menu-group {
  margin: 0;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--sidebar-divider);
  list-style: none;
}

.menu-group:last-child {
  border-bottom: 0;
}


.menu-header > i {
  font-size: 1.15rem;
  margin-right: 0.5rem;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem var(--spacing-md);
  cursor: pointer;
  user-select: none;
  background: transparent;
  color: var(--sidebar-text);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.menu-header:hover {
  background: var(--sidebar-hover);
}

.menu-header.active,
.menu-header.flyout-active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-border);
}

.menu-header .toggle-icon {
  margin-left: auto;
  color: var(--sidebar-text-dim);
  transition: transform 0.25s ease;
}

.nav-item {
  margin: 0;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem var(--spacing-md);
  color: var(--sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.nav-link i {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: transform 0.2s ease, background 0.2s ease;
}

.nav-link:hover i {
  transform: scale(1.1);
}

/* --- Colorful Icon Badges per Menu Group --- */
[aria-label="หน้าหลัก"] .nav-link i {
  background: rgba(79, 70, 229, 0.12);
  color: #4F46E5;
}
[aria-label="ตั้งค่าและดูแลระบบ"] .nav-link i {
  background: rgba(124, 58, 237, 0.12);
  color: #7C3AED;
}
[aria-label="ข้อมูลนักเรียน"] .nav-link i {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}
[aria-label="เวลาเรียน"] .nav-link i {
  background: rgba(6, 182, 212, 0.12);
  color: #0891B2;
}
[aria-label="คะแนนและผลการเรียน"] .nav-link i {
  background: rgba(245, 158, 11, 0.12);
  color: #D97706;
}
[aria-label="ประเมินผล"] .nav-link i {
  background: rgba(236, 72, 153, 0.12);
  color: #DB2777;
}
[aria-label="พิมพ์เอกสารและรายงาน"] .nav-link i {
  background: rgba(99, 102, 241, 0.12);
  color: #4F46E5;
}
[aria-label="ผู้ปกครอง"] .nav-link i {
  background: rgba(217, 119, 6, 0.12);
  color: #B45309;
}
[aria-label="ช่วยเหลือ"] .nav-link i {
  background: rgba(14, 165, 233, 0.12);
  color: #0284C7;
}
[aria-label="บัญชีผู้ใช้"] .nav-link i {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

/* --- Menu Header Icon Colors --- */
[aria-label="หน้าหลัก"] .menu-header i.fas,
[aria-label="หน้าหลัก"] .menu-header i.bi { color: #4F46E5; }
[aria-label="ตั้งค่าและดูแลระบบ"] .menu-header i.fas,
[aria-label="ตั้งค่าและดูแลระบบ"] .menu-header i.bi { color: #7C3AED; }
[aria-label="ข้อมูลนักเรียน"] .menu-header i.fas,
[aria-label="ข้อมูลนักเรียน"] .menu-header i.bi { color: #059669; }
[aria-label="สุขภาพนักเรียน"] .menu-header i.bi { color: #EF4444; }
[aria-label="เวลาเรียน"] .menu-header i.fas,
[aria-label="เวลาเรียน"] .menu-header i.bi { color: #0891B2; }
[aria-label="คะแนนและผลการเรียน"] .menu-header i.fas,
[aria-label="คะแนนและผลการเรียน"] .menu-header i.bi { color: #D97706; }
[aria-label="ประเมินผล"] .menu-header i.fas,
[aria-label="ประเมินผล"] .menu-header i.bi { color: #DB2777; }
[aria-label="พิมพ์เอกสารและรายงาน"] .menu-header i.fas,
[aria-label="พิมพ์เอกสารและรายงาน"] .menu-header i.bi { color: #4F46E5; }
[aria-label="ผู้ปกครอง"] .menu-header i.fas,
[aria-label="ผู้ปกครอง"] .menu-header i.bi { color: #B45309; }
[aria-label="ช่วยเหลือ"] .menu-header i.fas,
[aria-label="ช่วยเหลือ"] .menu-header i.bi { color: #0284C7; }
[aria-label="บัญชีผู้ใช้"] .menu-header i.fas,
[aria-label="บัญชีผู้ใช้"] .menu-header i.bi { color: #475569; }

/* toggle-icon ไม่ต้องมีสี */
.menu-header .toggle-icon i {
  color: var(--sidebar-text-dim) !important;
  background: none !important;
  width: auto !important;
  height: auto !important;
}

/* --- Dark Mode Icon Adjustments --- */
[data-theme="dark"] [aria-label="หน้าหลัก"] .nav-link i { background: rgba(99, 102, 241, 0.18); color: #818CF8; }
[data-theme="dark"] [aria-label="ตั้งค่าและดูแลระบบ"] .nav-link i { background: rgba(139, 92, 246, 0.18); color: #A78BFA; }
[data-theme="dark"] [aria-label="ข้อมูลนักเรียน"] .nav-link i { background: rgba(52, 211, 153, 0.18); color: #34D399; }
[data-theme="dark"] [aria-label="เวลาเรียน"] .nav-link i { background: rgba(34, 211, 238, 0.18); color: #22D3EE; }
[data-theme="dark"] [aria-label="คะแนนและผลการเรียน"] .nav-link i { background: rgba(251, 191, 36, 0.18); color: #FBBF24; }
[data-theme="dark"] [aria-label="ประเมินผล"] .nav-link i { background: rgba(244, 114, 182, 0.18); color: #F472B6; }
[data-theme="dark"] [aria-label="พิมพ์เอกสารและรายงาน"] .nav-link i { background: rgba(129, 140, 248, 0.18); color: #818CF8; }
[data-theme="dark"] [aria-label="ผู้ปกครอง"] .nav-link i { background: rgba(251, 191, 36, 0.18); color: #FBBF24; }
[data-theme="dark"] [aria-label="ช่วยเหลือ"] .nav-link i { background: rgba(56, 189, 248, 0.18); color: #38BDF8; }
[data-theme="dark"] [aria-label="บัญชีผู้ใช้"] .nav-link i { background: rgba(148, 163, 184, 0.18); color: #94A3B8; }
[data-theme="dark"] .menu-header i.fas,
[data-theme="dark"] .menu-header i.bi { color: inherit; }

.nav-link:hover {
  background: var(--sidebar-hover);
}

.nav-item.active .nav-link {
  background: var(--sidebar-active);
  border-left-color: var(--sidebar-active-border);
  font-weight: 600;
}

.nav-item.active .nav-link i {
  color: #fff !important;
  background: var(--sidebar-active-border) !important;
}

/* =========================
   BACKDROP
   ========================= */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* =========================
   FLYOUT
   ========================= */
.submenu-flyout {
  position: fixed;
  min-width: 260px;
  max-width: 320px;
  background: var(--bg-card);
  color: var(--sidebar-text);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: var(--z-flyout);
  display: none;
  padding: 10px;
  backdrop-filter: blur(12px);
  animation: flyoutIn 0.2s ease-out;
}

@keyframes flyoutIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

[data-theme="dark"] .submenu-flyout {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(31, 41, 55, 0.95);
}

.submenu-flyout .nav-link {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: none !important;
}

.submenu-flyout .nav-link:last-child {
  margin-bottom: 0;
}

.submenu-flyout .nav-link i {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px; /* เพิ่มระยะห่างระหว่างไอคอนกับข้อความ */
  font-size: 1.1rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  /* สีไอคอนเริ่มต้น */
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
}

.submenu-flyout .nav-link:hover {
  background: var(--sidebar-hover);
  transform: translateX(4px);
}

.submenu-flyout .nav-link:hover i {
  transform: scale(1.1);
}

/* --- Flyout Icon Colors per Group --- */
.submenu-flyout[data-group="หน้าหลัก"] .nav-link i { background: rgba(79, 70, 229, 0.12); color: #4F46E5; }
.submenu-flyout[data-group="ตั้งค่าและดูแลระบบ"] .nav-link i { background: rgba(124, 58, 237, 0.12); color: #7C3AED; }
.submenu-flyout[data-group="ข้อมูลนักเรียน"] .nav-link i { background: rgba(16, 185, 129, 0.12); color: #059669; }
.submenu-flyout[data-group="เวลาเรียน"] .nav-link i { background: rgba(6, 182, 212, 0.12); color: #0891B2; }
.submenu-flyout[data-group="คะแนนและผลการเรียน"] .nav-link i { background: rgba(245, 158, 11, 0.12); color: #D97706; }
.submenu-flyout[data-group="ประเมินผล"] .nav-link i { background: rgba(236, 72, 153, 0.12); color: #DB2777; }
.submenu-flyout[data-group="พิมพ์เอกสารและรายงาน"] .nav-link i { background: rgba(99, 102, 241, 0.12); color: #4F46E5; }
.submenu-flyout[data-group="ผู้ปกครอง"] .nav-link i { background: rgba(217, 119, 6, 0.12); color: #B45309; }
.submenu-flyout[data-group="ช่วยเหลือ"] .nav-link i { background: rgba(14, 165, 233, 0.12); color: #0284C7; }
.submenu-flyout[data-group="บัญชีผู้ใช้"] .nav-link i { background: rgba(100, 116, 139, 0.12); color: #475569; }

.submenu-flyout .nav-link:hover i {
  color: white;
}
.submenu-flyout[data-group="หน้าหลัก"] .nav-link:hover i { background: #4F46E5; }
.submenu-flyout[data-group="ตั้งค่าและดูแลระบบ"] .nav-link:hover i { background: #7C3AED; }
.submenu-flyout[data-group="ข้อมูลนักเรียน"] .nav-link:hover i { background: #059669; }
.submenu-flyout[data-group="เวลาเรียน"] .nav-link:hover i { background: #0891B2; }
.submenu-flyout[data-group="คะแนนและผลการเรียน"] .nav-link:hover i { background: #D97706; }
.submenu-flyout[data-group="ประเมินผล"] .nav-link:hover i { background: #DB2777; }
.submenu-flyout[data-group="พิมพ์เอกสารและรายงาน"] .nav-link:hover i { background: #4F46E5; }
.submenu-flyout[data-group="ผู้ปกครอง"] .nav-link:hover i { background: #B45309; }
.submenu-flyout[data-group="ช่วยเหลือ"] .nav-link:hover i { background: #0284C7; }
.submenu-flyout[data-group="บัญชีผู้ใช้"] .nav-link:hover i { background: #475569; }

.submenu-flyout .nav-link.danger i { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

/* Dark mode flyout */
[data-theme="dark"] .submenu-flyout[data-group="หน้าหลัก"] .nav-link i { background: rgba(99, 102, 241, 0.18); color: #818CF8; }
[data-theme="dark"] .submenu-flyout[data-group="ตั้งค่าและดูแลระบบ"] .nav-link i { background: rgba(139, 92, 246, 0.18); color: #A78BFA; }
[data-theme="dark"] .submenu-flyout[data-group="ข้อมูลนักเรียน"] .nav-link i { background: rgba(52, 211, 153, 0.18); color: #34D399; }
[data-theme="dark"] .submenu-flyout[data-group="เวลาเรียน"] .nav-link i { background: rgba(34, 211, 238, 0.18); color: #22D3EE; }
[data-theme="dark"] .submenu-flyout[data-group="คะแนนและผลการเรียน"] .nav-link i { background: rgba(251, 191, 36, 0.18); color: #FBBF24; }
[data-theme="dark"] .submenu-flyout[data-group="ประเมินผล"] .nav-link i { background: rgba(244, 114, 182, 0.18); color: #F472B6; }
[data-theme="dark"] .submenu-flyout[data-group="พิมพ์เอกสารและรายงาน"] .nav-link i { background: rgba(129, 140, 248, 0.18); color: #818CF8; }
[data-theme="dark"] .submenu-flyout[data-group="ผู้ปกครอง"] .nav-link i { background: rgba(251, 191, 36, 0.18); color: #FBBF24; }
[data-theme="dark"] .submenu-flyout[data-group="ช่วยเหลือ"] .nav-link i { background: rgba(56, 189, 248, 0.18); color: #38BDF8; }
[data-theme="dark"] .submenu-flyout[data-group="บัญชีผู้ใช้"] .nav-link i { background: rgba(148, 163, 184, 0.18); color: #94A3B8; }

/* =========================
   MAIN CONTENT
   ========================= */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: var(--spacing-xl);
  min-height: calc(100vh - var(--header-height));
  transition: margin-left 0.3s ease;
}

.main-content.expanded {
  margin-left: 0;
}

.content-card {
  background: var(--bg-card);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xl);
  border: 1px solid var(--gray-200);
  position: relative;
}

.content-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 18px 18px 0 0;
}

[data-theme="dark"] .content-card {
  border-color: #232a36;
}

/* =========================
   MOBILE QUICK MENU
   ========================= */
.mobile-quick-menu {
  display: none;
}

/* =========================
   DESKTOP (min-width: 992px)
   ========================= */
@media (min-width: 992px) {
  .menu-group .nav-item {
    display: none;
  }
  
  .menu-header .toggle-icon {
    display: none;
  }
  
  .menu-header::after {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: auto;
    color: var(--sidebar-text-dim);
    font-size: 0.85rem;
    transition: color 0.2s ease;
  }
  
  .menu-header.flyout-active::after {
    color: var(--sidebar-active-border);
  }

  .sidebar.searching .menu-group .nav-item {
    display: block;
  }
}

/* =========================
   MOBILE (max-width: 991.98px)
   ========================= */
@media (max-width: 991.98px) {
  :root {
    --header-height: 56px;
  }
  
  .app-header {
    height: 56px;
    padding: 0 0.75rem;
    gap: 0.5rem;
  }
  
  .main-content {
    margin-left: 0;
    padding: 0;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  
  .content-card {
    padding: 0.25rem;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  
  .content-card::before {
    display: none;
  }
  
  .sidebar {
    transform: translateX(-100%);
    z-index: var(--z-mobile-menu);
    width: min(300px, 85vw);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }
  
  .menu-group .nav-item {
    display: block;
    max-height: 200px;
    opacity: 1;
    overflow: visible;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
  }
  
  .menu-group.menu-collapsed .nav-item {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0;
  }
  
  .menu-group.menu-collapsed .menu-header .toggle-icon {
    transform: rotate(0deg);
  }
  
  .menu-group:not(.menu-collapsed) .menu-header .toggle-icon {
    transform: rotate(180deg);
  }
  
  .nav-link,
  .menu-header {
    padding: 1rem var(--spacing-md);
    min-height: 48px;
  }
  
  .menu-toggle {
    min-width: 48px;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }
  
  .menu-toggle i {
    font-size: 1.5rem;
    pointer-events: none;
  }
  
  .mobile-quick-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--gray-200);
    backdrop-filter: blur(6px);
    z-index: var(--z-mobile-menu);
  }
  
  [data-theme="dark"] .mobile-quick-menu {
    background: rgba(17, 24, 39, 0.96);
    border-top-color: #232a36;
  }
  
  .mobile-quick-menu .quick-btn {
    appearance: none;
    border: 0;
    background: var(--gray-100);
    border-radius: 12px;
    padding: 8px 6px;
    font-size: 0.82rem;
    font-family: inherit;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease;
  }
  
  .mobile-quick-menu .quick-btn:active {
    background: var(--gray-200);
  }
  
  [data-theme="dark"] .mobile-quick-menu .quick-btn {
    background: #1f2937;
    color: #e5e7eb;
  }
  
  .mobile-quick-menu .quick-btn i {
    display: block;
    font-size: 1.05rem;
    margin-bottom: 4px;
  }
  
  .header-actions {
    gap: 0.25rem;
    flex-shrink: 0;
  }
  
  .header-link span {
    display: none;
  }
  
  .header-link {
    padding: 0.4rem;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .header-link i {
    margin: 0;
    font-size: 1.2rem;
  }
}

/* =========================
   PRINT
   ========================= */
@media print {
  .sidebar,
  .app-header,
  .mobile-quick-menu,
  .sidebar-backdrop,
  .menu-toggle {
    display: none;
  }
  
  .main-content {
    margin: 0;
    padding: 0;
  }
  
  .content-card {
    box-shadow: none;
    border: 1px solid #000;
  }
}

/* =========================
   LOGO
   ========================= */
.app-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  flex-shrink: 0;
  min-width: 0;
  min-height: 46px;
  padding: 0.28rem 0.45rem 0.28rem 0.25rem;
  border-radius: 14px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.app-brand:hover {
  background: rgba(79, 70, 229, 0.06);
}

@media (max-width: 992px) {
  .app-brand {
    gap: 0.5rem;
    min-height: 40px;
    padding-right: 0.25rem;
  }
}

.logo-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #4F46E5 0%, #06B6D4 100%);
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  overflow: hidden;
}

.logo-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 72% 20%, rgba(255, 255, 255, 0.42) 0 7px, transparent 8px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 48%);
  pointer-events: none;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  z-index: 1;
  filter: drop-shadow(0 3px 5px rgba(15, 23, 42, 0.18));
}

.brand-mark .sheet {
  fill: #ffffff;
}

.brand-mark .fold {
  fill: #CFFAFE;
}

.brand-mark .line {
  stroke: #4F46E5;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.brand-mark .chart {
  fill: none;
  stroke: #06B6D4;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark .check {
  fill: none;
  stroke: #10B981;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-wordmark {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1;
}

.brand-text {
  font-weight: 800;
  letter-spacing: 0;
  font-family: 'Sarabun', sans-serif;
  font-size: 1.55rem;
  color: var(--gray-900);
  white-space: nowrap;
  line-height: 1;
}

.brand-text .brand-p5 {
  color: var(--primary);
}

.brand-text .brand-smart {
  color: #0F172A;
}

.brand-tagline {
  margin-top: 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  text-transform: uppercase;
  white-space: nowrap;
}

@media (max-width: 992px) {
  .logo-wrapper {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
  }

  .brand-text {
    font-size: 1.22rem;
  }

  .brand-tagline {
    display: none;
  }
}

@media (max-width: 720px) {
  .brand-wordmark {
    display: none;
  }
}

[data-theme="dark"] .app-brand:hover {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .brand-text .brand-smart {
  color: #F8FAFC;
}

[data-theme="dark"] .brand-tagline {
  color: #94A3B8;
}

.logo-placeholder,
.app-logo-img,
.logo-fallback-icon {
  display: none;
}

/* Legacy logo classes kept harmless for older cached markup. */
.logo-placeholder {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.logo-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 1.8s infinite;
  transform: translateX(-100%);
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.logo-placeholder-icon {
  color: white;
  font-size: 1.2rem;
  z-index: 1;
  opacity: 0.9;
}

@media (max-width: 992px) {
  .logo-placeholder {
    border-radius: 8px;
  }
  .logo-placeholder-icon {
    font-size: 1rem;
  }
}

.app-logo-img {
  height: 38px;
  width: auto;
  max-width: 120px;
  display: block;
  border-radius: 10px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.app-logo-img.loaded {
  opacity: 1;
  transform: scale(1);
}

.logo-wrapper.logo-ready .logo-placeholder {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

@media (max-width: 992px) {
  .app-logo-img {
    height: 30px;
    max-width: 90px;
    border-radius: 8px;
  }
}

[data-theme="dark"] .app-logo-img {
  filter: brightness(1.05) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

[data-theme="dark"] .logo-placeholder {
  background: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
}

.logo-fallback-icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 10px;
  color: white;
  font-size: 1.3rem;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.logo-wrapper.logo-error .logo-fallback-icon {
  display: flex;
}

.logo-wrapper.logo-error .logo-placeholder,
.logo-wrapper.logo-error .app-logo-img {
  display: none;
}

@media (max-width: 992px) {
  .logo-fallback-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 1.1rem;
  }
}

/* =========================
   UTILITIES
   ========================= */
.theme-toggle {
  border: none;
  background: transparent;
  color: var(--gray-700);
  font-size: 1.2rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  padding: 0.5rem;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--gray-100);
}

[data-theme="dark"] .theme-toggle {
  color: #f8f9fa;
}

[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle span {
  display: none;
}

.theme-toggle i {
  font-size: 1.25rem;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
}

.loading-spinner .spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #e5e7eb;
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.badge {
  font-size: 0.7rem;
  padding: 0.2em 0.5em;
  vertical-align: middle;
}

/* =========================
   MOBILE PROFESSIONAL LAYOUT
   ========================= */
@media (max-width: 991.98px) {
  :root {
    --header-height: 96px;
  }

  .app-header {
    height: var(--header-height);
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-rows: 50px 34px;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 10px 8px;
  }

  .menu-toggle {
    grid-column: 1;
    grid-row: 1;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 12px;
  }

  .app-brand {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0;
    overflow: hidden;
  }

  .app-brand:hover {
    background: transparent;
  }

  .logo-wrapper {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
  }

  .brand-wordmark {
    display: flex;
    min-width: 0;
  }

  .brand-text {
    font-size: 1.2rem;
  }

  .brand-tagline {
    display: none;
  }

  .header-actions {
    grid-column: 3;
    grid-row: 1;
    margin-left: 0;
    gap: 4px;
  }

  .header-actions .header-link {
    display: none !important;
  }

  .theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--gray-100);
  }

  [data-theme="dark"] .theme-toggle {
    background: rgba(255, 255, 255, 0.08);
  }

  #user-info {
    display: none !important;
  }

  .page-indicator {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 3px 8px;
    border-radius: 11px;
    background: rgba(79, 70, 229, 0.07);
    border: 1px solid rgba(79, 70, 229, 0.12);
    gap: 8px;
  }

  .page-indicator .page-home {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    flex: 0 0 28px;
  }

  .page-indicator .page-title {
    font-size: 0.88rem;
    line-height: 1.1;
    max-width: 100%;
  }

  .page-indicator .page-subtitle {
    display: none;
  }

  .main-content {
    margin-top: var(--header-height);
    padding: 8px;
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .content-card {
    padding: 0;
    border-radius: 0;
    overflow: visible;
  }

  .mobile-quick-menu {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
  }

  html.menu-open .mobile-quick-menu {
    display: none;
  }

  .mobile-quick-menu .quick-btn {
    min-width: 0;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 14px;
    padding: 6px 4px;
    color: var(--gray-700);
    background: transparent;
  }

  .mobile-quick-menu .quick-btn.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.10);
  }

  .mobile-quick-menu .quick-btn i {
    display: block;
    margin: 0;
    font-size: 1.08rem;
    line-height: 1;
  }

  .mobile-quick-menu .quick-label {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.1;
  }

  [data-theme="dark"] .mobile-quick-menu .quick-btn {
    background: transparent;
    color: #CBD5E1;
  }

  [data-theme="dark"] .mobile-quick-menu .quick-btn.active {
    color: #C7D2FE;
    background: rgba(99, 102, 241, 0.18);
  }
}

@media (max-width: 380px) {
  .brand-wordmark {
    display: none;
  }

  .app-header {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }
}

/* =========================
   THAI DATE PICKER
   ========================= */
.thai-global-date {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 150px;
}

.thai-global-date-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  inset: auto auto 0 0 !important;
}

.thai-global-date-button {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
}

.thai-global-date-button .date-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thai-global-date-button .date-icon {
  flex: 0 0 auto;
  opacity: 0.78;
}

.thai-date-popover {
  position: fixed;
  width: 310px;
  max-width: calc(100vw - 24px);
  padding: 12px;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  background: #fff;
  color: #1F2937;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
  z-index: 99999;
  font-family: 'Sarabun', sans-serif;
}

[data-theme="dark"] .thai-date-popover {
  background: #111827;
  color: #E5E7EB;
  border-color: #374151;
}

.thai-date-popover.hidden {
  display: none !important;
}

.thai-date-popover-head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.thai-date-popover-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  color: inherit;
}

.thai-date-popover-nav,
.thai-date-popover-day,
.thai-date-popover-today {
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.thai-date-popover-nav {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #F8FAFC;
  color: #334155;
  font-size: 1.35rem;
  line-height: 1;
}

.thai-date-popover-nav:hover {
  background: #EEF2FF;
  color: #4F46E5;
}

[data-theme="dark"] .thai-date-popover-nav {
  background: #1F2937;
  color: #E5E7EB;
}

.thai-date-popover-weekdays,
.thai-date-popover-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.thai-date-popover-weekdays {
  margin-bottom: 4px;
  text-align: center;
  color: #64748B;
  font-size: 0.76rem;
  font-weight: 800;
}

.thai-date-popover-day {
  aspect-ratio: 1;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 0.86rem;
  font-weight: 700;
}

.thai-date-popover-day:hover {
  background: #EEF2FF;
  color: #4338CA;
}

.thai-date-popover-day.is-muted {
  color: #CBD5E1;
  font-weight: 500;
}

[data-theme="dark"] .thai-date-popover-day.is-muted {
  color: #64748B;
}

.thai-date-popover-day.is-today {
  box-shadow: inset 0 0 0 1.5px #94A3B8;
}

.thai-date-popover-day.is-selected {
  background: #3B82F6;
  color: #fff;
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.3);
}

.thai-date-popover-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #F1F5F9;
}

[data-theme="dark"] .thai-date-popover-foot {
  border-color: #253044;
}

.thai-date-popover-today {
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #EEF2FF;
  color: #4F46E5;
  font-weight: 800;
}

.thai-date-popover-today:hover {
  background: #E0E7FF;
}

@media (max-width: 576px) {
  .thai-date-popover {
    width: min(310px, calc(100vw - 16px));
  }
}
  
/* =========================
   LOGIN PAGE (SUPABASE SPA)
   ========================= */
body.pp5-login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 15%, rgba(255,255,255,.18), transparent 35%),
    radial-gradient(circle at 85% 85%, rgba(99,102,241,.25), transparent 40%),
    linear-gradient(135deg, #3730a3 0%, #4f46e5 50%, #6366f1 100%);
}

body.pp5-login-page #mainContent {
  margin: 0 !important;
  padding: 16px !important;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box;
}

body.pp5-login-page #contentFrame {
  width: 100%;
  max-width: 440px;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

body.pp5-login-page #contentFrame::before { display: none; }

body.pp5-login-page .login-container {
  width: 100%;
  max-width: 440px;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0 auto;
  padding: 32px 36px 22px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 20px 45px -10px rgba(15, 23, 42, 0.25),
    0 4px 12px rgba(0, 0, 0, 0.05),
    0 0 0 1px rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px);
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Subtle top gradient accent on card */
body.pp5-login-page .login-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4f46e5, #06b6d4, #6366f1);
}

body.pp5-login-page .login-container .header {
  margin-bottom: 4px;
}

body.pp5-login-page .login-container .header h1 {
  margin: 0 0 4px;
  color: #0f172a;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

body.pp5-login-page .login-container #school-name {
  min-height: 0;
  margin: 0 0 18px;
  color: #64748b;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
}

body.pp5-login-page .login-container .logo-placeholder {
  position: relative;
  display: flex;
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  color: #6366f1;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  opacity: 1;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.12);
}

body.pp5-login-page .login-container #school-logo {
  display: none;
  width: auto;
  max-width: 64px;
  height: auto;
  max-height: 64px;
  margin: 0 auto 12px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
}

body.pp5-login-page .login-container #school-logo.loaded { display: block; }

body.pp5-login-page .login-container .form-group {
  position: relative;
  margin: 0 0 14px;
  text-align: left;
}

body.pp5-login-page .login-container label {
  display: block;
  margin: 0 0 5px;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 600;
}

body.pp5-login-page .login-container input[type="text"],
body.pp5-login-page .login-container input[type="password"] {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 44px 0 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  font: inherit;
  font-size: 15px;
  line-height: 44px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

body.pp5-login-page .login-container input:focus {
  background: #fff;
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

body.pp5-login-page .login-container .toggle-pass {
  position: absolute;
  right: 8px;
  top: 31px;
  width: auto;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #4f46e5;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
}

body.pp5-login-page .login-container .toggle-pass:hover {
  background: rgba(79, 70, 229, 0.08);
}

body.pp5-login-page .login-container #loginBtn {
  display: block;
  width: 100%;
  min-height: 44px;
  height: 44px;
  margin: 6px 0 0;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.32);
  transition: all 0.2s ease;
}

body.pp5-login-page .login-container #loginBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.42);
  filter: brightness(1.04);
}

body.pp5-login-page .login-container #loginBtn:active {
  transform: translateY(0);
}

body.pp5-login-page .login-container .forgot-password-link {
  margin: 10px 0 0;
  padding: 4px 0;
  text-align: center;
}

body.pp5-login-page .login-container .forgot-password-link a {
  color: #64748b;
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

body.pp5-login-page .login-container .forgot-password-link a:hover {
  color: #4f46e5;
  text-decoration: underline;
}

body.pp5-login-page .login-container .footer {
  display: flex;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #94a3b8;
  font-size: 0.76rem;
  line-height: 1.2;
  text-align: center;
}

body.pp5-login-page .login-container .footer img {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 50%;
  object-fit: cover;
}

@media (max-width: 480px) {
  body.pp5-login-page #mainContent { padding: 12px !important; }

  body.pp5-login-page #contentFrame,
  body.pp5-login-page .login-container {
    max-width: 100%;
    border-radius: 18px;
  }

  body.pp5-login-page .login-container { padding: 24px 20px 18px; }
}

@media (max-height: 700px) {
  body.pp5-login-page #mainContent {
    padding: 8px !important;
  }

  body.pp5-login-page .login-container {
    padding: 20px 24px 16px;
  }

  body.pp5-login-page .login-container .logo-placeholder {
    width: 50px;
    height: 50px;
    margin-bottom: 8px;
  }

  body.pp5-login-page .login-container #school-logo {
    max-height: 50px;
    margin-bottom: 8px;
  }

  body.pp5-login-page .login-container #school-name {
    margin-bottom: 12px;
  }
}
/* STABLE LOGIN TRANSITION: keeps the card dimensions fixed while auth runs. */
body.pp5-login-page .login-container { position: relative; }

body.pp5-login-page .login-container.pp5-login-pending {
  height: var(--pp5-login-locked-height);
  overflow: hidden;
}

body.pp5-login-page #pp5LoginTransition {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  padding: 24px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 9px;
  border-radius: inherit;
  background: rgba(255,255,255,.94);
  color: #312e81;
  text-align: center;
  backdrop-filter: blur(5px);
}

body.pp5-login-page #pp5LoginTransition strong { font-size: 1.05rem; }

body.pp5-login-page #pp5LoginTransition small {
  color: #64748b;
  font-size: .86rem;
}

body.pp5-login-page .pp5-login-transition-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e7ff;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: pp5-login-spin .75s linear infinite;
}

@keyframes pp5-login-spin { to { transform: rotate(360deg); } }
/* The Google Sheets score warehouse is retired in the Supabase runtime.
   Keep legacy embedded pages intact for contract compatibility, but never
   expose their navigation or rebuild controls to users. */
[data-page="warehouse_tools"],
a[onclick*="warehouse_tools"],
#scoreEntryBtnRebuildWarehouse,
#scoreEntryStatusRebuild {
  display: none !important;
}

/* ==========================================================
   COMPREHENSIVE DARK THEME RULES FOR SPA CONTENT
   ========================================================== */
[data-theme="dark"] .card {
  background-color: var(--bg-card) !important;
  color: #E5E7EB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .card-header {
  background-color: #1F2937 !important;
  color: #E5E7EB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .card-body {
  background-color: var(--bg-card) !important;
  color: #E5E7EB !important;
}
[data-theme="dark"] .card-footer {
  background-color: #1F2937 !important;
  color: #E5E7EB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] select {
  background-color: #1F2937 !important;
  color: #F3F4F6 !important;
  border-color: #4B5563 !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #1F2937 !important;
  color: #F9FAFB !important;
  border-color: #818CF8 !important;
  box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25) !important;
}
[data-theme="dark"] .table {
  color: #E5E7EB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .table > :not(caption) > * > * {
  background-color: transparent !important;
  color: #E5E7EB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255, 255, 255, 0.03) !important;
}
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(255, 255, 255, 0.06) !important;
}
[data-theme="dark"] .table thead th {
  background-color: #1F2937 !important;
  color: #F9FAFB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .modal-content {
  background-color: #1F2937 !important;
  color: #E5E7EB !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: #374151 !important;
}
[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}
[data-theme="dark"] .alert-info {
  background-color: #1e293b !important;
  color: #93c5fd !important;
  border-color: #3b82f6 !important;
}
[data-theme="dark"] .alert-success {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
  border-color: #059669 !important;
}
[data-theme="dark"] .alert-warning {
  background-color: #451a03 !important;
  color: #fcd34d !important;
  border-color: #d97706 !important;
}
[data-theme="dark"] .alert-danger {
  background-color: #450a0a !important;
  color: #fca5a5 !important;
  border-color: #dc2626 !important;
}
[data-theme="dark"] .text-muted {
  color: #94A3B8 !important;
}
