@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ═══════════════════════════════════════════════
   VARIABLES / DESIGN TOKENS
═══════════════════════════════════════════════ */
:root {
  --bg-base:        #0a0e1a;
  --bg-surface:     #0f1525;
  --bg-card:        #141b2d;
  --bg-card-hover:  #1a2337;
  --bg-input:       #1e2740;

  --border:         rgba(255,255,255,0.08);
  --border-focus:   rgba(99,115,255,0.6);

  --text-primary:   #e8edf5;
  --text-secondary: #8892a4;
  --text-muted:     #5a6478;

  --accent:         #6373ff;
  --accent-glow:    rgba(99,115,255,0.3);
  --accent-light:   #8a97ff;

  --green:          #22c55e;
  --green-bg:       rgba(34,197,94,0.12);
  --amber:          #f59e0b;
  --amber-bg:       rgba(245,158,11,0.12);
  --red:            #ef4444;
  --red-bg:         rgba(239,68,68,0.12);
  --blue:           #0ea5e9;
  --blue-bg:        rgba(14,165,233,0.12);

  --sidebar-w:      260px;
  --radius:         14px;
  --radius-sm:      8px;
  --radius-lg:      20px;
  --shadow:         0 8px 32px rgba(0,0,0,0.4);
  --shadow-card:    0 4px 20px rgba(0,0,0,0.3);
  --glass:          rgba(255,255,255,0.04);
  --glass-border:   rgba(255,255,255,0.07);

  --transition:     0.2s ease;
  --font:           'Inter', sans-serif;
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: #fff; }

img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* ═══════════════════════════════════════════════
   TYPOGRAPHY
═══════════════════════════════════════════════ */
h1 { font-size: 2rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-secondary); }

.text-accent   { color: var(--accent-light); }
.text-green    { color: var(--green); }
.text-amber    { color: var(--amber); }
.text-red      { color: var(--red); }
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 0.85rem; }
.text-xs       { font-size: 0.75rem; }

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #4f5ff0 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(99,115,255,0.5);
  transform: translateY(-1px);
}

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #16a34a; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: var(--glass);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ═══════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.13); }

.card-glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 10px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: var(--bg-card); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ═══════════════════════════════════════════════
   BADGES / STATUS
═══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-green   { background: var(--green-bg);  color: var(--green); }
.badge-amber   { background: var(--amber-bg);  color: var(--amber); }
.badge-red     { background: var(--red-bg);    color: var(--red); }
.badge-blue    { background: var(--blue-bg);   color: var(--blue); }
.badge-accent  { background: rgba(99,115,255,0.15); color: var(--accent-light); }
.badge-muted   { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ═══════════════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════════════ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.accent { background: rgba(99,115,255,0.15); }
.stat-icon.green  { background: var(--green-bg); }
.stat-icon.amber  { background: var(--amber-bg); }
.stat-icon.blue   { background: var(--blue-bg); }
.stat-icon.red    { background: var(--red-bg); }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* ═══════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  background: var(--bg-surface);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.03); }

/* ═══════════════════════════════════════════════
   SIDEBAR LAYOUT
═══════════════════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #4f5ff0);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.sidebar-subtitle { font-size: 0.72rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

.sidebar-user {
  padding: 14px;
  margin: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.sidebar-user-name { font-weight: 600; color: var(--text-primary); }
.sidebar-user-role { font-size: 0.75rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 10px 10px; overflow-y: auto; }
.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(99,115,255,0.15);
  color: var(--accent-light);
}
.nav-item .nav-icon { font-size: 1.1rem; min-width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-weight: 700; font-size: 1.1rem; }
.topbar-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.page-content { padding: 24px; flex: 1; }

/* ═══════════════════════════════════════════════
   ATTENDANCE BUTTONS
═══════════════════════════════════════════════ */
.att-btn-group {
  display: flex;
  gap: 6px;
}
.att-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.15s ease;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
}
.att-btn:hover { transform: translateY(-1px); }

.att-btn[data-status="present"] { border-color: rgba(34,197,94,0.3); }
.att-btn[data-status="present"].active,
.att-btn[data-status="present"]:hover {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}
.att-btn[data-status="absent"] { border-color: rgba(239,68,68,0.3); }
.att-btn[data-status="absent"].active,
.att-btn[data-status="absent"]:hover {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}
.att-btn[data-status="late"] { border-color: rgba(245,158,11,0.3); }
.att-btn[data-status="late"].active,
.att-btn[data-status="late"]:hover {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber);
}
.att-btn[data-status="excused"] { border-color: rgba(14,165,233,0.3); }
.att-btn[data-status="excused"].active,
.att-btn[data-status="excused"]:hover {
  background: var(--blue-bg);
  color: var(--blue);
  border-color: var(--blue);
}

/* ═══════════════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════════════ */
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.progress-green { background: linear-gradient(90deg, var(--green), #4ade80); }
.progress-amber { background: linear-gradient(90deg, var(--amber), #fcd34d); }
.progress-red   { background: linear-gradient(90deg, var(--red), #f87171); }

/* ═══════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}
.modal-backdrop.show .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--glass);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red-bg); color: var(--red); }

/* ═══════════════════════════════════════════════
   ALERTS / TOASTS
═══════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  animation: slideInRight 0.3s ease;
  cursor: pointer;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--amber); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { font-size: 0.88rem; color: var(--text-primary); line-height: 1.4; }

/* ═══════════════════════════════════════════════
   LOGIN PAGE SPECIFIC
═══════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-hero {
  background: linear-gradient(145deg, #0d1226 0%, #0a0e1a 50%, #111827 100%);
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -20%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(99,115,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.auth-hero::after {
  content: '';
  position: absolute;
  bottom: -10%;
  right: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle, rgba(34,197,94,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.auth-hero-content { position: relative; z-index: 1; }

.auth-form-side {
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 50px;
  position: relative;
}

.auth-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}
.role-option {
  position: relative;
}
.role-option input { display: none; }
.role-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.role-label:hover { border-color: rgba(99,115,255,0.4); }
.role-label .role-icon { font-size: 1.8rem; }
.role-option input:checked + .role-label {
  border-color: var(--accent);
  background: rgba(99,115,255,0.1);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════
   CALENDAR WIDGET
═══════════════════════════════════════════════ */
.mini-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 10px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}
.cal-day.present { background: var(--green-bg); color: var(--green); }
.cal-day.absent  { background: var(--red-bg);   color: var(--red); }
.cal-day.late    { background: var(--amber-bg);  color: var(--amber); }
.cal-day.today   { border: 1px solid var(--accent); }
.cal-header-day  { font-size: 0.68rem; color: var(--text-muted); text-align: center; font-weight: 600; }

/* ═══════════════════════════════════════════════
   LIVE INDICATOR
═══════════════════════════════════════════════ */
.live-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ═══════════════════════════════════════════════
   EMPTY STATES
═══════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 0.88rem; }

/* ═══════════════════════════════════════════════
   LOADING SKELETON
═══════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ═══════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════ */
@keyframes fadeIn   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin     { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn 0.35s ease both; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ═══════════════════════════════════════════════
   MOBILE BURGER BUTTON
═══════════════════════════════════════════════ */
.burger-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}
.burger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ═══════════════════════════════════════════════
   SIDEBAR OVERLAY (MOBILE)
═══════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — LARGE TABLETS (≤ 1024px)
═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 230px; }

  .stat-cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — TABLETS (≤ 900px)
═══════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Login page */
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-form-side { padding: 40px 28px; min-height: 100vh; }
  .form-row { grid-template-columns: 1fr; }

  /* Grids */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar */
  .burger-btn { display: flex; }
  .sidebar-overlay { display: block; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,0.6);
  }

  /* Layout */
  .main-content { margin-left: 0; }
  .page-content { padding: 14px; }

  /* Topbar */
  .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar-title { font-size: 1rem; }

  /* Stat cards */
  .stat-cards-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 1.6rem; }

  /* Grids (columns → single column on mobile) */
  .grid-2,
  .grid-3 { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 16px; }

  /* Toast – bottom-center on mobile */
  #toast-container {
    top: auto;
    bottom: 16px;
    right: 12px;
    left: 12px;
    max-width: 100%;
    align-items: stretch;
  }
  .toast { font-size: 0.85rem; }

  /* Modal */
  .modal {
    padding: 20px 16px;
    border-radius: var(--radius);
    max-height: 95vh;
  }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal-backdrop.show .modal { transform: translateY(0) scale(1); }

  /* Attendance buttons – tighter on mobile */
  .att-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
  }
  .att-btn-group { gap: 4px; }

  /* Student row – stack vertically */
  .student-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .student-row .att-btn-group {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  .student-row > button:last-child { order: 4; }

  /* Request card – stack */
  .request-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .request-card .flex-center { width: 100%; }
  .request-card .flex-center .btn { flex: 1; justify-content: center; }

  /* Teacher topbar date input */
  #global-date { font-size: 0.8rem; padding: 6px 8px; max-width: 140px; }

  /* Class detail header on mobile */
  .class-detail-header { flex-wrap: wrap; gap: 8px; }
  .class-detail-header > div { flex-wrap: wrap; gap: 6px; }

  /* Flex-between responsiveness */
  .flex-between { flex-wrap: wrap; gap: 8px; }

  /* Auth form side */
  .auth-form-side { padding: 28px 20px; }

  /* Form rows always single column on mobile */
  .form-row { grid-template-columns: 1fr; }

  /* Table – horizontal scroll with proper min-width */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Note type bar – wraps */
  .note-type-bar { flex-wrap: wrap; gap: 6px; }
  .note-type-btn { font-size: 0.74rem; padding: 5px 10px; }

  /* Class selector tabs */
  .class-selector-tab { font-size: 0.78rem; padding: 6px 12px; }

  /* h1, h2 scaling */
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤ 480px)
═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .stat-cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 12px; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
  .stat-value { font-size: 1.4rem; }
  .stat-label { font-size: 0.72rem; }

  .att-btn-group { flex-wrap: wrap; }

  /* Login */
  .auth-form-side { padding: 24px 16px; }
  .auth-tabs { font-size: 0.85rem; }

  /* Sidebar narrower */
  :root { --sidebar-w: 240px; }
  .sidebar { width: 240px; }

  /* Page content */
  .page-content { padding: 10px; }

  /* Topbar */
  .topbar { padding: 10px 12px; }

  /* Cards */
  .card { padding: 14px 12px; }
  .card-header { flex-wrap: wrap; gap: 6px; }

  /* Feature grid on index */
  .features-grid { grid-template-columns: 1fr !important; }

  /* Buttons full-width in tight spaces */
  .btn-sm { padding: 5px 10px; font-size: 0.75rem; }
}

/* ═══════════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════════ */
.stat-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-4   { margin-bottom: 4px; }
.mb-8   { margin-bottom: 8px; }
.mb-12  { margin-bottom: 12px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ═══════════════════════════════════════════════
   TEACHER — CLASS DETAIL RESPONSIVE HELPERS
   (applied to dynamically rendered JS content)
═══════════════════════════════════════════════ */

/* The back / actions row rendered above student list */
.class-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.class-action-row-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* ═══════════════════════════════════════════════
   TOPBAR — TEACHER DATE PICKER ALIGNMENT
═══════════════════════════════════════════════ */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   MOBILE — TABLE CARD FALLBACK
   Give table cells a softer wrap on very small screens
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Actions column buttons — keep tightly packed */
  tbody td .flex-center { gap: 4px; }

  /* Shrink select dropdowns in table cells */
  .form-select[style*="width:auto"] {
    max-width: 120px;
    font-size: 0.75rem;
  }

  /* Stat cards grid rendered by JS uses inline style:
     override to keep 2-col on mobile */
  [style*="grid-template-columns:repeat(auto-fill"][style*="280px"],
  [style*="grid-template-columns:repeat(auto-fill"][style*="270px"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  /* On very small screens stat-cards-grid to 1 col */
  .stat-cards-grid { grid-template-columns: 1fr 1fr; }

  /* Request-form max-width remove on mobile */
  [style*="max-width:560px"],
  [style*="max-width:520px"] {
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Class & student grids: force single column */
  [style*="grid-template-columns:repeat(auto-fill"] {
    grid-template-columns: 1fr !important;
  }
}

/* ═══════════════════════════════════════════════
   SCROLL LOCK body helper (set via JS)
═══════════════════════════════════════════════ */
body.sidebar-open { overflow: hidden; }

/* ═══════════════════════════════════════════════
   MISC POLISH
═══════════════════════════════════════════════ */
/* Ensure live-dot in topbar-meta doesn't break */
.topbar-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* Prevent long email/text breaking table layout */
tbody td { word-break: break-word; }

/* Badge min-width for very small text */
.badge { white-space: nowrap; }

/* Smooth transition for sidebar overlay */
.sidebar, .sidebar-overlay {
  will-change: transform, opacity;
}
