:root {
  --ink: #1a2744;
  --ink-soft: #6b7280;
  --paper: #f4f6fb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --accent: #c8a84b;
  --accent-hover: #b8963f;
  --paid: #059669;
  --pending: #d97706;
  --partial: #2563eb;
  --review: #d97706;
  --error: #dc2626;
  --ocr: #7c3aed;
  --manual: #6b7280;
  --sidebar-bg: #111827;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active: rgba(200,168,75,0.15);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Responsive media baseline: nothing may force the page sideways */
img, video, canvas, svg { max-width: 100%; }
img, video { height: auto; }

.display, h1, h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.mono, .num.mono { font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace; }

.eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 4px;
}

.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 200px;
  background: linear-gradient(180deg, rgba(200,168,75,0.06) 0%, transparent 100%);
  pointer-events: none;
}
.sidebar .brand {
  padding: 24px 20px 20px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.sidebar .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}
.sidebar .brand-text { display: flex; flex-direction: column; }
.sidebar .brand-name {
  color: #fff;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.sidebar .brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-top: 2px;
  font-weight: 600;
}

/* ── Sidebar nav ─────────────────────────── */
.sidebar nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 4px 10px;
  position: relative;
  overflow-y: auto;
  gap: 2px;
}

/* Nav icons (shared by standalone links, section headers, and section links) */
.sidebar .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

/* Standalone links (Dashboard, student/parent single links) */
.sidebar .nav-standalone {
  color: #9ca3af;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 450;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.sidebar .nav-standalone:hover {
  background: var(--sidebar-hover);
  color: #e5e7eb;
}
.sidebar .nav-standalone:hover .nav-icon { opacity: 0.85; }
.sidebar .nav-standalone.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 550;
}
.sidebar .nav-standalone.active .nav-icon { opacity: 1; }

/* ── Collapsible sections ────────────────── */
.sidebar .nav-section {
  margin-bottom: 1px;
}
.sidebar .nav-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  color: #9ca3af;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
  font-family: inherit;
  text-align: left;
}
.sidebar .nav-section-header:hover {
  background: var(--sidebar-hover);
  color: #d1d5db;
}
.sidebar .nav-section-header:hover .nav-icon { opacity: 0.85; }
.sidebar .nav-section-header .nav-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  opacity: 0.35;
  transition: transform 0.25s ease, opacity 0.15s;
  flex-shrink: 0;
}
.sidebar .nav-section.is-open > .nav-section-header .nav-chevron {
  transform: rotate(180deg);
  opacity: 0.6;
}
.sidebar .nav-section.is-open > .nav-section-header {
  color: #d1d5db;
}
.sidebar .nav-section.is-open > .nav-section-header .nav-icon {
  opacity: 0.85;
}

/* Section body — collapsible with max-height transition */
.sidebar .nav-section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.sidebar .nav-section.is-open > .nav-section-body {
  max-height: 500px;
}
.sidebar .nav-section-body a {
  color: #9ca3af;
  text-decoration: none;
  padding: 7px 12px 7px 40px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 450;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 1px 0;
}
.sidebar .nav-section-body a:hover {
  background: var(--sidebar-hover);
  color: #e5e7eb;
}
.sidebar .nav-section-body a.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 550;
  position: relative;
}
.sidebar .nav-section-body a.active::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
}

/* "New" badge inside sidebar links */
.sidebar .tag {
  background: var(--accent);
  color: #111827;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
  letter-spacing: 0.02em;
}

/* Sidebar footer */
.sidebar .foot {
  font-size: 12px;
  color: #6b7280;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin: 0 10px;
  flex-shrink: 0;
}

/* ── Main / Topbar ───────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.badge {
  background: var(--paper);
  text-transform: capitalize;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  border: 1px solid var(--border);
}
.logout {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.logout:hover { color: var(--error); background: rgba(220,38,38,0.06); }

.content { padding: 32px; flex: 1; min-width: 0; }

/* ── Page head ───────────────────────────── */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 28px; color: var(--ink); }
.page-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Quick Links bar ─────────────────────── */
.quick-links-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.ql-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
}
.ql-chip:hover {
  background: rgba(37,99,235,0.06);
  border-color: var(--partial);
  color: var(--partial);
}
.ql-chip svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.ql-chip-btn {
  font-family: inherit;
  margin: 0;
}
.ql-chip-btn:hover {
  background: rgba(5,150,105,0.06);
  border-color: var(--paid);
  color: var(--paid);
}

/* ── Admin/Manager quick-launch tiles ───── */
/* One row on laptop / desktop / tablet: tiles grow to share the width and
   shrink to fit (min-width:0 lets them go below their content size). Mobile
   re-wraps them into a 2-column grid below. */
.quick-launch {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px;
  margin-bottom: 26px;
}
.ql-tile {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.ql-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.ql-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ql-tile-icon svg { width: 23px; height: 23px; }
.ql-tile-icon.i-blue   { background: rgba(37,99,235,0.10);  color: var(--partial); }
.ql-tile-icon.i-green  { background: rgba(5,150,105,0.10);  color: var(--paid); }
.ql-tile-icon.i-purple { background: rgba(124,58,237,0.10); color: var(--ocr); }
.ql-tile-icon.i-gold   { background: rgba(200,168,75,0.14); color: var(--accent); }
.ql-tile-icon.i-red    { background: rgba(220,38,38,0.08);  color: var(--error); }
.ql-tile-label { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.ql-tile-desc  { font-size: 11.5px; color: var(--ink-soft); line-height: 1.3; }

/* Tablet / small-laptop: single row still, but tighten each tile so 7–8 fit
   comfortably without the labels getting crushed. */
@media (max-width: 1024px) {
  .quick-launch { gap: 10px; }
  .ql-tile { padding: 14px 12px; gap: 8px; }
  .ql-tile-icon { width: 38px; height: 38px; border-radius: 10px; }
  .ql-tile-icon svg { width: 20px; height: 20px; }
  .ql-tile-label { font-size: 13px; }
  .ql-tile-desc { font-size: 10.5px; }
}

/* Mobile: allow the row to wrap into a 2-column grid so tiles stay legible
   and keep a ≥44px tap target; drop to one column on very small screens. */
@media (max-width: 768px) {
  .quick-launch { flex-wrap: wrap; gap: 12px; }
  .ql-tile { flex: 1 1 calc(50% - 6px); }
}
@media (max-width: 480px) {
  .ql-tile { flex: 1 1 100%; }
}

/* ── Top Performers grade tabs ───────────── */
.tp-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 20px 0;
  flex-wrap: wrap;
}
.tp-tab {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tp-tab:hover { color: var(--ink); border-color: #d1d5db; }
.tp-tab.active {
  background: var(--ocr);
  border-color: var(--ocr);
  color: #fff;
}
/* At-Risk grade toggle reuses the pill look as plain links. */
a.tp-tab { text-decoration: none; display: inline-block; }

/* ── Stats ───────────────────────────────── */
.stats { display: flex; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.stat, .stats-responsive {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  min-width: 0;
  flex: 1 1 170px;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { font-size: 12px; color: var(--ink-soft); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Panels ──────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
}
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-body { padding: 24px; }

/* ── Collapsible subject groups (View Student results) ── */
/* Native <details>/<summary> so collapse/expand needs no JS (CSP-safe). Styled
   to match .panel; the caret rotates and the header gains a divider when open. */
details.subject-group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
details.subject-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #fafbfd;
  border-bottom: 1px solid transparent;
  user-select: none;
}
details.subject-group > summary::-webkit-details-marker { display: none; }
details.subject-group[open] > summary { border-bottom-color: var(--border); }
details.subject-group > summary .sg-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.subject-group > summary .caret {
  color: var(--ink-soft);
  font-size: 12px;
  display: inline-block;
  transition: transform 0.15s ease;
}
details.subject-group[open] > summary .caret { transform: rotate(90deg); }

/* ── Forms ───────────────────────────────── */
.field-row { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }

/* Side-by-side option forms (family-confirm pages) */
.split-forms { display: flex; gap: 12px; flex-wrap: wrap; }
.split-forms > form { flex: 1; min-width: 220px; }

/* GET filter bars above list tables (students, fees, staff, attendance…) */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar > div { display: flex; flex-direction: column; gap: 4px; }
input, select, textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: all 0.15s ease;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,168,75,0.15);
}
input[type="number"] { max-width: 100%; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.15s ease;
  letter-spacing: 0.01em;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2d3a56; box-shadow: var(--shadow-md); }
.btn-accent { background: var(--accent); color: var(--ink); font-weight: 700; }
.btn-accent:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--paper); border-color: #d1d5db; }

/* ── Tables ──────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-wrap .ledger { min-width: 500px; }
table.ledger { width: 100%; border-collapse: collapse; }
.ledger th, .ledger td {
  text-align: left;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.ledger th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
  background: #fafbfd;
}
.ledger tr:hover td { background: rgba(244,246,251,0.5); }
.ledger td.num, .ledger th.num { text-align: right; }

/* ── Pills ───────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  background: #f3f4f6;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.pill.paid { background: rgba(5,150,105,0.1); color: var(--paid); }
.pill.pending { background: rgba(217,119,6,0.1); color: var(--pending); }
.pill.partial { background: rgba(37,99,235,0.1); color: var(--partial); }
.pill.manual { background: rgba(107,114,128,0.1); color: var(--manual); }
.pill.ocr { background: rgba(124,58,237,0.1); color: var(--ocr); }
.pill.review { background: rgba(217,119,6,0.1); color: var(--review); }
.pill.error { background: rgba(220,38,38,0.08); color: var(--error); }

/* ── Flash messages ──────────────────────── */
.flash {
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.flash.ok {
  background: rgba(5,150,105,0.08);
  color: var(--paid);
  border: 1px solid rgba(5,150,105,0.15);
}
.flash.error {
  background: rgba(220,38,38,0.06);
  color: var(--error);
  border: 1px solid rgba(220,38,38,0.12);
}

/* ── Empty state ─────────────────────────── */
.empty { padding: 48px 20px; text-align: center; color: var(--ink-soft); }
.empty .display { font-size: 20px; color: var(--ink); margin-bottom: 8px; }

/* ── Tabs ────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-bar a {
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-bar a:hover { color: var(--ink); }
.tab-bar a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ── Attendance day cells ────────────────── */
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.day-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  background: var(--panel);
}
.day-cell .day-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.day-cell .day-counts {
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.day-cell .day-counts .c-present { color: var(--paid); }
.day-cell .day-counts .c-absent { color: var(--error); }
.day-cell .day-counts .c-late { color: var(--review); }

/* ── Student search results ──────────────── */
.att-student-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.att-student-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.att-student-row:last-child { border-bottom: none; }
.att-student-row:hover { background: #fafbfd; }
.att-student-row .att-s-info { display: flex; flex-direction: column; gap: 2px; }
.att-student-row .att-s-name { font-weight: 600; color: var(--ink); }
.att-student-row .att-s-meta { font-size: 11px; color: var(--ink-soft); }

/* ── Attendance history timeline ─────────── */
.att-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.att-timeline-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 16px;
}
.att-timeline-row:last-child { border-bottom: none; }
.att-timeline-row:hover { background: #fafbfd; }
.att-timeline-row .att-date { min-width: 110px; font-weight: 500; color: var(--ink); }
.att-timeline-row .att-day { min-width: 50px; font-size: 11px; color: var(--ink-soft); text-transform: uppercase; }

/* ── Attendance dashboard ────────────────── */
/* Incomplete-marking banner (amber, dismissible per view) */
.att-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(217,119,6,0.07);
  border: 1px solid rgba(217,119,6,0.25);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13.5px;
  color: var(--review);
}
.att-banner-icon { flex-shrink: 0; display: flex; padding-top: 1px; }
.att-banner-icon svg { width: 18px; height: 18px; }
.att-banner-text { flex: 1; color: var(--ink); line-height: 1.5; }
.att-banner-text strong { color: var(--review); }
.att-banner-close {
  flex: none;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--review);
  cursor: pointer;
  padding: 0 4px;
}
.att-banner-close:hover { color: var(--ink); }

/* Weekly trend + overview donut side by side */
.att-dash-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 20px;
  align-items: stretch;
}
.att-dash-grid > .panel { margin-bottom: 0; }
@media (max-width: 900px) {
  .att-dash-grid { grid-template-columns: 1fr; }
  .att-dash-grid > .panel { margin-bottom: 20px; }
}

/* Colour key under the weekly chart */
.att-chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 24px 16px;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.att-chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.att-chart-legend .key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Sortable class-wise table headings */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: var(--accent); }
.th-sort.sort-asc::after { content: ' ▲'; font-size: 9px; }
.th-sort.sort-desc::after { content: ' ▼'; font-size: 9px; }
#classWiseTable td .pill { margin-left: 8px; }

/* ── Login ───────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  position: relative;
  overflow: hidden;
}
.login-wrap::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(200,168,75,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(37,99,235,0.05) 0%, transparent 50%);
  pointer-events: none;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
}
.login-card .login-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 20px;
}
.login-card .login-brand {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.login-card h1 { margin: 0 0 24px; font-size: 24px; color: var(--ink); }
.role-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--paper);
}
.role-switch a {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.role-switch a.active {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

.login-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.login-alt span { font-weight: 500; }
.login-alt a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--paper);
  transition: all 0.15s;
}
.login-alt a:hover { background: var(--accent); color: var(--ink); }

.login-home {
  text-align: center;
  margin-top: 16px;
}
.login-home a {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s;
}
.login-home a:hover { color: var(--ink); }

/* ── Upload ──────────────────────────────── */
.upload-drop {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 60px 20px;
  text-align: center;
  background: var(--panel);
  transition: border-color 0.2s;
}
.upload-drop:hover { border-color: var(--accent); }
.upload-drop .display { font-size: 18px; margin-bottom: 8px; }
.upload-drop p { color: var(--ink-soft); font-size: 14px; margin-bottom: 20px; }

/* ── OCR layout ──────────────────────────── */
.ocr-layout { display: flex; gap: 20px; align-items: flex-start; }
.ocr-source { flex: 0 0 320px; position: sticky; top: 20px; }
.ocr-source img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.ocr-source .hint { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.ocr-layout .panel { flex: 1; }

.review-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
}
.total .l { display: block; font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.total { font-size: 20px; font-family: 'JetBrains Mono', monospace; font-weight: 700; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.high { background: var(--paid); }
.dot.medium { background: var(--pending); }
.dot.low { background: var(--error); }

/* ── Attendance ──────────────────────────── */
.attend-toggle { display: flex; gap: 6px; }
.attend-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.attend-btn:hover { border-color: #d1d5db; }
.attend-btn.present.active { background: var(--paid); border-color: var(--paid); color: #fff; }
.attend-btn.absent.active { background: var(--error); border-color: var(--error); color: #fff; }
.attend-btn.late.active { background: var(--pending); border-color: var(--pending); color: #fff; }

.attend-filters {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.attend-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  flex: 1;
  max-width: 260px;
}
.attend-filter-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.attend-filter-field input {
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.attend-filter-field input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(44,62,90,0.08);
}

/* ── Hamburger button ────────────────────── */
.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}
.hamburger:hover { background: var(--paper); }
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all 0.25s ease;
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ── Sidebar overlay (mobile) ────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.visible { opacity: 1; }

/* ── Dashboard stat cards with accent ────── */
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  min-width: 0;
  flex: 1;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.accent-blue::before { background: var(--partial); }
.stat-card.accent-green::before { background: var(--paid); }
.stat-card.accent-gold::before { background: var(--accent); }
.stat-card.accent-red::before { background: var(--error); }
.stat-card.accent-purple::before { background: var(--ocr); }
.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.stat-card .stat-icon svg { width: 20px; height: 20px; }
.stat-card.accent-blue .stat-icon { background: rgba(37,99,235,0.1); color: var(--partial); }
.stat-card.accent-green .stat-icon { background: rgba(5,150,105,0.1); color: var(--paid); }
.stat-card.accent-gold .stat-icon { background: rgba(200,168,75,0.12); color: var(--accent); }
.stat-card.accent-red .stat-icon { background: rgba(220,38,38,0.08); color: var(--error); }
.stat-card.accent-purple .stat-icon { background: rgba(124,58,237,0.1); color: var(--ocr); }
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Dashboard quick-action cards ────────── */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  text-decoration: none;
  color: var(--ink);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.action-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.action-card .action-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--paper);
  transition: background 0.2s;
}
.action-card:hover .action-icon { background: rgba(200,168,75,0.1); }
.action-card .action-icon svg { width: 20px; height: 20px; color: var(--ink-soft); }
.action-card:hover .action-icon svg { color: var(--accent); }
.action-card .action-text { display: flex; flex-direction: column; }
.action-card .action-title { font-size: 13.5px; font-weight: 600; }
.action-card .action-desc { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }

/* ── Dashboard recent activity ───────────── */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.activity-dot.green { background: var(--paid); }
.activity-dot.blue { background: var(--partial); }
.activity-dot.gold { background: var(--accent); }
.activity-text { font-size: 13.5px; flex: 1; }
.activity-time { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ── Pagination ──────────────────────────── */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
  flex-wrap: wrap;
  gap: 12px;
}
.pagination-info {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}
.pagination-links {
  display: flex;
  gap: 4px;
  align-items: center;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--border);
  background: #fff;
  transition: all 0.15s ease;
}
a.page-link:hover,
button.page-link:hover {
  background: var(--paper);
  border-color: var(--accent);
  color: var(--ink);
}
button.page-link { cursor: pointer; }
.page-link.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  pointer-events: none;
}
.page-link.disabled {
  color: #d1d5db;
  border-color: var(--border);
  background: #fafbfd;
  pointer-events: none;
}
.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 32px;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ── Card grid (parent portal etc.) ──────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.card-body {
  padding: 20px;
}
.card-body h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

/* ── Class Picker Component ──────────────────── */
.cpicker {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.cpicker-search {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
}
.cpicker-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cpicker-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,168,75,0.15);
}
.cpicker-summary {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--paper);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 34px;
  transition: background 0.2s, color 0.2s;
}
.cpicker-summary-count {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}
.cpicker-summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.cpicker-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(200,168,75,0.1);
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.cpicker-tag-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1;
  padding: 0 0 0 2px;
  font-family: inherit;
  transition: color 0.15s;
}
.cpicker-tag-x:hover { color: var(--error); }
.cpicker-summary-more {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 2px 6px;
}
.cpicker-list {
  max-height: 320px;
  overflow-y: auto;
}
.cpicker-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.cpicker-group-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  color: var(--ink-soft);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.cpicker-group.collapsed .cpicker-group-toggle {
  transform: rotate(-90deg);
}
.cpicker-group.collapsed .cpicker-group-body {
  display: none;
}
.cpicker-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}
.cpicker-group-count {
  font-weight: 400;
  color: var(--ink-soft);
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}
.cpicker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 38px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.cpicker-item:hover { background: #fafbfd; }
.cpicker-item:last-child { border-bottom: none; }
.cpicker-item-name { font-weight: 400; }
.cpicker-no-results {
  padding: 24px 14px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}
.cpicker-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}
.cpicker-hidden { display: none; }

/* ── Two-column inline grids (pick/OCR panels) ── */
.grid-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 12px;
}

/* ── Responsive ──────────────────────────── */
/* Only 1024 / 768 / 480 breakpoints are used portal-wide. */

/* Tablet landscape / small laptop: sidebar becomes off-canvas drawer */
@media (max-width: 1024px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    bottom: 0;
    width: min(240px, 85vw);
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
  .sidebar-overlay.active { display: block; }

  .content { padding: 24px; }
  .topbar { padding: 12px 24px; }
  .stat-card { padding: 16px 18px; }
  .stat-card .stat-value { font-size: 24px; }
  .action-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.chart-panel {
  display: flex;
  flex-direction: column;
}
.chart-panel--wide {
  grid-column: 1 / -1;
}
/* Admin dashboard row 1: attendance trend (wide) + mix donut + fee pie */
.charts-row--3 {
  grid-template-columns: 2fr 1fr 1fr;
}
/* Manager: records panel spans the full row on its own */
.charts-row--full { grid-template-columns: 1fr; }
/* Top Performers + Tests-awaiting-marking share a row (records panel wider) */
.charts-row--tp {
  grid-template-columns: 1fr 1.3fr;
}
/* Equal halves — overrides --tp's 1fr/1.3fr for the admin rows that pair two
   same-weight panels (records + marking, Top Performers + At-Risk) */
.charts-row--equal {
  grid-template-columns: 1fr 1fr;
}
/* Admin dashboard row 1: four compact charts side by side — quarter width
   each, shorter chart bodies and tighter heads so the row stays space-efficient */
.charts-row--quad {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.charts-row--quad .chart-body { height: 200px; padding: 8px 10px 10px; }
.charts-row--quad .panel-head { padding: 12px 14px; }
.charts-row--quad .panel-head h2 { font-size: 14.5px; }
@media (max-width: 1100px) {
  .charts-row--quad { grid-template-columns: 1fr 1fr; }
}
/* Scroll-capped panel bodies (dashboard rows that must not grow the page).
   Sticky header keeps column labels visible while the list scrolls. */
.capped-scroll { overflow-y: auto; }
.capped-scroll--300 { max-height: 300px; }
.capped-scroll--360 { max-height: 360px; }
.capped-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); }
/* Pending-marking table: tighter cells so the 6 columns fit the half-width
   panel without horizontal scroll; WA = compact icon-only reminder button. */
.pm-table { table-layout: fixed; width: 100%; }
/* the global .table-wrap .ledger rule forces min-width:500px for mobile
   scrolling — this compact panel must fit its column instead */
.table-wrap .ledger.pm-table { min-width: 0; }
.pm-table th, .pm-table td { padding: 8px 5px; overflow-wrap: break-word; }
.pm-table th { font-size: 10.5px; }
.pm-table th:nth-child(1), .pm-table td:nth-child(1) { width: 24%; }
.pm-table th:nth-child(2), .pm-table td:nth-child(2) { width: 25%; }
.pm-table th:nth-child(3), .pm-table td:nth-child(3) { width: 9%; }
.pm-table th:nth-child(4), .pm-table td:nth-child(4) { width: 17%; }
.pm-table th:nth-child(5), .pm-table td:nth-child(5) { width: 11%; }
.pm-table th:nth-child(6), .pm-table td:nth-child(6) { width: 14%; }
.wa-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 7px;
  color: #16a34a; background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.35);
  transition: background 0.15s ease, transform 0.15s ease;
}
.wa-ico:hover { background: rgba(22, 163, 74, 0.2); transform: translateY(-1px); }
.chart-body {
  position: relative;
  height: 260px;
  padding: 12px 16px 16px;
}
.chart-body--sm {
  height: 220px;
  max-width: 280px;
  margin: 0 auto;
}
.chart-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 8px;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 13px;
}

/* Mobile: full-width content, single-column forms, 44px tap targets,
   16px inputs (prevents iOS focus-zoom) */
@media (max-width: 768px) {
  .content { padding: 20px 16px; }
  .topbar { padding: 10px 16px; }
  .topbar .who span:not(.badge) { display: none; }

  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-head h1 { font-size: 22px; }

  .stats { gap: 12px; }
  .stat-card { min-width: calc(50% - 6px); padding: 14px 16px; }
  .stat-card .stat-value { font-size: 22px; }
  .stat-card .stat-icon { width: 34px; height: 34px; margin-bottom: 10px; }
  .stat-card .stat-icon svg { width: 16px; height: 16px; }
  .stat { min-width: calc(50% - 6px); padding: 14px 16px; }
  .stat .n { font-size: 22px; }

  .action-grid { grid-template-columns: 1fr; }

  .ledger th, .ledger td { padding: 10px 14px; font-size: 12.5px; }

  .login-card { width: 100%; max-width: 400px; margin: 16px; padding: 32px 24px; }

  .ocr-layout { flex-direction: column; }
  .ocr-source { position: static; flex: none; width: 100%; }

  .field-row { flex-direction: column; gap: 0; }
  .field { min-width: 0; width: 100%; }
  .field-row > .field { width: 100%; }

  /* Single-column forms: inputs and selects full width, ≥16px font, ≥44px tall */
  input, select, textarea {
    font-size: 16px;
    width: 100%;
    min-height: 44px;
  }
  input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
  .attend-filter-field { max-width: none; min-width: 0; width: 100%; }
  .attend-filter-field input { font-size: 16px; min-height: 44px; }

  /* Tap targets */
  .btn { min-height: 44px; }
  .ql-chip { min-height: 44px; display: inline-flex; }
  .page-link { min-width: 44px; height: 44px; font-size: 14px; }
  .attend-btn { width: 44px; height: 44px; }
  .logout { padding: 12px 14px; }
  .nav-standalone, .sidebar .nav-section-body a { min-height: 44px; }

  /* Two-column inline grids collapse */
  .grid-2col { grid-template-columns: 1fr; }

  /* Inline filter bars: full-width fields under 768px */
  .filter-bar > div { width: 100%; min-width: 0; }
  .filter-bar > div > select,
  .filter-bar > div > input { width: 100%; }
  .filter-bar > .filter-actions { width: auto; }

  .panel-body { padding: 16px; }
  .panel-head { padding: 14px 16px; }

  .review-foot { flex-direction: column; gap: 12px; align-items: flex-start; }
  .charts-row { grid-template-columns: 1fr; gap: 16px; }
  .charts-row--3 { grid-template-columns: 1fr; }
  .charts-row--tp { grid-template-columns: 1fr; }
  .charts-row--equal { grid-template-columns: 1fr; }
  .charts-row--quad { grid-template-columns: 1fr; }
  .chart-body { height: 220px; }

  .tab-bar a { padding: 8px 16px; font-size: 12.5px; }
  .card-grid { grid-template-columns: 1fr; }
  .quick-links-bar { padding: 12px 14px; }

  /* Family-confirm side-by-side option forms stack */
  .split-forms { flex-direction: column; }
  .split-forms > form { min-width: 0; width: 100%; }
}

/* Small mobile: stacked card rows for key lists, full-width stats */
@media (max-width: 480px) {
  .stat-card { min-width: 100%; }
  .stat { min-width: 100%; }
  .page-head h1 { font-size: 20px; }
  .btn { padding: 9px 14px; }
  .login-card { padding: 28px 20px; }
  .role-switch a { font-size: 12px; padding: 12px 4px; min-height: 44px; }
  .content { padding: 16px 12px; }
  .panel-head { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Card-row conversion for wide key lists (students, fees, defaulters…).
     Column headers become per-cell labels via td[data-label]. */
  table.ledger.card-table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
  }
  .card-table thead { display: none; }
  .card-table, .card-table tbody, .card-table tr, .card-table td { display: block; width: 100%; }
  .card-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    padding: 4px 0;
  }
  .card-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    padding: 7px 14px;
    border-bottom: none;
    font-size: 13px;
  }
  .card-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    padding-top: 2px;
  }
  .card-table td:not(:last-child) { border-bottom: 1px solid var(--border); }
  .card-table td.num { text-align: right; }
  .card-table td > form { width: auto; }
  .card-table td .btn { flex: 1; justify-content: center; }
}

/* ── Searchable student picker (shared typeahead) ────────────────────────
   One rule set for both consumers: the Fee add-record selector
   (views/fees/list.ejs) and every Student picker of the PDF-report filter
   cascade (views/reports/partials/filter-cascade.ejs). The dropdown is
   absolutely positioned under its .student-picker wrapper. */
.student-picker { position: relative; }
.student-typeahead-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
  background: var(--panel-bg, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.student-typeahead-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  cursor: pointer;
}
.student-typeahead-item:hover,
.student-typeahead-item.is-active { background: var(--hover-bg, #f5f5f5); }
.student-typeahead-item span { font-size: 12.5px; color: var(--muted, #888); }
.student-typeahead-empty { padding: 10px 12px; font-size: 13.5px; color: var(--muted, #888); }
