/* ============================================================
   GRADEFLOW  ·  World-class LMS Design System
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap");

/* ---- TOKENS ---- */
:root {
  --ink: #0d0f14;
  --ink-2: #1c2030;
  --ink-3: #2e3450;
  --muted: #3774a7;
  --border: #e3e6f0;
  --border-2: #c8cde0;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f9fafd;

  --accent: #4361ee;
  --accent-d: #2d46c7;
  --accent-l: #eef1fd;
  --accent-2: #7209b7;
  --accent-3: #3a0ca3;
  --gold: #f9a825;
  --emerald: #06d6a0;
  --rose: #ef476f;
  --sky: #4cc9f0;

  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #d63031;
  --info: #0984e3;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-full: 9999px;

  --sh-xs: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --sh-sm: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --sh-md: 0 10px 30px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
  --sh-lg: 0 20px 60px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.05);
  --sh-xl: 0 40px 80px rgba(0, 0, 0, 0.14), 0 16px 32px rgba(0, 0, 0, 0.07);
  --sh-accent: 0 12px 32px -8px rgba(67, 97, 238, 0.45);
  --sh-danger: 0 8px 24px -6px rgba(214, 48, 49, 0.4);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --trans: 0.2s var(--ease);

  --sidebar-w: 260px;
  --header-h: 64px;

  --font-display: "Syne", sans-serif;
  --font-body: "DM Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

/* ---- DARK MODE ---- */
[data-theme="dark"] {
  --ink: #f0f2ff;
  --ink-2: #d0d4ef;
  --ink-3: #a8aed0;
  --muted: #6b7280;
  --border: #2a2f45;
  --border-2: #3a4060;
  --bg: #0e1117;
  --surface: #161b2e;
  --surface-2: #1c2240;
  --accent-l: #1a1f3a;
  --sh-xs: 0 1px 3px rgba(0, 0, 0, 0.3);
  --sh-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --sh-md: 0 10px 30px rgba(0, 0, 0, 0.35);
  --sh-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ---- RESET ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition:
    background 0.3s,
    color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img {
  display: block;
  max-width: 100%;
}
button {
  cursor: pointer;
  font-family: inherit;
}
input,
select,
textarea {
  font-family: inherit;
}
a {
  text-decoration: none;
  color: inherit;
}

/* ============================================================
   PAGES
   ============================================================ */

/* All pages hidden by default — use visibility + position trick
   so inline styles can NEVER override page switching */
.page {
  display: none !important;
}
.page.active {
  display: block !important;
}
#page-dashboard.active {
  display: flex !important;
  height: 100vh;
  overflow: hidden;
  flex-direction: column;
}

/* When on the landing page, prevent body from scrolling into
   invisible dashboard content that exists in the DOM */
body.on-landing {
  overflow: hidden;
  height: 100vh;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */
#page-landing {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  /* Contain scroll entirely within the landing page element */
  overscroll-behavior: contain;
}

/* Dedicated auth and portal pages */
#page-login,
#page-portal-login,
#page-role-home {
  min-height: 100vh;
  background:
    radial-gradient(
      circle at 8% 10%,
      rgba(249, 168, 37, 0.14),
      transparent 45%
    ),
    radial-gradient(
      circle at 90% 95%,
      rgba(67, 97, 238, 0.14),
      transparent 42%
    ),
    var(--bg);
  padding: 2rem;
}

.route-auth-page {
  min-height: calc(100vh - 4rem);
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.5rem;
}

.route-auth-brand,
.route-auth-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
}

.route-auth-brand {
  padding: 2.3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.route-auth-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.35rem 0.8rem;
  border-radius: var(--r-full);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  margin-bottom: 1rem;
}

.route-auth-brand h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.2vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 0.8rem;
}

.route-auth-brand p {
  color: var(--muted);
  max-width: 44ch;
}

.route-auth-points {
  margin-top: 1.2rem;
  display: grid;
  gap: 0.65rem;
  font-weight: 600;
  color: var(--ink-2);
}

.route-auth-points i {
  color: var(--accent);
  margin-right: 0.45rem;
}

.route-auth-links {
  margin-top: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.route-auth-panel {
  padding: 2rem;
}

.route-tabs {
  margin-bottom: 1.2rem;
}

.route-consent-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.route-consent-row input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.route-consent-row a {
  color: var(--accent);
  font-weight: 700;
}

.portal-page-wrap {
  min-height: calc(100vh - 4rem);
  max-width: 1140px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  border: 1px solid rgba(122, 23, 23, 0.25);
}

.portal-brand-side {
  background:
    radial-gradient(
      circle at 20% 18%,
      rgba(249, 168, 37, 0.22),
      transparent 50%
    ),
    linear-gradient(145deg, #5c0f12, #701718 45%, #8f2323);
  color: #fdf2e0;
  padding: 2.3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-mark {
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.82;
}

.portal-brand-side h2 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  line-height: 1.1;
}

.portal-brand-side p {
  max-width: 40ch;
  opacity: 0.92;
}

.portal-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.7rem;
}

.portal-role-card {
  border: 1px solid rgba(252, 228, 192, 0.24);
  background: rgba(255, 255, 255, 0.07);
  color: #fff7ea;
  border-radius: var(--r-md);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  transition: var(--trans);
}

.portal-role-card i {
  font-size: 1rem;
}

.portal-role-card.active,
.portal-role-card:hover {
  border-color: #f9a825;
  background: rgba(249, 168, 37, 0.18);
}

.portal-login-side {
  background: #fffdf8;
  padding: 2.3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.portal-login-header {
  margin-bottom: 1rem;
}

.portal-login-kicker {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: #8b5e3c;
  font-weight: 700;
}

.portal-login-header h3 {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 0.35rem;
}

.portal-login-header p {
  color: var(--muted);
}

.portal-login-links {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.role-home-wrap {
  min-height: calc(100vh - 4rem);
  max-width: 1100px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--sh-md);
  padding: 2rem;
}

.role-home-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.8vw, 2.4rem);
  margin-top: 0.35rem;
}

.role-home-kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.role-home-head p {
  color: var(--muted);
  margin-top: 0.3rem;
}

.role-home-grid {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
}

.role-home-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem;
  background: var(--surface-2);
}

.role-home-card h4 {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.role-home-card p {
  font-size: 0.8rem;
  color: var(--muted);
}

.role-home-actions {
  margin-top: 1.2rem;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* ==================================================================== 
   DASHBOARD SHELLS (Admin, Student, Parent)
   ==================================================================== */

.admin-dashboard-wrap,
.student-dashboard-wrap,
.parent-dashboard-wrap {
  min-height: calc(100vh - 4rem);
  max-width: 1200px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--sh-md);
  padding: 2rem;
}

.dashboard-header {
  margin-bottom: 2rem;
}

.dashboard-kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.dashboard-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.8vw, 2.4rem);
  margin-top: 0.35rem;
  margin-bottom: 0.3rem;
}

.dashboard-header p {
  color: var(--muted);
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.2rem;
  text-align: center;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.dashboard-section {
  margin-bottom: 2rem;
}

.dashboard-section h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.teacher-list,
.approval-queue,
.performance-grid,
.assignment-list,
.child-performance,
.communication-log {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.teacher-item,
.approval-item,
.performance-item,
.assignment-item,
.child-card,
.communication-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.teacher-item:hover,
.approval-item:hover,
.performance-item:hover,
.assignment-item:hover,
.child-card:hover,
.communication-item:hover {
  background: var(--surface-3);
  border-color: var(--primary-light);
}

.teacher-item-left,
.approval-item-left,
.performance-item-left,
.assignment-item-left,
.child-card-left,
.communication-item-left {
  flex: 1;
}

.teacher-item-name,
.approval-item-title,
.performance-item-name,
.assignment-item-name,
.child-card-name,
.communication-item-subject {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.teacher-item-classes,
.approval-item-desc,
.performance-item-average,
.assignment-item-due,
.child-card-average,
.communication-item-date {
  font-size: 0.8rem;
  color: var(--muted);
}

.teacher-item-right,
.approval-item-right,
.performance-item-right,
.assignment-item-right,
.child-card-right,
.communication-item-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.status-badge {
  padding: 0.3rem 0.7rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.status-badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.status-badge.complete {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.urgent {
  background: #fee2e2;
  color: #b91c1c;
}

.progress-bar {
  width: 60px;
  height: 6px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}

.dashboard-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* Nav */
.land-nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 3rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(227, 230, 240, 0.6);
  transition: var(--trans);
}
[data-theme="dark"] .land-nav {
  background: rgba(22, 27, 46, 0.88);
  border-bottom-color: rgba(42, 47, 69, 0.6);
}
.land-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.land-nav-brand svg {
  width: 32px;
  height: 32px;
}
.land-nav-links {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  list-style: none;
}
.land-nav-links a {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--muted);
  transition: color var(--trans);
}
.land-nav-links a:hover {
  color: var(--accent);
}
.land-nav-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

/* Hero */
.land-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem 5rem;
  position: relative;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 80% 60% at 50% -10%,
      rgba(67, 97, 238, 0.18) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 50% 40% at 80% 80%,
      rgba(114, 9, 183, 0.1) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 0;
}
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(67, 97, 238, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67, 97, 238, 0.05) 1px, transparent 1px);
  background-size: 60px 60px;
  z-index: 0;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black, transparent);
}
.hero-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-l);
  color: var(--accent);
  border: 1px solid rgba(67, 97, 238, 0.25);
  padding: 0.4rem 1.2rem;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 2rem;
  animation: fadeUp 0.6s var(--bounce) both;
}
.hero-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -3px;
  color: var(--ink);
  margin-bottom: 1.5rem;
  animation: fadeUp 0.7s var(--bounce) 0.1s both;
}
.hero-title .accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto 3rem;
  line-height: 1.7;
  animation: fadeUp 0.7s var(--bounce) 0.2s both;
}
.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeUp 0.7s var(--bounce) 0.3s both;
}
.hero-stats {
  display: flex;
  gap: 3rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 5rem;
  animation: fadeUp 0.7s var(--bounce) 0.5s both;
}
.hero-stat {
  text-align: center;
}
.hero-stat-num {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.hero-stat-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.3rem;
  font-weight: 500;
}
.hero-divider {
  width: 1px;
  height: 48px;
  background: var(--border);
  margin-top: 1.2rem;
}

/* Features Section */
.land-section {
  padding: 7rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}
.section-label {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -1.5px;
  color: var(--ink);
  margin-bottom: 1.2rem;
}
.section-sub {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 580px;
  line-height: 1.7;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 4rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2.2rem;
  transition: var(--trans);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.feature-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-l), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-md);
  border-color: rgba(67, 97, 238, 0.3);
}
.feature-card:hover::before {
  opacity: 1;
}
.feature-icon {
  width: 52px;
  height: 52px;
  background: var(--accent-l);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}
.feature-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}
.feature-card p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.65;
  position: relative;
  z-index: 1;
}

/* Testimonials */
.testimonials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 4rem;
}
.testimonial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2rem;
  box-shadow: var(--sh-sm);
}
.testimonial-card p {
  font-size: 0.95rem;
  color: var(--ink-2);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  font-style: italic;
}
.testimonial-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.testimonial-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  font-weight: 700;
}
.testimonial-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}
.testimonial-role {
  font-size: 0.8rem;
  color: var(--muted);
}

/* CTA section */
.land-cta-section {
  background: linear-gradient(
    135deg,
    var(--accent-3) 0%,
    var(--accent) 50%,
    var(--accent-2) 100%
  );
  padding: 7rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.land-cta-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(
      circle at 20% 50%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 50%
    );
}
.land-cta-section h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  color: white;
  letter-spacing: -1.5px;
  margin-bottom: 1rem;
  position: relative;
}
.land-cta-section p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.05rem;
  margin-bottom: 2.5rem;
  position: relative;
}

/* Footer */
.land-footer {
  background: var(--ink);
  color: rgba(255, 253, 253, 0.6);
  text-align: center;
  padding: 2.5rem;
  font-size: 0.85rem;
}
.land-footer strong {
  color: var(--bg);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--r-full);
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font-body);
  transition: all 0.2s var(--bounce);
  white-space: nowrap;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: var(--sh-xs);
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
}
.btn:active {
  transform: translateY(0);
}
.btn:focus-visible {
  outline: 3px solid rgba(47, 109, 246, 0.22);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: var(--sh-accent);
}
.btn-primary:hover {
  background: var(--accent-d);
  box-shadow: 0 16px 40px -10px rgba(67, 97, 238, 0.55);
}
.btn-outline {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(122, 140, 182, 0.28);
}
.btn-outline:hover {
  background: var(--surface);
  border-color: rgba(47, 109, 246, 0.3);
  color: var(--accent);
}
.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: transparent;
  box-shadow: var(--sh-danger);
}
.btn-success {
  background: var(--success);
  color: white;
  border-color: transparent;
}
.btn-warning {
  background: var(--warning);
  color: var(--ink);
  border-color: transparent;
}
.btn-sm {
  padding: 0.45rem 1.1rem;
  font-size: 0.82rem;
  gap: 0.4rem;
}
.btn-xs {
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  gap: 0.3rem;
}
.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1rem;
}
.btn-icon {
  padding: 0.6rem;
  border-radius: var(--r-md);
  aspect-ratio: 1;
}
.btn-icon i,
.sidebar-nav-item i,
.sidebar-footer-item i,
.stat-card-icon i,
.page-header-title i,
.topbar-title i {
  transform: translateY(0.5px);
}
.btn-sm,
.btn-xs,
.btn-icon {
  min-height: 38px;
}
.btn-outline {
  background: transparent;
  border-color: var(--border-2);
  color: var(--ink);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-l);
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
#page-dashboard.active {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  z-index: 50;
  transition: width 0.3s var(--ease);
}
.app-sidebar.collapsed {
  width: 72px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.4rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  color: white;
  box-shadow: var(--sh-accent);
}
.sidebar-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
  letter-spacing: -0.5px;
  white-space: nowrap;
  transition: opacity 0.3s;
}
.app-sidebar.collapsed .sidebar-brand {
  opacity: 0;
  pointer-events: none;
}
.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.3rem;
  border-radius: var(--r-xs);
  transition: var(--trans);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  color: var(--accent);
  background: var(--accent-l);
}

.sidebar-user {
  margin: 1rem 1.2rem;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  overflow: hidden;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.user-info {
  overflow: hidden;
}
.user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Sidebar nav sections */
.sidebar-section-label {
  padding: 0.75rem 1.4rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
  transition: opacity 0.3s;
}
.app-sidebar.collapsed .sidebar-section-label {
  opacity: 0;
}

.sidebar-nav {
  flex-shrink: 0;
  padding: 0 0.8rem;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 0.15rem;
}
.sidebar-nav-item i {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.sidebar-nav-item:hover {
  background: var(--bg);
  color: var(--ink);
}
.sidebar-nav-item.active {
  background: var(--accent-l);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

/* Classes section in sidebar */
.sidebar-classes {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.8rem 0.8rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-classes::-webkit-scrollbar {
  width: 4px;
}
.sidebar-classes::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.class-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
}
.class-item:hover {
  background: var(--bg);
  color: var(--ink);
}
.class-item.active {
  background: var(--accent-l);
  color: var(--accent);
  font-weight: 600;
}
.class-emoji {
  font-size: 1rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.class-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.class-item-count {
  font-size: 0.72rem;
  background: var(--bg);
  color: var(--muted);
  padding: 0.1rem 0.45rem;
  border-radius: var(--r-full);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.class-item.active .class-item-count {
  background: rgba(67, 97, 238, 0.15);
  border-color: rgba(67, 97, 238, 0.2);
  color: var(--accent);
}
.class-delete-btn {
  display: none;
  background: none;
  border: none;
  color: var(--danger);
  padding: 0.2rem;
  border-radius: var(--r-xs);
  font-size: 0.85rem;
  transition: var(--trans);
  flex-shrink: 0;
}
.class-item:hover .class-delete-btn {
  display: flex;
}
.class-delete-btn:hover {
  background: rgba(214, 48, 49, 0.1);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar-footer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--trans);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  background: none;
  border: none;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-footer-item i {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.sidebar-footer-item:hover {
  background: var(--bg);
  color: var(--ink);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  white-space: nowrap;
}
.topbar-breadcrumb {
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: 0.5rem;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.topbar-search {
  position: relative;
}
.topbar-search input {
  width: 240px;
  padding: 0.5rem 1rem 0.5rem 2.4rem;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
  color: var(--ink);
  transition: var(--trans);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
  width: 300px;
}
.topbar-search i {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.75rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  min-height: 0;
}
.app-main::-webkit-scrollbar {
  width: 6px;
}
.app-main::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}

/* ============================================================
   DASHBOARD VIEW
   ============================================================ */
.view {
  display: none;
}
.view.active {
  display: block;
}

/* Stats row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--sh-xs);
  transition: var(--trans);
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--accent-l);
  z-index: 0;
}
.stat-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-3px);
}
.stat-card-icon {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 1;
}
.stat-card-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
}
.stat-card-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  margin-top: 0.2rem;
  position: relative;
  z-index: 1;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}
.stat-card-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.3rem;
  position: relative;
  z-index: 1;
}
.stat-card.accent-1::before {
  background: rgba(67, 97, 238, 0.08);
}
.stat-card.accent-2::before {
  background: rgba(6, 214, 160, 0.08);
}
.stat-card.accent-3::before {
  background: rgba(249, 168, 37, 0.08);
}
.stat-card.accent-4::before {
  background: rgba(239, 71, 111, 0.08);
}
.stat-card.accent-1 .stat-card-icon {
  color: var(--accent);
}
.stat-card.accent-2 .stat-card-icon {
  color: var(--emerald);
}
.stat-card.accent-3 .stat-card-icon {
  color: var(--gold);
}
.stat-card.accent-4 .stat-card-icon {
  color: var(--rose);
}

/* Page header row */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem; /* increased from 1.5rem */
  flex-wrap: wrap;
}
.page-header-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.5px;
}
.page-header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Subject tabs */
.subject-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.subject-tab {
  padding: 0.45rem 1.1rem;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: var(--trans);
}
.subject-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.subject-tab.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: var(--sh-accent);
}

/* Grade table */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-sm);
  width: 100%;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--surface-2);
}
.table-toolbar-search {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 300px;
}
.table-toolbar-search i {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.82rem;
  pointer-events: none;
}
.table-toolbar-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.2rem;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.83rem;
  color: var(--ink);
  transition: var(--trans);
}
.table-toolbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.table-toolbar-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.grade-table {
  width: 100%;
  border-collapse: collapse;
}
.grade-table thead {
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
}
.grade-table th {
  padding: 0.85rem 0.9rem;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  white-space: nowrap;
}
.grade-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.grade-table th.sortable:hover {
  color: var(--accent);
}
.grade-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--ink);
  vertical-align: middle;
}
.grade-table tbody tr:last-child td {
  border-bottom: none;
}
.grade-table tbody tr:hover td {
  background: var(--bg);
}
.grade-table tbody tr.selected td {
  background: var(--accent-l);
}

.student-name-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.student-mini-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.student-name {
  font-weight: 600;
}

/* Score inputs */
.score-input {
  width: 62px;
  padding: 0.35rem 0.5rem;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  font-size: 0.83rem;
  text-align: center;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  transition: var(--trans);
  font-weight: 600;
}
.score-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.score-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(214, 48, 49, 0.1);
}

/* Grade pills */
.grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.9rem;
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 0.78rem;
  min-width: 52px;
  font-family: var(--font-display);
}
.g-A {
  background: #d1fae5;
  color: #064e3b;
}
.g-B {
  background: #dbeafe;
  color: #1e3a5f;
}
.g-C {
  background: #fed7aa;
  color: #7c2d12;
}
.g-D {
  background: #fef9c3;
  color: #713f12;
}
.g-E {
  background: #ede9fe;
  color: #4c1d95;
}
.g-F {
  background: #fee2e2;
  color: #7f1d1d;
}
.g-none {
  background: #f1f5f9;
  color: #475569;
}
[data-theme="dark"] .g-A {
  background: #064e3b;
  color: #a7f3d0;
}
[data-theme="dark"] .g-B {
  background: #1e3a5f;
  color: #bfdbfe;
}
[data-theme="dark"] .g-F {
  background: #7f1d1d;
  color: #fecaca;
}

/* Score bar */
.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.score-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 50px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s var(--ease);
}
.score-val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 35px;
  text-align: right;
}

/* Position badge */
.pos-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-mono);
}
.pos-badge.pos-1 {
  color: var(--gold);
}
.pos-badge.pos-2 {
  color: #9ca3af;
}
.pos-badge.pos-3 {
  color: #a16207;
}

/* Batch action bar */
.batch-bar {
  position: fixed;
  bottom: 2rem; /* raised from 1.5rem */
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-2);
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: var(--r-full);
  display: none;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--sh-lg);
  z-index: 200;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  animation: slideUp 0.3s var(--bounce);
}
.batch-bar.active {
  display: flex;
}
@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(60px);
    opacity: 0;
  }
}

/* ============================================================
   ANALYTICS VIEW
   ============================================================ */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.analytics-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
  box-shadow: var(--sh-xs);
}
.analytics-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.analytics-card canvas {
  max-height: 220px;
}
@media (max-width: 900px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Grade distribution bars */
.dist-bar-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
.dist-bar-label {
  width: 28px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
}
.dist-bar-track {
  flex: 1;
  height: 22px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.dist-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s var(--ease);
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
}
.dist-bar-count {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 24px;
  text-align: right;
  font-family: var(--font-mono);
}

/* Top performers */
.top-performer-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.top-performer-row:last-child {
  border-bottom: none;
}
.top-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  width: 28px;
  text-align: center;
  color: var(--muted);
}
.top-rank.r1 {
  color: var(--gold);
}
.top-rank.r2 {
  color: #9ca3af;
}
.top-rank.r3 {
  color: #a16207;
}
.top-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.88rem;
}
.top-score {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}

/* ============================================================
   STUDENTS VIEW (cards mode)
   ============================================================ */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem; /* increased from 1.2rem */
}
.student-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
  box-shadow: var(--sh-xs);
  transition: var(--trans);
  cursor: pointer;
}
.student-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-3px);
  border-color: rgba(67, 97, 238, 0.25);
}
.student-card-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.student-card-avatar {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  font-family: var(--font-display);
}
.student-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}
.student-card-pos {
  font-size: 0.75rem;
  color: var(--muted);
}
.student-overall {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.student-card-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ============================================================
   SETTINGS VIEW
   ============================================================ */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--sh-xs);
}
.settings-section h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.settings-row:last-child {
  border-bottom: none;
}
.settings-row-label {
  font-weight: 600;
  font-size: 0.9rem;
}
.settings-row-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s var(--bounce);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.toggle input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Form groups */
.form-group {
  margin-bottom: 1.2rem;
}
.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.form-input {
  width: 100%;
  padding: 0.75rem 1.1rem;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 0.88rem;
  color: var(--ink);
  font-family: var(--font-body);
  transition: var(--trans);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7699' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.5);
  backdrop-filter: blur(8px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
.modal-box {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sh-xl);
  border: 1px solid var(--border);
  animation: scaleIn 0.25s var(--bounce);
  scrollbar-width: thin;
}
.modal-box.modal-lg {
  max-width: 700px;
}
@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
}
.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
  letter-spacing: -0.5px;
}
.modal-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 2rem;
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--trans);
}
.modal-close:hover {
  color: var(--ink);
  border-color: var(--border-2);
}
.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.modal-box {
  position: relative;
}

/* Auth modal special styling */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 2rem;
  background: var(--bg);
  border-radius: var(--r-lg);
  padding: 0.3rem;
}
.auth-tab {
  flex: 1;
  padding: 0.6rem;
  text-align: center;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--muted);
  transition: var(--trans);
  border: none;
  background: none;
  font-family: var(--font-body);
}
.auth-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-xs);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.3rem;
  border-radius: var(--r-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  background: var(--ink-2);
  box-shadow: var(--sh-lg);
  min-width: 200px;
  max-width: 360px;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s var(--bounce);
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.toast.show {
  transform: translateX(0);
  opacity: 1;
}
.toast.success {
  background: #064e3b;
  border-color: rgba(6, 214, 160, 0.3);
}
.toast.error {
  background: #7f1d1d;
  border-color: rgba(239, 71, 111, 0.3);
}
.toast.info {
  background: var(--ink-2);
}
.toast.warning {
  background: #7c2d12;
}
.toast i {
  flex-shrink: 0;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
}
[data-theme="dark"] .loading-overlay {
  background: rgba(14, 17, 23, 0.85);
}
.loading-overlay.active {
  display: flex;
}
.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-text {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ============================================================
   OFFLINE BANNER
   ============================================================ */
.offline-banner {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--ink);
  color: var(--warning);
  padding: 0.4rem 0.8rem;
  border-radius: var(--r-md);
  font-size: 0.7rem;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 0.3rem;
  z-index: 9000;
  transition: opacity 0.3s var(--bounce);
  box-shadow: var(--sh-sm);
}
.offline-banner.show {
  display: flex;
}

/* ============================================================
   CHARTS & ANALYTICS EXTRAS
   ============================================================ */
.chart-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}
.empty-state h3 {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
}
.empty-state p {
  font-size: 0.88rem;
  max-width: 320px;
  margin: 0 auto 1.5rem;
}

/* ============================================================
   REPORT CARD PRINT TEMPLATE
   ============================================================ */
#pdf-template {
  width: 210mm;
  padding: 15mm;
  background: white;
  display: none;
  font-family: "DM Sans", sans-serif;
  color: #1e293b;
  position: absolute;
  left: -9999px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.fade-in {
  animation: fadeUp 0.4s var(--ease) both;
}
.fade-in-delay-1 {
  animation-delay: 0.1s;
}
.fade-in-delay-2 {
  animation-delay: 0.2s;
}
.fade-in-delay-3 {
  animation-delay: 0.3s;
}

/* ============================================================
   UTILITY
   ============================================================ */
.flex {
  display: flex;
  align-items: center;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.gap-1 {
  gap: 0.5rem;
}
.gap-2 {
  gap: 1rem;
}
.gap-3 {
  gap: 1.5rem;
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.text-muted {
  color: var(--muted);
}
.text-accent {
  color: var(--accent);
}
.text-sm {
  font-size: 0.82rem;
}
.text-xs {
  font-size: 0.72rem;
}
.font-bold {
  font-weight: 700;
}
.font-display {
  font-family: var(--font-display);
}
.w-full {
  width: 100%;
}
.ml-auto {
  margin-left: auto;
}
.rounded-full {
  border-radius: var(--r-full);
}
.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.7rem;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-l);
  color: var(--accent);
  border: 1px solid rgba(67, 97, 238, 0.2);
}
.badge-pill.green {
  background: #d1fae5;
  color: #064e3b;
  border-color: rgba(6, 214, 160, 0.2);
}
.badge-pill.red {
  background: #fee2e2;
  color: #7f1d1d;
  border-color: rgba(239, 71, 111, 0.2);
}

/* ============================================================
   CLASS MATERIALS
   ============================================================ */

/* Filter bar */
.materials-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xs);
}
.mat-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.9rem;
  border-radius: var(--r-full);
  border: 1.5px solid transparent;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: var(--trans);
  font-family: var(--font-body);
}
.mat-filter-btn:hover {
  background: var(--bg);
  color: var(--ink);
}
.mat-filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px -4px rgba(67, 97, 238, 0.4);
}

/* Materials grid */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.2rem;
}

/* Material card */
.material-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-xs);
  transition: var(--trans);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}
.material-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-3px);
  border-color: rgba(67, 97, 238, 0.25);
}

.material-card-thumb {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.material-card-thumb.thumb-word {
  background: linear-gradient(135deg, #e8f0fc, #c8d8f8);
}
.material-card-thumb.thumb-html {
  background: linear-gradient(135deg, #fdf0e8, #f8d0b8);
}
.material-card-thumb.thumb-pdf {
  background: linear-gradient(135deg, #fee8ec, #fdb8c8);
}
.material-card-thumb.thumb-image {
  background: linear-gradient(135deg, #e8fdf4, #b8f0d8);
}
.material-card-thumb.thumb-other {
  background: linear-gradient(135deg, #f0f0f8, #d8d8ec);
}
.material-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.mat-type-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.18rem 0.6rem;
  border-radius: var(--r-full);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0, 0, 0, 0.07);
}
.mat-type-badge.word {
  color: #2b579a;
}
.mat-type-badge.html {
  color: #e44d26;
}
.mat-type-badge.pdf {
  color: #ef476f;
}
.mat-type-badge.image {
  color: #00b894;
}
.mat-type-badge.url {
  color: #4361ee;
}
.mat-type-badge.other {
  color: var(--muted);
}

.material-card-body {
  padding: 1rem 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.material-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.material-card-sub {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}
.mat-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: var(--r-full);
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--accent-l);
  color: var(--accent);
  border: 1px solid rgba(67, 97, 238, 0.15);
}
.material-card-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

/* Upload dropzone */
.mat-dropzone {
  border: 2px dashed var(--border-2);
  border-radius: var(--r-xl);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--trans);
  background: var(--bg);
  position: relative;
}
.mat-dropzone:hover,
.mat-dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-l);
}
.mat-dropzone-icon {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.mat-dropzone-title {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.3rem;
}
.mat-dropzone-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.mat-dropzone-selected {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(67, 97, 238, 0.1);
  padding: 0.5rem 1rem;
  border-radius: var(--r-full);
}

/* Input tabs */
.mat-input-tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-radius: var(--r-lg);
  padding: 0.25rem;
  margin-bottom: 0.8rem;
}
.mat-input-tab {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.83rem;
  cursor: pointer;
  color: var(--muted);
  transition: var(--trans);
  border: none;
  background: none;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.mat-input-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-xs);
}

/* Viewer modal */
.mat-viewer-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.mat-viewer-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}
.mat-viewer-meta {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 1.5rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
  align-items: center;
}
.mat-viewer-body {
  padding: 2rem;
  max-height: 75vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--surface);

  /* Prose styling for rendered documents */
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--ink);
}
.mat-viewer-body h1,
.mat-viewer-body h2,
.mat-viewer-body h3 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 1.2em 0 0.5em;
  color: var(--ink);
}
.mat-viewer-body h1 {
  font-size: 1.7rem;
}
.mat-viewer-body h2 {
  font-size: 1.3rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.4rem;
}
.mat-viewer-body h3 {
  font-size: 1.1rem;
}
.mat-viewer-body p {
  margin-bottom: 0.8em;
}
.mat-viewer-body ul,
.mat-viewer-body ol {
  padding-left: 1.5rem;
  margin-bottom: 0.8em;
}
.mat-viewer-body li {
  margin-bottom: 0.3em;
}
.mat-viewer-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.88rem;
}
.mat-viewer-body th,
.mat-viewer-body td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
}
.mat-viewer-body th {
  background: var(--surface-2);
  font-weight: 700;
}
.mat-viewer-body img {
  max-width: 100%;
  border-radius: var(--r-md);
  margin: 0.5em 0;
}

/* ============================================================
   LANDING PAGE UTILITY CLASSES
   ============================================================ */

/* Feature badge styles */
.badge-accent {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.72rem;
  background: var(--accent-l);
  color: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-weight: 700;
}

.badge-pro {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.72rem;
  background: #fef3c7;
  color: #92400e;
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  font-weight: 700;
}

/* Feature card center container */
.feature-card-center {
  text-align: center;
  padding: 1.5rem;
}

/* Pricing features list container */
.pricing-list-container {
  text-align: center;
  padding: 1.5rem;
}

/* Feature list styling */
.feature-list {
  margin-top: 1.5rem;
  padding: 0;
  list-style: none;
}

.feature-list li {
  text-align: center;
  padding: 0.8rem;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.feature-list i {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* How it works section styling */
.how-section-background {
  background: var(--surface);
  padding: 7rem 0;
}

.how-section-inner {
  padding-top: 0;
  padding-bottom: 0;
}

/* Feature divider */
.feature-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem !important;
  margin-bottom: 1.5rem !important;
}

/* Pricing tier flex layout */
.pricing-tiers-flex {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}

/* How-it-works grid container */
.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

/* Steps emoji icon */
.step-emoji {
  font-size: 2.8rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(67, 97, 238, 0.3));
}

/* Steps heading */
.step-heading {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* Steps description */
.step-desc {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Pricing cards grid */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.5rem;
  max-width: 1060px;
  margin: 3rem auto 0;
}

/* Pricing card */
.pricing-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  position: relative;
}

.pricing-card-highlight {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--r-xl);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transform: scale(1.02);
  box-shadow: var(--sh-md);
}

/* Pricing features list */
.pricing-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.pricing-features li {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.88rem;
}

.pricing-features i {
  color: var(--emerald);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.pricing-features li.disabled {
  color: var(--muted);
}

.pricing-features li.disabled i {
  color: inherit;
}

/* Pro pricing card highlight */
.pricing-pro {
  background: linear-gradient(160deg, #4361ee, #7209b7);
  border: 2px solid transparent;
  border-radius: var(--r-xl);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 60px -10px rgba(67, 97, 238, 0.5);
}

.pricing-pro .pricing-features {
  color: rgba(255, 255, 255, 0.9);
}

.pricing-pro .pricing-features i {
  color: #a7f3d0;
}

/* Pricing button container */
.pricing-button {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}

/* Pricing plan header */
.pricing-header {
  display: flex;
  flex-direction: column;
}

.pricing-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.pricing-price {
  font-size: 2.4rem;
  font-weight: 800;
  font-family: var(--font-display);
}

.pricing-price-period {
  font-size: 0.9rem;
  font-weight: 400;
  opacity: 0.7;
}

.pricing-description {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.4rem;
}

/* Pricing features list */
.pricing-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.pricing-features li {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.88rem;
}

.pricing-features li i {
  color: var(--emerald);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.pricing-feature-disabled {
  color: var(--muted);
}

.pricing-feature-disabled i {
  color: inherit;
}

/* Pricing divider */
.pricing-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Pro button styling */
.pricing-pro .pricing-button {
  background: white;
  color: #4361ee;
  font-weight: 700;
  border: none;
}

/* Pricing footer text */
.pricing-footer {
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.65;
  margin-top: -0.2rem;
}
.mat-viewer-body pre,
.mat-viewer-body code {
  font-family: var(--font-mono);
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 0.2em 0.5em;
  font-size: 0.85em;
}
.mat-viewer-body pre {
  padding: 1em;
  overflow-x: auto;
}
.mat-viewer-body blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
  font-style: italic;
  margin: 1em 0;
}

/* iframe for HTML materials */
.mat-viewer-body iframe {
  width: 100%;
  min-height: 500px;
  border: none;
  border-radius: var(--r-md);
}

/* Image viewer */
.mat-viewer-body .mat-img-viewer {
  text-align: center;
}
.mat-viewer-body .mat-img-viewer img {
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  margin: 0 auto;
}

/* URL card */
.mat-url-card {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.5rem;
  border: 2px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg);
  margin: 1rem 0;
}
.mat-url-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}
.mat-url-link {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  word-break: break-all;
}
.mat-url-link:hover {
  text-decoration: underline;
}

/* Empty state for materials */
.materials-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 2rem;
}

/* ============================================================
   GRADEFLOW — COMPLETE RESPONSIVE SYSTEM
   Breakpoints: 480px | 640px | 768px | 900px | 1024px | 1200px
   ============================================================ */

/* ── GLOBAL BASE FIXES ── */
html,
body {
  overflow-x: hidden;
}
img,
canvas,
table {
  max-width: 100%;
}
input,
select,
textarea,
button {
  min-width: 0;
}

/* Prevent mobile font size inflation */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ============================================================
   DASHBOARD LAYOUT — row on desktop, column-driven on mobile
   ============================================================ */
#page-dashboard.active {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ── SIDEBAR base (desktop) ── */
.app-sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    width 0.3s var(--ease),
    left 0.3s var(--ease),
    box-shadow 0.3s var(--ease);
}

/* ── APP BODY ── */
.app-body {
  flex: 1;
  min-width: 0; /* CRITICAL: prevents flex children from overflowing */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ── */
.app-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  width: 100%;
}

/* ── MAIN SCROLL AREA ── */
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 1.75rem 2rem;
}

/* ── TABLE WRAPPER ── */
.table-wrapper {
  overflow: hidden;
}
.table-wrapper > div[style*="overflow-x:auto"],
.table-wrapper > div[style*="overflow-x: auto"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.grade-table {
  min-width: 680px;
}

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem; /* aligned with increased gap */
  margin-bottom: 2rem;
}

/* ── ANALYTICS GRID ── */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── STUDENTS GRID ── */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem; /* aligned with increased gap */
}

/* ── MATERIALS GRID ── */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.2rem;
}

/* ── FEATURES GRID (Landing) ── */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* ── TOPBAR SEARCH WIDTH ── */
.topbar-search input {
  width: 220px;
}
.topbar-search input:focus {
  width: 280px;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem; /* aligned with increased margin */
  flex-wrap: wrap;
  min-height: 48px;
}
.page-header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── SUBJECT TABS ── */
.subject-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.subject-tabs::-webkit-scrollbar {
  display: none;
}

/* ── MATERIALS FILTER BAR ── */
.materials-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.materials-filter-bar::-webkit-scrollbar {
  display: none;
}
.materials-filter-bar > div:last-child {
  margin-left: auto;
  flex-shrink: 0;
}
#matSearch {
  min-width: 160px;
}

/* ── BATCH BAR ── */
.batch-bar {
  left: calc(var(--sidebar-w) + 1rem);
  right: 1rem;
  transform: none;
  max-width: 640px;
  margin: 0 auto;
  bottom: 2rem; /* aligned with increased bottom */
}
@keyframes slideUp {
  from {
    transform: translateY(60px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.batch-bar.active {
  animation: slideUp 0.3s var(--bounce);
}

/* ── HERO STATS (landing) ── */
.hero-stats {
  display: flex;
  gap: 3rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 5rem;
}
.hero-divider {
  width: 1px;
  height: 48px;
  background: var(--border);
  margin-top: 1.2rem;
}

/* ── MODAL ── */
.modal-overlay {
  padding: 1rem;
}
.modal-box {
  max-height: 92vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ── TOAST ── */
.toast-container {
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: calc(100vw - 3rem);
}
.toast {
  max-width: min(360px, calc(100vw - 3rem));
}

/* ── SCORE INPUTS keep compact ── */
.score-input {
  width: 65px;
}

/* ── TABLE TOOLBAR ── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.25rem;
  flex-wrap: wrap;
}
.table-toolbar-search {
  min-width: 150px;
  max-width: 260px;
  flex: 1;
}
.table-toolbar-right {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── SETTINGS SECTIONS ── */
.settings-section {
  padding: 1.5rem 2rem;
}

/* ── OFFLINE BANNER ── */
.offline-banner {
  max-width: calc(100vw - 2rem);
  text-align: center;
}

/* ============================================================
   1200px — Large screens: generous spacing
   ============================================================ */
@media (min-width: 1200px) {
  .land-section {
    padding: 8rem 4rem;
  }
  .app-main {
    padding: 2rem 2.5rem;
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   max-width: 1024px — Smaller desktops / large tablets
   ============================================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 260px;
  }

  .land-section {
    padding: 6rem 2.5rem;
  }
  .land-nav {
    padding: 0.9rem 2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
  .stat-card {
    padding: 1.2rem 1.4rem;
  }
  .stat-card-value {
    font-size: 2rem;
  }

  .topbar-search input {
    width: 180px;
  }
  .topbar-search input:focus {
    width: 240px;
  }

  .features-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

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

/* ============================================================
   max-width: 900px — Tablet landscape
   ============================================================ */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 240px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .app-main {
    padding: 1.5rem;
  }

  .page-header-title {
    font-size: 1.35rem;
  }

  .hero-title {
    letter-spacing: -2px;
  }
  .land-section {
    padding: 5rem 2rem;
  }

  .features-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.2rem;
  }
  .testimonials-grid {
    grid-template-columns: 1fr 1fr;
  }

  .settings-section {
    padding: 1.25rem 1.5rem;
  }
}

/* ============================================================
   max-width: 768px — Tablet portrait / Mobile pivot point
   ============================================================ */
@media (max-width: 768px) {
  /* ── SIDEBAR becomes an off-canvas drawer ── */
  .app-sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    width: 280px !important; /* override collapsed/variable width */
    height: 100vh;
    z-index: 200;
    box-shadow: none;
    transition:
      left 0.28s var(--ease),
      box-shadow 0.28s var(--ease);
  }
  .app-sidebar.open {
    left: 0;
    box-shadow: var(--sh-xl);
  }
  /* When collapsed class is also present on mobile, don't narrow it — it's a drawer */
  .app-sidebar.collapsed {
    width: 280px !important;
  }
  .app-sidebar.collapsed .sidebar-brand {
    opacity: 1;
    pointer-events: auto;
  }
  .app-sidebar.collapsed .sidebar-section-label {
    opacity: 1;
  }

  /* ── Sidebar overlay (backdrop when drawer is open) ── */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.active {
    display: block;
  }

  /* ── Show the mobile hamburger ── */
  #mobileMenuBtn {
    display: flex !important;
  }

  /* ── Topbar ── */
  .app-topbar {
    padding: 0 1rem;
    gap: 0.6rem;
  }
  .topbar-breadcrumb {
    display: none;
  }
  .topbar-search {
    display: none;
  } /* hidden on mobile, use in-view search */

  /* ── App main ── */
  .app-main {
    padding: 1.2rem 1rem;
  }

  /* ── Stats ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.2rem;
  }
  .stat-card {
    padding: 1rem 1.1rem;
    border-radius: var(--r-lg);
  }
  .stat-card-value {
    font-size: 1.8rem;
  }
  .stat-card-label {
    font-size: 0.72rem;
  }
  .stat-card-sub {
    display: none;
  }

  /* ── Page header ── */
  .page-header {
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-bottom: 1rem;
  }
  .page-header-title {
    font-size: 1.2rem;
    width: 100%;
  }
  .page-header-actions {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .page-header-actions .btn {
    font-size: 0.78rem;
    padding: 0.4rem 0.9rem;
  }

  /* ── Grade table ── */
  .grade-table {
    min-width: 600px;
  }
  .grade-table th,
  .grade-table td {
    padding: 0.65rem 0.7rem;
  }
  .grade-table th {
    font-size: 0.7rem;
  }
  .score-input {
    width: 58px;
    font-size: 0.8rem;
    padding: 0.35rem 0.4rem;
  }
  .student-mini-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
  }

  /* Hide less critical columns on mobile */
  .grade-table th:nth-child(8),   /* Remark */
  .grade-table td:nth-child(8) {
    display: none;
  }

  /* ── Subject tabs ── */
  .subject-tabs {
    gap: 0.4rem;
  }
  .subject-tab {
    padding: 0.38rem 0.85rem;
    font-size: 0.78rem;
  }

  /* ── Analytics ── */
  .analytics-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .analytics-card {
    padding: 1.1rem;
  }
  .analytics-card canvas {
    max-height: 180px !important;
  }

  /* ── Students grid ── */
  .students-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.9rem;
  }

  /* ── Materials ── */
  .materials-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
  }
  .material-card-thumb {
    height: 110px;
  }
  .materials-filter-bar {
    padding: 0.6rem 0.8rem;
    gap: 0.4rem;
    border-radius: var(--r-lg);
  }
  .mat-filter-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
  }
  #matSearch {
    width: 160px;
  }

  /* ── Batch bar ── */
  .batch-bar {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: var(--r-xl);
    padding: 0.85rem 1rem;
    gap: 0.6rem;
  }

  /* ── Settings ── */
  .settings-section {
    padding: 1rem 1.1rem;
    border-radius: var(--r-lg);
  }
  .settings-row {
    gap: 0.75rem;
  }

  /* ── Modals ── */
  .modal-overlay {
    padding: 0.75rem;
    align-items: flex-end;
  }
  .modal-box {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-width: 100%;
    max-height: 88vh;
    padding: 1.75rem 1.5rem 2rem;
    animation: slideUpModal 0.28s var(--bounce);
  }
  @keyframes slideUpModal {
    from {
      transform: translateY(40px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  .modal-box.modal-lg {
    max-width: 100%;
  }
  .modal-title {
    font-size: 1.25rem;
  }
  .modal-actions {
    gap: 0.6rem;
  }
  .modal-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* ── Auth modal ── */
  .auth-tabs {
    margin-bottom: 1.5rem;
  }

  /* ── Toast moves up a bit ── */
  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    align-items: center;
  }
  .toast {
    max-width: 100%;
    width: 100%;
    justify-content: center;
  }

  /* ── Table toolbar ── */
  .table-toolbar {
    padding: 0.85rem 1rem;
    gap: 0.6rem;
  }
  .table-toolbar-search {
    max-width: none;
    flex: 1 1 100%;
  }
  .table-toolbar-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* ── Nav (landing) ── */
  .land-nav {
    padding: 1rem 1.2rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-content: center;
    row-gap: 0.8rem;
  }
  .land-nav-brand {
    font-size: 1.2rem;
  }
  .land-nav-brand svg {
    width: 28px;
    height: 28px;
  }
  .land-nav-links {
    display: none;
  }
  .land-nav-actions {
    gap: 0.6rem;
    width: 100%;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    order: 3;
  }
  .land-nav-actions .btn {
    font-size: 0.8rem;
    padding: 0.55rem 0.95rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
  }
  .land-nav-actions .btn i {
    margin-right: 0.3rem;
    font-size: 0.85rem;
  }

  /* ── Hero (landing) ── */
  .land-hero {
    padding: 5rem 1.2rem 2rem;
    min-height: clamp(350px, 80vh, 550px);
  }
  .hero-title {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    letter-spacing: -1px;
    margin-bottom: clamp(0.8rem, 2vw, 1.2rem);
  }
  .hero-sub {
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  }
  .hero-cta {
    gap: clamp(0.6rem, 2vw, 0.9rem);
  }
  .hero-cta .btn {
    width: 100%;
    max-width: 320px;
    justify-content: center;
    padding: clamp(0.55rem, 1.5vw, 0.75rem) clamp(1rem, 2vw, 1.4rem);
    font-weight: 600;
  }
  .hero-stats {
    gap: clamp(1rem, 3vw, 1.8rem);
    margin-top: clamp(2rem, 4vw, 3.5rem);
  }
  .hero-divider {
    display: none;
  }
  .hero-stat-num {
    font-size: clamp(1.4rem, 3vw, 1.8rem);
  }

  /* ── Features/How/CTA sections ── */
  .land-section {
    padding: 3.5rem 1.2rem;
  }
  .section-title {
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    margin-bottom: clamp(1rem, 3vw, 2rem);
  }
  .features-grid {
    grid-template-columns: 1fr;
    gap: clamp(0.8rem, 2vw, 1.2rem);
  }
  .feature-card {
    padding: clamp(1.2rem, 3vw, 1.8rem);
    border-radius: clamp(12px, 3vw, 18px);
  }
  .feature-card-icon {
    font-size: clamp(2rem, 4vw, 2.8rem);
    margin-bottom: clamp(0.8rem, 2vw, 1.2rem);
  }
  .feature-card h3 {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin-bottom: 0.6rem;
  }
  .feature-card p {
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    line-height: 1.6;
  }
  .testimonials-grid {
    grid-template-columns: 1fr;
    gap: clamp(1rem, 2vw, 1.5rem);
  }
  .land-cta-section {
    padding: 3rem 1.2rem;
  }
  .land-cta-section h2 {
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    letter-spacing: -1px;
    margin-bottom: clamp(1rem, 2vw, 1.5rem);
  }

  /* ── Sidebar toggle button (hide on mobile when sidebar is a drawer) ── */
  .sidebar-toggle {
    display: none;
  }

  /* ── Material viewer modal ── */
  .mat-viewer-header {
    padding: 0.9rem 1.1rem;
  }
  .mat-viewer-title {
    font-size: 0.92rem;
    max-width: 200px;
  }
  .mat-viewer-body {
    padding: 1.2rem;
    max-height: 65vh;
  }
}

/* ============================================================
   max-width: 640px — Larger phones
   ============================================================ */
@media (max-width: 640px) {
  /* ── Stats ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }
  .stat-card-value {
    font-size: 1.6rem;
  }

  /* ── Materials grid single column ── */
  .materials-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
  .material-card {
    flex-direction: row;
    align-items: center;
    border-radius: var(--r-lg);
  }
  .material-card-thumb {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    font-size: 2rem;
  }
  .material-card-body {
    padding: 0.75rem 0.9rem;
  }
  .material-card-title {
    font-size: 0.85rem;
    -webkit-line-clamp: 1;
  }
  .material-card-actions {
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.5rem 0.7rem;
    border-top: none;
    border-left: 1px solid var(--border);
    justify-content: center;
  }
  .material-card-actions .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  /* ── Students grid ── */
  .students-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .student-card {
    padding: 1.1rem 1.25rem;
  }

  /* ── Grade table column visibility ── */
  .grade-table th:nth-child(4),   /* Practical */
  .grade-table td:nth-child(4) {
    display: none;
  }

  /* ── Buttons in page header ── */
  .page-header-actions .btn-success {
    display: none;
  } /* hide All PDFs on very small screens */

  /* ── Modal padding ── */
  .modal-box {
    padding: 1.5rem 1.25rem 1.75rem;
  }
  .modal-title {
    font-size: 1.15rem;
  }
  .form-input {
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
  }

  /* ── Settings row ── */
  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .settings-row > div:first-child {
    width: 100%;
  }

  /* ── Auth modal ── */
  .auth-tabs {
    gap: 0;
  }

  /* ── Upload material modal ── */
  .mat-dropzone {
    padding: 1.5rem 1rem;
  }
  .mat-dropzone-icon {
    font-size: 2rem;
  }

  /* ── Table toolbar ── */
  .table-toolbar-right .btn span {
    display: none;
  } /* icons only */
}

/* ============================================================
   max-width: 480px — Small phones
   ============================================================ */
@media (max-width: 480px) {
  /* ── Nav (landing) ── */
  .land-nav {
    padding: 0.85rem 1rem;
    row-gap: 0.7rem;
  }
  .land-nav-brand {
    font-size: 1.1rem;
    width: 100%;
    order: 1;
    margin-bottom: 0.2rem;
  }
  .land-nav-actions {
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .land-nav-actions .btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.8rem;
    flex: 1 1 calc(33.333% - 0.35rem);
    justify-content: center;
    min-width: 0;
  }
  .land-nav-actions .btn i {
    display: block;
    margin: 0 0 0.2rem 0;
    font-size: 0.9rem;
  }
  .land-nav-actions .btn span {
    display: block;
    font-size: 0.65rem;
  }

  /* ── Topbar ── */
  .topbar-title {
    font-size: 1rem;
  }
  .app-topbar {
    padding: 0 0.8rem;
    gap: 0.5rem;
  }
  .topbar-actions {
    gap: 0.4rem;
  }
  .topbar-actions > .btn {
    padding: 0.45rem 0.7rem;
  }

  /* ── Stats ── */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .stat-card {
    padding: 0.9rem 1rem;
  }
  .stat-card-value {
    font-size: 1.45rem;
  }
  .stat-card-icon {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  /* ── Table ── */
  .grade-table {
    min-width: 480px;
  }
  .grade-table th,
  .grade-table td {
    padding: 0.55rem 0.5rem;
  }
  .score-input {
    width: 52px;
    font-size: 0.75rem;
  }

  /* Position column hidden too */
  .grade-table th:nth-child(9),
  .grade-table td:nth-child(9) {
    display: none;
  }

  /* ── Page header ── */
  .page-header-title {
    font-size: 1.05rem;
  }
  .page-header-actions .btn {
    font-size: 0.75rem;
    padding: 0.38rem 0.75rem;
  }

  /* ── Subject tabs ── */
  .subject-tab {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
  }

  /* ── Section title (landing) ── */
  .section-title {
    font-size: 1.75rem;
    letter-spacing: -0.75px;
  }
  .hero-title {
    font-size: 2.6rem;
  }

  /* ── Modals full-screen feel ── */
  .modal-overlay {
    padding: 0;
  }
  .modal-box {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 1.25rem 1rem 1.5rem;
    max-height: 95vh;
  }

  /* ── Grade pill compact ── */
  .grade-pill {
    min-width: 40px;
    padding: 0.2rem 0.65rem;
    font-size: 0.73rem;
  }

  /* ── Batch bar ── */
  .batch-bar {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem;
    border-radius: var(--r-xl);
    font-size: 0.82rem;
  }
  .batch-bar .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Hero CTA ── */
  .hero-cta {
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
  }
  .hero-cta .btn {
    width: 100%;
    max-width: 320px;
    justify-content: center;
    padding: 0.65rem 1.4rem;
    font-weight: 600;
    letter-spacing: 0.3px;
  }

  /* ── Student cards ── */
  .student-card-head {
    gap: 0.75rem;
  }
  .student-card-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.88rem;
  }

  /* ── Sidebar user ── */
  .sidebar-user {
    margin: 0.75rem 0.9rem;
    padding: 0.75rem;
  }
  .user-name {
    font-size: 0.8rem;
  }
  .user-role {
    font-size: 0.7rem;
  }

  /* ── Toast ── */
  .toast {
    font-size: 0.8rem;
    padding: 0.7rem 1rem;
  }

  /* ── Analytics cards ── */
  .analytics-card {
    padding: 0.9rem;
  }
  .analytics-card h3 {
    font-size: 0.9rem;
  }
}

/* ============================================================
   COLLAPSED SIDEBAR STATE (desktop only)
   ============================================================ */
@media (min-width: 769px) {
  .app-sidebar.collapsed .sidebar-brand,
  .app-sidebar.collapsed .sidebar-section-label,
  .app-sidebar.collapsed .sidebar-user .user-info,
  .app-sidebar.collapsed .class-item-name,
  .app-sidebar.collapsed .class-item-count,
  .app-sidebar.collapsed .class-delete-btn,
  .app-sidebar.collapsed .sidebar-footer-item span,
  .app-sidebar.collapsed .sidebar-nav-item span {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
  }
  .app-sidebar.collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 0.65rem;
  }
  .app-sidebar.collapsed .sidebar-footer-item {
    justify-content: center;
    padding: 0.55rem;
  }
  .app-sidebar.collapsed .class-item {
    justify-content: center;
    padding: 0.6rem;
  }
  .app-sidebar.collapsed .class-emoji {
    width: auto;
  }
  .app-sidebar.collapsed .sidebar-user {
    justify-content: center;
  }
  .app-sidebar.collapsed .user-avatar {
    margin: 0 auto;
  }

  .app-sidebar.collapsed ~ .app-body .batch-bar {
    left: calc(72px + 1rem);
  }
}

/* ============================================================
   PRINT STYLES — no sidebar, clean layout
   ============================================================ */
@media print {
  .app-sidebar,
  .app-topbar,
  .batch-bar,
  .toast-container,
  .offline-banner,
  .loading-overlay,
  .land-nav {
    display: none !important;
  }

  .app-body {
    width: 100%;
  }
  .app-main {
    padding: 0;
    overflow: visible;
  }
  .page-header-actions {
    display: none;
  }
  .grade-table td,
  .grade-table th {
    font-size: 11px;
    padding: 6px 8px;
  }

  #page-dashboard.active {
    display: block;
    height: auto;
    overflow: visible;
  }
}

/* ============================================================
   UTILITY — Safe area for notched phones (iOS)
   ============================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .batch-bar {
    bottom: calc(1rem + env(safe-area-inset-bottom));
  }
  .modal-box {
    padding-bottom: calc(1.75rem + env(safe-area-inset-bottom));
  }
  .app-topbar {
    padding-top: env(safe-area-inset-top, 0);
  }
}

/* ============================================================
   FIX: hero-stats layout — hide dividers when wrapping
   ============================================================ */
@media (max-width: 520px) {
  .hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 1rem;
  }
  .hero-divider {
    display: none;
  }
  .hero-stat {
    text-align: center;
  }
}

/* ============================================================
   FIX: Landing nav on very small screens
   ============================================================ */
@media (max-width: 380px) {
  .land-nav {
    padding: 0.8rem 0.9rem;
  }
  .land-nav-brand {
    font-size: 1rem;
  }
  .land-nav-actions {
    gap: 0.4rem;
  }
  .land-nav-actions .btn {
    font-size: 0.7rem;
    padding: 0.45rem 0.7rem;
  }
  .hero-title {
    font-size: 2.2rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   FIX: Score bar wrapping in table
   ============================================================ */
.score-bar-wrap {
  flex-wrap: nowrap;
  min-width: 0;
}
.score-bar {
  min-width: 30px;
}
.score-val {
  min-width: 28px;
  font-size: 0.8rem;
}

/* ============================================================
   FIX: topbar actions wrapping
   ============================================================ */
.topbar-actions {
  flex-wrap: nowrap;
  overflow: hidden;
}
@media (max-width: 540px) {
  /* Hide Excel export btn text on small screens, keep icon */
  .topbar-actions > .btn:not(#mobileMenuBtn) i {
    margin: 0;
  }
}

/* ============================================================
   FIX: How it works grid on landing
   ============================================================ */
#how > .land-section > div[style*="grid"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2rem;
}
@media (max-width: 640px) {
  #how > .land-section > div[style*="grid"] {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
}
@media (max-width: 400px) {
  #how > .land-section > div[style*="grid"] {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   FIX: Student detail modal table on mobile
   ============================================================ */
#studentDetailContent > div[style*="overflow-x"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#studentDetailContent > div:first-child {
  flex-wrap: wrap;
  gap: 0.9rem;
}
#studentDetailContent > div:first-child > div:last-child {
  margin-left: 0;
  text-align: left;
}
@media (max-width: 480px) {
  #studentDetailContent > div:first-child > div:last-child {
    width: 100%;
  }
}

/* ============================================================
   FIX: mat-viewer-header on mobile
   ============================================================ */
@media (max-width: 480px) {
  .mat-viewer-header {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
  }
  .mat-viewer-header > div[style*="margin-left:auto"] {
    margin-left: 0 !important;
  }
  .mat-viewer-title {
    max-width: 100%;
    font-size: 0.88rem;
  }
  .mat-viewer-body {
    padding: 1rem;
    max-height: 60vh;
  }
}

/* == LANDING PAGE ANIMATIONS == */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* Animate nav and hero on load */
@media (prefers-reduced-motion: no-preference) {
  .land-nav {
    animation: fadeInDown 0.6s var(--ease) forwards;
  }
  .land-nav-brand,
  .land-nav-links,
  .land-nav-actions {
    animation: fadeInDown 0.6s var(--ease) 0.1s forwards;
    opacity: 0;
  }
  .hero-title {
    animation: fadeInUp 0.7s var(--ease) forwards;
  }
  .hero-sub {
    animation: fadeInUp 0.7s var(--ease) 0.2s forwards;
    opacity: 0;
  }
  .hero-cta {
    animation: fadeInUp 0.7s var(--ease) 0.3s forwards;
    opacity: 0;
  }
  .hero-stats {
    animation: fadeInUp 0.7s var(--ease) 0.4s forwards;
    opacity: 0;
  }
  .feature-card {
    animation: scaleIn 0.5s var(--ease) forwards;
    opacity: 0;
  }
  .testimonial-card {
    animation: scaleIn 0.5s var(--ease) forwards;
    opacity: 0;
  }
}

/* Hero section improvements */
.land-hero {
  position: relative;
  background: linear-gradient(135deg, var(--bg) 0%, var(--accent-l) 100%);
}
.hero-title {
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}
.hero-sub {
  max-width: 600px;
  margin: 0 auto 2.5rem;
  line-height: 1.8;
}
.hero-cta {
  margin-bottom: clamp(2rem, 5vw, 4rem);
}

/* Call-to-action buttons with better styling */
.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-d) 100%);
  box-shadow: 0 8px 24px rgba(67, 97, 238, 0.3);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 32px rgba(67, 97, 238, 0.4);
  transform: translateY(-2px);
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 100%
  );
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.btn-primary:hover::before {
  opacity: 1;
}

/* Feature cards with hover effects */
.feature-card {
  position: relative;
  border: 2px solid transparent;
  transition: all 0.3s var(--ease);
}
.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow:
    var(--sh-lg),
    0 0 0 1px var(--accent-l);
}
.feature-card-icon {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin-bottom: 1rem;
  display: inline-block;
}

/* ── FLUID TYPOGRAPHY (scales smoothly) ── */
h1,
.page-header-title {
  font-size: clamp(1.5rem, 5vw, 2.8rem);
  line-height: 1.2;
}
h2,
.section-title {
  font-size: clamp(1.3rem, 4vw, 2.2rem);
  line-height: 1.25;
}
h3 {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
}
.hero-title {
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  line-height: 1.1;
  letter-spacing: clamp(-2px, -0.5vw, -1px);
}
.hero-sub {
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

/* ── OPTIMAL TOUCH TARGETS (minimum 44px iOS, 48px Android) ── */
button,
.btn,
input[type="button"],
input[type="submit"],
input[type="reset"],
.tab-btn,
[role="button"],
.clickable {
  min-height: 44px;
  min-width: 44px;
  padding: clamp(0.5rem, 1vw, 0.75rem) clamp(0.9rem, 2vw, 1.2rem);
  touch-action: manipulation;
}

/* Make sure buttons don't shrink below minimum */
.btn-sm {
  min-height: 36px;
  min-width: 36px;
}
.btn-xs {
  min-height: 32px;
  min-width: 32px;
}

/* ── IMPROVED FORM INPUTS ── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
select,
textarea {
  min-height: 44px;
  padding: clamp(0.6rem, 1.5vw, 0.85rem) clamp(0.9rem, 2vw, 1.2rem);
  font-size: 16px; /* Prevents zoom on iOS */
  line-height: 1.5;
  border-radius: clamp(8px, 2vw, 12px);
  transition: all 0.2s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent-l);
}

/* ── IMPROVED FOCUS STATES (keyboard navigation) ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-md);
}

/* ── BETTER SCROLLING (momentum scroll on mobile) ── */
.app-main,
.table-wrapper > div,
.materials-grid-container,
.subject-tabs,
.batch-bar {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.app-main::-webkit-scrollbar,
.table-wrapper > div::-webkit-scrollbar {
  width: 6px;
}
.app-main::-webkit-scrollbar-track,
.table-wrapper > div::-webkit-scrollbar-track {
  background: transparent;
}
.app-main::-webkit-scrollbar-thumb,
.table-wrapper > div::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.app-main::-webkit-scrollbar-thumb:hover,
.table-wrapper > div::-webkit-scrollbar-thumb:hover {
  background: var(--border-2);
}

/* ── REDUCED MOTION FOR ACCESSIBILITY ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── BETTER SPACING WITH CLAMP (fluid padding) ── */
.page-header {
  margin-bottom: clamp(1rem, 3vw, 2rem);
  gap: clamp(0.5rem, 2vw, 1rem);
}
.app-main {
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem);
}
.analytics-grid,
.stats-grid,
.materials-grid {
  gap: clamp(0.8rem, 2vw, 1.5rem);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
}

/* ── OPTIMIZED MODALS FOR MOBILE ── */
@media (max-width: 768px) {
  .modal-overlay {
    bottom: 0;
    align-items: flex-end;
  }
  .modal-box {
    border-radius: max(var(--r-xl), clamp(12px, 5vw, 24px))
      max(var(--r-xl), clamp(12px, 5vw, 24px)) 0 0;
    max-height: min(90vh, 100dvh - 80px);
    animation: slideUpModal 0.3s var(--bounce);
    will-change: transform;
  }
}

/* ── RESPONSIVE ICON SIZING ── */
.bi,
i {
  font-size: clamp(0.8rem, 2vw, 1.5rem);
}
.stat-card-icon {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

/* ── RESPONSIVE GRID AUTO-FIT ── */
.students-grid {
  grid-template-columns: repeat(
    auto-fill,
    minmax(clamp(160px, 20vw, 280px), 1fr)
  );
  gap: clamp(0.75rem, 2vw, 1.5rem);
}
.materials-grid {
  grid-template-columns: repeat(
    auto-fill,
    minmax(clamp(200px, 25vw, 300px), 1fr)
  );
  gap: clamp(0.9rem, 2vw, 1.5rem);
}
.features-grid {
  grid-template-columns: repeat(
    auto-fill,
    minmax(clamp(240px, 30vw, 320px), 1fr)
  );
  gap: clamp(1rem, 2vw, 1.5rem);
}

/* ── HIGH CONTRAST MODE SUPPORT ── */
@media (prefers-contrast: more) {
  button,
  .btn,
  input,
  textarea,
  select {
    border-width: 2px;
  }
  :focus-visible {
    outline-width: 3px;
    outline-offset: 3px;
  }
}

/* ── BETTER BUTTON HOVER/ACTIVE STATES ── */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.2s var(--ease);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── LONG PRESS / HOLD FEEDBACK ── */
.btn,
button,
[role="button"],
.clickable {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  opacity: 0.8;
}

/* ── PREVENTS DOUBLE-TAP ZOOM ON BUTTONS ── */
@media (hover: none) {
  .btn,
  button {
    padding: clamp(0.65rem, 1.5vw, 0.9rem) clamp(1rem, 2.5vw, 1.4rem);
  }
}

/* ── RESPONSIVE CARD PADDING ── */
.stat-card,
.analytics-card,
.student-card,
.material-card,
.feature-card {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-radius: clamp(8px, 2vw, 16px);
  transition: all 0.2s var(--ease);
}
.stat-card:hover,
.student-card:hover,
.material-card:hover,
.feature-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}

/* ── RESPONSIVE TEXT TRUNCATION ── */
.text-truncate,
.line-clamp-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* ── BETTER TABLE RESPONSIVENESS ── */
.grade-table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.75rem, 1.5vw, 0.95rem);
}
.grade-table th,
.grade-table td {
  padding: clamp(0.5rem, 1vw, 0.75rem);
  text-align: center;
  vertical-align: middle;
}

/* ── SMOOTH PAGE TRANSITIONS ── */
@media (prefers-reduced-motion: no-preference) {
  .view-transition {
    animation: fadeIn 0.3s var(--ease);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── MOBILE SAFE AREAS (notches, etc) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .app-topbar {
    padding-top: env(safe-area-inset-top, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-left: env(safe-area-inset-left, 0);
  }
  .batch-bar {
    bottom: calc(clamp(1rem, 2vw, 1.5rem) + env(safe-area-inset-bottom, 0));
    right: env(safe-area-inset-right, 1rem);
    left: env(safe-area-inset-left, 1rem);
  }
  .modal-box {
    padding-bottom: calc(1.75rem + env(safe-area-inset-bottom, 0));
  }
  .toast-container {
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
    right: env(safe-area-inset-right, 1.5rem);
    left: auto;
  }
}

/* ── RESPONSIVE HERO SECTION ── */
.land-hero {
  padding: clamp(3rem, 8vw, 7rem) clamp(1.5rem, 5vw, 4rem);
  min-height: clamp(400px, 70vh, 600px);
}

/* ── VIEWPORT HEIGHT FIX FOR MOBILE ── */
.app-sidebar,
.app-body,
#page-dashboard.active {
  height: 100dvh; /* 100% of dynamic viewport height */
}

/* ── IMPROVED LOADING STATES ── */
.skeleton,
.loading {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ── RESPONSIVE BADGE / PILL ── */
.badge,
.pill {
  padding: clamp(0.25rem, 0.75vw, 0.4rem) clamp(0.6rem, 1.5vw, 0.9rem);
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  border-radius: clamp(12px, 3vw, 20px);
  display: inline-block;
}

/* ── HERO STATS MOBILE OPTIMIZATION ── */
@media (max-width: 768px) {
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: clamp(1.5rem, 3vw, 2rem);
    margin-top: clamp(2rem, 5vw, 3.5rem);
  }
}

/* ── PERFORMANCE: Disable animations on low-end devices ── */
@media (max-width: 480px) {
  * {
    animation-duration: 0.15s !important;
  }
}

/* ============================================================
   FIX: PDF template never affects layout
   ============================================================ */
#pdf-template {
  position: absolute !important;
  left: -9999px !important;
  top: 0 !important;
  width: 210mm !important;
  visibility: hidden;
  pointer-events: none;
}
#pdf-template[style*="display: block"],
#pdf-template[style*="display:block"] {
  visibility: visible;
}

/* ============================================================
   SIDEBAR OVERLAY injection point (JS adds this)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 199;
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.sidebar-overlay.active {
  display: block;
}
/* New Class button container – adds separation from class list */
.sidebar-new-class {
  padding: 1rem 0.8rem 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.sidebar-new-class .btn {
  background: var(--accent-l);
  color: var(--accent);
  border-color: transparent;
  font-weight: 600;
  transition: var(--trans);
}
.sidebar-new-class .btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

/* ============================================================
   AI COMMENT — TONE BUTTONS
   ============================================================ */
.ai-tone-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--ink-3);
  border-radius: var(--r-full);
  padding: 0.4rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--trans);
  font-family: inherit;
}
.ai-tone-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-l);
}
.ai-tone-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ============================================================
   PWA INSTALL BANNER — minimal appearance
   ============================================================ */
#pwaInstallBanner {
  animation: fadeUp 0.4s var(--bounce) both;
  bottom: 0.5rem !important;
  left: 0.5rem !important;
  right: auto !important;
  transform: none !important;
  width: auto !important;
  max-width: 320px !important;
}

/* ============================================================
   CUSTOM GRADE SCALE EDITOR
   ============================================================ */
.gs-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.gs-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--trans);
}
.gs-row:hover {
  background: var(--surface-2);
  border-radius: var(--r-xs);
}
.gs-row-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--muted);
}
.gs-input {
  width: 72px !important;
  text-align: center;
  padding: 0.38rem 0.5rem !important;
  font-family: var(--font-mono) !important;
  font-size: 0.88rem !important;
}
.gs-pct {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 14px;
}
.gs-preview-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.28rem 0;
  font-size: 0.85rem;
}
.gs-prev-label {
  flex: 1;
  color: var(--ink-3);
  font-weight: 500;
}
.gs-prev-range {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface-2);
  padding: 0.15rem 0.55rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
}

/* ============================================================
   SUBJECT PICKER
   ============================================================ */
.subject-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.4rem 0 0.8rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.subject-picker-grid::-webkit-scrollbar {
  width: 4px;
}
.subject-picker-grid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.subject-chip {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--ink-3);
  border-radius: var(--r-full);
  padding: 0.32rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--trans);
  font-family: inherit;
  white-space: nowrap;
}
.subject-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-l);
  transform: translateY(-1px);
}

/* ============================================================
   PREMIUM UI POLISH LAYER
   ============================================================ */
:root {
  --accent: #2f6df6;
  --accent-d: #1f4fc2;
  --accent-l: #eaf0ff;
  --accent-2: #0ea5a3;
  --accent-3: #103a8d;
  --muted: #5b6782;
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f6f9ff;
  --border: #dce3f2;
  --border-2: #c9d3e8;
}

body {
  background:
    radial-gradient(
      circle at 8% -5%,
      rgba(47, 109, 246, 0.12) 0%,
      transparent 34%
    ),
    radial-gradient(
      circle at 92% 8%,
      rgba(14, 165, 163, 0.1) 0%,
      transparent 30%
    ),
    linear-gradient(180deg, #f4f7fd 0%, #eef2f8 100%);
}

#page-dashboard.active {
  background:
    radial-gradient(
      circle at 12% 0%,
      rgba(47, 109, 246, 0.09) 0%,
      transparent 28%
    ),
    radial-gradient(
      circle at 100% 0%,
      rgba(14, 165, 163, 0.06) 0%,
      transparent 25%
    );
}

.app-sidebar {
  background: linear-gradient(180deg, #0e1830 0%, #101f3d 55%, #13274d 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 22px 0 45px -30px rgba(10, 17, 33, 0.75);
}

.sidebar-header,
.sidebar-footer,
.sidebar-new-class {
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-brand,
.user-name,
.sidebar-section-label,
.sidebar-nav-item,
.class-item,
.sidebar-footer-item,
.user-role,
.class-item-count,
.sidebar-toggle {
  color: rgba(233, 240, 255, 0.86);
}

.sidebar-logo,
.user-avatar {
  background: linear-gradient(135deg, #2f6df6 0%, #0ea5a3 100%);
}

.sidebar-user {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-nav-item:hover,
.class-item:hover,
.sidebar-footer-item:hover,
.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-nav-item.active,
.class-item.active {
  background: linear-gradient(
    135deg,
    rgba(47, 109, 246, 0.3),
    rgba(14, 165, 163, 0.25)
  );
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.class-item-count,
.class-item.active .class-item-count {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ecf2ff;
}

.app-topbar {
  margin: 0.9rem 1rem 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 14px 36px -28px rgba(20, 45, 102, 0.55);
}

.app-main {
  padding-top: 1.15rem;
}

.topbar-title {
  font-size: 1.08rem;
  letter-spacing: 0;
}

.topbar-breadcrumb,
.settings-row-desc,
.stat-card-sub,
.user-role,
.class-item-count,
.score-val,
.pos-badge,
.toast,
.modal-sub,
.feature-card p,
.testimonial-card p {
  color: var(--muted);
}

.topbar-search input,
.table-toolbar-search input,
.form-input,
.score-input {
  border-color: #d5def0;
  background: #f8faff;
}

.topbar-search input:focus,
.table-toolbar-search input:focus,
.form-input:focus,
.score-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 109, 246, 0.13);
}

::placeholder {
  color: #8a96b4;
  opacity: 1;
}

.btn {
  border-radius: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #2f6df6 0%, #295de0 65%, #1f4fc2 100%);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 35px -14px rgba(47, 109, 246, 0.65);
}

.stats-grid {
  gap: 1rem;
}

.stat-card {
  border: 1px solid rgba(170, 188, 226, 0.38);
  box-shadow: 0 8px 30px -24px rgba(25, 56, 122, 0.6);
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.35),
    transparent 45%
  );
  pointer-events: none;
}

.stat-card-value {
  letter-spacing: -0.5px;
}

.table-wrapper,
.analytics-card,
.settings-section,
.student-card,
.material-card,
.modal-box {
  border: 1px solid rgba(165, 182, 220, 0.42);
  box-shadow: 0 18px 34px -30px rgba(16, 43, 99, 0.6);
}

.analytics-card,
.settings-section,
.student-card,
.material-card,
.modal-box,
.table-wrapper,
.feature-card,
.testimonial-card {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(249, 251, 255, 0.96)
  );
}

.grade-table thead,
.table-toolbar {
  background: linear-gradient(180deg, #f7f9ff 0%, #eef3ff 100%);
}

.grade-table th {
  letter-spacing: 0.04em;
}

.grade-table td {
  color: #1f2937;
}

.grade-table tbody tr:hover td,
.grade-table tbody tr.selected td {
  background: rgba(47, 109, 246, 0.045);
}

.grade-table tbody tr:hover td {
  background: #f4f8ff;
}

.subject-tab {
  border-radius: 12px;
}

.subject-tab.active {
  background: linear-gradient(135deg, #2f6df6, #1f4fc2);
}

.settings-section h3,
.analytics-card h3,
.page-header-title,
.modal-title {
  letter-spacing: -0.35px;
}

.view.active .stats-grid .stat-card {
  animation: premiumRise 0.45s var(--ease) both;
}

.view.active .stats-grid .stat-card:nth-child(2) {
  animation-delay: 0.05s;
}

.view.active .stats-grid .stat-card:nth-child(3) {
  animation-delay: 0.1s;
}

.view.active .stats-grid .stat-card:nth-child(4) {
  animation-delay: 0.15s;
}

.page-header-title,
.section-title,
.land-cta-section h2,
.hero-title,
.modal-title {
  overflow-wrap: anywhere;
}

.page-header-title,
.section-title,
.hero-title,
.topbar-title {
  color: #10203d;
}

.settings-section h3,
.analytics-card h3,
.feature-card h3,
.testimonial-name,
.top-performer-row,
.student-card-name {
  color: #10203d;
}

.feature-card,
.testimonial-card,
.analytics-card,
.settings-section,
.student-card,
.material-card,
.modal-box {
  border-radius: 24px;
}

.feature-icon,
.sidebar-logo,
.user-avatar,
.student-card-avatar,
.student-mini-avatar {
  box-shadow: 0 12px 28px -18px rgba(47, 109, 246, 0.55);
}

.feature-card:hover,
.testimonial-card:hover,
.analytics-card:hover,
.student-card:hover,
.material-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 40px -28px rgba(16, 43, 99, 0.62);
}

.settings-row {
  padding: 1rem 0;
}

.settings-row-label,
.form-label,
.modal-title,
.page-header-title,
.section-label,
.stat-card-label {
  font-weight: 700;
}

.table-toolbar-search input,
.topbar-search input,
.form-input,
.score-input {
  border-radius: 16px;
}

.toast {
  background: rgba(16, 32, 61, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.grade-pill {
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.05);
}

.hero-badge,
.subject-tab,
.class-item-count,
.nav-badge {
  box-shadow: 0 8px 20px -18px rgba(47, 109, 246, 0.45);
}

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

@media (max-width: 768px) {
  .app-topbar {
    margin: 0.6rem 0.55rem 0;
    border-radius: 14px;
  }

  .app-main {
    padding-top: 0.95rem;
  }
}
.subject-chip.taken {
  background: var(--accent-l);
  border-color: var(--accent);
  color: var(--accent);
  cursor: default;
  opacity: 0.7;
}
.subject-chip.taken:hover {
  transform: none;
}

/* ============================================================
   ATTENDANCE TRACKER
   ============================================================ */
.att-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.att-stat {
  flex: 1;
  min-width: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  text-align: center;
  box-shadow: var(--sh-xs);
}
.att-stat span {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}
.att-stat small {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-top: 0.2rem;
  display: block;
}
.att-present span {
  color: #00b894;
}
.att-absent span {
  color: var(--rose);
}
.att-late span {
  color: var(--gold);
}
.attendance-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.att-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.75rem 1rem;
  transition: var(--trans);
}
.att-row:hover {
  box-shadow: var(--sh-xs);
}
.att-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.att-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}
.att-btns {
  display: flex;
  gap: 0.4rem;
}
.att-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--trans);
  font-family: inherit;
}
.att-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-xs);
}
.att-p-active {
  background: #d1fae5;
  border-color: #00b894;
  color: #065f46;
}
.att-a-active {
  background: #fee2e2;
  border-color: var(--rose);
  color: #7f1d1d;
}
.att-l-active {
  background: #fef9c3;
  border-color: var(--gold);
  color: #713f12;
}

/* ============================================================
   CBT QUIZ BUILDER
   ============================================================ */
.cbt-quiz-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem 0;
}
.cbt-quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--sh-xs);
  transition: var(--trans);
}
.cbt-quiz-card:hover {
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
}
.cbt-quiz-info {
  flex: 1;
  min-width: 0;
}
.cbt-quiz-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}
.cbt-quiz-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.cbt-quiz-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.cbt-quiz-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.quiz-q-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem;
  margin-bottom: 0.8rem;
}
.quiz-q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}
.quiz-q-num {
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1rem;
}
.quiz-q-text {
  margin-bottom: 0.8rem !important;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.quiz-opt-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.quiz-opt-label {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-l);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quiz-opt-input {
  flex: 1;
}
.quiz-correct-radio {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}
.quiz-take-q {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
}
.quiz-take-qnum {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
}
.quiz-take-qtext {
  color: var(--ink);
  font-weight: 600;
  font-size: 1rem;
}
.quiz-take-opts {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.quiz-take-opt {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--trans);
}
.quiz-take-opt:hover {
  border-color: var(--accent);
  background: var(--accent-l);
}
.quiz-take-opt input {
  display: none;
}
.quiz-take-opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-l);
}
.quiz-take-opt-label {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--trans);
}
.quiz-take-opt-text {
  font-size: 0.9rem;
}
.quiz-result-q {
  padding: 0.8rem 1rem;
  border-radius: var(--r-sm);
  margin-bottom: 0.5rem;
  border-left: 3px solid transparent;
}
.quiz-r-correct {
  background: #d1fae5;
  border-left-color: #00b894;
}
.quiz-r-wrong {
  background: #fee2e2;
  border-left-color: var(--rose);
}
.quiz-result-qnum {
  font-weight: 600;
  font-size: 0.88rem;
}

/* ============================================================
   FIXES & POLISH — v3
   ============================================================ */

/* Quiz option selected state — JS adds .selected class for cross-browser compat */
.quiz-take-opt.selected {
  border-color: var(--accent);
  background: var(--accent-l);
}
.quiz-take-opt.selected .quiz-take-opt-label {
  background: var(--accent);
  color: white;
}

/* Grade scale preview rows */
#gradeScalePreview {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
}

/* Logo preview container */
#logoPreview {
  border-radius: calc(var(--r-md) - 2px);
}

/* CBT quiz list scrollable on small screens */
.cbt-quiz-list {
  min-height: 200px;
}

/* Quiz result q readable in dark mode */
[data-theme="dark"] .quiz-r-correct {
  background: rgba(0, 184, 148, 0.15);
}
[data-theme="dark"] .quiz-r-wrong {
  background: rgba(239, 71, 111, 0.15);
}

/* Attendance summary bar in dark mode */
[data-theme="dark"] .att-stat {
  background: var(--surface-2);
}

/* Subject chip in dark mode */
[data-theme="dark"] .subject-chip {
  background: var(--surface-2);
}

/* Grade scale editor in dark mode */
[data-theme="dark"] .gs-row:hover {
  background: var(--surface-2);
}

/* Make sure quiz-take-opt label updates on JS .selected */
.quiz-take-opt.selected .quiz-take-opt-label {
  background: var(--accent);
  color: white;
}

/* Responsive attendance on mobile */
@media (max-width: 600px) {
  .att-row {
    flex-wrap: wrap;
    gap: 0.6rem;
  }
  .att-name {
    min-width: 0;
    flex: 1 0 calc(100% - 120px);
  }
  .att-btns {
    margin-left: auto;
  }
  .att-summary {
    gap: 0.5rem;
  }
  .att-stat {
    min-width: 60px;
    padding: 0.6rem 0.5rem;
  }
  .att-stat span {
    font-size: 1.4rem;
  }
  .cbt-quiz-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }
  .cbt-quiz-actions {
    width: 100%;
  }
  .cbt-quiz-actions .btn {
    flex: 1;
    justify-content: center;
  }
  .gs-row-label {
    display: none;
  }
  .gs-row {
    gap: 0.5rem;
  }
}

/* ============================================================
   PRICING SECTION
   ============================================================ */

#pricing .land-section {
  padding-top: 5rem;
  padding-bottom: 5rem;
}

/* Feature card Pro badge */
.feature-card span[style*="background:#fef3c7"] {
  display: inline-block;
}

/* Pricing grid responsive */
@media (max-width: 640px) {
  #pricing > div[style*="grid"] {
    grid-template-columns: 1fr !important;
  }
}

/* Hero sub refinement */
.hero-sub {
  max-width: 560px;
}

/* Testimonials — 3 col on big screens, 2 on medium, 1 on mobile */
.testimonials-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2.5rem;
}
@media (max-width: 1024px) {
  .testimonials-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .testimonials-grid {
    grid-template-columns: 1fr;
  }
}

/* CTA dual-button layout */
.land-cta-section .hero-cta,
.land-cta-section > div[style*="flex"] {
  justify-content: center;
}

@media (max-width: 980px) {
  #page-login,
  #page-portal-login,
  #page-role-home,
  #page-admin-dashboard,
  #page-student-dashboard,
  #page-parent-dashboard {
    padding: 1rem;
  }

  .route-auth-page,
  .portal-page-wrap {
    grid-template-columns: 1fr;
  }

  .route-auth-brand,
  .route-auth-panel,
  .portal-brand-side,
  .portal-login-side,
  .role-home-wrap,
  .admin-dashboard-wrap,
  .student-dashboard-wrap,
  .parent-dashboard-wrap {
    padding: 1.25rem;
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .portal-role-grid {
    grid-template-columns: 1fr;
  }

  .portal-login-links,
  .route-auth-links,
  .role-home-actions,
  .dashboard-actions {
    flex-direction: column;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .teacher-item-right,
  .approval-item-right,
  .performance-item-right,
  .assignment-item-right,
  .child-card-right,
  .communication-item-right {
    flex-direction: row;
  }
}

/* ============================================================
   ENHANCED BUTTON STYLES & MICRO-INTERACTIONS
   ============================================================ */

/* Premium button styling with multiple states */
.btn,
button:not([class*="quiz"]):not([class*="att-"])[onclick],
.button-link {
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
  font-weight: 600;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.btn:not(:disabled):active {
  transform: translateY(0);
}

/* Primary button gradient effect */
.btn-primary,
[style*="background:rgb(47,109,246)"],
[style*="background: rgb(47, 109, 246)"] {
  background: linear-gradient(135deg, #2f6df6 0%, #1f4fc2 100%);
  box-shadow: 0 6px 20px rgba(47, 109, 246, 0.25);
}

.btn-primary:not(:disabled):hover {
  box-shadow: 0 10px 28px rgba(47, 109, 246, 0.35);
}

/* Success button styling */
.btn-success,
[style*="background:#10b981"],
[style*="color: white"][style*="emerald"] {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.25);
}

.btn-success:not(:disabled):hover {
  box-shadow: 0 10px 28px rgba(16, 185, 129, 0.35);
}

/* Danger button styling */
.btn-danger,
[style*="background:#ef4444"],
[style*="color: white"][style*="rose"] {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.25);
}

.btn-danger:not(:disabled):hover {
  box-shadow: 0 10px 28px rgba(239, 68, 68, 0.35);
}

/* Secondary button styling */
.btn-secondary,
.btn-outline,
[type="button"]:not([class*="btn-primary"]):not([class*="btn-success"]):not(
    [class*="btn-danger"]
  ) {
  background: #f6f9ff;
  border: 2px solid #dce3f2;
  color: #2f6df6;
  font-weight: 600;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-secondary:not(:disabled):hover,
.btn-outline:not(:disabled):hover {
  background: #2f6df6;
  color: white;
  border-color: #2f6df6;
  box-shadow: 0 8px 16px rgba(47, 109, 246, 0.25);
}

/* Small button sizing */
.btn-sm {
  padding: 0.6rem 1.2rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

/* Large button sizing */
.btn-lg {
  padding: 0.95rem 2rem;
  font-size: 1.02rem;
  border-radius: 14px;
}

/* Icon buttons */
.btn i,
button i {
  margin-right: 0.35rem;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Disabled button state */
.btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Active state with pulse */
.btn.active,
button.active {
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.2);
}

/* Loading state animation */
@keyframes buttonPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 109, 246, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(47, 109, 246, 0);
  }
}

.btn.loading {
  animation: buttonPulse 1.8s infinite;
  pointer-events: none;
}

/* ============================================================
   ENHANCED FORM STYLING & INTERACTIONS
   ============================================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid #dce3f2;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2f6df6;
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.1);
  outline: none;
}

input:invalid,
input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ============================================================
   ICON ANIMATIONS & ENHANCEMENTS
   ============================================================ */

/* Icon hover rotation */
.btn i:hover,
a i:hover {
  animation: iconBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iconBounce {
  0% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.15) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* Loading spinner */
@keyframes spinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  animation: spinner 1s linear infinite;
}

/* Icon pulse for notifications */
@keyframes iconPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.icon-pulse {
  animation: iconPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================================
   CARD & COMPONENT ANIMATIONS
   ============================================================ */

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.card,
.modal {
  animation: fadeInScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   RESPONSIVE BUTTON ADJUSTMENTS
   ============================================================ */

@media (max-width: 768px) {
  .btn-sm {
    padding: 0.55rem 1rem;
    font-size: 0.78rem;
  }

  .btn {
    padding: 0.7rem 1.4rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 480px) {
  .btn-sm {
    padding: 0.5rem 0.9rem;
    font-size: 0.75rem;
  }

  .btn {
    padding: 0.65rem 1.2rem;
  }

  /* Full-width buttons on mobile */
  .btn-mobile-full {
    width: 100%;
  }
}

/* ============================================================
   ACCESSIBILITY & REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .btn,
  button,
  input,
  select,
  textarea,
  .btn i,
  .icon-pulse,
  .spinner,
  .card,
  .modal {
    animation: none !important;
    transition: none !important;
  }
}
