@import url('https://fonts.googleapis.com/css2?family=Playfair+Display&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --maroon: #5a2420;
  --maroon-dark: #3d1810;
  --maroon-light: #7a3a34;
  --orange: #d48300;
  --orange-dark: #b87100;
  --orange-light: #e89b20;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --text: #2d2d2d;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-w: 260px;
  --header-h: 60px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.15);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all .25s cubic-bezier(.4,0,.2,1);
  --heading-font: 'Playfair Display', serif;
  --body-font: 'Inter', sans-serif;
  --text-main: #111111;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ─── Toast Notifications ─────────────────────────── */
.toast-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: #fff; box-shadow: var(--shadow-lg);
  font-size: 0.85rem; font-weight: 500;
  width: 100%; max-width: 340px;
  animation: slideIn .3s ease; border-left: 4px solid var(--info);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 0.95rem; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error i   { color: var(--danger); }
.toast.warning i { color: var(--warning); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── App Layout ──────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(160deg, var(--maroon-dark) 0%, var(--maroon) 60%, var(--maroon-light) 100%);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; height: 100vh;
  z-index: 200;
  box-shadow: 4px 0 24px rgba(90,36,32,.25);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand img {
  height: 40px; width: 40px; object-fit: contain;
  border-radius: 8px; background: rgba(255,255,255,.15); padding: 4px;
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: 0.88rem; line-height: 1.2; }
.brand-sub  { font-family: 'Montserrat', sans-serif; color: rgba(255,255,255,.5); font-size: 0.66rem; letter-spacing: 0.5px; }

.sidebar-user {
  margin: 14px 12px 6px;
  background: rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--orange); display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; color: #fff; font-weight: 700; flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name { color: #fff; font-size: 0.82rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,.5); font-size: 0.68rem; text-transform: capitalize; }

.sidebar-nav { flex: 1; padding: 6px 10px 10px; overflow-y: auto; }
.nav-section-label {
  color: rgba(255,255,255,.35); font-size: 0.62rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
  padding: 12px 8px 5px; user-select: none;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7); font-size: 0.875rem; font-weight: 400;
  cursor: pointer; transition: var(--transition); margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: left;
  min-height: 44px; /* touch target */
}
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; box-shadow: 0 4px 12px rgba(212,131,0,.35); }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 0.62rem; font-weight: 500; padding: 2px 6px; border-radius: 20px;
}

.sidebar-footer { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.1); flex-shrink: 0; }
.logout-btn {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 10px 13px; border-radius: var(--radius-sm);
  color: #fca5a5; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  border: 1.5px solid rgba(239,68,68,.3); background: rgba(239,68,68,.1); width: 100%;
}
.logout-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 4px 12px rgba(239,68,68,.3); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ─── Main Content ────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ─── App Header ──────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.mobile-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.2rem; color: var(--text-muted);
  cursor: pointer; padding: 8px; border-radius: 8px;
  min-width: 36px; min-height: 36px;
  flex-shrink: 0;
}
.mobile-toggle:hover { background: var(--bg); }
.page-title { font-size: 1rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-breadcrumb { font-size: 0.72rem; color: var(--text-muted); display: none; }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-badge {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--orange); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}

/* ─── Page Content ────────────────────────────────── */
.page-content { flex: 1; padding: 20px; }

.section-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.section-title { font-size: 1.25rem; font-weight: 700; color: var(--text); font-family: 'Montserrat', sans-serif; }
.section-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Stat Cards ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.maroon { background: rgba(90,36,32,.1);  color: var(--maroon); }
.stat-icon.orange  { background: rgba(212,131,0,.1); color: var(--orange); }
.stat-icon.green   { background: rgba(16,185,129,.1); color: var(--success); }
.stat-icon.red     { background: rgba(239,68,68,.1);  color: var(--danger); }
.stat-icon.blue    { background: rgba(59,130,246,.1); color: var(--info); }
.stat-value { font-size: 1.55rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-top: 4px; }

/* ─── Cards ───────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
}
.card-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.card-sub   { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Charts ──────────────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-card { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.chart-title { font-size: 0.85rem; font-weight: 700; color: var(--text); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.chart-title i { color: var(--orange); }
.chart-wrap { position: relative; height: 200px; }

/* ─── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); white-space: nowrap;
  min-height: 40px; /* touch target */
}
.btn-primary { background: var(--maroon); color: #fff; }
.btn-primary:hover { background: var(--maroon-dark); transform: translateY(-1px); }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(212,131,0,.3); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--maroon); color: var(--maroon); background: rgba(90,36,32,.04); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm  { padding: 6px 12px; font-size: 0.78rem; min-height: 34px; }
.btn-icon { padding: 8px; border-radius: 8px; min-width: 36px; min-height: 36px; justify-content: center; }

/* ─── Table ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  background: #f8fafc; padding: 10px 14px;
  font-weight: 700; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); text-align: left;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

/* ─── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700;
}
.badge-green  { background: rgba(16,185,129,.1);  color: var(--success); }
.badge-red    { background: rgba(239,68,68,.1);   color: var(--danger); }
.badge-orange { background: rgba(212,131,0,.1);   color: var(--orange); }
.badge-blue   { background: rgba(59,130,246,.1);  color: var(--info); }
.badge-maroon { background: rgba(90,36,32,.1);    color: var(--maroon); }

/* ─── Progress Bar ────────────────────────────────── */
.progress-bar-wrap { background: var(--border); border-radius: 20px; height: 7px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width .5s ease; }
.progress-bar.high { background: var(--success); }
.progress-bar.mid  { background: var(--warning); }
.progress-bar.low  { background: var(--danger); }

/* ─── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: 'Plus Jakarta Sans', sans-serif;
  background: #fff; color: var(--text); transition: var(--transition);
  min-height: 42px; /* touch target */
}
.form-control:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(90,36,32,.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── Filters Bar ─────────────────────────────────── */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  background: #fff; padding: 12px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  margin-bottom: 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-select {
  padding: 8px 11px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; font-family: 'Plus Jakarta Sans', sans-serif; background: #fff; color: var(--text);
  cursor: pointer; min-width: 130px; transition: var(--transition); min-height: 40px;
}
.filter-select:focus { outline: none; border-color: var(--maroon); }
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.82rem; pointer-events: none; }
.search-input {
  width: 100%; padding: 9px 11px 9px 34px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: 'Plus Jakarta Sans', sans-serif; transition: var(--transition);
  min-height: 40px;
}
.search-input:focus { outline: none; border-color: var(--maroon); }

/* ─── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 1000; padding: 0;
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: 20px 20px 0 0;
  width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.34,1.1,.64,1);
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal::before {
  content: ''; display: block;
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 12px auto 0; flex-shrink: 0;
}
.modal-header {
  padding: 14px 20px 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.1rem; color: var(--text-muted);
  cursor: pointer; padding: 6px; border-radius: 8px; min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-wrap: wrap;
  position: sticky; bottom: 0; background: #fff;
}
.modal-footer .btn { flex: 1; justify-content: center; }

/* ─── Attendance Toggle ───────────────────────────── */
.att-toggle {
  display: flex; border-radius: 8px; overflow: hidden;
  border: 1.5px solid var(--border); width: fit-content;
}
.att-toggle-btn {
  padding: 8px 16px; font-size: 0.82rem; font-weight: 700;
  cursor: pointer; border: none; background: #fff; transition: var(--transition);
  color: var(--text-muted); min-height: 38px; /* bigger touch target */
}
.att-toggle-btn.present.active { background: var(--success); color: #fff; }
.att-toggle-btn.absent.active  { background: var(--danger);  color: #fff; }
.att-toggle-btn:hover:not(.active) { background: #f0f2f5; }

/* ─── Pagination ──────────────────────────────────── */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; margin-top: 16px; flex-wrap: wrap;
}
.page-btn {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); background: #fff;
  font-size: 0.82rem; cursor: pointer; font-weight: 700; transition: var(--transition);
}
.page-btn:hover { border-color: var(--maroon); color: var(--maroon); }
.page-btn.active { background: var(--maroon); color: #fff; border-color: var(--maroon); }

/* ─── Alert Card ──────────────────────────────────── */
.alert-card {
  border-radius: var(--radius-sm); padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 14px; border: 1px solid;
}
.alert-card.warning { background: #fffbeb; border-color: #fcd34d; }
.alert-card.danger  { background: #fef2f2; border-color: #fca5a5; }
.alert-card.success { background: #f0fdf4; border-color: #86efac; }
.alert-card i { font-size: 0.95rem; flex-shrink: 0; margin-top: 1px; }
.alert-card.warning i { color: var(--warning); }
.alert-card.danger i  { color: var(--danger); }
.alert-card.success i { color: var(--success); }
.alert-card p { font-size: 0.85rem; line-height: 1.5; }

/* ─── Subject Attendance Cards ────────────────────── */
.subject-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.subject-att-card {
  background: #fff; border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); transition: var(--transition);
  border-top: 4px solid var(--border);
}
.subject-att-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.subject-att-card.high-att { border-top-color: var(--success); }
.subject-att-card.mid-att  { border-top-color: var(--warning); }
.subject-att-card.low-att  { border-top-color: var(--danger); }
.subj-name { font-weight: 700; font-size: 0.9rem; color: var(--text); margin-bottom: 3px; }
.subj-code { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; margin-bottom: 12px; }
.att-percentage { font-size: 1.8rem; font-weight: 700; margin-bottom: 6px; }
.att-percentage.high { color: var(--success); }
.att-percentage.mid  { color: var(--warning); }
.att-percentage.low  { color: var(--danger); }
.att-fraction { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 10px; }

/* ─── Spinner ─────────────────────────────────────── */
.spinner-wrap { display: flex; justify-content: center; align-items: center; padding: 50px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--maroon); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ─────────────────────────────────── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .35; display: block; }
.empty-state p { font-size: 0.88rem; }

/* ─── Mobile Action Bar ───────────────────────────── */
.mobile-action-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  z-index: 150; gap: 10px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}

/* ════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════ */

/* ─── Tablet (≤ 1024px) ───────────────────────────── */
@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .page-breadcrumb { display: none; }
}

/* ─── Mobile (≤ 768px) ────────────────────────────── */
@media (max-width: 768px) {
  :root { --header-h: 56px; }

  /* Sidebar becomes drawer */
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,.3); }

  /* Main content fills screen */
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .mobile-toggle { display: flex; align-items: center; justify-content: center; }

  /* Header */
  .app-header { padding: 0 14px; }
  .page-title { font-size: 0.95rem; }

  /* Page content */
  .page-content { padding: 14px; padding-bottom: 80px; }

  /* Section header wrap */
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
  .section-header .btn { flex: 1; justify-content: center; min-width: 120px; }

  /* Stats: 2 columns on tablet/mobile */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 1rem; }
  .stat-value { font-size: 1.35rem; }
  .stat-label { font-size: 0.68rem; }

  /* Charts */
  .chart-grid { grid-template-columns: 1fr; gap: 12px; }
  .chart-wrap { height: 180px; }

  /* Cards */
  .card { padding: 14px; }

  /* Tables — keep horizontal scroll, make compact */
  thead th { padding: 8px 10px; font-size: 0.68rem; }
  tbody td { padding: 10px 10px; font-size: 0.82rem; }

  /* Filters stack vertically */
  .filters-bar { flex-direction: column; gap: 10px; padding: 12px; }
  .filter-group { width: 100%; }
  .filter-select { width: 100%; min-width: unset; }
  .search-wrap { width: 100%; min-width: unset; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-row.cols-3 { grid-template-columns: 1fr; }

  /* Modal — bottom sheet style */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 95vh; }
  .modal-footer { flex-direction: row; }

  /* Attendance toggle — full button size */
  .att-toggle { width: 100%; }
  .att-toggle-btn { flex: 1; text-align: center; justify-content: center; }

  /* Subject cards — 1 col */
  .subject-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .subject-att-card { padding: 14px; }
  .att-percentage { font-size: 1.5rem; }

  /* Table action buttons side by side */
  .btn-icon { min-width: 34px; min-height: 34px; }

  /* Mobile action bar */
  .mobile-action-bar { display: flex; }

  /* Pagination center */
  .pagination { justify-content: center; }
}

/* ─── Small Mobile (≤ 480px) ──────────────────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 10px; gap: 8px; border-radius: var(--radius-sm); }
  .stat-icon { width: 36px; height: 36px; font-size: 0.9rem; }
  .stat-value { font-size: 1.2rem; }
  .stat-label { font-size: 0.65rem; }

  .subject-cards { grid-template-columns: 1fr; }

  .section-title { font-size: 1.1rem; }

  /* Smaller chart */
  .chart-wrap { height: 160px; }

  /* Table — hide less important cols via .hide-mobile class */
  .hide-mobile { display: none !important; }

  /* Badge smaller */
  .badge { font-size: 0.68rem; padding: 2px 7px; }

  /* Inline action buttons */
  table .btn-sm { padding: 5px 8px; font-size: 0.72rem; }

  /* Attendance toggle text */
  .att-toggle-btn { font-size: 0.78rem; padding: 8px 10px; }

  /* Toast full width */
  .toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: 100%; }
}

/* ─── Very Small (≤ 360px) ────────────────────────── */
@media (max-width: 360px) {
  .page-content { padding: 10px; padding-bottom: 80px; }
  .stats-grid { grid-template-columns: 1fr; }
  .card { padding: 12px; }
}

/* ─── Safe area for notched phones ───────────────────*/
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
  .mobile-action-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* ─── Alert System Styles ─────────────────────────── */
.ale-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
    pointer-events: none;
}

.btn-blue {
    background: var(--info);
    color: #fff;
}

.btn-blue:hover {
    background: #2563eb;
}

/* ─── Timetable Slot States ──────────────────────── */
#noSlotsCard {
    background: #fff;
    border-color: #cbd5e1 !important;
    max-width: 600px;
    margin: 40px auto;
}

#noSlotsCard i {
    color: #94a3b8;
}

#activeSlotCard {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

#activeSlotDetails {
    color: var(--maroon-dark);
}

#activeSlotTime {
    color: #166534;
    font-weight: 500;
}

#serverStatusInfo {
    font-family: monospace;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    color: #475569;
}

/* ─── VoiceOS Assistant Styles ────────────────────────── */
.btn-voice-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--maroon);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  z-index: 1001;
}

.btn-voice-nav:hover {
  background: var(--maroon);
  color: #fff;
  transform: scale(1.1);
  box-shadow: var(--shadow);
}

.btn-voice-nav.is-listening {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#voice-os-indicator {
  position: fixed;
  bottom: 90px;
  right: 30px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  border: 1px solid var(--border);
}

.voice-os-hidden {
  transform: translateY(150%) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

.voice-wave-container {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.voice-wave-bar {
  width: 3px;
  height: 8px;
  background: linear-gradient(to top, var(--maroon), var(--orange));
  border-radius: 10px;
  animation: wavePulse 1s ease-in-out infinite;
}

.voice-wave-bar:nth-child(2) { animation-delay: 0.1s; height: 12px; }
.voice-wave-bar:nth-child(3) { animation-delay: 0.2s; height: 16px; }
.voice-wave-bar:nth-child(4) { animation-delay: 0.3s; height: 12px; }
.voice-wave-bar:nth-child(5) { animation-delay: 0.4s; height: 8px; }

@keyframes wavePulse {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(2); }
}

.voice-os-label {
  font-family: var(--body-font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}

/* Floating Voice Trigger for Dashboards */
.voice-float {
  position: fixed;
  bottom: 25px;
  right: 85px; /* Offset from WhatsApp button */
  z-index: 1000;
  width: 50px;
  height: 50px;
}

@media (max-width: 768px) {
  #voice-os-indicator { bottom: 140px; right: 20px; padding: 10px 16px; }
  .voice-float { bottom: 20px; right: 20px; }
  .whatsapp-float { bottom: 85px; } /* Adjust WhatsApp for voice visibility on mobile */
}
