:root {
  --primary: #2563EB;
  --secondary: #16A34A;
  --accent: #38BDF8;
  --dark: #0F172A;
  --dark2: #1E293B;
  --muted: #64748B;
  --cardbg: #F1F5F9;
  --cardbg2: #F8FAFC;
  --line: #E2E8F0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #F8FAFC;
  color: var(--dark);
}

h1, h2, h3, .font-head { font-family: Georgia, Cambria, serif; }

a { color: inherit; text-decoration: none; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 15rem; flex-shrink: 0; background: var(--dark); color: #fff;
  display: flex; flex-direction: column; min-height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.5rem; padding: 1.4rem 1.5rem; }
.brand-mark {
  width: 2rem; height: 2rem; border-radius: 0.5rem; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--dark);
}
.brand-word { font-size: 1.1rem; }
.brand-word b.white { color: #fff; }
.brand-word b.accent { color: var(--accent); }

.switcher { padding: 0 0.75rem 0.75rem; }
.switcher select {
  width: 100%; background: var(--dark2); color: #E2E8F0; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.5rem; padding: 0.5rem; font-size: 0.75rem;
}

.nav { flex: 1; padding: 0 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem; border-radius: 0.5rem;
  font-size: 0.875rem; color: #94A3B8; transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; }

.sidebar-footer { padding: 0.75rem; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user { padding: 0.5rem 0.75rem; font-size: 0.75rem; color: #94A3B8; }
.sidebar-user .role { text-transform: uppercase; color: #64748B; margin-left: 0.25rem; }
.logout-btn {
  width: 100%; display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem;
  border-radius: 0.5rem; font-size: 0.875rem; color: #94A3B8; background: transparent; border: none; cursor: pointer;
  font-family: inherit; transition: background 0.15s ease, color 0.15s ease;
}
.logout-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.logout-btn svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid var(--line); background: #fff; padding: 1.25rem 2rem; }
.topbar h1 { margin: 0; font-size: 1.5rem; }
.topbar p { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--muted); }
.content { padding: 2rem; }

/* Cards & grids */
.card { background: #fff; border: 1px solid var(--line); border-radius: 0.85rem; box-shadow: 0 1px 2px rgba(15, 23, 42,0.03); min-width: 0; }
.card > * { min-width: 0; }
.card.pad { padding: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card { background: var(--primary); color: #fff; border-radius: 0.85rem; padding: 1.25rem; }
.stat-card .num { font-size: 1.9rem; font-weight: bold; color: #fff; font-family: Georgia, serif; }
.stat-card .label { font-size: 0.875rem; margin-top: 0.4rem; color: rgba(255,255,255,0.85); }
.stat-card .sub { font-size: 0.75rem; color: rgba(255,255,255,0.7); margin-top: 0.2rem; }

.stat-plain { background: #fff; border: 1px solid var(--line); border-radius: 0.85rem; padding: 1rem; box-shadow: 0 1px 2px rgba(15, 23, 42,0.03); }
.stat-plain .num { font-size: 1.6rem; font-weight: bold; font-family: Georgia, serif; color: var(--primary); }
.stat-plain .label { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 1rem; border-radius: 0.6rem; font-size: 0.875rem; font-weight: 600;
  border: none; cursor: pointer; font-family: inherit; text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 85%, black); }
.btn-secondary { background: var(--accent); color: var(--dark); }
.btn-secondary:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.btn-ghost { background: transparent; color: var(--dark); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--cardbg2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
label.field { display: block; margin-bottom: 0.75rem; }
label.field .lbl { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-bottom: 0.3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel],
select, textarea {
  width: 100%; padding: 0.5rem 0.7rem; border-radius: 0.55rem; border: 1px solid var(--line); font-size: 0.875rem;
  font-family: inherit; background: #fff; color: var(--dark); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
input[type=file] { font-size: 0.85rem; }
textarea { resize: vertical; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--line);
}
tbody td { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--cardbg2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--cardbg2); }

/* Badges */
.badge { display: inline-block; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }
.badge-green { background: rgba(75,127,82,0.14); color: var(--secondary); }
.badge-amber { background: rgba(212,162,76,0.18); color: #8A6416; }
.badge-muted { background: rgba(138,128,120,0.15); color: var(--muted); }
.badge-red { background: #FBEAE6; color: #B3432B; }

/* Misc */
.muted { color: var(--muted); }
.note-box { background: var(--cardbg2); border: 1px solid var(--line); border-radius: 0.55rem; padding: 0.75rem 1rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 1.25rem; }
.flash-error { background: #FBEAE6; color: #B3432B; border-radius: 0.55rem; padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1.25rem; }
.flash-ok { background: #EAF3EA; color: #3E6B44; border-radius: 0.55rem; padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1.25rem; }
.mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; } .mb-5 { margin-bottom: 1.25rem; } .mb-6 { margin-bottom: 1.5rem; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .items-center { align-items: center; } .items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.gap-2 { gap: 0.5rem; } .gap-3 { gap: 0.75rem; }
.text-right { text-align: right; } .text-center { text-align: center; }
.small { font-size: 0.75rem; }
.w-32 { width: 8rem; }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--dark); padding: 1rem; }
.login-box { width: 100%; max-width: 24rem; }
.login-card { background: #fff; border-radius: 1rem; padding: 1.75rem; box-shadow: 0 20px 40px rgba(0,0,0,0.25); }
.login-brand { display: flex; align-items: center; gap: 0.5rem; justify-content: center; margin-bottom: 2rem; }
.login-brand .brand-mark { width: 2.25rem; height: 2.25rem; font-size: 1.1rem; }
.login-brand .brand-word { font-size: 1.4rem; }

/* ==========================================================================
   Additions below this line — mobile-responsive sidebar, parent portal,
   and a couple of small usability fixes. Nothing above this comment was
   changed from the original stylesheet.
   ========================================================================== */

/* Mobile sidebar toggle (hidden on desktop, shown under the breakpoint) */
.menu-toggle {
  display: none;
  background: transparent; border: none; cursor: pointer; padding: 0.4rem;
  border-radius: 0.4rem; color: var(--dark); flex-shrink: 0;
}
.menu-toggle:hover { background: var(--cardbg2); }
.menu-toggle svg { width: 1.4rem; height: 1.4rem; }

.sidebar-scrim { display: none; }

/* Wide tables scroll horizontally within their card at any viewport width,
   instead of overflowing the page (was previously mobile-only). */
.card > table { display: block; overflow-x: auto; white-space: nowrap; }

@media (max-width: 880px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 40;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .sidebar-scrim {
    display: block; position: fixed; inset: 0; background: rgba(15, 23, 42,0.5);
    z-index: 30; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .sidebar-scrim.visible { opacity: 1; pointer-events: auto; }

  .topbar { padding: 1rem 1.25rem; }
  .content { padding: 1.25rem; }

  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  /* Parent/student portal topbar: stop "Log out" and the school name from
     wrapping onto multiple lines on phone-width screens. */
  .parent-topbar { padding: 0.75rem 0.85rem; gap: 0.5rem; }
  .parent-topbar .flex.items-center.gap-3 { gap: 0.5rem; }
  .parent-topbar .brand-word > .small.muted { display: none; }
  .parent-topbar > div:last-child > span.small.muted {
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }
  .parent-logout-btn { white-space: nowrap; padding: 0.35rem 0.6rem; font-size: 0.72rem; }
  .parent-logout-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

  /* Safety net: collapse any remaining inline multi-column grid (e.g. a
     dashboard set via style="grid-template-columns:1fr 1fr") to one column,
     same as the .grid-2/.grid-3/.grid-4/.grid-5 classes above. */
  div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

/* Parent portal — deliberately simple, separate top bar (not the staff sidebar) */
.parent-topbar {
  background: var(--dark); color: #fff; padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.parent-body { background: #F8FAFC; min-height: 100vh; }
.parent-content { max-width: 52rem; margin: 0 auto; padding: 2rem 1.25rem; }
.parent-logout-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.25); color: #E2E8F0;
  padding: 0.4rem 0.9rem; border-radius: 0.5rem; font-size: 0.8rem; cursor: pointer; font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
.parent-logout-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.parent-child-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 0.85rem;
  padding: 1.1rem 1.25rem; margin-bottom: 0.85rem; box-shadow: 0 1px 2px rgba(15, 23, 42,0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.parent-child-card:hover { border-color: var(--primary); box-shadow: 0 2px 6px rgba(15, 23, 42,0.06); }

/* CBT theory answers were truncated at 2 rows — give them real room */
textarea.theory-answer { min-height: 7rem; }

/* ==========================================================================
   UI/UX refresh (Sep 2026) — warmer, more editorial "Claude-like" palette
   and a touch more polish (soft card shadows, smoother hover/focus states).
   Every selector name and layout rule above is unchanged, so no PHP template
   needed to change for this pass — only color values and small additive
   niceties (shadows, transitions, hover states) were touched.
   ========================================================================== */

/* A consistent page header pattern so every section reads as part of one
   product instead of a stack of separate tools. Pages can wrap their intro
   in .page-lede for a slightly larger, breathing first paragraph. */
.page-lede { color: var(--muted); font-size: 0.95rem; max-width: 42rem; }

/* Subtle section labels used to group related cards together on a page. */
.section-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 0 0.6rem;
}

/* A light "step" pill used on multi-step flows (e.g. admissions, onboarding). */
.step-pill {
  display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; font-weight: 600;
  color: var(--primary); background: rgba(37,99,235,0.1); padding: 0.3rem 0.7rem; border-radius: 999px;
}


/* Shared confirm modal (replaces native confirm() dialogs) */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.confirm-modal {
  max-width: 24rem;
  width: 100%;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}
.confirm-modal-message {
  margin: 0 0 1.25rem;
  font-size: 0.925rem;
  color: var(--dark);
  line-height: 1.5;
}
.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}
