/* ==========================================================================
   Anand Academy — Design System
   Cool indigo/teal palette, mobile-first, large touch targets.
   ========================================================================== */

:root {
  /* Brand */
  --color-primary: #4338ca;
  --color-primary-hover: #3730a3;
  --color-primary-light: #eef2ff;
  --color-accent: #0d9488;
  --color-accent-hover: #0f766e;
  --color-accent-light: #ccfbf1;

  /* Semantic (income/expense/status) */
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;

  /* Neutrals */
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-faint: #94a3b8;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Reset ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
/* The `hidden` attribute must always win — component rules like
   `.lightbox { display: flex }` / `.notice-bar { display: flex }` would
   otherwise override the UA default and leave the element (and its dark
   overlay) permanently on screen. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- App shell ---------------------------------------------------------
   Mobile-first: sidebar is an off-canvas drawer by default; becomes a
   fixed column at >=1024px. */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #312e81 0%, #4338ca 60%, #4f46e5 100%);
  color: #eef2ff;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.25rem 1.25rem 1rem;
}
.sidebar__brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; color: #fff;
  flex-shrink: 0;
}
.sidebar__brand-mark--logo {
  background: #fff;
  object-fit: cover;
  object-position: top center;
}
.sidebar__brand-text { line-height: 1.2; }
.sidebar__brand-text strong { display: block; font-size: 1rem; color: #fff; }
.sidebar__brand-text span { font-size: 0.72rem; color: #c7d2fe; letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar__branch {
  margin: 0.25rem 1rem 1rem;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: #e0e7ff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar__nav { flex: 1; padding: 0.25rem 0.75rem 1rem; }
.sidebar__section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a5b4fc;
  padding: 0.9rem 0.6rem 0.35rem;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 0.7rem;
  border-radius: var(--radius-sm);
  color: #e0e7ff;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.sidebar__link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar__link.is-active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.sidebar__link.is-disabled { opacity: 0.45; pointer-events: none; }
.sidebar__link .badge-soon {
  margin-left: auto;
  font-size: 0.6rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.sidebar__group { margin-bottom: 2px; }
.sidebar__group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0.9rem 0.6rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a5b4fc;
}
.sidebar__group-toggle:hover { color: #e0e7ff; }
.sidebar__group-chevron { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.8; transition: transform 0.15s ease; }
.sidebar__group.is-open .sidebar__group-chevron { transform: rotate(180deg); }
.sidebar__group-links { display: none; }
.sidebar__group.is-open .sidebar__group-links { display: block; }

.sidebar__footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar__user { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.sidebar__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.sidebar__user-meta strong { display: block; font-size: 0.82rem; color: #fff; }
.sidebar__user-meta span { font-size: 0.72rem; color: #c7d2fe; }
.sidebar__logout {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: 100%; padding: 0.55rem; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1); color: #fff; border: none;
  font-size: 0.82rem; font-weight: 600;
}
.sidebar__logout:hover { background: rgba(255, 255, 255, 0.18); }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

.main-area { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__menu-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.topbar__menu-btn:hover { background: var(--color-bg); }
.topbar__title { font-size: 1.05rem; font-weight: 700; flex: 1; min-width: 0; }
.topbar__title span {
  display: block; font-size: 0.72rem; font-weight: 500; color: var(--color-text-muted);
}
.topbar__actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--color-border); background: var(--color-surface);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.icon-btn svg { width: 18px; height: 18px; color: var(--color-text-muted); }
.icon-btn:hover { background: var(--color-bg); }
.icon-btn__dot {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--color-danger); border: 2px solid var(--color-surface);
}
.icon-btn__badge {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px;
  border-radius: 999px; background: var(--color-danger); color: #fff;
  font-size: 0.65rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid var(--color-surface);
}

/* Teacher-portal topbar extras: boxed Notice, date. (Profile/logout already
   live in the sidebar — no duplicate avatar/dropdown in the topbar.) */
.topbar__notice-box {
  display: none; align-items: center; gap: 0.35rem;
  border: 1.5px solid var(--color-text); border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem; font-size: 0.8rem; white-space: nowrap; overflow: hidden;
}
.topbar__notice-box strong { flex-shrink: 0; }
.topbar__notice-box span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__date {
  display: none; flex-direction: column; align-items: flex-end; line-height: 1.25;
  font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.topbar__date span { font-size: 0.7rem; font-weight: 500; color: var(--color-text-muted); }
@media (min-width: 900px) {
  .topbar__notice-box { display: flex; max-width: 260px; }
  .topbar__date { display: flex; }
}

.content { flex: 1; padding: 1.1rem 1rem 3rem; max-width: 1280px; width: 100%; margin: 0 auto; }

/* Single-object / form pages: the narrow card sits centred on the page
   rather than hugging the left edge. Any card the page constrains with an
   inline max-width (the convention across every *_form.html) is centred,
   and the back-link / helper rows above it line up to the same 640px column. */
.content > .card[style*="max-width"],
.content > form > .card[style*="max-width"],
.content > .form-card { margin-left: auto; margin-right: auto; }
.content:has(> .card[style*="max-width"]) > .flex,
.content:has(> .card[style*="max-width"]) > .card:not([style*="max-width"]),
.content:has(> .card[style*="max-width"]) > .alert {
  max-width: 640px; margin-left: auto; margin-right: auto;
}

/* ---- Cards / stat tiles ------------------------------------------------ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.15rem; border-bottom: 1px solid var(--color-border);
  gap: 0.75rem; flex-wrap: wrap;
}
.card__header h2 { font-size: 0.98rem; font-weight: 700; }
.card__header p { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 2px; }
.card__body { padding: 1.15rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-tile::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--tile-accent, var(--color-primary));
}
.stat-tile__label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-text-muted); font-weight: 600; display: flex; align-items: center; gap: 0.4rem;
}
.stat-tile__label svg { width: 14px; height: 14px; }
.stat-tile__value { font-size: 1.5rem; font-weight: 800; margin-top: 0.35rem; letter-spacing: -0.01em; }
.stat-tile__sub { font-size: 0.76rem; color: var(--color-text-muted); margin-top: 0.15rem; }
.stat-tile--income { --tile-accent: var(--color-success); }
.stat-tile--expense { --tile-accent: var(--color-danger); }
.stat-tile--net { --tile-accent: var(--color-primary); }
.stat-tile--accent { --tile-accent: var(--color-accent); }

.section-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 1024px) { .section-grid--2 { grid-template-columns: 1.4fr 1fr; } }
@media (min-width: 1024px) { .section-grid--charts { grid-template-columns: 1fr 1fr; } }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 0.86rem; padding: 0.62rem 1.1rem;
  min-height: 44px; transition: background 0.15s ease, border-color 0.15s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-accent { background: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-hover); }
.btn-outline { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.55; pointer-events: none; }

/* ---- Badges / status ----------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 700; padding: 0.22rem 0.6rem; border-radius: 999px;
}
.badge-success { background: var(--color-success-light); color: #15803d; }
.badge-danger { background: var(--color-danger-light); color: #b91c1c; }
.badge-warning { background: var(--color-warning-light); color: #b45309; }
.badge-neutral { background: var(--color-border); color: var(--color-text-muted); }

/* ---- Tables --------------------------------------------------------------- */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 0.86rem; }
.data-table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-text-muted); font-weight: 700; padding: 0.7rem 0.9rem;
  background: var(--color-bg); border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--color-primary-light); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.text-income { color: var(--color-success); font-weight: 700; }
.text-expense { color: var(--color-danger); font-weight: 700; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-muted); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 0.75rem; opacity: 0.4; }

/* Student Attendance — one small checkbox-style radio per Present/Absent
   column instead of a per-row dropdown: a single tap marks the student,
   no picker to open/scroll through. */
.attendance-table__col { width: 70px; text-align: center; }
.attendance-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--color-border);
  cursor: pointer; transition: border-color 0.12s ease, background 0.12s ease;
}
.attendance-check input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; cursor: pointer; }
.attendance-check--present input { accent-color: var(--color-success); }
.attendance-check--absent input { accent-color: var(--color-danger); }
.attendance-check--leave input { accent-color: var(--color-warning); }
.attendance-check--late input { accent-color: var(--color-primary); }
.attendance-check--weekly-off input { accent-color: var(--color-text-muted); }
.attendance-check--present:has(input:checked) { border-color: var(--color-success); background: var(--color-success-light); }
.attendance-check--absent:has(input:checked) { border-color: var(--color-danger); background: var(--color-danger-light); }
.attendance-check--leave:has(input:checked) { border-color: var(--color-warning); background: var(--color-warning-light); }
.attendance-check--late:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-light); }
.attendance-check--weekly-off:has(input:checked) { border-color: var(--color-text-muted); background: rgba(100, 116, 139, 0.12); }

/* ---- Forms ------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 640px) { .form-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.field--wide { grid-column: 1 / -1; }
.field label {
  display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--color-text);
}
.field .hint { font-size: 0.72rem; color: var(--color-text-muted); margin-top: 0.3rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.65rem 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  min-height: 44px;
}
.field textarea { min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light);
}
.field .error { color: var(--color-danger); font-size: 0.76rem; margin-top: 0.3rem; }
.field-inline { display: flex; align-items: center; gap: 0.5rem; }

/* ---- dd-mm-yyyy date picker (static/js/app.js) ---------------------- */
.datepick { position: relative; display: block; }
.datepick > input { width: 100%; padding-right: 2.5rem; }
.datepick__btn {
  position: absolute; top: 50%; right: 0.5rem; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0.3rem; color: var(--color-text-muted);
}
.datepick__btn:hover { color: var(--color-primary); }
.datepick__pop {
  position: fixed; z-index: 1200; width: 268px; padding: 0.6rem;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.datepick__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.datepick__title { font-size: 0.85rem; font-weight: 600; }
.datepick__nav {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  font-size: 1rem; line-height: 1; color: var(--color-text);
}
.datepick__nav:hover { background: var(--color-bg); }
.datepick__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepick__dow {
  text-align: center; font-size: 0.68rem; font-weight: 600;
  color: var(--color-text-faint); padding: 0.25rem 0;
}
.datepick__day {
  height: 32px; border: 0; background: none; border-radius: var(--radius-sm);
  font-size: 0.8rem; color: var(--color-text);
}
.datepick__day:hover:not(:disabled) { background: var(--color-primary-light); }
.datepick__day.is-muted { color: var(--color-text-faint); }
.datepick__day.is-today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--color-border); }
.datepick__day.is-selected,
.datepick__day.is-selected:hover { background: var(--color-primary); color: #fff; }
.datepick__day:disabled { opacity: 0.3; cursor: default; }
.datepick__foot { display: flex; justify-content: space-between; margin-top: 0.5rem; }
.datepick__link {
  background: none; border: 0; font-size: 0.76rem; font-weight: 600;
  color: var(--color-primary); padding: 0.3rem 0.4rem; border-radius: var(--radius-sm);
}
.datepick__link:hover { background: var(--color-primary-light); }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin-bottom: 1rem;
}
.filter-bar .field { min-width: 150px; flex: 1; }

/* ---- Alerts / messages -------------------------------------------------------- */
.alert {
  border-radius: var(--radius-sm); padding: 0.75rem 1rem; font-size: 0.85rem;
  border: 1px solid transparent; margin-bottom: 0.85rem; display: flex; gap: 0.5rem; align-items: flex-start;
}
.alert-success { background: var(--color-success-light); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--color-danger-light); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--color-warning-light); color: #92400e; border-color: #fde68a; }
.alert-info { background: var(--color-primary-light); color: #3730a3; border-color: #c7d2fe; }

/* ---- Auth (login) shell -------------------------------------------------------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 15% 15%, #4f46e5 0%, #312e81 45%, #1e1b4b 100%);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--color-surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem 1.75rem;
}
.auth-card__brand { text-align: center; margin-bottom: 1.5rem; }
.auth-card__brand .sidebar__brand-mark { margin: 0 auto 0.75rem; background: var(--color-primary-light); color: var(--color-primary); }
.auth-card__brand h1 { font-size: 1.15rem; font-weight: 800; color: var(--color-text); }
.auth-card__brand p { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.2rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.auth-card__footer { text-align: center; margin-top: 1.25rem; font-size: 0.78rem; color: var(--color-text-muted); }

/* ---- Utilities ------------------------------------------------------------------- */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.82rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.85rem; }
.chart-box { position: relative; height: 260px; }
.chart-box--sm { height: 200px; }

/* ---- Bottom nav (mobile app feel) ---------------------------------------
   Teacher Panel only (base.html sets body.has-bottom-nav) — an Android-style
   fixed tab bar for the handful of things a teacher reaches for constantly;
   everything else stays one tap away behind "More" (opens the same sidebar
   drawer as the topbar hamburger — see app.js). Hidden entirely at desktop
   width, where the sidebar is already always visible. */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.2rem;
  padding: 0.5rem 0.25rem;
  min-height: 58px;
  border: none; background: transparent;
  color: var(--color-text-muted);
  font-size: 0.66rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav__item svg { width: 21px; height: 21px; }
.bottom-nav__item.is-active { color: var(--color-primary); }

body.has-bottom-nav .content { padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0)); }

/* App-like touch polish (site-wide, not just the bottom nav) */
html { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
a, button, .btn { -webkit-tap-highlight-color: transparent; }

/* ---- Desktop layout ---------------------------------------------------------------- */
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); }
  .main-area { margin-left: var(--sidebar-width); }
  .topbar__menu-btn { display: none; }
  .sidebar-backdrop { display: none; }
  .content { padding: 1.5rem 2rem 3rem; }
  .bottom-nav { display: none; }
  body.has-bottom-nav .content { padding-bottom: 3rem; }
}

/* ==========================================================================
   Admin Dashboard — widgets specific to dashboard/index.html
   ========================================================================== */

/* Filter bar: FY / Branch / Date-range selects + Refresh, plus a Notice card. */
.dash-filters {
  display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-end;
  margin-bottom: 1.1rem;
}
.dash-filters .field { min-width: 150px; flex: 0 1 190px; margin: 0; }
.dash-filters .field label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.dash-filters .field select { min-height: 42px; padding: 0.5rem 0.7rem; }
.dash-filters .btn { min-height: 42px; }
.dash-filters__spacer { flex: 1 1 auto; }

.notice-card {
  flex: 1 1 260px; min-width: 240px; max-width: 420px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 0.7rem 0.85rem;
}
.notice-card__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 0.4rem;
}
.notice-card__list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 96px; overflow-y: auto; }
.notice-card__item { font-size: 0.8rem; line-height: 1.35; }
.notice-card__item strong { display: block; font-weight: 600; color: var(--color-text); }
.notice-card__item span { color: var(--color-text-muted); font-size: 0.74rem; }
.notice-card__empty { font-size: 0.8rem; color: var(--color-text-faint); }

/* KPI tiles: present / absent split under the value. */
.stat-tile__split { display: flex; gap: 0.9rem; margin-top: 0.35rem; font-size: 0.76rem; }
.stat-tile__split b { font-weight: 700; }
.stat-tile__split .is-present { color: var(--color-success); }
.stat-tile__split .is-absent { color: var(--color-danger); }
.stat-tile__split .is-late { color: #b45309; text-decoration: none; }
.stat-tile__split a.is-late:hover { text-decoration: underline; }
.stat-tile__split a.is-present,
.stat-tile__split a.is-absent { text-decoration: none; }
.stat-tile__split a.is-present:hover,
.stat-tile__split a.is-absent:hover { text-decoration: underline; }

/* 3-up grid for the breakdown row. */
.section-grid--3 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .section-grid--3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .section-grid--3 { grid-template-columns: 1fr 1.1fr 1fr; } }

/* Cash Position rows. */
.cash-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0; font-size: 0.86rem; border-bottom: 1px dashed var(--color-border);
}
.cash-row:last-child { border-bottom: none; }
.cash-row__label { color: var(--color-text-muted); display: flex; align-items: center; gap: 0.45rem; }
.cash-row__label svg { width: 15px; height: 15px; }
.cash-row--total { font-weight: 800; font-size: 0.95rem; }
.cash-row--total .cash-row__label { color: var(--color-text); }

/* Important Alerts list. */
.alert-list { display: flex; flex-direction: column; gap: 0.6rem; }
.alert-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 0.84rem;
}
.alert-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-item__text { flex: 1; min-width: 0; }
.alert-item__text b { display: block; font-weight: 700; }
.alert-item__text span { font-size: 0.75rem; opacity: 0.85; }
.alert-item--danger { background: var(--color-danger-light); color: #991b1b; border-color: #fecaca; }
.alert-item--warning { background: var(--color-warning-light); color: #92400e; border-color: #fde68a; }
.alert-item--info { background: var(--color-primary-light); color: #3730a3; border-color: #c7d2fe; }

/* Branchwise comparison: proportional Net bar in the last cell. */
.mini-bar { position: relative; height: 8px; border-radius: 999px; background: var(--color-border); overflow: hidden; margin-top: 0.3rem; }
.mini-bar__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--color-primary); }
.mini-bar__fill--neg { background: var(--color-danger); }

/* Legend list next to the doughnut charts. */
.chart-legend { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.6rem; }
.chart-legend__row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.chart-legend__swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-legend__name { flex: 1; min-width: 0; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-legend__val { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Chart range tabs on the Overview card. */
.chart-tabs { display: inline-flex; gap: 2px; background: var(--color-bg); border-radius: var(--radius-sm); padding: 3px; }
.chart-tabs button {
  border: none; background: transparent; font-size: 0.76rem; font-weight: 600;
  padding: 0.3rem 0.6rem; border-radius: 6px; color: var(--color-text-muted);
}
.chart-tabs button.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   Teacher Dashboard — widgets specific to dashboard/teacher.html
   ========================================================================== */

/* Payment Due callout — full-width danger card above the fold. */
.payment-due-card {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.9rem;
  background: var(--color-danger-light); border: 1px solid #fecaca; border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1.1rem;
}
.payment-due-card__title { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #b91c1c; }
.payment-due-card__amount { font-size: 1.1rem; font-weight: 800; color: #991b1b; margin-top: 0.2rem; }

/* Assigned Details: 4-up mini-stat grid (Branches/Courses/Classes/Subjects). */
.assigned-details-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
@media (min-width: 720px) { .assigned-details-grid { grid-template-columns: repeat(4, 1fr); } }
.assigned-details-grid__item { display: flex; align-items: flex-start; gap: 0.65rem; }
.assigned-details-grid__icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--color-primary-light);
  color: var(--color-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.assigned-details-grid__icon svg { width: 18px; height: 18px; }
.assigned-details-grid__count { font-size: 1.15rem; font-weight: 800; line-height: 1.2; }
.assigned-details-grid__label { font-size: 0.78rem; font-weight: 700; color: var(--color-text); }
.assigned-details-grid__list { font-size: 0.74rem; color: var(--color-text-muted); }

/* Tappable action tiles (Take Attendance / My Timetable / Face Check-In). */
.tappable-tile { padding: 1.15rem; display: flex; align-items: center; gap: 0.85rem; }
.tappable-tile__icon {
  width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.tappable-tile__icon svg { width: 20px; height: 20px; }
.tappable-tile__icon--primary { background: var(--color-primary-light); color: var(--color-primary); }
.tappable-tile__icon--accent { background: var(--color-accent-light); color: var(--color-accent); }
.tappable-tile__icon--success { background: var(--color-success-light); color: var(--color-success); }

/* Right-hand rail (Quick Actions + tappable tiles), stacked alongside the
   main column — mirrors the admin dashboard's Cash Position/Alerts rail. */
.dashboard-rail { display: flex; flex-direction: column; gap: 1rem; }

/* Quick Actions list — icon + title/subtitle rows with a trailing chevron. */
.quick-action-list { display: flex; flex-direction: column; gap: 0.15rem; }
.quick-action-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.4rem; border-radius: var(--radius-sm);
}
.quick-action-item:hover { background: var(--color-bg); }
.quick-action-item__icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.quick-action-item__icon svg { width: 18px; height: 18px; }
.quick-action-item__icon--success { background: var(--color-success-light); color: var(--color-success); }
.quick-action-item__icon--primary { background: var(--color-primary-light); color: var(--color-primary); }
.quick-action-item__icon--purple { background: #ede9fe; color: #7c3aed; }
.quick-action-item__icon--warning { background: var(--color-warning-light); color: var(--color-warning); }
.quick-action-item__icon--danger { background: var(--color-danger-light); color: var(--color-danger); }
.quick-action-item__body { flex: 1; min-width: 0; }
.quick-action-item__body strong { display: block; font-size: 0.87rem; font-weight: 700; }
.quick-action-item__body span { display: block; font-size: 0.75rem; color: var(--color-text-muted); margin-top: 1px; }
.quick-action-item__chevron { flex-shrink: 0; color: var(--color-text-faint); }

/* ==========================================================================
   Round-2 correction sheet — shared widgets
   ========================================================================== */

/* Fee-collection "Fee for Month(s)" — compact multi-column checkbox grid
   instead of one full-width row per month. Checkbox sits just left of the
   month name. */
[data-field="fee_for_months"] > div,
[data-field="fee_for_months"] > ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.9rem;
  margin: 0; padding: 0; list-style: none;
}
@media (min-width: 560px) {
  [data-field="fee_for_months"] > div,
  [data-field="fee_for_months"] > ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 820px) {
  [data-field="fee_for_months"] > div,
  [data-field="fee_for_months"] > ul { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
[data-field="fee_for_months"] > div > div,
[data-field="fee_for_months"] > ul > li { margin: 0; }
[data-field="fee_for_months"] label {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.86rem; font-weight: 500; margin: 0; cursor: pointer;
}
[data-field="fee_for_months"] input[type="checkbox"] {
  width: 16px; height: 16px; min-height: 0;
  padding: 0; margin: 0; flex-shrink: 0;
}

/* Bulk timetable entry — "Classes" / "Periods" checkbox grid (same shape as
   the fee-months grid above: compact checkbox chips, 2-3 per row, no bullets,
   no stray vertical gap — a raw CheckboxSelectMultiple <ul> looks broken
   without this). */
[data-field="bulk-batches"] > div,
[data-field="bulk-batches"] > ul,
[data-field="class-rows"] > div,
[data-field="class-rows"] > ul,
[data-field="periods"] > div,
[data-field="periods"] > ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.5rem 0.7rem;
  margin: 0; padding: 0; list-style: none;
}
[data-field="bulk-batches"] > div > div,
[data-field="bulk-batches"] > ul > li,
[data-field="class-rows"] > div > div,
[data-field="class-rows"] > ul > li,
[data-field="periods"] > div > div,
[data-field="periods"] > ul > li { margin: 0; }
[data-field="bulk-batches"] label,
[data-field="class-rows"] label,
[data-field="periods"] label {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.86rem; font-weight: 500; margin: 0; cursor: pointer;
  padding: 0.5rem 0.7rem; border: 1px solid var(--color-border);
  border-radius: 9px; transition: border-color 0.12s ease, background 0.12s ease;
}
[data-field="bulk-batches"] label:hover,
[data-field="class-rows"] label:hover,
[data-field="periods"] label:hover { border-color: var(--color-primary); }
[data-field="bulk-batches"] label:has(input:checked),
[data-field="class-rows"] label:has(input:checked),
[data-field="periods"] label:has(input:checked) {
  border-color: var(--color-primary); background: var(--color-primary-light); font-weight: 600;
}
[data-field="bulk-batches"] input[type="checkbox"],
[data-field="class-rows"] input[type="checkbox"],
[data-field="periods"] input[type="checkbox"] {
  width: 16px; height: 16px; min-height: 0;
  padding: 0; margin: 0; flex-shrink: 0; accent-color: var(--color-primary);
}

/* Bulk timetable wizard — step indicator + toolbars + grid. */
.tt-steps {
  list-style: none; margin: 0 0 1.1rem; padding: 0.6rem 0.9rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface);
}
.tt-steps__item {
  display: flex; align-items: center; gap: 0.45rem; white-space: nowrap;
  font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted);
}
.tt-steps__item:not(:last-child)::after {
  content: ""; width: 1.4rem; height: 1px; background: var(--color-border);
  margin-left: 0.5rem;
}
.tt-steps__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 999px; flex-shrink: 0;
  border: 1px solid var(--color-border); background: var(--color-bg);
  font-size: 0.75rem; font-weight: 700;
}
.tt-steps__item.is-current { color: var(--color-text); }
.tt-steps__item.is-current .tt-steps__num { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.tt-steps__item.is-done .tt-steps__num { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); }

.tt-branch-form { display: flex; align-items: center; gap: 0.5rem; }
.tt-branch-form label { font-size: 0.78rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.tt-branch-form select {
  min-height: 38px; padding: 0.35rem 0.65rem; font-size: 0.85rem;
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
}
.tt-step1-form .form-grid { max-width: 520px; }
.tt-step1-form .tt-classes { max-width: 900px; }
.tt-chip-tools { display: flex; gap: 0.5rem; margin: 0.1rem 0 0.6rem; flex-wrap: wrap; }
.card__header .tt-chip-tools { margin: 0; }

.tt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem 1.1rem;
  padding: 0.7rem 0.85rem; border: 1px solid var(--color-border);
  border-radius: var(--radius); background: var(--color-surface);
}
.tt-toolbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.tt-toolbar label { font-size: 0.78rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.tt-toolbar input[type="date"],
.tt-toolbar select {
  min-height: 38px; padding: 0.35rem 0.6rem; font-size: 0.85rem;
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
}
.tt-quickfill { padding-left: 1.1rem; border-left: 1px solid var(--color-border); }
@media (max-width: 640px) { .tt-quickfill { padding-left: 0; border-left: 0; } }

/* Grid: don't stretch a 1-2 column grid across the page — size to content and
   let it scroll horizontally when there are many classes. */
.tt-grid-table { width: auto; max-width: 100%; min-width: 0; }
.tt-grid-table th, .tt-grid-table td { min-width: 190px; }
.tt-grid-table th:first-child, .tt-grid-table td:first-child { min-width: 128px; }
.tt-grid-table th:first-child,
.tt-grid-table td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--color-bg);
}
.tt-grid-table tbody td:first-child { background: var(--color-surface); }
.tt-grid-period strong { display: block; font-size: 0.85rem; }
.tt-grid-period span { display: block; font-size: 0.72rem; color: var(--color-text-muted); }
.tt-cell { min-height: 38px; max-width: 260px; }

/* Image lightbox (voucher bill preview). */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  display: flex; align-items: center; justify-content: center; padding: 2rem;
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-lg); }

/* Global notice ticker under the topbar. */
.notice-bar {
  background: var(--color-warning-light); color: #92400e;
  border-bottom: 1px solid #fde68a;
  font-size: 0.82rem; font-weight: 600;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 1rem; overflow: hidden;
}
.notice-bar__icon { flex-shrink: 0; display: flex; }
.notice-bar__icon svg { width: 15px; height: 15px; }
.notice-bar__track {
  flex: 1; overflow: hidden; white-space: nowrap;
}
.notice-bar__track span {
  display: inline-block; padding-left: 100%;
  animation: notice-scroll 26s linear infinite;
}
.notice-bar:hover .notice-bar__track span { animation-play-state: paused; }
.notice-bar__close {
  flex-shrink: 0; background: none; border: 0; color: inherit;
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.25rem;
}
@keyframes notice-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}
@media (prefers-reduced-motion: reduce) {
  .notice-bar__track span { animation: none; padding-left: 0; }
}

/* Dashboard image strip (auto-advancing, right → left). */
.dash-banners {
  position: relative; overflow: hidden;
  border-radius: var(--radius); margin-bottom: 1.1rem;
  border: 1px solid var(--color-border); box-shadow: var(--shadow-sm);
  background: var(--color-surface);
}
.dash-banners__track { display: flex; transition: transform 0.6s ease; }
.dash-banners__slide { min-width: 100%; position: relative; }
.dash-banners__slide img { width: 100%; height: 200px; object-fit: cover; display: block; }
.dash-banners__caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(15, 23, 42, 0.75));
  color: #fff; font-size: 0.85rem; font-weight: 600; padding: 1.5rem 1rem 0.7rem;
}
.dash-banners__dots {
  position: absolute; bottom: 0.6rem; right: 0.8rem; display: flex; gap: 0.3rem;
}
.dash-banners__dots i {
  width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.5);
}
.dash-banners__dots i.is-active { background: #fff; }
