/* ═══════════════════════════════════════════════════════════════
   Precious Minds Qatar — Tutor Hub demo
   Direction: "Qatari heritage luxury" — Qatar maroon, warm gold,
   ivory surfaces. Fraunces (display) + Plus Jakarta Sans (UI).
   Proposed palette (client has no published brand assets yet).
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* palette */
  --bg: #F8F3EC;
  --surface: #FFFFFF;
  --surface-warm: #FDFAF5;
  --line: #EBE2D5;
  --line-soft: #F1EAE0;

  --maroon-950: #43091B;
  --maroon-900: #5C0E26;
  --maroon-800: #71122F;
  --maroon-700: #8A1538;      /* primary — Qatar maroon */
  --maroon-600: #A8244D;
  --maroon-100: #F3DDE4;
  --maroon-50:  #FAF0F3;

  --gold-600: #A87A1F;
  --gold-500: #C9962E;
  --gold-300: #E4C97A;
  --gold-100: #F5E9CF;
  --gold-50:  #FBF5E7;

  --ink: #2B2126;
  --ink-soft: #6B5D63;
  --ink-faint: #9C8F94;
  --ivory: #FBF2E4;
  --ivory-soft: #E9D9C4;

  --green-700: #256B44;
  --green-100: #DDF0E4;
  --amber-700: #8F6212;
  --amber-100: #F8ECD2;
  --red-700: #A8322A;
  --red-100: #F9E2DF;

  /* type */
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --text-base: clamp(0.95rem, 0.9rem + 0.2vw, 1rem);

  /* rhythm */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(67, 9, 27, 0.05);
  --shadow-md: 0 8px 28px -10px rgba(67, 9, 27, 0.16);
  --shadow-lg: 0 24px 60px -20px rgba(67, 9, 27, 0.30);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 220ms;

  /* z scale */
  --z-side: 10; --z-top: 20; --z-bnav: 40; --z-scrim: 90; --z-layer: 100; --z-toast: 110;
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(201, 150, 46, 0.07), transparent 60%),
    var(--bg);
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }

:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ═══════════ App frame ═══════════ */
.app { min-height: 100dvh; }

/* ── Sidebar ── */
.sidebar {
  display: none;
  position: sticky; top: 0; height: 100dvh;
  flex-direction: column;
  background: linear-gradient(168deg, var(--maroon-800) 0%, var(--maroon-900) 55%, var(--maroon-950) 100%);
  color: var(--ivory);
  padding: var(--sp-6) var(--sp-4);
  z-index: var(--z-side);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-2) var(--sp-6); }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gold-500), var(--gold-600));
  color: var(--maroon-950);
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 12px -4px rgba(0,0,0,.4);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; }
.brand-mark.small svg { width: 16px; height: 16px; }
.brand-name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; display: block; }
.brand-sub { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ivory-soft); }

.nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  min-height: 44px;
  border-radius: var(--r-sm);
  color: var(--ivory-soft);
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item svg { width: 20px; height: 20px; flex: 0 0 auto; opacity: 0.85; }
.nav-item:hover { background: rgba(251, 242, 228, 0.08); color: var(--ivory); }
.nav-item.is-active {
  background: rgba(251, 242, 228, 0.12);
  color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold-500);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-4); }
.tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--gold-100);
  padding: 0 var(--sp-2);
}
.demo-card {
  display: flex; gap: var(--sp-2); align-items: flex-start;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(251, 242, 228, 0.14);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: 0.78rem; line-height: 1.45;
  color: var(--ivory-soft);
}
.demo-card strong { color: var(--ivory); }
.demo-dot {
  width: 8px; height: 8px; margin-top: 5px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201, 150, 46, 0.25);
}

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: var(--z-top);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-brand {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem;
  color: var(--maroon-800);
}
.topbar-brand .brand-mark { color: var(--maroon-950); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.6rem); color: var(--maroon-900); }
.topbar-title p { font-size: 0.8rem; color: var(--ink-soft); }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); }
.date-chip {
  display: none;
  font-size: 0.78rem; font-weight: 600; color: var(--maroon-800);
  background: var(--surface); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--maroon-700), var(--maroon-900));
  color: var(--gold-100);
  font-weight: 700; font-size: 0.8rem; letter-spacing: 0.04em;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--gold-300);
}

/* ── Content shell ── */
.content { padding: var(--sp-5) var(--sp-4) calc(84px + env(safe-area-inset-bottom)); max-width: 1240px; margin-inline: auto; width: 100%; }
.view { display: none; }
.view.is-active { display: block; animation: rise 320ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ═══════════ Shared pieces ═══════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2 { font-size: 1.15rem; color: var(--maroon-900); }
.card-sub { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  font-weight: 600; font-size: 0.88rem;
  transition: transform 120ms var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(140deg, var(--maroon-600), var(--maroon-800));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(138, 21, 56, 0.55), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { box-shadow: 0 8px 22px -6px rgba(138, 21, 56, 0.65); }
.btn-ghost { color: var(--maroon-700); background: var(--maroon-50); }
.btn-ghost:hover { background: var(--maroon-100); }
.btn-soft { background: var(--gold-100); color: var(--gold-600); }
.btn-soft:hover { background: var(--gold-50); }

.icon-btn {
  width: 44px; height: 44px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--maroon-700); background: var(--maroon-50);
  transition: background var(--dur) var(--ease), transform 120ms var(--ease);
}
.icon-btn:hover { background: var(--maroon-100); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.wa { color: var(--green-700); background: var(--green-100); }
.icon-btn.wa:hover { background: #CDE8D8; }

.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 6px 16px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.85rem; font-weight: 600; color: var(--ink-soft);
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--maroon-100); color: var(--maroon-700); }
.chip.is-active {
  background: var(--maroon-800); border-color: var(--maroon-800); color: var(--ivory);
  box-shadow: 0 4px 12px -4px rgba(138, 21, 56, 0.5);
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.paid, .badge.active   { background: var(--green-100); color: var(--green-700); }
.badge.pending, .badge.partial { background: var(--amber-100); color: var(--amber-700); }
.badge.overdue { background: var(--red-100); color: var(--red-700); }
.badge.trial   { background: var(--gold-100); color: var(--gold-600); }
.badge.online  { background: var(--maroon-50); color: var(--maroon-700); }
.badge.home    { background: var(--gold-50); color: var(--gold-600); }

.stu-avatar {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.78rem;
  background: var(--maroon-50); color: var(--maroon-700);
  border: 1px solid var(--maroon-100);
}

.amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.muted { color: var(--ink-soft); font-size: 0.8rem; }

.empty {
  text-align: center; color: var(--ink-soft);
  padding: var(--sp-8) var(--sp-4);
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
  font-size: 0.9rem;
}

/* ═══════════ Dashboard ═══════════ */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--maroon-700), var(--gold-500));
  opacity: 0.9;
}
.kpi.gold::after { background: linear-gradient(90deg, var(--gold-500), var(--gold-300)); }
.kpi-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); }
.kpi-value { font-family: var(--font-display); font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); font-weight: 600; color: var(--maroon-900); margin-top: 4px; }
.kpi-value small { font-size: 0.6em; color: var(--ink-soft); font-family: var(--font-ui); font-weight: 600; }
.kpi-note { font-size: 0.76rem; color: var(--ink-soft); margin-top: 4px; }
.kpi-note.up { color: var(--green-700); font-weight: 600; }
.kpi-note.warn { color: var(--red-700); font-weight: 600; }

.dash-grid { display: grid; gap: var(--sp-4); }

.today-list, .due-list { display: flex; flex-direction: column; }
.today-item, .due-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line-soft);
}
.today-item:first-child, .due-item:first-child { border-top: 0; }

.t-time {
  flex: 0 0 auto; width: 62px;
  text-align: center;
  background: var(--maroon-50);
  border-radius: var(--r-sm);
  padding: 7px 4px;
}
.t-time strong { display: block; font-size: 0.9rem; color: var(--maroon-800); font-variant-numeric: tabular-nums; }
.t-time span { font-size: 0.68rem; color: var(--ink-soft); }
.t-body { flex: 1; min-width: 0; }
.t-body strong { display: block; font-size: 0.95rem; }
.t-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: 3px; flex-wrap: wrap; }

.due-item .t-body strong { font-size: 0.92rem; }
.due-amt { text-align: right; flex: 0 0 auto; }
.due-amt .amount { color: var(--red-700); display: block; }
.due-amt .muted { font-size: 0.72rem; }

/* chart */
.chart { display: flex; align-items: flex-end; gap: var(--sp-3); height: 190px; padding-top: var(--sp-4); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-val { font-size: 0.7rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bar {
  width: 100%; max-width: 46px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--maroon-600), var(--maroon-800));
  min-height: 8px;
  transition: transform var(--dur) var(--ease);
}
.bar-col:hover .bar { transform: scaleY(1.02); transform-origin: bottom; }
.bar-col.now .bar { background: linear-gradient(180deg, var(--gold-300), var(--gold-500)); }
.bar-m { font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); }
.bar-col.now .bar-m { color: var(--gold-600); font-weight: 700; }

/* ═══════════ Students ═══════════ */
.toolbar { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.search {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 0 var(--sp-4);
  min-height: 48px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--maroon-600); box-shadow: 0 0 0 3px var(--maroon-50); }
.search svg { width: 18px; height: 18px; color: var(--ink-faint); flex: 0 0 auto; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; font-size: 16px; color: var(--ink); }
.search input::placeholder { color: var(--ink-faint); }

.student-list { display: grid; gap: var(--sp-3); }
.stu-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
  text-align: left; width: 100%;
  transition: transform 150ms var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.stu-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--maroon-100); }
.stu-main { min-width: 0; }
.stu-main strong { display: block; font-size: 0.98rem; }
.stu-main .muted { margin-top: 2px; }
.stu-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.stu-balance { font-size: 0.85rem; }
.stu-balance.owed { color: var(--red-700); font-weight: 700; }
.stu-balance.clear { color: var(--green-700); font-weight: 600; }

/* ═══════════ Schedule ═══════════ */
.week-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  background: linear-gradient(140deg, var(--maroon-800), var(--maroon-950));
  color: var(--ivory);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  position: relative; overflow: hidden;
}
.week-banner::after {
  content: ""; position: absolute; right: -40px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201,150,46,0.35), transparent 70%);
}
.week-banner h2 { font-size: 1.2rem; }
.week-banner p { font-size: 0.8rem; color: var(--ivory-soft); margin-top: 2px; }

.day-tabs { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4); overflow-x: auto; padding-bottom: 2px; }
.day-tab {
  flex: 1; min-width: 60px; min-height: 56px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem; color: var(--ink-soft);
  transition: all var(--dur) var(--ease);
}
.day-tab span { font-size: 0.68rem; font-weight: 500; color: var(--ink-faint); }
.day-tab.is-active { background: var(--maroon-800); border-color: var(--maroon-800); color: var(--ivory); }
.day-tab.is-active span { color: var(--gold-100); }
.day-tab.today:not(.is-active) { border-color: var(--gold-500); color: var(--gold-600); }

.week-grid { display: grid; gap: var(--sp-3); }
.day-col { display: none; }
.day-col.is-active { display: block; }
.day-col-head {
  display: none;
  font-weight: 700; font-size: 0.85rem; color: var(--maroon-800);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 2px solid var(--maroon-100);
  margin-bottom: var(--sp-3);
}
.day-col-head span { color: var(--ink-faint); font-weight: 500; }
.day-col.today .day-col-head { color: var(--gold-600); border-color: var(--gold-300); }
.day-body { display: flex; flex-direction: column; gap: var(--sp-3); }

.sess-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--maroon-600);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.sess-card.online { border-left-color: var(--gold-500); }
.sess-time { font-size: 0.78rem; font-weight: 700; color: var(--maroon-700); font-variant-numeric: tabular-nums; }
.sess-card.online .sess-time { color: var(--gold-600); }
.sess-card strong { display: block; font-size: 0.92rem; margin-top: 2px; }
.sess-card .muted { margin-top: 2px; }

/* ═══════════ Attendance ═══════════ */
.att-intro { margin-bottom: var(--sp-4); }
.att-intro h2 { font-size: 1.15rem; color: var(--maroon-900); }
.att-intro .card-sub { margin-bottom: var(--sp-4); }

.att-sheet { display: flex; flex-direction: column; gap: var(--sp-3); }
.att-row {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.att-row .t-body { flex: 1 1 160px; }
.seg { display: flex; gap: var(--sp-1); background: var(--bg); border-radius: var(--r-full); padding: 4px; }
.seg button {
  min-height: 40px; padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft);
  transition: all 160ms var(--ease);
}
.seg button.on-present { background: var(--green-700); color: #fff; }
.seg button.on-late    { background: var(--amber-700); color: #fff; }
.seg button.on-absent  { background: var(--red-700); color: #fff; }
.att-save { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-4); flex-wrap: wrap; }
.att-summary { font-size: 0.85rem; color: var(--ink-soft); }

/* ═══════════ Invoices ═══════════ */
.inv-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.inv-stat {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.inv-stat .kpi-label { font-size: 0.68rem; }
.inv-stat .kpi-value { font-size: 1.3rem; }
.inv-stat.alert .kpi-value { color: var(--red-700); }

.invoice-list { display: grid; gap: var(--sp-3); }
.inv-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.inv-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.inv-no { font-size: 0.75rem; font-weight: 700; color: var(--ink-faint); letter-spacing: 0.03em; }
.inv-card strong { font-size: 0.95rem; }
.inv-amt { text-align: right; }
.inv-amt .amount { font-size: 1.05rem; color: var(--maroon-900); display: block; }
.inv-actions { grid-column: 1 / -1; display: flex; gap: var(--sp-2); flex-wrap: wrap; border-top: 1px solid var(--line-soft); padding-top: var(--sp-3); margin-top: var(--sp-1); }
.inv-actions .btn { min-height: 40px; font-size: 0.82rem; flex: 1 1 auto; }

/* ═══════════ Bottom nav (mobile) ═══════════ */
.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-bnav);
  display: flex;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px var(--sp-2) calc(6px + env(safe-area-inset-bottom));
}
.bn-item {
  flex: 1; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--r-sm);
  color: var(--ink-faint);
  font-size: 0.65rem; font-weight: 600;
  transition: color var(--dur) var(--ease);
}
.bn-item svg { width: 21px; height: 21px; }
.bn-item.is-active { color: var(--maroon-700); }
.bn-item.is-active svg { filter: drop-shadow(0 3px 6px rgba(138,21,56,0.35)); }

/* ═══════════ Overlays ═══════════ */
.scrim {
  position: fixed; inset: 0; z-index: var(--z-scrim);
  background: rgba(43, 33, 38, 0.5);
  backdrop-filter: blur(2px);
  animation: fade 200ms var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-layer);
  width: min(430px, 100%);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: slide-in 280ms var(--ease);
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-hero {
  background: linear-gradient(150deg, var(--maroon-800), var(--maroon-950));
  color: var(--ivory);
  padding: var(--sp-6) var(--sp-5);
  display: flex; gap: var(--sp-4); align-items: center;
  position: relative;
}
.drawer-hero .stu-avatar { width: 56px; height: 56px; font-size: 1rem; background: var(--gold-100); color: var(--maroon-900); border: 0; }
.drawer-hero h2 { font-size: 1.3rem; }
.drawer-hero .muted { color: var(--ivory-soft); }
.drawer-close {
  position: absolute; top: var(--sp-3); right: var(--sp-3);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ivory); background: rgba(0,0,0,0.25);
}
.drawer-body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-5); }
.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.fact {
  background: var(--surface-warm); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: var(--sp-3);
}
.fact .kpi-label { font-size: 0.62rem; }
.fact strong { font-size: 0.92rem; }
.drawer-section h3 { font-size: 0.95rem; color: var(--maroon-900); margin-bottom: var(--sp-2); }
.note-box {
  background: var(--gold-50); border: 1px solid var(--gold-100);
  border-radius: var(--r-sm); padding: var(--sp-3);
  font-size: 0.86rem; line-height: 1.5;
}
.drawer-actions { display: flex; gap: var(--sp-2); }
.drawer-actions .btn { flex: 1; }

.modal {
  position: fixed; z-index: var(--z-layer);
  inset: auto 0 0 0;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  animation: sheet-up 280ms var(--ease);
  max-height: 88dvh; overflow-y: auto;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
.modal h2 { font-size: 1.25rem; color: var(--maroon-900); }
.modal .muted { margin-top: 2px; }
.field { margin-top: var(--sp-4); }
.field label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; color: var(--ink-soft); }
.field input {
  width: 100%; min-height: 48px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 var(--sp-4); font-size: 16px;
  background: var(--surface-warm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field input:focus { outline: 0; border-color: var(--maroon-600); box-shadow: 0 0 0 3px var(--maroon-50); }
.method-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.method-row .chip { justify-content: center; display: inline-flex; align-items: center; }
.modal-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); }
.modal-actions .btn { flex: 1; }

/* toast */
.toast-root {
  position: fixed; z-index: var(--z-toast);
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--maroon-950); color: var(--ivory);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: rise 240ms var(--ease);
}
.toast svg { width: 18px; height: 18px; color: var(--gold-300); flex: 0 0 auto; }

/* ═══════════ Responsive ═══════════ */

/* small phones */
@media (max-width: 359px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .inv-stats { grid-template-columns: 1fr; }
}

/* tablet ≥ 640 */
@media (min-width: 640px) {
  .content { padding-inline: var(--sp-6); }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .search { flex: 1; max-width: 380px; }
  .date-chip { display: inline-flex; }
  .modal {
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(460px, calc(100vw - 48px));
    border-radius: var(--r-lg);
    animation: pop 240ms var(--ease);
  }
}
@keyframes pop { from { opacity: 0; } }

/* desktop ≥ 1024: sidebar appears, bottom nav goes away */
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 264px minmax(0, 1fr); }
  .sidebar { display: flex; }
  .bottomnav { display: none; }
  .topbar-brand { display: none; }
  .topbar { padding: var(--sp-5) var(--sp-8); }
  .content { padding: var(--sp-6) var(--sp-8) var(--sp-10); }

  .dash-grid { grid-template-columns: 1.35fr 1fr; grid-template-areas: "today due" "chart due"; }
  .span-today { grid-area: today; }
  .span-due   { grid-area: due; }
  .span-chart { grid-area: chart; }

  /* full week visible */
  .day-tabs { display: none; }
  .week-grid { grid-template-columns: repeat(5, 1fr); }
  .day-col { display: block; }
  .day-col-head { display: flex; justify-content: space-between; align-items: baseline; }
  .sess-card { padding: var(--sp-3); }

  .toast-root { bottom: var(--sp-6); }
}

/* large desktop ≥ 1440 */
@media (min-width: 1440px) {
  .app { grid-template-columns: 288px minmax(0, 1fr); }
  .content { max-width: 1320px; }
}

/* ≥ 1920: keep things centered and readable */
@media (min-width: 1920px) {
  .content { max-width: 1400px; }
}
