:root {
  /* Brand Colors */
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #ec4899;
  --secondary-hover: #db2777;
  --sidebar-width: 260px;

  /* Status Colors */
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;

  /* Accent Colors (Light) */
  --color-purple: #7e22ce;
  --color-blue: #3b82f6;
  --color-indigo: #818cf8;
  --color-rose: #f472b6;
  --color-emerald: #34d399;
  --color-yellow: #fbbf24;
  --color-sky: #38bdf8;
  --color-teal: #2dd4bf;
  --color-violet: #a78bfa;
  --color-orange: #d97706;
  --color-pink: #ec4899;
  --color-amber: #f59e0b;
  --color-green: #22c55e;
  --color-red: #ef4444;
  --color-green-dark: #16a34a;
  --color-green-darker: #059669;
  --color-amber-dark: #d97706;
  --color-red-dark: #dc2626;
  --color-slate: #64748b;

  /* Accent Background Tints (Light) */
  --bg-green-soft: rgba(34, 197, 94, 0.1);
  --bg-blue-soft: rgba(59, 130, 246, 0.1);
  --bg-amber-soft: rgba(245, 158, 11, 0.1);
  --bg-purple-soft: rgba(126, 34, 206, 0.08);
  --bg-pink-soft: rgba(236, 72, 153, 0.08);
  --bg-slate-soft: rgba(100, 116, 139, 0.1);
  --bg-error-soft: rgba(239, 68, 68, 0.1);
  --bg-primary-soft: rgba(99, 102, 241, 0.08);
  --bg-red-soft: rgba(239, 68, 68, 0.08);
  --bg-indigo-soft: rgba(99, 102, 241, 0.08);
  --bg-sky-soft: rgba(14, 165, 233, 0.08);
  --bg-yellow-soft: #fef9c3;
  --bg-orange-soft: #ffedd5;
  --border-red-soft: #fecaca;
  --border-green-soft: #bbf7d0;
  --border-yellow-soft: #fde68a;
  --border-orange-soft: #fed7aa;

  /* Backgrounds & Surfaces (Light) */
  --bg-color: #f1f5f9;
  --surface-color: #ffffff;
  --surface-muted: #f8fafc;
  --surface-hover: rgba(0, 0, 0, 0.02);
  --surface-elevated: #ffffff;
  --surface-overlay: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;

  /* Form / Input (Light) */
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --input-placeholder: #94a3b8;
  --input-focus-ring: rgba(99, 102, 241, 0.2);
  --input-disabled-bg: #f1f5f9;

  /* Table (Light) */
  --table-stripe: rgba(0, 0, 0, 0.02);
  --table-hover: rgba(99, 102, 241, 0.03);
  --table-header-bg: var(--surface-muted);

  /* Scrollbar (Light) */
  --scrollbar-track: transparent;
  --scrollbar-thumb: var(--border-color);
  --scrollbar-thumb-hover: var(--text-muted);

  /* Code (Light) */
  --code-bg: var(--surface-muted);
  --code-text: var(--text-main);
  --code-border: var(--border-color);

  /* Status Surfaces (Light) */
  --surface-success: rgba(34, 197, 94, 0.1);
  --surface-warning: rgba(245, 158, 11, 0.1);
  --surface-error: rgba(239, 68, 68, 0.1);
  --surface-info: rgba(99, 102, 241, 0.1);
  --border-success: #22c55e;
  --border-warning: #f59e0b;
  --border-error: #ef4444;
  --border-info: #6366f1;

  /* Layout */
  --border-radius-xl: 24px;
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.15), 0 12px 24px -8px rgba(0, 0, 0, 0.08);
  --shadow-glow-primary: 0 0 40px rgba(99, 102, 241, 0.15), 0 0 80px rgba(99, 102, 241, 0.05);
  --shadow-glow-secondary: 0 0 40px rgba(236, 72, 153, 0.15), 0 0 80px rgba(236, 72, 153, 0.05);
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.35);
  --glass-bg-strong: rgba(255, 255, 255, 0.7);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --gradient-mesh: linear-gradient(135deg, #0f172a 0%, #1e1b4b 25%, #312e81 50%, #4c1d95 75%, #581c87 100%);
  --gradient-premium: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(236, 72, 153, 0.08) 50%, rgba(16, 185, 129, 0.06) 100%);
  --gradient-surface: linear-gradient(180deg, var(--surface-color) 0%, var(--surface-muted) 100%);
  --gradient-indigo: linear-gradient(90deg, #6366f1, #818cf8);
  --gradient-pink: linear-gradient(135deg, #ec4899, #f472b6);
  --gradient-green: linear-gradient(135deg, #10b981, #34d399);

  /* Typography */
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
}

[data-theme="dark"] {
  --bg-color: #020617;
  --surface-color: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --surface-muted: #1e293b;
  --card-bg: #1e293b;
  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-border: rgba(30, 41, 59, 0.5);
  --glass-bg-strong: rgba(15, 23, 42, 0.85);
  --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 12px 24px -8px rgba(0, 0, 0, 0.3);

  /* Dark: Accent Colors (brighter for visibility) */
  --color-purple: #a855f7;
  --color-blue: #60a5fa;
  --color-indigo: #a5b4fc;
  --color-rose: #f9a8d4;
  --color-emerald: #6ee7b7;
  --color-yellow: #fcd34d;
  --color-sky: #7dd3fc;
  --color-teal: #5eead4;
  --color-violet: #c4b5fd;
  --color-orange: #fbbf24;
  --color-pink: #f472b6;
  --color-amber: #fbbf24;
  --color-green: #4ade80;
  --color-red: #f87171;
  --color-green-dark: #4ade80;
  --color-green-darker: #34d399;
  --color-amber-dark: #fbbf24;
  --color-red-dark: #f87171;
  --color-slate: #94a3b8;

  /* Dark: Accent Background Tints (stronger opacity) */
  --bg-green-soft: rgba(34, 197, 94, 0.2);
  --bg-blue-soft: rgba(59, 130, 246, 0.2);
  --bg-amber-soft: rgba(245, 158, 11, 0.2);
  --bg-purple-soft: rgba(168, 85, 247, 0.2);
  --bg-pink-soft: rgba(236, 72, 153, 0.2);
  --bg-slate-soft: rgba(148, 163, 184, 0.15);
  --bg-error-soft: rgba(239, 68, 68, 0.2);
  --bg-primary-soft: rgba(99, 102, 241, 0.15);
  --bg-red-soft: rgba(239, 68, 68, 0.2);
  --bg-indigo-soft: rgba(129, 140, 248, 0.15);
  --bg-sky-soft: rgba(56, 189, 248, 0.15);
  --bg-yellow-soft: #422006;
  --bg-orange-soft: #431407;
  --border-red-soft: #7f1d1d;
  --border-green-soft: #14532d;
  --border-yellow-soft: #422006;
  --border-orange-soft: #431407;

  /* Dark: Surface Hierarchy */
  --surface-hover: rgba(255, 255, 255, 0.03);
  --surface-elevated: #1e293b;
  --surface-overlay: #1e293b;

  /* Dark: Form / Input */
  --input-bg: #1e293b;
  --input-border: #334155;
  --input-placeholder: #64748b;
  --input-focus-ring: rgba(99, 102, 241, 0.3);
  --input-disabled-bg: #0f172a;

  /* Dark: Table */
  --table-stripe: rgba(255, 255, 255, 0.02);
  --table-hover: rgba(99, 102, 241, 0.06);
  --table-header-bg: var(--surface-muted);

  /* Dark: Scrollbar */
  --scrollbar-track: var(--surface-muted);
  --scrollbar-thumb: #475569;
  --scrollbar-thumb-hover: #64748b;

  /* Dark: Code */
  --code-bg: #1e293b;
  --code-text: var(--text-main);
  --code-border: #334155;

  /* Dark: Status Surfaces */
  --surface-success: rgba(34, 197, 94, 0.15);
  --surface-warning: rgba(245, 158, 11, 0.15);
  --surface-error: rgba(239, 68, 68, 0.15);
  --surface-info: rgba(99, 102, 241, 0.15);
  --border-success: #4ade80;
  --border-warning: #fbbf24;
  --border-error: #f87171;
  --border-info: #818cf8;
}

/* System preference auto-detection (no saved preference) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg-color: #020617;
    --surface-color: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --surface-muted: #1e293b;
    --card-bg: #1e293b;
    --color-purple: #a855f7;
    --color-blue: #60a5fa;
    --color-indigo: #a5b4fc;
    --color-rose: #f9a8d4;
    --color-emerald: #6ee7b7;
    --color-yellow: #fcd34d;
    --color-sky: #7dd3fc;
    --color-teal: #5eead4;
    --color-violet: #c4b5fd;
    --color-orange: #fbbf24;
    --color-pink: #f472b6;
    --color-amber: #fbbf24;
    --color-green: #4ade80;
    --color-red: #f87171;
    --color-green-dark: #4ade80;
    --color-green-darker: #34d399;
    --color-amber-dark: #fbbf24;
    --color-red-dark: #f87171;
    --color-slate: #94a3b8;
    --bg-green-soft: rgba(34, 197, 94, 0.2);
    --bg-blue-soft: rgba(59, 130, 246, 0.2);
    --bg-amber-soft: rgba(245, 158, 11, 0.2);
    --bg-purple-soft: rgba(168, 85, 247, 0.2);
    --bg-pink-soft: rgba(236, 72, 153, 0.2);
    --bg-slate-soft: rgba(148, 163, 184, 0.15);
    --bg-error-soft: rgba(239, 68, 68, 0.2);
    --bg-primary-soft: rgba(99, 102, 241, 0.15);
    --bg-red-soft: rgba(239, 68, 68, 0.2);
    --bg-indigo-soft: rgba(129, 140, 248, 0.15);
    --bg-sky-soft: rgba(56, 189, 248, 0.15);
    --bg-yellow-soft: #422006;
    --bg-orange-soft: #431407;
    --border-red-soft: #7f1d1d;
    --border-green-soft: #14532d;
    --border-yellow-soft: #422006;
    --border-orange-soft: #431407;
    --surface-hover: rgba(255, 255, 255, 0.03);
    --surface-elevated: #1e293b;
    --surface-overlay: #1e293b;
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-placeholder: #64748b;
    --input-focus-ring: rgba(99, 102, 241, 0.3);
    --input-disabled-bg: #0f172a;
    --table-stripe: rgba(255, 255, 255, 0.02);
    --table-hover: rgba(99, 102, 241, 0.06);
    --scrollbar-track: var(--surface-muted);
    --scrollbar-thumb: #475569;
    --scrollbar-thumb-hover: #64748b;
    --code-bg: #1e293b;
    --code-border: #334155;
    --surface-success: rgba(34, 197, 94, 0.15);
    --surface-warning: rgba(245, 158, 11, 0.15);
    --surface-error: rgba(239, 68, 68, 0.15);
    --surface-info: rgba(99, 102, 241, 0.15);
    --border-success: #4ade80;
    --border-warning: #fbbf24;
    --border-error: #f87171;
    --border-info: #818cf8;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(30, 41, 59, 0.5);
    --glass-bg-strong: rgba(15, 23, 42, 0.85);
    --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 12px 24px -8px rgba(0, 0, 0, 0.3);
  }
}

/* Dark mode body background */
body.bg-light[data-theme="dark"],
body[data-theme="dark"] {
  background-color: var(--bg-color) !important;
  color: var(--text-main) !important;
}

/* Dark mode common elements */
[data-theme="dark"] body,
[data-theme="dark"] .app-container,
[data-theme="dark"] .main-content,
[data-theme="dark"] .sidebar,
[data-theme="dark"] header,
[data-theme="dark"] .topbar,
[data-theme="dark"] .public-header {
  background-color: var(--surface-color) !important;
  color: var(--text-main) !important;
}

/* Form elements in dark mode */
[data-theme="dark"] input, 
[data-theme="dark"] textarea, 
[data-theme="dark"] select {
  background-color: var(--input-bg) !important;
  color: var(--text-main) !important;
  border-color: var(--input-border) !important;
}

/* Cards and containers in dark mode */
[data-theme="dark"] .card,
[data-theme="dark"] .card.glass,
[data-theme="dark"] .card.glass-strong,
[data-theme="dark"] .card.premium,
[data-theme="dark"] .analytics-card,
[data-theme="dark"] .matrix-container,
[data-theme="dark"] .grid-wrapper,
[data-theme="dark"] section,
[data-theme="dark"] .modal,
[data-theme="dark"] .table-container,
[data-theme="dark"] .hero-highlight-card {
  background-color: var(--surface-color) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

/* Text colors in dark mode */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .text-main,
[data-theme="dark"] .brand,
[data-theme="dark"] p:not(.text-muted) {
  color: var(--text-main) !important;
}

[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

/* Form labels in dark mode */
[data-theme="dark"] .form-label,
[data-theme="dark"] label {
  color: var(--text-main) !important;
}

/* Buttons in dark mode */
[data-theme="dark"] .btn {
  background-color: var(--surface-muted) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .btn-primary {
  background-color: var(--primary-color) !important;
  color: #fff !important;
}

[data-theme="dark"] .btn-secondary {
  background-color: var(--secondary-color) !important;
  color: #fff !important;
}

[data-theme="dark"] .btn-warning {
  background-color: var(--warning) !important;
  color: #fff !important;
}

[data-theme="dark"] .btn-danger {
  background-color: var(--error) !important;
  color: #fff !important;
}

/* Tables in dark mode */
[data-theme="dark"] table,
[data-theme="dark"] th,
[data-theme="dark"] td {
  background-color: var(--surface-color) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] thead {
  background-color: var(--surface-muted) !important;
}

/* Badges and tags */
[data-theme="dark"] .badge {
  background-color: var(--surface-muted) !important;
  color: var(--text-main) !important;
}

/* Nav items and links in dark mode */
[data-theme="dark"] .nav-item,
[data-theme="dark"] a:not(.btn) {
  color: var(--text-main) !important;
}

[data-theme="dark"] .nav-section-label {
  color: var(--text-muted) !important;
}

[data-theme="dark"] a:not(.btn):hover {
  color: var(--primary-color) !important;
}

/* Form controls */
[data-theme="dark"] .form-control {
  background-color: var(--input-bg) !important;
  color: var(--text-main) !important;
  border-color: var(--input-border) !important;
}

/* Tab buttons */
[data-theme="dark"] .tab-btn,
[data-theme="dark"] .msg-tab-btn {
  background-color: transparent !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .tab-btn.active,
[data-theme="dark"] .msg-tab-btn.active {
  background-color: rgba(99, 102, 241, 0.15) !important;
  color: var(--primary-color) !important;
}

/* Modal overlay */
[data-theme="dark"] .modal-overlay {
  background-color: rgba(0, 0, 0, 0.7) !important;
}

/* Search results in omni search */
[data-theme="dark"] .omni-results a {
  color: var(--text-main) !important;
}

/* Scrollbar styling for dark mode */
[data-theme="dark"] ::-webkit-scrollbar {
  background: var(--surface-muted);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

/* Additional dark mode fixes for readability */
[data-theme="dark"] .modal {
  background-color: var(--surface-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .modal h2,
[data-theme="dark"] .modal h3 {
  color: var(--text-main) !important;
}

[data-theme="dark"] .modal p {
  color: var(--text-muted) !important;
}

/* Text colors */
[data-theme="dark"] [style*="color: var(--text-main)"],
[data-theme="dark"] [style*="color:var(--text-main)"] {
  color: var(--text-main) !important;
}

[data-theme="dark"] [style*="color: var(--text-muted)"],
[data-theme="dark"] [style*="color:var(--text-muted)"] {
  color: var(--text-muted) !important;
}

[data-theme="dark"] [style*="color: var(--primary-color)"],
[data-theme="dark"] [style*="color:var(--primary-color)"] {
  color: var(--primary-color) !important;
}

/* Border colors */
[data-theme="dark"] [style*="border-color: var(--border-color)"] {
  border-color: var(--border-color) !important;
}

/* Omni search modal in dark mode */
[data-theme="dark"] #omni-search-modal {
  background: rgba(0, 0, 0, 0.7) !important;
}

[data-theme="dark"] #omni-search-modal > div {
  background: var(--surface-color) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #omni-input {
  background: transparent !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #omni-results {
  background: var(--surface-color) !important;
}

[data-theme="dark"] #omni-results a {
  color: var(--text-main) !important;
}

[data-theme="dark"] kbd {
  background: var(--surface-muted) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

/* Header nav in dark mode */
[data-theme="dark"] .public-header {
  background: var(--surface-color) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .public-header nav a,
[data-theme="dark"] .public-header nav button {
  color: var(--text-main) !important;
}

[data-theme="dark"] .public-header .brand {
  color: var(--primary-color) !important;
}

/* ── Subscription Alert (dark mode overrides for inline-style bg) ── */
[data-theme="dark"] .sub-alert {
  background-color: var(--surface-color) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

/* Enhanced upgrade banner dark mode */
[data-theme="dark"] .sub-alert--upgrade {
  background: linear-gradient(135deg, #0f172a 0%, #1a1540 50%, #1e1030 100%) !important;
  border-color: #312e81 !important;
}

[data-theme="dark"] .sub-alert__accent {
  background: linear-gradient(135deg, #818cf8, #a78bfa, #f472b6) !important;
}

[data-theme="dark"] .sub-alert__title {
  color: var(--text-main) !important;
}

[data-theme="dark"] .sub-alert__badge {
  background: rgba(129, 140, 248, 0.2) !important;
  color: #a5b4fc !important;
}

[data-theme="dark"] .sub-alert__desc {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .sub-alert__feature {
  background: rgba(129, 140, 248, 0.12) !important;
  color: #a5b4fc !important;
  border-color: rgba(129, 140, 248, 0.2) !important;
}

[data-theme="dark"] .sub-alert__link {
  color: #a5b4fc !important;
}

[data-theme="dark"] .sub-alert__divider {
  background: #312e81 !important;
}

[data-theme="dark"] .sub-alert .usage-toggle {
  color: var(--primary-color) !important;
}

/* Usage panel dark mode */
[data-theme="dark"] .usage-card {
  background-color: var(--surface-muted) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .usage-card-label {
  color: var(--text-main) !important;
}

[data-theme="dark"] .usage-card-value {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .usage-bar {
  background-color: var(--border-color) !important;
}

/* Feature chips dark mode */
[data-theme="dark"] .feature-chip.off {
  background-color: var(--surface-muted) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .feature-chip.on {
  background-color: var(--surface-success) !important;
  color: var(--color-green) !important;
  border-color: var(--border-success) !important;
}

/* Standard alert text dark mode */
[data-theme="dark"] .sub-alert strong {
  color: var(--primary-color) !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
}

/* Fluid Typography */
h1 { font-size: clamp(2.5rem, 5vw + 1rem, 4.5rem); line-height: 1.1; letter-spacing: -0.03em; }
h2 { font-size: clamp(2rem, 3vw + 0.5rem, 3rem); line-height: 1.15; letter-spacing: -0.02em; }

a {
  text-decoration: none;
  color: var(--primary-color);
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

/* Sidebar Navigation - Always visible, fixed position */
.sidebar {
  background-color: var(--surface-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  transition: transform 0.3s ease;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: visible;
  flex-shrink: 0;
  z-index: 200;
}

/* Base Layout - flex container for main content, sidebar is fixed */
.app-container {
  display: flex;
  min-height: 100vh;
  flex: 1;
  padding-left: var(--sidebar-width);
}

/* Role-based sidebar widths */
.sidebar[data-width="280"] { width: 280px; }
.sidebar[data-width="260"] { width: 260px; }
.sidebar[data-width="250"] { width: 250px; }

body:has(.sidebar[data-width="280"]) .app-container { padding-left: 280px; }
body:has(.sidebar[data-width="260"]) .app-container { padding-left: 260px; }
body:has(.sidebar[data-width="250"]) .app-container { padding-left: 250px; }

.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Sidebar scroll wrapper */
.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem;
  margin-top: 1rem;
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

[data-theme="dark"] .sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

.sidebar .brand {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 2rem;
  text-align: center;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.75rem 1rem 0.25rem;
  opacity: 0.7;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  text-decoration: none;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--primary-color);
}

.nav-item.active {
  background-color: rgba(99, 102, 241, 0.15);
  font-weight: 600;
}

/* Sidebar Scroll */
aside.sidebar {
  overflow: hidden;
}

/* Header / Top Navigation (Public/Student) */
.public-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease;
}

[data-theme="dark"] .public-header {
  background-color: rgba(15, 23, 42, 0.8);
}

.topbar {
  width: 100%;
  height: 70px;
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

/* Cards (Glassmorphism & Premium UI) */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-main);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--glass-border);
}

.card.glass-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border: 1px solid var(--glass-border);
}

.card.premium {
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-premium);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.card.premium:hover {
  box-shadow: var(--shadow-glow-primary);
  border-color: rgba(99, 102, 241, 0.25);
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-heading);
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.25s;
}

.btn:hover::before {
  opacity: 1;
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

/* Button with icon animation */
.btn .icon {
  transition: transform 0.25s;
}
.btn:hover .icon {
  transform: translateX(3px);
}

/* Button group animation */
.btn-group {
  display: inline-flex;
}
.btn-group .btn {
  border-radius: 0;
}
.btn-group .btn:first-child {
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}
.btn-group .btn:last-child {
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}
.btn-group .btn:not(:last-child) {
  border-right: 1px solid rgba(255,255,255,0.2);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #fff;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4), 0 0 15px rgba(99, 102, 241, 0.2);
  transform: translateY(-2px) scale(1.02);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: #fff;
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
  color: #fff;
  box-shadow: 0 10px 25px -5px rgba(236, 72, 153, 0.4), 0 0 15px rgba(236, 72, 153, 0.2);
  transform: translateY(-2px) scale(1.02);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  border-radius: var(--border-radius-sm);
  line-height: 1.4;
}

.btn-warning {
  background-color: var(--warning);
  color: #fff;
}

.btn-warning:hover {
  background-color: var(--color-amber-dark);
  color: #fff;
}

.btn-danger {
  background-color: var(--error);
  color: #fff;
}

.btn-danger:hover {
  background-color: var(--color-red-dark);
  color: #fff;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  background: var(--surface-color);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--table-stripe);
  font-weight: 600;
  color: var(--text-muted);
}

[data-theme="dark"] th {
  background: var(--table-stripe);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success { background: var(--surface-success); color: var(--success); }
.badge-warning { background: var(--surface-warning); color: var(--warning); }
.badge-error { background: var(--surface-error); color: var(--error); }

/* Animations & Special Effects */
@keyframes pulse-primary {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

@keyframes pulse-success {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes pulse-warning {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-error {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes slide-up-fade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes notification-flash {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.1); filter: brightness(1.2); }
}

/* Premium Homepage Animations */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up-delay-1 {
  0%, 15% { opacity: 0; transform: translateY(40px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up-delay-2 {
  0%, 30% { opacity: 0; transform: translateY(40px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3), 0 0 60px rgba(99, 102, 241, 0.1); }
  50% { box-shadow: 0 0 30px rgba(99, 102, 241, 0.5), 0 0 80px rgba(99, 102, 241, 0.2); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes counter-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes orb-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

@keyframes orb-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-30px, 20px) scale(0.9); }
  66% { transform: translate(20px, -30px) scale(1.05); }
}

.animate-pulse-primary { animation: pulse-primary 2s infinite; }
.animate-pulse-success { animation: pulse-success 2s infinite; }
.animate-pulse-warning { animation: pulse-warning 2s infinite; }
.animate-pulse-error { animation: pulse-error 2s infinite; }
.animate-flash { animation: notification-flash 1.5s infinite; }
.animate-room-enter { animation: slide-up-fade 0.5s ease-out forwards; }
.animate-fade-up { animation: fade-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-fade-up-d1 { animation: fade-up-delay-1 1s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-fade-up-d2 { animation: fade-up-delay-2 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-glow { animation: glow-pulse 3s ease-in-out infinite; }
.animate-float { animation: float 6s ease-in-out infinite; }
.animate-scale-in { animation: scale-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-counter { animation: counter-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

.notification-dot {
  position: relative;
}

.notification-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background-color: var(--error);
  border-radius: 50%;
  border: 2px solid var(--surface-color);
  animation: notification-flash 1.5s infinite;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface-color);
  border-radius: var(--border-radius-lg);
  width: 90%;
  max-width: 500px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

/* ── Standardized Modal Card System — Docs/popupmodel/modal_system_guide.md ── */
.modal-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl, 24px);
  box-shadow: var(--shadow-premium, 0 25px 50px -12px rgba(0, 0, 0, 0.15));
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(15px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gradient-surface);
  flex-shrink: 0;
}

.modal-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-title-icon {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  font-weight: 400;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background-color: var(--surface-muted);
  color: var(--text-main);
  transform: rotate(90deg);
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  background-color: var(--surface-muted);
  flex-shrink: 0;
}

/* Quiz Instructions Panel */
#instructions-panel h1, #instructions-panel h2, #instructions-panel h3 {
    margin-top: 0;
}
#instructions-panel ul, #instructions-panel ol {
    padding-left: 1.5rem;
}
#instructions-panel a {
    color: inherit;
    text-decoration: underline;
}

/* ==============================
   PREMIUM HOME PAGE SYSTEM
   ============================== */

/* Hero Section - Gradient Mesh Background */
.hero-enhanced {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem;
  overflow: hidden;
  background: var(--gradient-mesh);
  color: #fff;
}

.hero-enhanced::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.3), transparent),
    radial-gradient(ellipse 60% 40% at 80% 50%, rgba(236, 72, 153, 0.2), transparent),
    radial-gradient(ellipse 50% 60% at 20% 80%, rgba(16, 185, 129, 0.15), transparent);
  z-index: 1;
}

/* Floating orbs for ambient effect */
.hero-enhanced::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: orb-float-1 20s ease-in-out infinite;
  z-index: 1;
}

.hero-enhanced .container {
  position: relative;
  z-index: 2;
  max-width: 900px;
  text-align: center;
}

.hero-enhanced h1 {
  font-size: clamp(2.75rem, 8vw, 5rem);
  margin-bottom: 1.5rem;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.hero-enhanced p {
  font-size: clamp(1.125rem, 2.5vw, 1.375rem);
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 3rem;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* Hero Highlight / Dashboard Mockup */
.hero-highlight-wrapper {
  margin-top: 4rem;
  perspective: 1200px;
}

.hero-highlight-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius-xl);
  padding: 2rem;
  max-width: 700px;
  margin: 0 auto;
  transform: rotateX(2deg);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.3);
}

.hero-highlight-card:hover {
  transform: rotateX(0deg) translateY(-4px);
}

/* Analytics Grid (6-card bento in hero) */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.analytics-mini-card {
  border-radius: 14px;
  padding: 1rem 0.75rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.analytics-mini-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Chart Cards */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.chart-card:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

[data-theme="dark"] .chart-card {
  background: rgba(30, 41, 59, 0.8);
}

[data-theme="dark"] .chart-card:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Bento Box Feature Grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.bento-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  padding: 2.5rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.bento-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.bento-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-premium);
  border-color: rgba(99, 102, 241, 0.2);
}

.bento-card:hover::before {
  opacity: 1;
}

.bento-card.span-2 {
  grid-column: span 2;
}

.bento-card .bento-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.bento-card h3 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.bento-card p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.7;
}

/* Stats Section - Floating Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  padding: 2.5rem 2rem;
  text-align: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  transition: opacity 0.3s;
  opacity: 0;
}

.stat-card:nth-child(1)::after { background: var(--gradient-indigo); }
.stat-card:nth-child(2)::after { background: var(--gradient-pink); }
.stat-card:nth-child(3)::after { background: var(--gradient-green); }

.stat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-premium);
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card:nth-child(2) .stat-value {
  background: var(--gradient-pink);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card:nth-child(3) .stat-value {
  background: var(--gradient-green);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
}

/* Vanguard Leaderboard Premium Wrapper */
.vanguard-premium-wrapper {
  background: var(--gradient-premium);
  border: 1px solid var(--border-color);
  border-radius: 32px;
  padding: 3rem;
  max-width: 1200px;
  margin: 0 auto;
  box-shadow: var(--shadow-premium);
}

/* Final CTA - Dark Premium */
.cta-final {
  background: var(--gradient-mesh);
  padding: 10rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cta-final::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(99, 102, 241, 0.2), transparent),
    radial-gradient(ellipse 40% 40% at 80% 20%, rgba(236, 72, 153, 0.15), transparent);
}

.cta-final .cta-content {
  position: relative;
  z-index: 2;
  max-width: 700px;
  margin: 0 auto;
}

.cta-final h2 {
  color: #fff;
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  font-weight: 800;
  margin-bottom: 1.5rem;
  letter-spacing: -0.03em;
}

.cta-final p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.1875rem;
  margin-bottom: 3rem;
  line-height: 1.7;
}

/* Feature Grid Legacy Support */
.feature-grid-enhanced {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  padding: 0 1rem;
}

.feature-card {
  background: var(--surface-color);
  padding: 3rem 2rem;
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--border-color);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.feature-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-premium);
  border-color: rgba(99, 102, 241, 0.2);
}

.feature-card:hover::before {
  opacity: 1;
}

.feature-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--primary-gradient);
  color: #fff;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.section-tag {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-color);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Scroll Reveal - elements start hidden, revealed by JS */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; max-height: 70vh; border-right: none; border-bottom: 1px solid var(--border-color); padding: 1rem; overflow-y: auto; overflow-x: visible; }
  .sidebar .nav-item { display: flex; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
  .feature-grid-enhanced { grid-template-columns: 1fr; padding: 2rem 1rem; }
  .bento-grid { grid-template-columns: 1fr; }
  .bento-card.span-2 { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr; }
  .hero-enhanced { min-height: 80vh; padding: 4rem 1.5rem; }
  .vanguard-premium-wrapper { padding: 1.5rem; border-radius: 20px; }
  .cta-final { padding: 6rem 1.5rem; }
}





@media (max-width: 1024px) and (min-width: 769px) {
  .bento-grid { grid-template-columns: repeat(2, 1fr); }
  .bento-card.span-2 { grid-column: span 2; }
  .feature-grid-enhanced { grid-template-columns: repeat(2, 1fr); }
}

/* Tab Navigation (Teacher Dash) */
.msg-tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 2px solid var(--border-color);
}

.msg-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 1rem 0;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.msg-tab-btn:hover {
  color: var(--primary-color);
}

.msg-tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* ── Override Section ── */
.override-section {
  background: var(--surface-muted);
  padding: 1.25rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}
.override-section .edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.override-section .btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--surface-color);
  cursor: pointer;
}
.override-section .btn-sm:hover {
  background: var(--border-color);
}

/* ── Subscription Alert ── */
.sub-alert {
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

/* ── Enhanced Upgrade Banner ── */
.sub-alert--upgrade {
  position: relative;
  display: flex;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf2f8 100%);
  border: 1px solid #c7d2fe;
  overflow: hidden;
  padding: 0;
}
.sub-alert__accent {
  width: 5px;
  flex-shrink: 0;
  border-radius: 20px 0 0 20px;
}
.sub-alert__body {
  flex: 1;
  padding: 1.5rem 1.5rem 1.25rem 1.25rem;
  min-width: 0;
}
.sub-alert__icon-ring {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.sub-alert__icon {
  font-size: 1.35rem;
  line-height: 1;
}
.sub-alert__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}
.sub-alert__badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  text-transform: uppercase;
  line-height: 1.4;
}
.sub-alert__desc {
  margin: 0.35rem 0 0;
  font-size: 0.835rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 520px;
}
.sub-alert__features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.sub-alert__feature {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.07);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.12);
}
.sub-alert__feature-icon {
  font-size: 0.8rem;
}
.sub-alert__cta {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.5rem;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.835rem;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
.sub-alert__cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}
.sub-alert__link {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6366f1;
  text-decoration: none;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.sub-alert__link:hover {
  opacity: 1;
  text-decoration: underline;
}
.sub-alert__divider {
  height: 1px;
  background: #e0e7ff;
  margin: 0 -1.5rem;
  opacity: 0.7;
}

/* ── Usage Panel (Collapsible) ── */
.usage-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.25rem 0;
}
.usage-toggle-icon {
  transition: transform 0.2s;
}
.usage-toggle-icon.open {
  transform: rotate(90deg);
}
.usage-panel {
  display: none;
  margin-top: 1rem;
  animation: slideDown 0.25s ease-out;
}
.usage-panel.open {
  display: block;
}
@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 2000px; }
}
.usage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.usage-card {
  background: var(--surface-color);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}
.usage-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.usage-card-label {
  font-weight: 700;
  font-size: 0.8125rem;
}
.usage-card-value {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.usage-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.usage-bar-fill.normal { background: var(--success); }
.usage-bar-fill.warning { background: var(--color-orange); }
.usage-bar-fill.danger { background: var(--error); }

/* ── Feature Chips (Boolean) ── */
.feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}
.feature-chip.on {
  background: var(--surface-success);
  border: 1px solid var(--border-success);
}
.feature-chip.off {
  background: var(--surface-muted);
  opacity: 0.5;
}

/* ── Limit Modal ── */
.limit-modal {
  max-width: 440px;
  border-radius: 24px;
  padding: 2rem;
  text-align: center;
}
.limit-modal-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.limit-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 800;
}
.limit-modal-desc {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.limit-modal-stats {
  background: var(--surface-color);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}
.limit-modal-stats-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.limit-modal-stats-label {
  font-weight: 600;
  font-size: 0.875rem;
}
.limit-modal-stats-value {
  font-weight: 800;
  font-size: 0.875rem;
}
.limit-modal-stats-value.danger { color: var(--error); }
.limit-modal-stats-value.warning { color: var(--color-orange); }
.limit-modal-bar {
  height: 10px;
  background: var(--border-color);
  border-radius: 5px;
  overflow: hidden;
}
.limit-modal-bar-fill {
  height: 100%;
  border-radius: 5px;
}
.limit-modal-bar-fill.danger { background: var(--error); }
.limit-modal-bar-fill.warning { background: var(--color-orange); }
.limit-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .usage-grid { grid-template-columns: 1fr; }
}

