/* ==========================================================================
   growFIT — shared stylesheet
   "Grow up the fit way"
   Design tokens live at the top as CSS custom properties so every page
   (splash, login, dashboards) stays visually consistent.
   ========================================================================== */

:root {
  /* --- Brand colors --- */
  --green-light: #A8E063;   /* top of gradient */
  --green-dark: #4CAF50;    /* bottom of gradient */
  --ink: #1A1A1A;            /* near-black for text/buttons */
  --ink-soft: #2E2E2E;
  --white: #FFFFFF;
  --gray: #6B7280;           /* body copy on white */
  --gray-light: #9CA3AF;     /* tagline / muted text */
  --gray-mist: #E9EFE4;      /* faint card borders on green */

  /* --- Status colors --- */
  --danger: #E53935;
  --danger-bg: #FDE8E7;
  --warning: #FB8C00;
  --warning-bg: #FFF3E0;
  --ok: #2E7D32;
  --ok-bg: #E8F5E9;

  /* --- Layout --- */
  --app-max-width: 420px;
  --radius-pill: 999px;
  --radius-card: 18px;
  --radius-sm: 10px;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.06);

  /* --- Type --- */
  --font-main: 'Nunito', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-main);
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }

/* Visible keyboard focus for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ==========================================================================
   App shell — mobile-first, centered on larger screens
   ========================================================================== */

.app-shell {
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow-x: hidden;
}

/* White header zone (used on every screen) */
.app-header {
  background: var(--white);
  padding: 28px 24px 20px;
  position: relative;
  z-index: 2;
}

/* Green gradient body zone */
.app-body {
  flex: 1;
  background: linear-gradient(180deg, var(--green-light) 0%, var(--green-dark) 100%);
  padding: 28px 20px 100px;
  position: relative;
  overflow: hidden;
}

/* Full-screen green gradient (splash / role select) */
.app-body--full {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 24px;
}

/* ==========================================================================
   Sparkle / star decorative accents
   ========================================================================== */

.sparkle {
  position: absolute;
  opacity: 0.18;
  pointer-events: none;
  color: var(--white);
  z-index: 0;
}
.sparkle--dark { color: var(--ink); opacity: 0.08; }
.sparkle-1 { top: 18px; left: 16px; width: 26px; height: 26px; }
.sparkle-2 { top: 40px; right: 22px; width: 18px; height: 18px; }
.sparkle-3 { bottom: 60px; left: 24px; width: 22px; height: 22px; }
.sparkle-4 { bottom: 120px; right: 18px; width: 30px; height: 30px; }

/* ==========================================================================
   Logo / wordmark
   ========================================================================== */

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 2rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.logo-w {
  width: 1.62em;
  height: 1.28em;
  margin: 0 0.02em;
  overflow: visible;
  transform: translateY(-0.3em);
}

.logo-prefix {
  color: #6F926D;
  font-weight: 700;
}

.logo-suffix {
  font-weight: 800;
}

.logo-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tagline {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gray-light);
  text-align: center;
}

.logo--sm { font-size: 1.3rem; }
.logo--sm .tagline { font-size: 0.55rem; }

.sidebar-brand { display: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow-card);
}

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
  min-height: auto;
  padding: 8px;
  font-weight: 700;
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 2px solid var(--danger);
}

.btn-google {
  background: var(--white);
  color: var(--ink-soft);
  border: 2px solid rgba(0,0,0,0.12);
  box-shadow: var(--shadow-soft);
}

.google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-sm {
  min-height: 42px;
  padding: 10px 18px;
  font-size: 0.88rem;
}

.btn-icon {
  font-size: 1.15em;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-stack { display: flex; flex-direction: column; gap: 14px; width: 100%; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.field-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--gray);
  margin-top: 4px;
}

.input, .select, textarea.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(0,0,0,0.08);
  background: var(--white);
  font-size: 0.95rem;
  color: var(--ink);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' stroke='%23404b3a' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 42px;
  cursor: pointer;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ==========================================================================
   Pill-select — a chip grid standing in for a plain <select>, used for the
   class Grade/Section picker. A visually-hidden native <select> right
   above it still holds the real value, so form logic doesn't need to
   change; the pills just drive it.
   ========================================================================== */

.visually-hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pill-select-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pill-select-group--section {
  grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 359px) {
  .pill-select-group--section { grid-template-columns: repeat(3, 1fr); }
}

.pill-select {
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--gray-mist);
  border: 2px solid transparent;
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}

.pill-select:active { transform: scale(0.96); }

.pill-select.active {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

.copy-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.copy-link-row code {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  background: rgba(0,0,0,0.04);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.78rem;
}

.copy-btn {
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--white);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 14px;
  cursor: pointer;
}

.copy-btn:active { transform: scale(0.97); }
.copy-btn.copied { background: var(--ok); }

.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--ink);
  outline: none;
}

textarea.input {
  min-height: 90px;
  resize: vertical;
}

.input-error {
  border-color: var(--danger) !important;
}

.error-text {
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 700;
  margin-top: 4px;
  display: none;
}

.error-text.show { display: block; }

.form-card {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 22px 18px;
  box-shadow: var(--shadow-card);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 18px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}

.card-flat {
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.section-title--onwhite { color: var(--ink); }
.section-title--onwhite.light { color: var(--white); }

/* ==========================================================================
   Student list (teacher dashboard)
   ========================================================================== */

.search-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-wrap .input {
  padding-left: 42px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.6;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 2px;
}

.chip {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.6);
  border: 2px solid transparent;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.chip.active {
  background: var(--ink);
  color: var(--white);
}

/* ==========================================================================
   Icon chips — used for the posture-notes picker so options read as
   quick visual choices instead of a plain text dropdown.
   ========================================================================== */

.icon-chip-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.icon-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--gray-mist);
  border: 2px solid transparent;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.icon-chip-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.icon-chip.active {
  background: var(--ok-bg);
  border-color: var(--ok);
}

.icon-chip:active { transform: scale(0.98); }

@media (max-width: 359px) {
  .icon-chip-group { grid-template-columns: 1fr; }
}

.student-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-soft);
  min-height: 60px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--ink);
  flex-shrink: 0;
  font-size: 0.95rem;
}

.student-info { flex: 1; min-width: 0; }
.student-name { font-weight: 800; font-size: 0.95rem; }
.student-meta { font-size: 0.76rem; color: var(--gray); margin-top: 2px; }

.chev { color: var(--gray-light); font-size: 1.2rem; }

/* ==========================================================================
   Badges / flags
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* ==========================================================================
   Stat cards (parent dashboard)
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-unit { font-size: 0.7rem; font-weight: 700; color: var(--gray); }

/* ==========================================================================
   History list / mini chart
   ========================================================================== */

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.history-item:last-child { border-bottom: none; }
.history-date { font-size: 0.78rem; color: var(--gray); font-weight: 700; }
.history-value { font-size: 0.9rem; font-weight: 800; }

.chart-wrap {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 16px 14px 10px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}

/* ==========================================================================
   Suggestions / notes panel
   ========================================================================== */

.suggestion-item {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-icon { font-size: 1.1rem; flex-shrink: 0; }
.suggestion-text { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.4; }

.note-block {
  background: var(--gray-mist);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-top: 4px;
}

/* ==========================================================================
   Bottom navigation
   ========================================================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  background: var(--white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  z-index: 10;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  min-width: 56px;
  min-height: 48px;
  justify-content: center;
  color: var(--gray);
  position: relative;
}

.nav-item.active { color: var(--ink); }
.nav-icon { font-size: 1.25rem; }
.nav-label { font-size: 0.62rem; font-weight: 700; }

.nav-dot {
  position: absolute;
  top: 2px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--white);
}

/* ==========================================================================
   Top app bar (dashboard header, inside white zone)
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: none;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 800;
  flex: 1;
}

.topbar-sub {
  font-size: 0.75rem;
  color: var(--gray);
  font-weight: 600;
}

/* ==========================================================================
   Role selection cards
   ========================================================================== */

.role-heading {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--white);
  text-transform: uppercase;
  margin-bottom: 28px;
  text-align: center;
}

/* ==========================================================================
   Toast (lightweight feedback)
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  max-width: 85%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--white);
  opacity: 0.9;
}
.empty-state--onwhite { color: var(--gray); }
.empty-emoji { font-size: 2.2rem; margin-bottom: 10px; }
.empty-title { font-weight: 800; margin-bottom: 4px; }
.empty-sub { font-size: 0.82rem; }

/* ==========================================================================
   Utility
   ========================================================================== */

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--gray); font-size: 0.82rem; }
.muted-onwhite { color: rgba(255,255,255,0.85); font-size: 0.85rem; }
.hidden { display: none !important; }
.pad-bottom-nav { padding-bottom: 90px; }

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.6s ease forwards; }
.fade-in-delay { animation: fadeIn 0.6s ease 0.15s forwards; opacity: 0; }

/* ==========================================================================
   Splash screen logo animation
   The green "W" traces its up/down/up trajectory first (like a growth
   arrow), then the surrounding letters and tagline settle in behind it.
   Scoped to the splash screen only — every other page keeps the plain,
   static wordmark it already has.
   ========================================================================== */

@keyframes splashArrowDraw {
  to { stroke-dashoffset: 0; }
}

@keyframes splashLetterIn {
  from { opacity: 0; transform: translateY(0.35em); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes splashTaglineIn {
  from { opacity: 0; transform: translateY(0.3em); }
  to { opacity: 1; transform: translateY(0); }
}

body[data-page="splash"] .splash-logo {
  /* Scales with the smaller of the viewport's two dimensions, so the
     mark grows or shrinks with the actual screen — not just a couple
     of fixed breakpoint sizes. */
  font-size: clamp(1.9rem, 12vmin, 3.6rem);
}

body[data-page="splash"] .splash-tagline {
  font-size: clamp(0.68rem, 2.2vmin, 0.95rem);
}

body[data-page="splash"] .splash-logo .logo-prefix {
  opacity: 0;
  display: inline-block;
  animation: splashLetterIn 0.5s ease 0.8s forwards;
}

body[data-page="splash"] .splash-logo .logo-suffix {
  opacity: 0;
  display: inline-block;
  animation: splashLetterIn 0.5s ease 0.9s forwards;
}

body[data-page="splash"] .splash-logo .logo-w-path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: splashArrowDraw 0.85s cubic-bezier(0.65, 0, 0.35, 1) 0.15s forwards;
}

body[data-page="splash"] .splash-tagline {
  opacity: 0;
  animation: splashTaglineIn 0.5s ease 1.15s forwards;
}

/* ==========================================================================
   Responsive breakpoints
   The app is mobile-first (built for ~375–420px), but should read as a
   deliberate, adjusted layout at every size — not just a stretched phone
   screen. --app-max-width drives both .app-shell and .bottom-nav together,
   so they always stay aligned no matter which breakpoint is active.
   ========================================================================== */

/* --- Small phones (e.g. iPhone SE, small Android) — tighten up spacing --- */
@media (max-width: 359px) {
  .app-header { padding: 22px 16px 16px; }
  .app-body { padding: 22px 14px 96px; }
  .app-body--full { padding: 32px 18px; }
  .logo { font-size: 1.7rem; }
  .role-heading { font-size: 0.9rem; }
  .form-row-2 { grid-template-columns: 1fr; }
  .btn { font-size: 0.9rem; min-height: 52px; padding: 12px 18px; }
  .stat-grid { gap: 10px; }
}

/* --- Landscape phones / short viewports — the splash + role screens
       shouldn't force extra scrolling when height is tight --- */
@media (max-height: 480px) and (orientation: landscape) {
  .app-body--full { padding: 20px; justify-content: flex-start; padding-top: 40px; }
  .bottom-nav { padding-top: 4px; padding-bottom: 4px; }
  .nav-item { min-height: 38px; }
}

/* --- Tablets and small laptops — give the layout room to breathe --- */
@media (min-width: 600px) {
  :root {
    --app-max-width: 480px;
  }

  html { font-size: 17px; }

  body { background: #EEF3EA; }

  .app-shell {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.08);
  }

  .app-header { padding: 34px 32px 22px; }
  .app-body { padding: 32px 28px 110px; }
  .app-body--full { padding: 48px 32px; }

  .logo { font-size: 2.2rem; }
  .tagline { font-size: 0.72rem; }

  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .form-row-2 { gap: 14px; }

  .btn { min-height: 58px; }
}

/* --- Desktop — widen the reading column a little further and make the
       centered app read intentionally against the page backdrop. The shell
       stays a full-height column (not a floating card) so the fixed bottom
       nav — which is pinned to the real viewport edge — stays flush with it. --- */
@media (min-width: 900px) {
  :root {
    --app-max-width: 540px;
  }

  body {
    background: linear-gradient(160deg, #F3F7EF 0%, #E7F0E1 100%);
  }

  .app-shell {
    box-shadow: 0 0 70px rgba(0, 0, 0, 0.12);
  }

  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }

  .student-list-item:hover,
  .chip:hover,
  .nav-item:hover {
    filter: brightness(0.97);
  }

  .btn-primary:hover { opacity: 0.92; }
}

/* --- Large desktop — cap growth so line lengths and tap targets stay
       sane; the app is a mobile product, not a full desktop redesign --- */
@media (min-width: 1200px) {
  :root {
    --app-max-width: 580px;
  }
}

/* --- Splash screen — always edge-to-edge, never the centered "phone
       card" treatment the rest of the app uses at wider widths. It's a
       loading screen, so it should fill the real viewport at any size. --- */
body[data-page="splash"] .app-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  box-shadow: none;
  min-height: 100vh;
  min-height: 100dvh;
}

body[data-page="splash"] .app-body--full {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Health check-up — same edge-to-edge idea: the green zone should
       always fill the viewport, with the form itself capped to a
       comfortable reading width and centered within it. --- */
body[data-page="student-entry"] .app-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  box-shadow: none;
}

body[data-page="student-entry"] .page-container {
  max-width: var(--app-max-width);
  margin: 0 auto;
}

.topbar-spacer { width: 40px; flex-shrink: 0; }
.topbar-save { display: none; }

@media (min-width: 900px) {
  body[data-page="student-entry"] .page-container {
    max-width: 640px;
  }

  /* The save button moves up into the header so it's reachable without
     scrolling on larger screens; the bottom "Save record" button stays
     put for everyone else. */
  body[data-page="student-entry"] .topbar-spacer { display: none; }
  body[data-page="student-entry"] .topbar-save {
    display: inline-flex;
    width: auto;
    flex-shrink: 0;
  }
}

/* ==========================================================================
   Desktop/laptop layouts — auth screens (role select, login, reset password)
   Side-by-side: brand on the left, the actual task on the right. The
   phone-card treatment above only kicks in below this breakpoint.
   ========================================================================== */

@media (min-width: 900px) {
  body[data-page="role-selection"] .app-shell,
  body[data-page="login"] .app-shell,
  body[data-page="forgot-password"] .app-shell {
    max-width: none;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    flex-direction: row;
    box-shadow: none;
  }

  body[data-page="role-selection"] .app-header,
  body[data-page="login"] .app-header,
  body[data-page="forgot-password"] .app-header {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
  }

  body[data-page="role-selection"] .app-body,
  body[data-page="login"] .app-body,
  body[data-page="forgot-password"] .app-body {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    min-height: 0;
  }

  body[data-page="role-selection"] .logo,
  body[data-page="login"] .logo,
  body[data-page="forgot-password"] .logo {
    font-size: 2.6rem;
  }

  body[data-page="role-selection"] .tagline,
  body[data-page="login"] .tagline,
  body[data-page="forgot-password"] .tagline {
    font-size: 0.8rem;
  }

  /* Right-hand content shouldn't stretch full panel width */
  body[data-page="login"] #login-body > *,
  body[data-page="forgot-password"] #fp-body > * {
    width: 100%;
    max-width: 380px;
  }

  body[data-page="role-selection"] .btn-stack {
    max-width: 320px !important;
  }
}

/* ==========================================================================
   Desktop/laptop layout — logged-in screens with a left sidebar
   Applies to any .app-shell also carrying .app-with-sidebar (teacher &
   parent dashboards, profile, notifications). Turns the fixed bottom tab
   bar into a left-hand navigation rail instead.
   ========================================================================== */

@media (min-width: 900px) {
  .app-shell.app-with-sidebar {
    max-width: none;
    width: 100%;
    margin: 0;
    box-shadow: none;
    display: grid;
    grid-template-columns: 232px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "nav header"
      "nav main";
    min-height: 100vh;
    align-items: stretch;
  }

  .app-shell.app-with-sidebar .app-header { grid-area: header; }
  .app-shell.app-with-sidebar .app-body { grid-area: main; padding: 32px 40px 40px; }
  .app-shell.app-with-sidebar .bottom-nav { grid-area: nav; }

  .app-shell.app-with-sidebar .pad-bottom-nav { padding-bottom: 40px; }

  .app-shell.app-with-sidebar .bottom-nav {
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    max-width: none;
    height: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 28px 16px;
    box-shadow: none;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
  }

  .app-shell.app-with-sidebar .sidebar-brand {
    display: block;
    padding: 4px 16px 24px;
  }

  .app-shell.app-with-sidebar .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
  }

  .app-shell.app-with-sidebar .nav-item.active {
    background: var(--gray-mist);
  }

  .app-shell.app-with-sidebar .nav-icon { font-size: 1.15rem; }
  .app-shell.app-with-sidebar .nav-label { font-size: 0.88rem; }

  .app-shell.app-with-sidebar .nav-dot {
    top: 8px;
    right: 14px;
  }

  /* Teacher dashboard: student list becomes a card grid with the avatar
     ("photo"), name, and condition badge stacked and centered per card. */
  .app-shell.app-with-sidebar #student-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
  }

  .app-shell.app-with-sidebar #student-list .student-list-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 26px 16px;
    margin-bottom: 0;
  }

  .app-shell.app-with-sidebar #student-list .avatar {
    width: 68px;
    height: 68px;
    font-size: 1.3rem;
  }

  .app-shell.app-with-sidebar #student-list .student-info {
    width: 100%;
  }

  .app-shell.app-with-sidebar #student-list .student-meta {
    white-space: normal;
  }

  .app-shell.app-with-sidebar #student-list .chev {
    display: none;
  }

  .app-shell.app-with-sidebar #student-list .empty-state {
    grid-column: 1 / -1;
  }
}

/* --- Large desktop — give the sidebar layout a bit more breathing room --- */
@media (min-width: 1200px) {
  .app-shell.app-with-sidebar {
    grid-template-columns: 256px 1fr;
  }

  .app-shell.app-with-sidebar #student-list {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }

  .app-shell.app-with-sidebar .app-body {
    padding: 40px 56px 56px;
  }
}

/* --- Profile page always shows exactly two stats, so keep it a
       2-column grid at every breakpoint instead of inheriting the
       3-column dashboard grid (which left an empty, misaligned gap). --- */
body[data-page="profile"] .stat-grid {
  grid-template-columns: repeat(2, 1fr);
}

/* --- Parent dashboard: put the weight graph and the check-up history
       side by side as two square panels on desktop, instead of two
       separate full-width sections stacked on top of each other. --- */
@media (min-width: 900px) {
  body[data-page="parent-dashboard"] #history-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 16px;
    max-width: 860px;
  }

  body[data-page="parent-dashboard"] #history-section > .section-title {
    grid-column: 1 / -1;
  }

  body[data-page="parent-dashboard"] #history-section .chart-wrap,
  body[data-page="parent-dashboard"] #history-section > .card {
    margin-bottom: 0;
    height: 300px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  body[data-page="parent-dashboard"] #history-section .chart-wrap {
    justify-content: flex-end;
  }
}

/* --- Ultra-wide screens — keep the main content column from stretching
       into unreadably long rows/lines; let it breathe with side gutters
       instead of growing forever. --- */
@media (min-width: 1600px) {
  .app-shell.app-with-sidebar .app-body {
    padding-left: max(56px, calc((100% - 1400px) / 2));
    padding-right: max(56px, calc((100% - 1400px) / 2));
  }
}

