/* Modern School Attendance Stylesheet - Kanit & Inter Fonts */
:root {
  /* Common variables */
  --font-family: 'Kanit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

  /* Attendance Status Colors (HSL) */
  --color-present: 142.1 70.6% 45.3%;      /* Emerald */
  --color-late: 37.9 90.2% 50.8%;         /* Amber */
  --color-leave: 198.6 88.7% 48.4%;        /* Sky Blue */
  --color-absent: 346.8 77.2% 49.8%;       /* Rose */

  --color-present-bg: rgba(16, 185, 129, 0.1);
  --color-late-bg: rgba(245, 158, 11, 0.1);
  --color-leave-bg: rgba(14, 165, 233, 0.1);
  --color-absent-bg: rgba(244, 63, 94, 0.1);
}

/* Theme settings */
html[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-sidebar: rgba(17, 24, 39, 0.85);
  --bg-card: rgba(30, 41, 59, 0.65);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-input: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --glass-blur: blur(20px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --bg-modal: rgba(15, 23, 42, 0.8);
}

html[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-sidebar: rgba(255, 255, 255, 0.85);
  --bg-card: rgba(255, 255, 255, 0.75);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --bg-input: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(0, 0, 0, 0.15);
  --primary: #4f46e5;
  --primary-hover: #3730a3;
  --primary-glow: rgba(79, 70, 229, 0.15);
  --glass-blur: blur(20px);
  --glass-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
  --bg-modal: rgba(15, 23, 42, 0.4);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.app-sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-slow), background-color var(--transition-normal);
  box-shadow: var(--glass-shadow);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  background: var(--primary);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--primary-glow);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.nav-item:hover .nav-icon {
  transform: translateX(2px);
}

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

.btn-theme-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-theme-toggle:hover {
  background: var(--border-color);
  border-color: var(--border-color-hover);
}

/* Main Layout Area */
.app-main {
  flex: 1;
  margin-left: 280px;
  padding: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
  display: none;
  height: 64px;
  background: var(--bg-sidebar);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.mobile-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

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

.mobile-only {
  display: none;
}

/* Universal Spinner Loading state */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 1s infinite linear;
}

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

/* Glass Cards & Layout elements */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--glass-shadow);
  transition: transform var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal);
}

.glass-card:hover {
  border-color: var(--border-color-hover);
}

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

.page-title h2 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Dashboard / Daily View Styles */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 20px;
  border-radius: var(--radius-lg);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.4rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Assign Colors dynamically via status styles */
.stat-card.present { border-left: 4px solid hsl(var(--color-present)); }
.stat-card.present .stat-icon { background: var(--color-present-bg); color: hsl(var(--color-present)); }

.stat-card.late { border-left: 4px solid hsl(var(--color-late)); }
.stat-card.late .stat-icon { background: var(--color-late-bg); color: hsl(var(--color-late)); }

.stat-card.leave { border-left: 4px solid hsl(var(--color-leave)); }
.stat-card.leave .stat-icon { background: var(--color-leave-bg); color: hsl(var(--color-leave)); }

.stat-card.absent { border-left: 4px solid hsl(var(--color-absent)); }
.stat-card.absent .stat-icon { background: var(--color-absent-bg); color: hsl(var(--color-absent)); }

/* Dashboard layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.chart-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chart-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Beautiful custom progress bars for charts */
.progress-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.progress-track {
  height: 10px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-fill.present { background: hsl(var(--color-present)); }
.progress-fill.late { background: hsl(var(--color-late)); }
.progress-fill.leave { background: hsl(var(--color-leave)); }
.progress-fill.absent { background: hsl(var(--color-absent)); }

/* Selection filters & Control Bars */
.controls-card {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Standard Inputs, Selects & Buttons */
.form-select {
  padding: 12px 36px 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input {
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

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

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--border-color);
  border-color: var(--border-color-hover);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: hsl(var(--color-absent));
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

/* Attendance Checker Table/Grid */
.checker-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.student-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

.student-row:hover {
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
}

.student-roll {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.student-info-main {
  display: flex;
  flex-direction: column;
}

.student-name {
  font-size: 1.05rem;
  font-weight: 500;
}

.student-class-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Attendance buttons state selector */
.attendance-picker {
  display: flex;
  gap: 8px;
}

.btn-status {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  user-select: none;
}

.btn-status:active {
  transform: scale(0.95);
}

/* Selected button states */
.btn-status.present.active {
  background: hsl(var(--color-present));
  border-color: hsl(var(--color-present));
  color: white;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.btn-status.present:hover:not(.active) {
  border-color: hsl(var(--color-present));
  color: hsl(var(--color-present));
  background: var(--color-present-bg);
}

.btn-status.late.active {
  background: hsl(var(--color-late));
  border-color: hsl(var(--color-late));
  color: white;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}
.btn-status.late:hover:not(.active) {
  border-color: hsl(var(--color-late));
  color: hsl(var(--color-late));
  background: var(--color-late-bg);
}

.btn-status.leave.active {
  background: hsl(var(--color-leave));
  border-color: hsl(var(--color-leave));
  color: white;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}
.btn-status.leave:hover:not(.active) {
  border-color: hsl(var(--color-leave));
  color: hsl(var(--color-leave));
  background: var(--color-leave-bg);
}

.btn-status.absent.active {
  background: hsl(var(--color-absent));
  border-color: hsl(var(--color-absent));
  color: white;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}
.btn-status.absent:hover:not(.active) {
  border-color: hsl(var(--color-absent));
  color: hsl(var(--color-absent));
  background: var(--color-absent-bg);
}

/* Empty State Styling */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  background: var(--border-color);
  color: var(--text-muted);
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-state p {
  font-size: 0.95rem;
  max-width: 400px;
  margin-bottom: 24px;
}

/* Management View Panels */
.manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.manage-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.manage-section-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.data-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--border-color);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.data-table td {
  font-size: 0.95rem;
}

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

.data-table tr:hover td {
  background: var(--border-color);
}

.actions-cell {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-table-action {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-table-action:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.btn-table-action.delete:hover {
  background: var(--color-absent-bg);
  color: hsl(var(--color-absent));
}

/* CSV Drag and Drop Upload Area */
.csv-upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.csv-upload-zone:hover, .csv-upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.csv-upload-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.csv-upload-zone.dragover .csv-upload-icon {
  background: var(--primary);
  color: white;
}

.csv-template-link {
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

/* Modals & Dialog overlays */
.modal-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-modal);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 90%;
  max-width: 500px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2000;
  max-width: 360px;
  width: 90%;
}

.toast {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(20px);
  opacity: 0;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid hsl(var(--color-present));
}

.toast.error {
  border-left: 4px solid hsl(var(--color-absent));
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ==========================================================================
   Responsive adjustments (Mobile-first principles / overrides)
   ========================================================================== */
@media (max-width: 992px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  
  .manage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* Toggle layouts for mobile app shell */
  .app-sidebar {
    transform: translateX(-100%);
    width: 290px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
  }
  
  .app-sidebar.active {
    transform: translateX(0);
  }
  
  .app-main {
    margin-left: 0;
    padding: 88px 16px 40px 16px; /* Offset for Mobile Header */
  }
  
  .mobile-header {
    display: flex;
  }
  
  .mobile-only {
    display: flex;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .page-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .controls-card {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input-wrapper {
    width: 100%;
  }
  
  .form-select {
    width: 100%;
  }

  /* Optimize attendance check rows for mobile screen width */
  .student-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
    position: relative;
  }

  .student-roll {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 1rem;
  }

  .student-info-main {
    margin-bottom: 4px;
  }

  .student-name {
    font-size: 1.1rem;
    padding-right: 40px; /* Leave space for absolute roll number */
  }
  
  .attendance-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    gap: 6px;
  }
  
  .btn-status {
    padding: 10px 0; /* Increase touch target */
    font-size: 0.85rem;
    min-width: unset;
  }
  
  /* Stats grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
    gap: 12px;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  
  .stat-value {
    font-size: 1.4rem;
  }
}

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