:root {
  --sidebar-width: 280px;
  /* === Color Palette === */
  --primary: #ffd700;
  --primary-dark: #ffa500;
  --primary-gradient: linear-gradient(135deg, #ffd700, #ffa500);
  --secondary: #1a1a1a;
  --bg-white: #ffffff;
  --bg-body: #fdfefe;
  --text-dark: #111111;
  /* Deeper black for high contrast */
  --text-muted: #555555;
  /* Darker grey for better readability */
  --border-light: #eeeeee;

  /* Semantic Colors */
  --success: #00c853;
  --danger: #ff5252;
  --warning: #ffab00;
  --info: #2196f3;

  /* === Fluid Spacing Scale (Mobile-First) === */
  --space-3xs: clamp(0.25rem, 0.5vw, 0.375rem);
  /* 4-6px */
  --space-2xs: clamp(0.375rem, 0.75vw, 0.5rem);
  /* 6-8px */
  --space-xs: clamp(0.5rem, 1vw, 0.75rem);
  /* 8-12px */
  --space-s: clamp(0.75rem, 1.5vw, 1rem);
  /* 12-16px */
  --space-m: clamp(1rem, 2vw, 1.5rem);
  /* 16-24px */
  --space-l: clamp(1.5rem, 3vw, 2rem);
  /* 24-32px */
  --space-xl: clamp(2rem, 4vw, 3rem);
  /* 32-48px */
  --space-2xl: clamp(3rem, 6vw, 4rem);
  /* 48-64px */

  /* === Fluid Typography === */
  --font-xs: clamp(0.75rem, 1.5vw, 0.875rem);
  /* 12-14px */
  --font-sm: clamp(0.875rem, 1.75vw, 1rem);
  /* 14-16px */
  --font-md: clamp(1rem, 2vw, 1.125rem);
  /* 16-18px */
  --font-lg: clamp(1.25rem, 2.5vw, 1.5rem);
  /* 20-24px */
  --font-xl: clamp(1.5rem, 3vw, 2rem);
  /* 24-32px */
  --font-2xl: clamp(2rem, 4vw, 3rem);
  /* 32-48px */

  /* === Responsive Border Radius === */
  --radius-sm: clamp(0.25rem, 0.5vw, 0.375rem);
  /* 4-6px */
  --radius-md: clamp(0.5rem, 1vw, 0.75rem);
  /* 8-12px */
  --radius-lg: clamp(0.75rem, 1.5vw, 1rem);
  /* 12-16px */
  --radius-xl: clamp(1rem, 2vw, 1.25rem);
  /* 16-20px */
  --radius-full: 9999px;

  /* === Shadows === */
  --shadow-soft: 0 0.625rem 1.875rem rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 1.25rem 2.5rem rgba(255, 215, 0, 0.15);
  --shadow-premium: 0 0.625rem 1.875rem -0.625rem rgba(0, 0, 0, 0.1);

  /* === Touch-Friendly Sizes === */
  --touch-min: 2.75rem;
  /* 44px - Apple HIG minimum */
  --icon-sm: clamp(1rem, 2vw, 1.25rem);
  --icon-md: clamp(1.25rem, 2.5vw, 1.5rem);
  --icon-lg: clamp(1.5rem, 3vw, 2rem);

  /* === Layout === */
  --sidebar-width: clamp(15rem, 20vw, 17.5rem);
  /* 240-280px */
  --content-max: 75rem;
  /* 1200px */

  /* === Transitions === */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Outfit", sans-serif;
}

body {
  background-color: var(--bg-body);
  color: var(--text-dark);
  line-height: 1.6;
  overflow-x: hidden;
  /* Prevent horizontal scroll */
  font-size: var(--font-md);
  min-height: 100vh;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  background-color: var(--bg-body);
}

/* Main Content Area */
.main-content {
  background-color: var(--bg-body);
  padding: var(--space-l);
  min-height: 100vh;
  overflow-y: auto;
}


@keyframes popIn {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.card {
  background: var(--bg-white);
  padding: var(--space-l);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(0, 0, 0, 0.03);
  transition: var(--transition);
  animation: popIn 0.4s ease-out;
}

.card:hover {
  transform: translateY(calc(-1 * var(--space-xs)));
  box-shadow: var(--shadow-hover);
}

.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.btn {
  padding: var(--space-s) var(--space-l);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--font-sm);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  letter-spacing: 0.03125em;
  min-height: var(--touch-min);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-dark);
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  transform: translateY(calc(-1 * var(--space-3xs))) scale(1.02);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: var(--bg-white);
  border: 2px solid var(--primary);
  color: var(--text-dark);
}

.form-control {
  width: 100%;
  padding: var(--space-s);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
  font-size: var(--font-md);
  min-height: var(--touch-min);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem rgba(255, 215, 0, 0.1);
}

.dashboard-grid {
  position: relative;
  min-height: 100vh;
  background-color: var(--bg-body);
}

/* Sidebar Logic - Desktop (Default) */
.sidebar {
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  padding: var(--space-xl) var(--space-l);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  /* Always visible on desktop */
  width: var(--sidebar-width);
  z-index: 1100;
  transition: var(--transition);
  box-shadow: var(--shadow-premium);
}

/* Main Content - Desktop Default */
.main-content {
  width: 100%;
  margin-left: var(--sidebar-width);
  /* Push content right */
  background-color: var(--bg-body);
  padding: var(--space-l);
  padding-bottom: var(--space-xl);
  transition: var(--transition);
  max-width: 1920px;
  /* Prevent infinite stretching on 4K */
  min-height: 100vh;
}

/* === Global Responsive Grids === */
.auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-m);
}

.trio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-m);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-m);
}

/* --- Large Screens (> 1500px) --- */
@media (min-width: 1501px) {
  .auto-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --- Laptops & Desktops (1025px - 1500px) --- */
@media (max-width: 1500px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .trio-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Tablets & Large Phones (769px - 1024px) --- */
@media (max-width: 1024px) {
  /* Hide Sidebar on Tablet/Mobile */
  .dashboard-grid {
    display: block;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: var(--space-m);
  }

  .sidebar {
    transform: translateX(-110%);
    box-shadow: var(--shadow-premium);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  /* Show Toggle Button */
  .menu-toggle,
  .menu-toggle-btn {
    display: flex !important;
    position: fixed;
    bottom: var(--space-l);
    right: var(--space-l);
    width: 56px;
    height: 56px;
    background: var(--primary-gradient);
    color: var(--text-dark);
    border: none;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-premium);
    z-index: 9999;
    font-size: var(--font-xl);
    cursor: pointer;
    transition: var(--transition);
  }

  .menu-toggle:hover,
  .menu-toggle-btn:hover {
    transform: scale(1.1);
  }

  /* Grids */
  .stats-grid,
  .trio-grid,
  .auto-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Mobile Devices (< 768px) --- */
@media (max-width: 768px) {
  .main-content {
    padding: var(--space-s);
  }

  /* Single Column Grids */
  .stats-grid,
  .trio-grid,
  .auto-grid {
    grid-template-columns: 1fr;
    gap: var(--space-s);
  }

  .card {
    padding: var(--space-m);
  }

  .btn {
    width: 100%; /* Full width buttons on mobile */
    justify-content: center;
  }

  .form-control {
    font-size: 16px; /* Prevent iOS zoom */
  }
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(0.25rem);
  z-index: 1050;
  display: none;
  opacity: 0;
  transition: var(--transition);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.profile-box {
  background: #f8f9fa;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid rgba(0, 0, 0, 0.02);
}

.profile-avatar {
  width: var(--icon-lg);
  height: var(--icon-lg);
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: var(--font-lg);
  box-shadow: var(--shadow-soft);
}

.profile-info h4 {
  font-size: var(--font-sm);
  font-weight: 800;
  color: var(--text-dark);
}

.profile-info p {
  font-size: var(--font-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: capitalize;
}

.nav-menu {
  list-style: none;
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 250px);
  padding-right: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-dark);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 4px;
  transition: var(--transition);
  font-size: 0.85rem;
  min-height: 36px;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
  transform: translateX(var(--space-xs));
}

.nav-item.active {
  background: var(--primary-gradient);
  color: var(--text-dark);
  box-shadow: var(--shadow-soft);
}

.nav-item i {
  font-size: var(--icon-md);
}

/* === Nav Dropdown Styles === */
.nav-dropdown {
  list-style: none;
  margin-bottom: var(--space-xs);
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-dark);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  min-height: 36px;
}

.nav-dropdown-toggle:hover {
  background: rgba(0, 0, 0, 0.03);
}

.nav-dropdown-toggle span {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}

.nav-dropdown-toggle .arrow {
  font-size: 0.75rem;
  transition: transform 0.3s ease;
}

.nav-dropdown.open .arrow {
  transform: rotate(90deg);
}

.nav-dropdown-menu {
  list-style: none;
  padding-left: var(--space-l);
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.4s ease,
    opacity 0.3s ease;
  opacity: 0;
}

.nav-dropdown.open .nav-dropdown-menu {
  max-height: 500px;
  opacity: 1;
  margin-top: var(--space-3xs);
}

.nav-sub-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: #444;
  /* Darker than text-muted for better visibility */
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 3px;
  transition: var(--transition);
  min-height: 30px;
}

.nav-sub-item i {
  width: 20px;
  margin-right: var(--space-xs);
  font-size: 0.9rem;
  color: var(--primary-dark);
  /* Accent color for icons */
}

.nav-sub-item:hover {
  color: var(--text-dark);
  background: rgba(0, 0, 0, 0.02);
  transform: translateX(var(--space-3xs));
}

.nav-sub-item.active {
  color: var(--primary-dark);
  background: rgba(255, 215, 0, 0.05);
  font-weight: 700;
}

/* === Filter Buttons (Chips Style) === */
.filter-group {
  display: flex !important;
  flex-wrap: wrap;
  gap: var(--space-xs) !important;
  align-items: center;
}

.filter-btn {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  background: #f8f9fa;
  color: var(--text-dark);
  border-color: var(--text-muted);
}

.filter-btn.active {
  background: var(--text-dark);
  color: white;
  border-color: var(--text-dark);
  box-shadow: var(--shadow-soft);
}

/* === Sidebar Footer & Logout === */
.sidebar-footer {
  margin-top: auto;
  padding: var(--space-m);
  border-top: 1px solid var(--border-light);
}

.logout-btn {
  width: 100%;
  padding: 10px;
  background: #fff5f5 !important;
  color: #ff4d4d !important;
  border: 1px solid #ffe0e0 !important;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.logout-btn:hover {
  background: #ffe0e0 !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

/* === General Button Refinement === */
.btn {
  padding: 8px 16px; /* Slightly smaller padding */
  font-size: 0.9rem;
  min-height: 40px; /* Reduced from touch-min (44px) for desktop preference */
}

/* Mobile Specific Adjustments for Compactness */
@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-m);
  }
  
  .filter-group {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap !important; /* Horizontally scrollable on mobile */
    -webkit-overflow-scrolling: touch;
  }
  
  .filter-btn {
    flex: 0 0 auto; /* Don't shrink */
    padding: 8px 16px; /* Larger touch target */
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Make action buttons side-by-side if possible */
  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-s);
    width: 100%;
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-white);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: min(90vw, 27.5rem);
  box-shadow: var(--shadow-premium);
  transform: scale(0.9) translateY(var(--space-m));
  transition: var(--transition);
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-overlay.active .modal-box {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-l);
}

.modal-title {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--text-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-xl);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
}

.modal-close:hover {
  color: var(--text-dark);
  transform: rotate(90deg);
}

.input-group {
  margin-bottom: var(--space-m);
}

.input-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 700;
  color: var(--text-dark);
  font-size: var(--font-sm);
}

/* Unified Header Styles */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  background: var(--bg-white);
  padding: var(--space-m) var(--space-l);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  position: relative;
  z-index: 100;
  flex-wrap: wrap;
  gap: var(--space-m);
  min-height: auto;
  overflow: visible;
}

.dashboard-header button {
  white-space: nowrap;
  flex-shrink: 0;
  min-width: fit-content;
}

@media (max-width: 600px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-s);
  }

  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .dashboard-header button {
    width: 100%;
    margin-top: 8px; /* Add spacing between stacked buttons */
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-m);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info-text {
  text-align: right;
}

.user-name {
  font-weight: 800;
  font-size: 1rem;
}

.user-role-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: capitalize;
  background: #f0f2f5;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
}

/* Mobile Responsiveness (Refactored) */
@media (max-width: 1500px) {
  .main-content {
    padding: var(--space-m);
    width: 100% !important;
    /* Force full width on smaller screens */
    max-width: 100vw;
    overflow-x: hidden;
  }

  .dashboard-header {
    top: 0;
    border-radius: 0;
    margin: calc(-1 * var(--space-m)) calc(-1 * var(--space-m)) var(--space-l)
      calc(-1 * var(--space-m));
    padding: var(--space-m);
  }
}

@media (max-width: 768px) {
  .header-subtitle {
    display: none;
  }

  #welcomeMsg {
    font-size: var(--font-lg);
  }

  .user-info-text {
    display: none;
  }

  /* Mobile-Responsive Table System */
  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: block;
  }

  .responsive-table tr {
    display: block;
    margin-bottom: var(--space-m);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-m);
    background: var(--bg-white);
    box-shadow: var(--shadow-soft);
  }

  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-s) 0;
    border-bottom: 1px solid #f9f9f9;
    text-align: right !important;
    gap: var(--space-s);
  }

  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 800;
    font-size: var(--font-sm);
    color: var(--text-muted);
    text-align: left;
    flex: 0 0 auto;
  }

  .responsive-table td:last-child {
    border-bottom: none;
  }
}

/* Sidebar Toggle for JS */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: none;
  opacity: 0;
  transition: var(--transition);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
  .btn {
    width: 100%;
    justify-content: center;
    padding: var(--space-m);
  }

  .card {
    padding: var(--space-m);
  }

  .dashboard-layout,
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-m);
  }

  /* === TEACHER PANEL RESPONSIVE & COMPACT STYLES === */

  /* Compact Grid for Cards (Attendance List, Dashboard) */
  .teacher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }

  /* Compact Card Style */
  .compact-card {
    padding: 16px !important;
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .compact-card h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
  }

  .compact-card p {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  /* Attendance Form List */
  .attendance-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .attendance-card {
    padding: 12px 16px !important;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: white;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Attendance Header (Student Name & Avatar) */
  .att-student-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .att-student-info {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .att-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .att-name {
    font-weight: 700;
    font-size: 0.95rem;
  }

  .att-sub {
    font-size: 0.8rem;
    color: var(--secondary);
    font-weight: 600;
  }

  /* Controls (Radio Buttons & Inputs) */
  .att-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
  }

  .att-toggles {
    display: flex;
    background: #f8f9fa;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #eee;
    flex: 1;
    min-width: 200px;
    justify-content: space-between;
  }

  .att-toggle-label {
    flex: 1;
    text-align: center;
    padding: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background 0.2s;
  }

  .att-toggle-label:hover {
    background: rgba(0, 0, 0, 0.02);
  }

  .att-inputs {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 200px;
  }

  /* MEDIA QUERIES FOR TEACHER PANEL */

  /* Mobile Phones (< 480px) */
  @media (max-width: 480px) {
    .teacher-grid {
      grid-template-columns: 1fr;
      /* Full width cards */
    }

    .compact-card {
      padding: 12px !important;
    }

    .att-controls {
      flex-direction: column;
      align-items: stretch;
    }

    .att-toggles,
    .att-inputs {
      width: 100%;
      min-width: unset;
    }
  }

  /* Tablets (481px - 768px) */
  @media (min-width: 481px) and (max-width: 768px) {
    .teacher-grid {
      grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
  }

  /* Large Screens */
  @media (min-width: 1600px) {
    .teacher-grid {
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .compact-card h3 {
      font-size: 1.25rem;
    }
  }

  /* Unified Footer */
  .dashboard-footer {
    border-top: 1px solid var(--border-light);
    margin-top: var(--space-2xl);
    padding: var(--space-xl) 0;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-sm);
  }

  .dashboard-footer .footer-links {
    margin-top: var(--space-s);
    display: flex;
    justify-content: center;
    gap: var(--space-l);
    flex-wrap: wrap;
  }

  .dashboard-footer .footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
  }

  .dashboard-footer .footer-links a:hover {
    color: var(--primary);
  }

  /* Data Table Styles */
  .table-container {
    overflow-x: auto;
    margin-top: var(--space-m);
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 40rem;
  }

  .data-table th,
  .data-table td {
    padding: var(--space-m);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
  }

  .data-table th {
    background: #f9fafb;
    font-weight: 700;
    font-size: var(--font-sm);
    color: var(--text-dark);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  /* Grid helper for mobile */
  .mobile-stack {
    display: grid !important;
    gap: var(--space-m);
  }

  @media (max-width: 1500px) {
    .mobile-stack {
      grid-template-columns: 1fr !important;
    }
  }

  /* Visibility Utilities */
  .hide-mobile {
    display: block;
  }

  .show-mobile {
    display: none;
  }

  @media (max-width: 768px) {
    .hide-mobile {
      display: none !important;
    }

    .show-mobile {
      display: block !important;
    }

    .modal-box {
      width: 92%;
      margin: var(--space-m);
    }
  }

  /* Word break & Spacing utilities */
  .text-break {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  @media (max-width: 768px) {
    .mt-mobile-s {
      margin-top: var(--space-s) !important;
    }

    .mt-mobile-m {
      margin-top: var(--space-m) !important;
    }

    .mb-mobile-s {
      margin-bottom: var(--space-s) !important;
    }

    .mb-mobile-m {
      margin-bottom: var(--space-m) !important;
    }
  }

  /* Flex Wrap Utility */
  .flex-wrap-mobile {
    display: flex;
    flex-wrap: nowrap;
  }

  @media (max-width: 768px) {
    .flex-wrap-mobile {
      flex-wrap: wrap !important;
      gap: var(--space-m) !important;
    }
  }

  /* ============================================================ */
  /* COMPREHENSIVE RESPONSIVE DESIGN - Teacher Panel Fix */
  /* ============================================================ */

  /* Mobile Devices (320px - 480px) */
  @media (max-width: 480px) {
    .main-content {
      width: 100% !important;
      padding: var(--space-s) !important;
      margin-left: 0 !important;
    }

    .dashboard-header {
      flex-direction: column;
      align-items: flex-start !important;
      gap: var(--space-m);
    }

    .header-left {
      width: 100%;
      flex-direction: column !important;
    }

    .user-profile {
      width: 100%;
      justify-content: flex-start;
    }

    .user-profile button {
      width: 100%;
    }

    .stats-grid {
      grid-template-columns: 1fr !important;
      gap: var(--space-s);
    }

    .stats-grid .card {
      padding: 16px !important;
    }

    table {
      font-size: 0.85rem !important;
    }

    .btn {
      padding: 10px 12px !important;
      margin-bottom: 1rem;
      font-size: 0.85rem !important;
    }

    .card {
      padding: 16px !important;
      margin-bottom: 16px !important;
    }

    h2 {
      font-size: 1.5rem !important;
    }

    h3 {
      font-size: 1.1rem !important;
    }

    .profile-avatar {
      width: 40px !important;
      height: 40px !important;
      font-size: 0.9rem !important;
    }
  }

  /* Tablets & Small Devices (481px - 768px) */
  @media (max-width: 768px) {
    .main-content {
      width: 100% !important;
      padding: var(--space-m) !important;
      margin-left: 0 !important;
    }

    .dashboard-header {
      flex-direction: column;
      align-items: flex-start !important;
      gap: var(--space-m);
      margin-bottom: var(--space-l);
    }

    .header-left {
      width: 100%;
    }

    .user-profile {
      width: 100%;
    }

    .user-profile button {
      width: 100%;
    }

    .stats-grid {
      grid-template-columns: repeat(2, 1fr) !important;
      gap: var(--space-m);
    }

    .card {
      padding: 20px !important;
    }

    #recentRewardsContainer,
    #myStudentsContainer {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: var(--space-m);
    }

    table {
      font-size: 0.9rem;
    }

    th,
    td {
      padding: 12px !important;
    }
  }

  /* Laptops (769px - 1024px) */
  @media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
      width: 100% !important;
      padding: var(--space-l) !important;
      margin-left: 0 !important;
    }

    .stats-grid {
      grid-template-columns: repeat(2, 1fr) !important;
    }

    .card {
      padding: 24px !important;
    }

    table {
      font-size: 0.95rem;
    }
  }

  /* Medium Screens (1025px - 1499px) */
  @media (min-width: 1025px) and (max-width: 1499px) {
    .main-content {
      width: calc(100% - var(--sidebar-width)) !important;
      margin-left: var(--sidebar-width) !important;
      padding: var(--space-l);
    }

    .stats-grid {
      grid-template-columns: repeat(2, 1fr) !important;
      gap: var(--space-m);
    }

    .dashboard-header {
      flex-wrap: wrap;
    }
  }

  /* Desktop (1500px - 1920px) */
  @media (min-width: 1500px) and (max-width: 1920px) {
    .main-content {
      width: calc(100% - var(--sidebar-width)) !important;
      margin-left: var(--sidebar-width) !important;
      padding: var(--space-xl);
      max-width: 1920px;
    }

    .stats-grid {
      grid-template-columns: repeat(4, 1fr) !important;
      gap: var(--space-m);
    }

    .card {
      padding: 28px !important;
    }
  }

  /* Large Monitors (4K+, 1921px+) */
  @media (min-width: 1921px) {
    .main-content {
      width: calc(100% - var(--sidebar-width)) !important;
      margin-left: var(--sidebar-width) !important;
      padding: var(--space-xl);
      max-width: 2560px;
    }

    .stats-grid {
      grid-template-columns: repeat(4, 1fr) !important;
      gap: var(--space-l);
    }

    .card {
      padding: 32px !important;
    }

    h2 {
      font-size: 2.5rem !important;
    }

    h3 {
      font-size: 1.8rem !important;
    }

    table {
      font-size: 1.05rem;
    }

    th,
    td {
      padding: 20px !important;
    }
  }

  /* Responsive Layouts for Teacher-Specific Components */
  @media (max-width: 768px) {
    /* Homework Cards */
    #homeworkList {
      grid-template-columns: 1fr !important;
    }

    /* Table Responsive Mode */
    table {
      width: 100%;
      border-collapse: collapse;
    }

    table thead {
      display: none;
    }

    table tr {
      display: block;
      margin-bottom: var(--space-m);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-md);
      padding: var(--space-m);
      background: var(--bg-white);
    }

    table td {
      display: flex;
      justify-content: space-between;
      padding: 12px 0;
      border-bottom: 1px solid #f5f5f5;
    }

    table td::before {
      content: attr(data-label);
      font-weight: 700;
      color: var(--text-muted);
    }

    table td:last-child {
      border-bottom: none;
    }
  }

  /* Fix Modal Responsiveness */
  .modal-box {
    max-width: 95vw !important;
    max-height: 90vh !important;
    width: auto !important;
  }

  @media (max-width: 768px) {
    .modal-box {
      margin: var(--space-s) !important;
      border-radius: var(--radius-lg) !important;
    }

    .modal-box h3 {
      font-size: 1.3rem !important;
    }
  }

  /* Fix Stats Grid Card Content */
  .stats-grid .card h3 {
    margin: 0 !important;
  }

  @media (max-width: 480px) {
    .stats-grid .card h3 {
      font-size: 1.5rem !important;
    }

    .stats-grid .card p {
      font-size: 0.8rem !important;
    }
  }

  /* Ensure sidebar doesn't overlap content */
  @media (max-width: 1500px) {
    .dashboard-grid {
      display: flex;
      flex-direction: column;
    }

    .sidebar {
      position: fixed;
      left: 0;
      top: 0;
      width: var(--sidebar-width);
      height: 100vh;
      z-index: 1100;
      transform: translateX(-110%);
      transition: transform 0.3s ease;
    }

    .sidebar.active {
      transform: translateX(0);
    }

    .main-content {
      flex: 1;
      width: 100%;
      margin-left: 0;
    }
  }

  /* Additional breakpoints for better tablet/laptop support */
  @media (max-width: 600px) {
    .card {
      margin-bottom: 12px !important;
    }

    .btn {
      padding: 8px 10px !important;
      font-size: 0.8rem !important;
    }

    .modal-box {
      width: 90vw !important;
      max-height: 85vh !important;
    }
  }

  /* Optimized breakpoint for 1920px displays */
  @media (min-width: 1921px) {
    .main-content {
      max-width: 2560px !important;
      margin-left: auto !important;
      margin-right: auto !important;
    }

    .card {
      padding: 40px !important;
    }
  }

  /* ============================================
   ENHANCED TEACHER PANEL RESPONSIVE DESIGN
   ============================================ */

  /* TABLET SPECIFIC (768px-1023px) */
  @media (min-width: 768px) and (max-width: 1023px) {
    .stats-grid {
      grid-template-columns: repeat(2, 1fr) !important;
      gap: var(--space-l);
    }

    .table-wrapper {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }

    table {
      min-width: 600px;
    }
  }

  /* LAPTOP & DESKTOP (1024px-1439px) */
  @media (min-width: 1024px) and (max-width: 1439px) {
    .stats-grid {
      grid-template-columns: repeat(4, 1fr) !important;
      gap: var(--space-l);
    }

    .dashboard-grid {
      grid-template-columns: var(--sidebar-width) 1fr;
    }

    .sidebar {
      position: fixed !important;
      transform: translateX(0) !important;
    }

    .main-content {
      margin-left: var(--sidebar-width);
      padding: var(--space-xl);
    }
  }

  /* LARGE DESKTOP (1440px-1919px) */
  @media (min-width: 1440px) and (max-width: 1919px) {
    .main-content {
      max-width: 1600px;
      padding: var(--space-2xl);
    }

    .card {
      padding: 32px !important;
    }

    .btn {
      padding: 12px 24px;
    }
  }

  /* Touch-friendly for all mobile/tablet */
  @media (max-width: 1023px) {
    .btn,
    button {
      min-height: 44px;
    }

    .form-control,
    input,
    select,
    textarea {
      min-height: 44px;
      font-size: 16px;
      /* Prevents iOS zoom */
    }

    /* Teacher-specific: Stack header elements */
    .dashboard-header {
      flex-direction: column;
      gap: var(--space-m);
    }

    .header-left,
    .user-profile {
      width: 100%;
    }
  }

  /* Student/Class cards responsive grid */
  #myStudentsContainer,
  #classListContainer {
    display: grid;
    display: flex;
    gap: var(--space-m);
  }

  @media (max-width: 767px) {
    #myStudentsContainer,
    #classListContainer {
      grid-template-columns: 3fr;
    }
  }

  @media (min-width: 768px) and (max-width: 1023px) {
    #myStudentsContainer,
    #classListContainer {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (min-width: 1024px) {
    #myStudentsContainer,
    #classListContainer {
      grid-template-columns: repeat(3, 1fr);
    }
  }
}
/* ============================================
   ADMIN, TEACHER, STUDENT PANEL RESPONSIVE DESIGN (ADAPTED)
   ============================================ */

/* COMMON RESPONSIVE UTILITIES */
.hide-mobile {
  display: block;
}

.show-mobile {
  display: none;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }
}

/* PANEL-SPECIFIC HEADER STYLES (Mapped to .dashboard-header) */
.dashboard-header {
  /* Base styles from main.css apply, these are overrides/additions */
  transition: background 0.3s ease;
}

/* If user adds specific classes to body, these headers can change color */
body.admin-panel .dashboard-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

body.teacher-panel .dashboard-header {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

body.student-panel .dashboard-header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    padding: var(--space-s) !important;
    gap: var(--space-s);
    border-radius: 0;
    margin: calc(-1 * var(--space-s)) calc(-1 * var(--space-s)) var(--space-l)
      calc(-1 * var(--space-s));
  }

  .panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    width: 100%;
  }

  .panel-actions .btn {
    flex: 1;
    min-width: 120px;
  }
}

/* ADMIN/TEACHER/STUDENT GRIDS (Mapped to .stats-grid) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-m);
  margin-bottom: var(--space-xl);
}

/* CARD STYLES (Mapped to .card) */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  border: 2px solid transparent;
  transition: var(--transition);
  box-shadow: var(--shadow-soft);
}

.card:hover {
  border-color: var(--primary);
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.card h3 {
  color: var(--text-dark);
  margin-bottom: var(--space-s);
  font-size: var(--font-lg);
}

.card p {
  color: var(--text-muted);
  margin-bottom: var(--space-m);
  font-size: var(--font-sm);
}

/* TABLE STYLES (Mapped to .responsive-table) */
.responsive-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-m);
}

.responsive-table th {
  background: var(--bg-body);
  padding: var(--space-m);
  text-align: left;
  font-weight: 700;
  color: var(--text-dark);
  border-bottom: 2px solid var(--border-light);
}

.responsive-table td {
  padding: var(--space-m);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.user-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  margin-right: var(--space-s);
}

.user-row {
  display: flex;
  align-items: center;
}

.status-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 700;
  display: inline-block;
}

.status-active {
  background: rgba(0, 200, 83, 0.1);
  color: var(--success);
}

.status-inactive {
  background: rgba(255, 82, 82, 0.1);
  color: var(--danger);
}

.status-pending {
  background: rgba(255, 171, 0, 0.1);
  color: var(--warning);
}

/* ATTENDANCE & QUICK ACTIONS */
.attendance-quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-m);
  margin-bottom: var(--space-xl);
}

.quick-action-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: var(--shadow-soft);
}

.quick-action-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.quick-action-icon {
  width: 60px;
  height: 60px;
  background: var(--primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-m);
  color: white;
  font-size: var(--icon-lg);
}

/* STUDENT PROFILE & PROGRESS */
.student-avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary-gradient);
  margin: 0 auto var(--space-m);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-2xl);
  font-weight: 700;
  border: 4px solid white;
  box-shadow: var(--shadow-soft);
}

.student-points-display {
  background: var(--primary-gradient);
  padding: var(--space-m) var(--space-l);
  border-radius: var(--radius-lg);
  color: var(--text-dark);
  font-weight: 800;
  font-size: var(--font-xl);
  display: inline-flex;
  align-items: center;
  gap: var(--space-s);
  margin-top: var(--space-m);
}

.progress-bar {
  height: 12px;
  background: #f0f0f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-s);
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

/* COURSE STYLES */
.course-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: var(--space-s);
}

.course-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 700;
}

.badge-completed {
  background: rgba(0, 200, 83, 0.1);
  color: var(--success);
}

.badge-inprogress {
  background: rgba(255, 171, 0, 0.1);
  color: var(--warning);
}

.badge-upcoming {
  background: rgba(33, 150, 243, 0.1);
  color: var(--info);
}

/* RESPONSIVE MEDIA QUERIES (Unified) */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-s);
  }

  .card {
    padding: var(--space-m);
  }

  .responsive-table {
    display: block;
    overflow-x: auto;
  }

  .responsive-table th,
  .responsive-table td {
    padding: var(--space-s);
    font-size: var(--font-sm);
  }

  .attendance-quick-actions {
    grid-template-columns: 1fr;
    gap: var(--space-s);
  }

  .student-avatar-large {
    width: 80px;
    height: 80px;
    font-size: var(--font-xl);
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-m);
  }

  .attendance-quick-actions {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-m);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* NOTIFICATIONS */
.notification {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  margin-bottom: var(--space-s);
  box-shadow: var(--shadow-premium);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: var(--space-s);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification-success {
  border-left-color: var(--success);
}

.notification-error {
  border-left-color: var(--danger);
}

.notification-warning {
  border-left-color: var(--warning);
}

.notification-info {
  border-left-color: var(--info);
}

/* FILTERS & SEARCH */
.panel-filters {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-m);
  align-items: center;
}

@media (max-width: 768px) {
  .panel-filters {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-s);
  }
}

/* CHARTS */
.chart-container {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  box-shadow: var(--shadow-soft);
  margin-bottom: var(--space-xl);
  position: relative;
  height: 400px;
}

@media (max-width: 768px) {
  .chart-container {
    height: 300px;
    padding: var(--space-m);
  }
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-body);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-m);
  color: var(--text-muted);
  font-size: var(--icon-lg);
}

/* LOADING STATES */
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-m);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* QUICK STATS WIDGETS */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-m);
  margin-bottom: var(--space-xl);
}

.stat-widget {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
  border: 2px solid transparent;
}

.stat-widget:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-s);
  font-size: var(--icon-lg);
}

.stat-value {
  font-size: var(--font-2xl);
  font-weight: 800;
  color: var(--text-dark);
  display: block;
  line-height: 1.2;
}

@media (max-width: 768px) {
  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-s);
  }
}

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

/* CALENDAR WIDGET */
.calendar-widget {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  box-shadow: var(--shadow-soft);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-xs);
}

.calendar-date {
  text-align: center;
  padding: var(--space-xs);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: var(--font-sm);
}

.calendar-date:hover {
  background: var(--bg-body);
}

.calendar-date.today {
  background: var(--primary-gradient);
  color: var(--text-dark);
  font-weight: 700;
}

/* PANEL SPECIFIC OVERRIDES */
body.admin-panel {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.teacher-panel {
  --primary: #f5576c;
  --primary-dark: #f093fb;
  --primary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

body.student-panel {
  --primary: #4facfe;
  --primary-dark: #00f2fe;
  --primary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* LAST MINUTE FIXES */
@media (max-width: 480px) {
  .panel-main-title {
    font-size: var(--font-lg) !important;
  }

  .panel-subtitle {
    font-size: var(--font-sm) !important;
  }
}

/* IOS INPUT ZOOM FIX */
@supports (-webkit-touch-callout: none) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============================================
   CRITICAL RESPONSIVE FIXES FOR ALL PANELS
   ============================================ */

/* Force menu toggle to always show on mobile */
@media (max-width: 1500px) {
  .menu-toggle {
    display: flex !important;
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 999999 !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Ensure sidebar is properly hidden on mobile */
  .sidebar:not(.active) {
    transform: translateX(-110%) !important;
  }

  /* Ensure main content takes full width */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Fix dashboard-grid for mobile */
  .dashboard-grid {
    display: block !important;
    grid-template-columns: none !important;
  }
}

/* Fix stats-grid responsiveness */
@media (max-width: 768px) {
  .stats-grid,
  .auto-grid,
  .trio-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-m) !important;
  }

  /* Fix dashboard header */
  .dashboard-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-m) !important;
    padding: var(--space-m) !important;
  }

  .header-left {
    width: 100% !important;
    flex-direction: column !important;
  }

  /* Ensure buttons wrap properly */
  .flex-wrap-mobile {
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  /* Fix card padding */
  .card {
    padding: var(--space-m) !important;
  }

  /* Fix table responsiveness */
  .responsive-table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .responsive-table thead {
    display: none !important;
  }

  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block !important;
    width: 100% !important;
  }

  .responsive-table tr {
    margin-bottom: var(--space-m) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-md) !important;
    padding: var(--space-s) !important;
  }

  .responsive-table td {
    padding: var(--space-xs) var(--space-s) !important;
    text-align: left !important;
    position: relative !important;
    padding-left: 50% !important;
  }

  .responsive-table td:before {
    content: attr(data-label) !important;
    position: absolute !important;
    left: var(--space-s) !important;
    font-weight: 700 !important;
    color: var(--text-dark) !important;
  }

  .responsive-table td[data-label="Actions"] {
    padding-left: var(--space-s) !important;
  }

  .responsive-table td[data-label="Actions"]:before {
    display: none !important;
  }
}

/* Fix buttons and form controls on mobile */
@media (max-width: 768px) {
  .btn,
  button,
  .form-control,
  input,
  select,
  textarea {
    min-height: 44px !important;
    font-size: 16px !important;
  }

  .btn {
    padding: 12px 20px !important;
  }

  /* Fix filter buttons */
  .filter-group {
    width: 100% !important;
    flex-wrap: wrap !important;
  }

  .filter-btn {
    flex: 1 1 auto !important;
    min-width: 80px !important;
    padding: 8px 12px !important;
  }
}

/* Fix modals on mobile */
@media (max-width: 768px) {
  .modal-box {
    width: calc(100vw - 32px) !important;
    max-width: 100% !important;
    max-height: calc(100vh - 32px) !important;
    margin: 16px !important;
  }

  .modal-overlay {
    padding: 0 !important;
    align-items: flex-start !important;
  }
}

/* Student panel specific fixes */
@media (max-width: 768px) {
  .stat-card {
    padding: var(--space-m) !important;
  }

  .shop-grid,
  .coin-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-s) !important;
  }
}

/* Teacher panel specific fixes */
@media (max-width: 768px) {
  .attendance-card {
    padding: var(--space-s) !important;
  }

  .att-student-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
}

/* Admin panel specific fixes */
@media (max-width: 768px) {
  .admin-controls {
    flex-direction: column !important;
    gap: var(--space-s) !important;
  }

  .admin-controls .btn {
    width: 100% !important;
  }
}

/* Landscape mode fixes */
@media (max-height: 600px) and (orientation: landscape) {
  .sidebar {
    overflow-y: auto !important;
    max-height: 100vh !important;
  }

  .main-content {
    padding: var(--space-s) !important;
  }

  .modal-box {
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
}

/* Ultra small screens (< 360px) */
@media (max-width: 359px) {
  :root {
    --font-base: 14px !important;
    --space-base: 12px !important;
  }

  .menu-toggle {
    width: 48px !important;
    height: 48px !important;
    bottom: 16px !important;
    right: 16px !important;
  }

  .sidebar {
    width: 85vw !important;
    max-width: 280px !important;
  }
}

/* Print styles */
@media print {
  .sidebar,
  .menu-toggle,
  .sidebar-overlay,
  .btn,
  button {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    page-break-inside: avoid !important;
  }
}

/* FIX: Ensure ultrawide screens (2560px+) don't have layout gaps */
@media (min-width: 1400px) {
    .dashboard-grid {
        display: block !important;
        max-width: none !important; /* Allow full width so sidebar is not detached */
        margin: 0 !important;
    }
    
    .main-content {
        margin-left: 280px !important; /* Sidebar width from variable */
        width: auto !important;
        max-width: 100% !important; /* Allow content to fill remaining space */
        min-height: 100vh;
    }

    .sidebar {
        width: 280px !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        height: 100vh !important;
    }
}
