/* ═══════════════════════════════════════════════════════════════════════════
   FORD SCHOOL & COLLEGE — ATTENDANCE SYSTEM
   Design: Alpine Frost × Indigo Ink — institutional authority with clarity
   Fonts: Plus Jakarta Sans (UI) + Instrument Serif (display)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Core palette */
  --navy:        #0D1B4B;
  --navy-mid:    #1A2E6B;
  --navy-light:  #2E4A8F;
  --gold:        #C9A84C;
  --gold-light:  #E8C96A;
  --gold-pale:   #FDF3D8;

  /* Neutrals */
  --bg:          #F0F4FA;
  --surface:     #FFFFFF;
  --surface-2:   #F7F9FC;
  --border:      #DDE3EE;
  --border-dark: #B8C4D8;
  --text-primary:#0D1B4B;
  --text-secondary:#5A6A8A;
  --text-muted:  #8A9AB8;

  /* Status colors */
  --present:     #16A34A;
  --present-bg:  #DCFCE7;
  --absent:      #DC2626;
  --absent-bg:   #FEE2E2;
  --holiday:     #D97706;
  --holiday-bg:  #FEF3C7;
  --leave:       #7C3AED;
  --leave-bg:    #EDE9FE;
  --weekend:     #64748B;
  --weekend-bg:  #F1F5F9;

  /* Sidebar */
  --sidebar-w:   260px;
  --sidebar-bg:  #0D1B4B;
  --sidebar-text:#C8D4F0;
  --sidebar-active:#FFFFFF;
  --sidebar-hover:rgba(255,255,255,0.08);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(13,27,75,0.08);
  --shadow-md:   0 4px 16px rgba(13,27,75,0.12);
  --shadow-lg:   0 8px 32px rgba(13,27,75,0.16);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Transitions */
  --t-fast: 150ms ease;
  --t-mid:  250ms ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--t-mid);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo-emblem svg { width: 44px; height: 44px; flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; }
.school-name {
  font-family: 'Instrument Serif', serif;
  font-size: 1.1rem;
  color: #FFFFFF;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
.school-sub {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(200,212,240,0.45);
  padding: 8px 8px 4px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.nav-item svg { width: 16px; height: 16px; opacity: 0.7; transition: opacity var(--t-fast); }
.nav-item:hover { background: var(--sidebar-hover); color: #FFFFFF; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
}
.nav-item.active svg { opacity: 1; stroke: var(--navy); }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.session-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--sidebar-text);
}
.session-badge svg { width: 14px; height: 14px; }
.session-badge strong { color: var(--gold); }

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
}
.sidebar-toggle:hover { background: var(--bg); }
.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.class-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Pages ─────────────────────────────────────────────────────────────────── */
.page { display: none; padding: 28px 28px 48px; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 2rem;
  color: var(--navy);
  line-height: 1.2;
}
.page-header h1 .accent { color: var(--gold); }
.page-header p { color: var(--text-secondary); margin-top: 4px; font-size: 0.9rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background var(--t-fast), transform var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--navy-mid); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--navy);
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-gold {
  background: var(--gold);
  color: var(--navy);
  border: none;
  padding: 9px 20px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 700;
  transition: background var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-gold:hover { background: var(--gold-light); }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: 4px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--t-fast);
}
.btn-icon:hover { border-color: var(--navy); color: var(--navy); background: var(--bg); }

/* ── Selects ───────────────────────────────────────────────────────────────── */
.top-select {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t-fast);
  cursor: pointer;
}
.top-select:focus { border-color: var(--navy); }

/* ── Dashboard Stats ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-blue .stat-icon  { background: #EFF6FF; color: #2563EB; }
.stat-green .stat-icon { background: var(--present-bg); color: var(--present); }
.stat-red .stat-icon   { background: var(--absent-bg); color: var(--absent); }
.stat-gold .stat-icon  { background: var(--gold-pale); color: var(--gold); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

/* ── Dashboard Grid ────────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.dash-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.dash-card.full-width { grid-column: 1 / -1; }
.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.dash-card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}
.badge-navy { background: var(--navy); color: #fff; }
.badge-gold { background: var(--gold-pale); color: var(--gold); border: 1px solid var(--gold); }
.badge-green { background: var(--present-bg); color: var(--present); }
.badge-red { background: var(--absent-bg); color: var(--absent); }

/* Month pills */
.month-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.month-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.month-pill:hover { border-color: var(--navy); color: var(--navy); }
.month-pill.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.month-pill.current { border-color: var(--gold); color: var(--gold); }

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qa-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  text-align: center;
}
.qa-btn svg { width: 22px; height: 22px; color: var(--navy); }
.qa-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.qa-btn:hover svg { color: var(--gold); }

/* Bar chart */
.bar-chart-wrap { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); width: 80px; text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 22px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--navy), var(--navy-light)); border-radius: 4px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); display: flex; align-items: center; padding-left: 8px; }
.bar-count { font-size: 0.72rem; font-weight: 700; color: #fff; }

/* ── Upload Page ───────────────────────────────────────────────────────────── */
.upload-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  margin-bottom: 28px;
}
.upload-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.upload-zone {
  border: 2.5px dashed var(--border-dark);
  border-radius: var(--r-lg);
  padding: 48px 24px;
  text-align: center;
  transition: border-color var(--t-fast), background var(--t-fast);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--navy);
  background: #F0F4FF;
}
.upload-icon {
  width: 64px; height: 64px;
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.upload-icon svg { width: 28px; height: 28px; color: var(--navy); }
.upload-title { font-size: 1.05rem; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.upload-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--gold));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}
#progressText { font-size: 0.85rem; color: var(--text-secondary); text-align: center; }

.upload-result {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
}
.upload-result.success { background: var(--present-bg); color: var(--present); border: 1px solid #86EFAC; }
.upload-result.error   { background: var(--absent-bg); color: var(--absent); border: 1px solid #FCA5A5; }

.upload-info-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.upload-info-card h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); margin-bottom: 16px; }
.req-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.req-list li { display: flex; align-items: flex-start; gap: 10px; font-size: 0.83rem; color: var(--text-secondary); }
.req-icon { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.req-ok   { background: var(--present-bg); color: var(--present); }
.req-warn { background: var(--holiday-bg); color: var(--holiday); }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table thead tr { background: var(--navy); }
.data-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--t-fast); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:nth-child(even) { background: var(--surface-2); }
.data-table tbody tr:nth-child(even):hover { background: var(--bg); }
.data-table td { padding: 10px 14px; color: var(--text-primary); vertical-align: middle; }

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 24px 0 12px;
}

/* ── Filter Bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--t-fast);
  min-width: 240px;
}
.search-input:focus { border-color: var(--navy); }

/* ── Attendance Sheet ──────────────────────────────────────────────────────── */
.attendance-header-bar {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 22px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.att-header-info h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.4rem;
  color: var(--navy);
}
.att-header-info p { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.att-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Legend */
.att-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.legend-dot {
  width: 22px; height: 22px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
}
.legend-p  { background: var(--present-bg); color: var(--present); }
.legend-a  { background: var(--absent-bg); color: var(--absent); }
.legend-h  { background: var(--holiday-bg); color: var(--holiday); }
.legend-l  { background: var(--leave-bg); color: var(--leave); }
.legend-wk { background: var(--weekend-bg); color: var(--weekend); }

/* Attendance grid wrapper */
.att-grid-wrap {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.att-grid-scroll { overflow-x: auto; }

/* Attendance table */
.att-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 100%;
}
.att-table th, .att-table td {
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

/* Fixed left columns */
.att-table .col-sno   { width: 42px; min-width: 42px; }
.att-table .col-adm   { width: 72px; min-width: 72px; }
.att-table .col-name  { width: 180px; min-width: 180px; text-align: left; padding-left: 10px; }

/* Header rows */
.att-table .row-month-header th {
  background: var(--navy);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 10px 6px;
  letter-spacing: 0.04em;
}
.att-table .row-day-header th {
  background: #1A2E6B;
  color: #C8D4F0;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 2px;
  letter-spacing: 0.05em;
}
.att-table .row-date-header th {
  background: #2E4A8F;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 2px;
}

/* Student rows */
.att-table .row-student td {
  padding: 0;
  height: 34px;
}
.att-table .row-student:nth-child(even) .cell-info { background: var(--surface-2); }
.att-table .row-student:hover .cell-info { background: #EFF6FF; }

.cell-info {
  padding: 6px 8px;
  font-size: 0.78rem;
  color: var(--text-primary);
  background: var(--surface);
  height: 34px;
  display: flex;
  align-items: center;
}
.cell-sno  { justify-content: center; color: var(--text-muted); font-size: 0.72rem; }
.cell-adm  { justify-content: center; font-weight: 600; color: var(--navy); font-size: 0.72rem; }
.cell-name { font-weight: 500; }

/* Attendance cells */
.att-cell {
  width: 28px; min-width: 28px;
  height: 34px;
  cursor: pointer;
  transition: transform var(--t-fast);
  position: relative;
  font-size: 0.72rem;
  font-weight: 800;
  user-select: none;
}
.att-cell:hover { transform: scale(1.15); z-index: 2; }
.att-cell.status-P { background: var(--present-bg); color: var(--present); }
.att-cell.status-A { background: var(--absent-bg); color: var(--absent); }
.att-cell.status-H { background: var(--holiday-bg); color: var(--holiday); }
.att-cell.status-L { background: var(--leave-bg); color: var(--leave); }
.att-cell.status-W { background: var(--weekend-bg); color: var(--weekend); cursor: default; font-size: 0.6rem; }
.att-cell.status-W:hover { transform: none; }
.att-cell.status-  { background: #F8FAFC; color: transparent; }

/* Summary columns */
.col-summary { background: var(--surface-2); }
.cell-present-count { background: var(--present-bg); color: var(--present); font-weight: 700; font-size: 0.78rem; padding: 0 6px; }
.cell-absent-count  { background: var(--absent-bg); color: var(--absent); font-weight: 700; font-size: 0.78rem; padding: 0 6px; }
.cell-total-count   { background: #EFF6FF; color: #2563EB; font-weight: 700; font-size: 0.78rem; padding: 0 6px; }
.cell-prev-present  { background: #F0FDF4; color: #15803D; font-weight: 600; font-size: 0.75rem; padding: 0 6px; }
.cell-overall-p     { background: #DCFCE7; color: #15803D; font-weight: 700; font-size: 0.78rem; padding: 0 6px; }
.cell-overall-a     { background: #FEE2E2; color: #B91C1C; font-weight: 700; font-size: 0.78rem; padding: 0 6px; }
.cell-overall-t     { background: #EFF6FF; color: #1D4ED8; font-weight: 700; font-size: 0.78rem; padding: 0 6px; }
.cell-overall-pct   { background: var(--gold-pale); color: #92400E; font-weight: 800; font-size: 0.78rem; padding: 0 6px; }

/* Summary header cells */
.th-present  { background: #16A34A !important; }
.th-absent   { background: #DC2626 !important; }
.th-total    { background: #2563EB !important; }
.th-prev     { background: #0891B2 !important; }
.th-overall  { background: #7C3AED !important; }
.th-pct      { background: #D97706 !important; }

/* Bottom summary rows */
.row-total-present td { background: var(--present-bg); color: var(--present); font-weight: 700; font-size: 0.75rem; padding: 5px 4px; }
.row-total-absent  td { background: var(--absent-bg); color: var(--absent); font-weight: 700; font-size: 0.75rem; padding: 5px 4px; }
.row-grand-total   td { background: #DBEAFE; color: #1D4ED8; font-weight: 700; font-size: 0.75rem; padding: 5px 4px; }
.row-avg-att       td { background: var(--gold-pale); color: #92400E; font-weight: 700; font-size: 0.75rem; padding: 5px 4px; }
.row-label-cell    { text-align: left !important; padding-left: 10px !important; font-size: 0.72rem !important; font-weight: 700 !important; }

/* Class stats box */
.class-stats-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.cs-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cs-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cs-value { font-size: 1.1rem; font-weight: 800; color: var(--navy); }
.cs-value.gold { color: var(--gold); }
.cs-value.green { color: var(--present); }
.cs-value.red { color: var(--absent); }

/* Bulk mark bar */
.bulk-mark-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.bulk-mark-bar span { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.bulk-btn {
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: opacity var(--t-fast);
}
.bulk-btn:hover { opacity: 0.85; }
.bulk-p { background: var(--present-bg); color: var(--present); }
.bulk-a { background: var(--absent-bg); color: var(--absent); }
.bulk-h { background: var(--holiday-bg); color: var(--holiday); }

/* ── Reports Page ──────────────────────────────────────────────────────────── */
.reports-filter {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.reports-filter label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }

.report-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.report-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.report-card-header h3 { font-size: 1rem; font-weight: 700; color: var(--navy); }

/* Attendance percentage bar */
.pct-bar-wrap { display: flex; align-items: center; gap: 10px; }
.pct-bar { flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.pct-fill { height: 100%; border-radius: 5px; transition: width 0.6s ease; }
.pct-fill.high   { background: var(--present); }
.pct-fill.medium { background: var(--holiday); }
.pct-fill.low    { background: var(--absent); }
.pct-label { font-size: 0.78rem; font-weight: 700; width: 42px; text-align: right; }

/* ── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 16px;
}
.empty-state svg { width: 56px; height: 56px; opacity: 0.3; }
.empty-state p { font-size: 0.95rem; max-width: 360px; line-height: 1.6; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { background: var(--present); }
.toast.error   { background: var(--absent); }
.toast.warning { background: var(--holiday); color: var(--navy); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Print Styles ──────────────────────────────────────────────────────────── */
#printOverlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 10000;
  overflow: auto;
  padding: 20px;
}
.print-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--navy);
}
.print-school-name {
  font-family: 'Instrument Serif', serif;
  font-size: 1.6rem;
  color: var(--navy);
  font-weight: 700;
}
.print-sheet-title { font-size: 0.9rem; color: var(--text-secondary); margin-top: 2px; }
.print-close-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--absent);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  z-index: 10001;
}

@media print {
  .print-close-btn { display: none !important; }
  #printOverlay { position: static; padding: 0; }
  body > *:not(#printOverlay) { display: none !important; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .upload-layout { grid-template-columns: 1fr; }
  .class-selector-wrap { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
  .page-header h1 { font-size: 1.5rem; }
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-light); }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.font-bold   { font-weight: 700; }
.text-muted  { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }