/* ══════════════════════════════════════════════════════════════
   SIVRA V9 — Design Tokens (variables.css)
   PostgreSQL-inspired palette: #336791 primary blue.
   Supports [data-theme] for runtime theme switching.
   All tokens mapped to CSS Custom Properties for zero-runtime cost.
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Open+Sans:wght@300;400;500;600;700;800&family=Roboto:wght@300;400;500;700;900&display=swap');

/* ── PostgreSQL Core Palette ── */
:root {
  /* Primary — PostgreSQL Blue */
  --pg-blue-900: #1A3B4F;
  --pg-blue-800: #244B66;
  --pg-blue-700: #2D5C7A;
  --pg-blue-600: #336791;  /* Classic PostgreSQL blue */
  --pg-blue-500: #4479A1;
  --pg-blue-400: #5C8DB5;
  --pg-blue-300: #7DA8C9;
  --pg-blue-200: #A3C4DB;
  --pg-blue-100: #CADDED;
  --pg-blue-50:  #E8F1F7;

  /* Secondary — Slate */
  --pg-slate-900: #1A202C;
  --pg-slate-800: #2D3748;
  --pg-slate-700: #4A5568;
  --pg-slate-600: #718096;
  --pg-slate-500: #A0AEC0;
  --pg-slate-400: #CBD5E0;
  --pg-slate-300: #E2E8F0;
  --pg-slate-200: #EDF2F7;
  --pg-slate-100: #F7FAFC;
  --pg-slate-50:  #FAFCFD;

  /* Accent — Amber (warnings, highlights) */
  --pg-amber-600: #B7791F;
  --pg-amber-500: #D69E2E;
  --pg-amber-400: #ECC94B;
  --pg-amber-300: #F6E05E;
  --pg-amber-200: #FAF089;
  --pg-amber-100: #FEFCBF;
  --pg-amber-50:  #FFFFF0;

  /* Semantic Colors (WCAG AA verified on white) */
  --color-success-700: #1C6B37;
  --color-success-600: #2F855A;
  --color-success-500: #38A169;  /* Contrast 4.3:1 on white */
  --color-success-400: #48BB78;
  --color-success-300: #68D391;
  --color-success-200: #9AE6B4;
  --color-success-100: #C6F6D5;
  --color-success-50:  #F0FFF4;

  --color-danger-700: #9B2C2C;
  --color-danger-600: #C53030;
  --color-danger-500: #E53E3E;   /* Contrast 4.6:1 on white */
  --color-danger-400: #FC8181;
  --color-danger-300: #FEB2B2;
  --color-danger-200: #FED7D7;
  --color-danger-100: #FFF5F5;

  --color-warning-700: #975A16;
  --color-warning-600: #B7791F;
  --color-warning-500: #D69E2E;  /* Contrast 4.5:1 on white */
  --color-warning-400: #ECC94B;
  --color-warning-300: #F6E05E;
  --color-warning-200: #FAF089;
  --color-warning-100: #FFFAF0;

  --color-info-700: #2A4365;
  --color-info-600: #2B6CB0;
  --color-info-500: #3182CE;     /* Contrast 4.5:1 on white */
  --color-info-400: #63B3ED;
  --color-info-300: #90CDF4;
  --color-info-200: #BEE3F8;
  --color-info-100: #EBF8FF;

  /* Neutral — Gray scale */
  --color-neutral-950: #0D1117;
  --color-neutral-900: #161B22;
  --color-neutral-800: #1E293B;
  --color-neutral-700: #334155;
  --color-neutral-600: #475569;
  --color-neutral-500: #64748B;
  --color-neutral-400: #94A3B8;
  --color-neutral-300: #CBD5E0;
  --color-neutral-200: #E2E8F0;
  --color-neutral-150: #EDF2F7;
  --color-neutral-100: #F1F5F9;
  --color-neutral-50:  #F8FAFC;
  --color-neutral-0:   #FFFFFF;
}

/* ── Semantic Token Aliases (use these in components) ── */
:root {
  --color-primary:         var(--pg-blue-600);
  --color-primary-hover:   var(--pg-blue-700);
  --color-primary-light:   var(--pg-blue-50);
  --color-primary-dark:    var(--pg-blue-800);
  --color-secondary:       var(--pg-slate-600);
  --color-secondary-hover: var(--pg-slate-700);
  --color-success:         var(--color-success-500);
  --color-success-light:   var(--color-success-50);
  --color-danger:          var(--color-danger-500);
  --color-danger-light:    var(--color-danger-100);
  --color-warning:         var(--color-warning-500);
  --color-warning-light:   var(--color-warning-100);
  --color-info:            var(--color-info-500);
  --color-info-light:      var(--color-info-100);

  /* Background & Surface */
  --color-bg:              var(--color-neutral-50);
  --color-surface:         var(--color-neutral-0);
  --color-surface-raised:  var(--color-neutral-0);
  --color-surface-hover:   var(--color-neutral-100);

  /* Text */
  --color-text-primary:    var(--color-neutral-900);
  --color-text-secondary:  var(--color-neutral-600);
  --color-text-tertiary:   var(--color-neutral-500);
  --color-text-inverse:    var(--color-neutral-0);
  --color-text-link:       var(--pg-blue-600);
  --color-text-link-hover: var(--pg-blue-700);

  /* Borders */
  --color-border:          var(--color-neutral-200);
  --color-border-light:    var(--color-neutral-150);
  --color-border-focus:    var(--pg-blue-400);

  /* Legacy variable aliases (backward compat) */
  --primary-900: var(--pg-blue-900);
  --primary-800: var(--pg-blue-800);
  --primary-700: var(--pg-blue-700);
  --primary-600: var(--pg-blue-600);
  --primary-500: var(--pg-blue-500);
  --primary-400: var(--pg-blue-400);
  --primary-300: var(--pg-blue-300);
  --primary-200: var(--pg-blue-200);
  --primary-100: var(--pg-blue-100);
  --primary-50:  var(--pg-blue-50);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #0F4C81 0%, #2586D9 100%);
  --gradient-accent:  linear-gradient(135deg, #FF6B35 0%, #FF8A5C 100%);
}

/* ── Spacing Scale (4px base) ── */
:root {
  --space-0:   0;
  --space-0-5: 2px;
  --space-1:   4px;
  --space-1-5: 6px;
  --space-2:   8px;
  --space-2-5: 10px;
  --space-3:   12px;
  --space-3-5: 14px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-7:   28px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;
  --space-14:  56px;
  --space-16:  64px;
  --space-20:  80px;
  --space-24:  96px;
  --space-32:  128px;
}

/* ── Typography Scale ── */
:root {
  --font-family-sans: 'Inter', 'Roboto', 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                      Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono',
                      Consolas, 'Liberation Mono', Menlo, monospace;
  --font-family-display: 'Inter', var(--font-family-sans);

  /* Convenience aliases (used by design-system.css) */
  --font-family:      var(--font-family-sans);
  --font-size-base:   var(--text-base);
  --line-height-base: var(--leading-normal);

  /* Fluid type scale using clamp() */
  --text-xs:   clamp(0.6875rem, 0.65rem + 0.1vw, 0.75rem);
  --text-sm:   clamp(0.8125rem, 0.77rem + 0.12vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
  --text-lg:   clamp(1.0625rem, 1rem + 0.2vw, 1.125rem);
  --text-xl:   clamp(1.1875rem, 1.1rem + 0.25vw, 1.25rem);
  --text-2xl:  clamp(1.375rem, 1.25rem + 0.35vw, 1.5rem);
  --text-3xl:  clamp(1.6875rem, 1.5rem + 0.5vw, 1.875rem);
  --text-4xl:  clamp(2rem, 1.75rem + 0.7vw, 2.25rem);
  --text-5xl:  clamp(2.5rem, 2rem + 1vw, 3rem);
  --text-6xl:  clamp(3rem, 2.5rem + 1.5vw, 4rem);

  /* Font weights */
  --font-light:    300;
  --font-regular:  400;
  --font-medium:   500;
  --font-semibold: 600;
  --font-bold:     700;
  --font-extrabold: 800;

  /* Line heights */
  --leading-none:    1;
  --leading-tight:   1.25;
  --leading-snug:    1.375;
  --leading-normal:  1.5;
  --leading-relaxed: 1.625;
  --leading-loose:   2;

  /* Letter spacing */
  --tracking-tighter: -0.05em;
  --tracking-tight:   -0.025em;
  --tracking-normal:  0;
  --tracking-wide:    0.025em;
  --tracking-wider:   0.05em;
}

/* ── Border Radius ── */
:root {
  --radius-none:   0;
  --radius-xs:     2px;
  --radius-sm:     4px;
  --radius-md:     6px;
  --radius-base:   8px;
  --radius-lg:     12px;
  --radius-xl:     16px;
  --radius-2xl:    24px;
  --radius-3xl:    32px;
  --radius-full:   9999px;
}

/* ── Border Widths ── */
:root {
  --border-0: 0;
  --border-1: 1px;
  --border-2: 2px;
  --border-4: 4px;
}

/* ── Shadows (Elevation 0-4) ── */
:root {
  --elevation-0: none;
  --elevation-1: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --elevation-2: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --elevation-3: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --elevation-4: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --elevation-5: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --elevation-card: var(--elevation-1);

  /* Inset shadow for inputs */
  --shadow-inset: inset 0 1px 2px rgb(0 0 0 / 0.06);
}

/* ── Transitions ── */
:root {
  --ease-linear:    cubic-bezier(0, 0, 1, 1);
  --ease-in:        cubic-bezier(0.4, 0, 1, 1);
  --ease-out:       cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out:    cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);

  --duration-75:   75ms;
  --duration-100:  100ms;
  --duration-150:  150ms;
  --duration-200:  200ms;
  --duration-300:  300ms;
  --duration-500:  500ms;
  --duration-700:  700ms;
  --duration-1000: 1000ms;

  --transition-colors:  background-color var(--duration-200) var(--ease-in-out),
                        color var(--duration-200) var(--ease-in-out),
                        border-color var(--duration-200) var(--ease-in-out);
  --transition-opacity: opacity var(--duration-150) var(--ease-in-out);
  --transition-transform: transform var(--duration-200) var(--ease-out);
  --transition-shadow:    box-shadow var(--duration-200) var(--ease-in-out);
  --transition-all:       all var(--duration-200) var(--ease-in-out);
}

/* ── Z-Index Scale ── */
:root {
  --z-base:      0;
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-overlay:   300;
  --z-modal:     400;
  --z-popover:   500;
  --z-tooltip:   600;
  --z-toast:     700;
}

/* ── Layout ── */
:root {
  --container-sm:  640px;
  --container-md:  768px;
  --container-lg:  1024px;
  --container-xl:  1280px;
  --container-2xl: 1536px;

  --sidebar-width:       260px;
  --sidebar-collapsed:   64px;
  --topbar-height:       56px;
  --footer-height:       48px;
}

/* ── PostgreSQL Status Mapping (drives [data-status] CSS) ── */
:root {
  /* Course / Trail / Generation status colors */
  --status-draft-bg:       var(--color-neutral-100);
  --status-draft-text:     var(--color-neutral-600);
  --status-draft-border:   var(--color-neutral-300);

  --status-published-bg:   var(--color-success-50);
  --status-published-text: var(--color-success-600);
  --status-published-border: var(--color-success-300);

  --status-archived-bg:    var(--color-neutral-150);
  --status-archived-text:  var(--color-neutral-500);
  --status-archived-border: var(--color-neutral-300);

  --status-processing-bg:      var(--color-info-100);
  --status-processing-text:    var(--color-info-600);
  --status-processing-border:  var(--color-info-300);

  --status-completed-bg:   var(--color-success-50);
  --status-completed-text: var(--color-success-600);
  --status-completed-border: var(--color-success-300);

  --status-failed-bg:      var(--color-danger-100);
  --status-failed-text:    var(--color-danger-600);
  --status-failed-border:  var(--color-danger-300);

  --status-submitted-bg:   var(--color-info-100);
  --status-submitted-text: var(--color-info-600);
  --status-submitted-border: var(--color-info-300);

  --status-graded-bg:      var(--pg-amber-100);
  --status-graded-text:    var(--pg-amber-700);
  --status-graded-border:  var(--pg-amber-300);

  --status-returned-bg:    var(--color-success-50);
  --status-returned-text:  var(--color-success-600);
  --status-returned-border: var(--color-success-300);

  --status-locked-bg:      var(--color-neutral-100);
  --status-locked-text:    var(--color-neutral-500);
  --status-locked-border:  var(--color-neutral-300);

  --status-available-bg:   var(--color-primary-light);
  --status-available-text: var(--pg-blue-700);
  --status-available-border: var(--pg-blue-300);

  --status-in-progress-bg:   var(--color-info-100);
  --status-in-progress-text: var(--color-info-600);
  --status-in-progress-border: var(--color-info-300);

  --status-active-bg:      var(--color-success-50);
  --status-active-text:    var(--color-success-600);
  --status-active-border:  var(--color-success-300);

  --status-suspended-bg:   var(--color-danger-100);
  --status-suspended-text: var(--color-danger-600);
  --status-suspended-border: var(--color-danger-300);

  --status-trial-bg:       var(--color-warning-100);
  --status-trial-text:     var(--color-warning-600);
  --status-trial-border:   var(--pg-amber-300);
}

/* ── [data-theme] overrides (applied by themes.css) ── */
/* These are placeholder tokens — themes.css fills the real values */
[data-theme] {
  /* Each theme redefines the semantic aliases */
}
/* ============================================
   SIVRA V9 — Design System (design-system.css)
   Import order: variables.css, then this file
   ============================================ */

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--color-neutral-800);
    background: var(--color-neutral-50);
    min-height: 100vh;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--primary-600);
    text-decoration: none;
}
a:hover {
    color: var(--primary-800);
}

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--neutral-900);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

p { margin-bottom: var(--space-4); }

/* ----- Scrollbar ----- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--neutral-100); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb { background: var(--primary-400); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--primary-500); }

/* ----- Selection ----- */
::selection { background: var(--primary-500); color: white; }

/* ----- Focus ----- */
:focus-visible { outline: 3px solid var(--primary-400); outline-offset: 2px; }

/* ----- Container ----- */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

/* ══════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-base);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1.5;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    min-height: 40px;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--gradient-primary); color: white; border-color: var(--primary-600); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.btn-accent { background: var(--gradient-accent); color: white; border-color: var(--accent-500); }
.btn-accent:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,107,53,0.3); }

.btn-outline { background: transparent; color: var(--primary-600); border-color: var(--primary-200); }
.btn-outline:hover:not(:disabled) { background: var(--primary-50); border-color: var(--primary-400); }

.btn-ghost { background: transparent; color: var(--neutral-600); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--neutral-100); }

.btn-success { background: var(--color-success-500); color: white; border-color: var(--color-success-500); }
.btn-success:hover:not(:disabled) { background: var(--color-success-600); border-color: var(--color-success-600); transform: translateY(-2px); }

.btn-danger { background: var(--color-error-500); color: white; border-color: var(--color-error-500); }
.btn-danger:hover:not(:disabled) { background: var(--color-error-600); border-color: var(--color-error-600); transform: translateY(-2px); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); min-height: 32px; }
.btn-lg { padding: var(--space-3) var(--space-8); font-size: var(--font-size-base); min-height: 48px; }
.btn-icon { width: 40px; height: 40px; padding: 0; min-height: auto; border-radius: var(--radius-full); }
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn-block { width: 100%; justify-content: center; }

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-base);
    border: 1px solid var(--neutral-200);
    overflow: hidden;
    transition: all var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: var(--space-5); }
.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--neutral-200); }
.card-title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); color: var(--neutral-800); }
.card-subtitle { font-size: var(--font-size-sm); color: var(--neutral-500); }

/* ══════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.6;
}
.badge-success { background: var(--color-success-100); color: var(--color-success-500); }
.badge-warning { background: var(--color-warning-100); color: var(--color-warning-500); }
.badge-error   { background: var(--color-error-100);   color: var(--color-error-500); }
.badge-info    { background: var(--primary-100);  color: var(--primary-600); }
.badge-neutral { background: var(--neutral-100);  color: var(--neutral-600); }
.badge-accent  { background: var(--accent-100);   color: var(--accent-500); }

/* ══════════════════════════════════════════════
   PROGRESS BARS
   ══════════════════════════════════════════════ */

.progress {
    width: 100%;
    height: 8px;
    background: var(--neutral-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
    background: var(--gradient-primary);
}
.progress-bar.accent  { background: var(--gradient-accent); }
.progress-bar.success { background: var(--color-success-500); }
.progress-bar.warning { background: var(--color-warning-500); }
.progress-sm { height: 4px; }
.progress-lg { height: 12px; }

/* ══════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════ */

.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-base);
    border-left: 4px solid;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}
.alert-icon { font-size: var(--font-size-lg); flex-shrink: 0; margin-top: 2px; }
.alert-content { flex: 1; }
.alert-title { font-weight: var(--font-weight-semibold); }
.alert-info    { background: var(--primary-50);  border-color: var(--primary-500);  color: var(--primary-700); }
.alert-success { background: var(--color-success-100); border-color: var(--color-success-500); color: var(--color-success-600); }
.alert-warning { background: var(--color-warning-100); border-color: var(--color-warning-500); color: var(--color-warning-600); }
.alert-error   { background: var(--color-error-100);   border-color: var(--color-error-500);   color: var(--color-error-600); }

/* ══════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════ */

.form-group { margin-bottom: var(--space-4); }
.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--neutral-700);
    margin-bottom: var(--space-1);
}
.form-label .required { color: var(--color-error-500); }
.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--neutral-200);
    border-radius: var(--radius-base);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--neutral-800);
    transition: all var(--transition-fast);
    background: white;
    min-height: 44px;
}
.form-control:focus { outline: none; border-color: var(--primary-400); box-shadow: 0 0 0 4px rgba(58,157,245,0.1); }
.form-control::placeholder { color: var(--neutral-400); }
.form-control.error { border-color: var(--color-error-500); }
.form-control.error:focus { box-shadow: 0 0 0 4px rgba(229,62,62,0.1); }
.form-control:disabled { background: var(--neutral-100); cursor: not-allowed; }
.form-error { font-size: var(--font-size-xs); color: var(--color-error-500); margin-top: var(--space-1); }
.form-hint { font-size: var(--font-size-xs); color: var(--neutral-400); margin-top: var(--space-1); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath fill='%234A5568' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-8);
}

/* Checkbox & Radio */
.form-check { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary-500); cursor: pointer; }
.form-check-label { font-size: var(--font-size-sm); color: var(--neutral-700); }

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px; height: 24px;
    background: var(--neutral-300);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-base);
    flex-shrink: 0;
}
.toggle.active { background: var(--primary-500); }
.toggle .toggle-knob {
    position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: white;
    border-radius: var(--radius-full);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-sm);
}
.toggle.active .toggle-knob { transform: translateX(20px); }

/* ══════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════ */

.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.table thead { background: var(--neutral-50); }
.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: var(--font-weight-semibold);
    color: var(--neutral-600);
    border-bottom: 2px solid var(--neutral-200);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--neutral-100); color: var(--neutral-700); }
.table tbody tr:hover { background: var(--primary-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ══════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════ */

.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    justify-content: center;
    margin-top: var(--space-6);
}
.pagination .page-btn {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-base);
    background: white;
    color: var(--neutral-600);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    min-height: 36px;
}
.pagination .page-btn:hover:not(.active):not(.disabled) { background: var(--neutral-50); border-color: var(--primary-300); }
.pagination .page-btn.active { background: var(--primary-500); color: white; border-color: var(--primary-500); }
.pagination .page-btn.disabled { opacity: 0.5; cursor: not-allowed; }

/* ══════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════ */

.empty-state { text-align: center; padding: var(--space-10) var(--space-6); }
.empty-icon { font-size: 64px; color: var(--neutral-300); margin-bottom: var(--space-4); }
.empty-title { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); color: var(--neutral-700); margin-bottom: var(--space-2); }
.empty-description { color: var(--neutral-500); max-width: 400px; margin: 0 auto var(--space-4); }

/* ══════════════════════════════════════════════
   GRID
   ══════════════════════════════════════════════ */

.grid { display: grid; gap: var(--space-4); }
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.grid-cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ══════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════ */

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--neutral-500); }
.text-primary { color: var(--primary-600); }
.text-accent  { color: var(--accent-500); }
.text-success { color: var(--color-success-500); }
.text-error   { color: var(--color-error-500); }
.font-bold      { font-weight: var(--font-weight-bold); }
.font-semibold  { font-weight: var(--font-weight-semibold); }
.font-medium    { font-weight: var(--font-weight-medium); }

.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); } .mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); } .mb-6 { margin-bottom: var(--space-6); }
.p-1 { padding: var(--space-1); } .p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); } .p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); } .p-6 { padding: var(--space-6); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.rounded { border-radius: var(--radius-base); }
.rounded-full { border-radius: var(--radius-full); }
.shadow { box-shadow: var(--shadow-base); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* ══════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.4s ease forwards; }

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}
.slide-in { animation: slideIn 0.3s ease forwards; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}
.pulse { animation: pulse 2s ease-in-out infinite; }

@keyframes spin {
    to { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; }

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */

@media (max-width: 1280px) { .container { max-width: var(--container-lg); } }
@media (max-width: 1024px) {
    .container { max-width: var(--container-md); }
    .grid-cols-3 { grid-template-columns: 1fr 1fr; }
    .grid-cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .container { padding: 0 var(--space-3); }
    .grid-cols-2 { grid-template-columns: 1fr; }
    .grid-cols-3 { grid-template-columns: 1fr; }
    .grid-cols-4 { grid-template-columns: 1fr 1fr; }
    h1 { font-size: var(--font-size-3xl); }
    h2 { font-size: var(--font-size-2xl); }
    h3 { font-size: var(--font-size-xl); }
}
@media (max-width: 480px) {
    .grid-cols-4 { grid-template-columns: 1fr 1fr; }
    .btn { font-size: var(--font-size-xs); padding: var(--space-1) var(--space-3); }
}

/* ══════════════════════════════════════════════
   SKELETON LOADING
   ══════════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(90deg, var(--neutral-200) 25%, var(--neutral-100) 50%, var(--neutral-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-base);
}
.skeleton-text { height: 16px; margin-bottom: var(--space-2); }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 24px; width: 40%; margin-bottom: var(--space-4); }
.skeleton-card { height: 200px; border-radius: var(--radius-lg); }
.skeleton-avatar { width: 48px; height: 48px; border-radius: var(--radius-full); }
.skeleton-btn { height: 40px; width: 120px; border-radius: var(--radius-base); }
.skeleton-image { height: 160px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

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

/* ══════════════════════════════════════════════
   STEPPER / PROGRESS STEPS
   ══════════════════════════════════════════════ */

.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}
.stepper-step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
}
.stepper-step .step-circle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    border: 2px solid var(--neutral-300);
    color: var(--neutral-400);
    background: #fff;
    transition: all var(--transition-base);
    flex-shrink: 0;
}
.stepper-step .step-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--neutral-500);
    transition: color var(--transition-base);
}
.stepper-step.active .step-circle {
    border-color: var(--primary-500);
    background: var(--primary-500);
    color: #fff;
}
.stepper-step.active .step-label {
    color: var(--primary-600);
    font-weight: var(--font-weight-semibold);
}
.stepper-step.completed .step-circle {
    border-color: var(--color-success-500);
    background: var(--color-success-500);
    color: #fff;
}
.stepper-step.completed .step-label {
    color: var(--color-success-500);
}
.stepper-line {
    flex: 1;
    min-width: 32px;
    height: 2px;
    background: var(--neutral-200);
    margin: 0 var(--space-2);
    transition: background var(--transition-base);
}
.stepper-line.completed {
    background: var(--color-success-500);
}
.stepper-line.active {
    background: linear-gradient(90deg, var(--color-success-500), var(--primary-400));
}

/* ══════════════════════════════════════════════
   PIPELINE TWO-PHASE V2
   ══════════════════════════════════════════════ */

.pipeline-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}
@media (max-width: 768px) {
    .pipeline-container { grid-template-columns: 1fr; }
}

.pipeline-phase {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    padding: var(--space-5);
}
.pipeline-phase-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--neutral-100);
}
.pipeline-phase-num {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-extrabold);
    font-size: var(--font-size-lg);
    flex-shrink: 0;
}
.pipeline-phase.phase-1 .pipeline-phase-num { background: var(--primary-100); color: var(--primary-600); }
.pipeline-phase.phase-2 .pipeline-phase-num { background: var(--accent-100); color: var(--accent-500); }
.pipeline-phase-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    margin: 0;
}
.pipeline-phase.phase-1 .pipeline-phase-title { color: var(--primary-800); }
.pipeline-phase.phase-2 .pipeline-phase-title { color: var(--accent-500); }
.pipeline-phase-desc {
    font-size: var(--font-size-sm);
    color: var(--neutral-500);
    margin: var(--space-1) 0 0;
}
.pipeline-step-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.pipeline-step-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--neutral-700);
}
.pipeline-step-item .step-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}
.pipeline-step-item.done .step-dot { background: var(--color-success-500); }
.pipeline-step-item.current .step-dot { background: var(--primary-500); box-shadow: 0 0 0 3px rgba(58,157,245,0.2); }
.pipeline-step-item.pending .step-dot { background: var(--neutral-300); }
.pipeline-step-item.done { color: var(--neutral-500); }
.pipeline-step-item.done .step-check { color: var(--color-success-500); margin-left: auto; }

/* ══════════════════════════════════════════════
   STATUS PILLS
   ══════════════════════════════════════════════ */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}
.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}
.status-pill.success { background: var(--color-success-100); color: var(--color-success-500); }
.status-pill.success::before { background: var(--color-success-500); }
.status-pill.warning { background: var(--color-warning-100); color: var(--color-warning-500); }
.status-pill.warning::before { background: var(--color-warning-500); }
.status-pill.error { background: var(--color-error-100); color: var(--color-error-500); }
.status-pill.error::before { background: var(--color-error-500); }
.status-pill.info { background: var(--primary-100); color: var(--primary-600); }
.status-pill.info::before { background: var(--primary-600); }
.status-pill.neutral { background: var(--neutral-100); color: var(--neutral-600); }
.status-pill.neutral::before { background: var(--neutral-400); }
.status-pill.pending { background: #FEF3C7; color: #92400E; }
.status-pill.pending::before { background: #D97706; }
.status-pill.approved { background: #D1FAE5; color: #065F46; }
.status-pill.approved::before { background: #059669; }

/* ══════════════════════════════════════════════
   QUIZ PREVIEW CARD
   ══════════════════════════════════════════════ */

.quiz-preview-card {
    border: 2px dashed var(--primary-300);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    background: var(--primary-50);
    margin-top: var(--space-3);
}
.quiz-preview-card .quiz-question {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--neutral-800);
    margin-bottom: var(--space-3);
}
.quiz-preview-card .quiz-option {
    padding: var(--space-2) var(--space-3);
    margin: var(--space-1) 0;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-base);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    background: #fff;
}
.quiz-preview-card .quiz-option:hover { background: var(--primary-100); border-color: var(--primary-400); }
.quiz-preview-card .quiz-option.correct { background: var(--color-success-100); border-color: var(--color-success-500); font-weight: var(--font-weight-semibold); }
.quiz-preview-card .quiz-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--primary-200);
}

/* ══════════════════════════════════════════════
   MODULE CARD
   ══════════════════════════════════════════════ */

.module-card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    overflow: hidden;
    transition: all var(--transition-base);
}
.module-card:hover { box-shadow: var(--shadow-md); }
.module-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    background: var(--neutral-50);
    border-bottom: 1px solid var(--neutral-200);
    cursor: pointer;
}
.module-card-header .module-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
    color: var(--neutral-800);
}
.module-card-header .module-num {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--primary-500);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
}
.module-card-body {
    padding: var(--space-5);
}
.module-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--neutral-100);
    background: var(--neutral-50);
}
.module-card .module-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}
/* ============================================
   SIVRA V9 — Layout (sidebar + main content)
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* alias — layout.html uses .app-layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
    width: 280px;
    background: var(--neutral-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-fixed, 1030);
    transition: transform var(--transition-base, 0.25s ease);
    overflow-y: auto;
}

.sidebar-brand {
    padding: var(--space-5, 24px) var(--space-6, 32px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    text-decoration: none;
    color: white;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-accent, linear-gradient(135deg, #FF6B35 0%, #FF8A5C 100%));
    border-radius: var(--radius-md, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-extrabold, 800);
    font-size: var(--font-size-xl, 1.25rem);
    color: white;
    flex-shrink: 0;
}

.brand-text {
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-bold, 700);
}

.brand-text span {
    color: var(--accent-500, #FF6B35);
}

/* ----- Navigation ----- */
.sidebar-nav {
    flex: 1;
    padding: var(--space-4, 16px) var(--space-3, 12px);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: var(--space-5, 24px);
}

.nav-section-title {
    font-size: var(--font-size-xs, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--neutral-500, #718096);
    padding: 0 var(--space-3, 12px);
    margin-bottom: var(--space-2, 8px);
    font-weight: var(--font-weight-semibold, 600);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    padding: var(--space-2, 8px) var(--space-3, 12px);
    border-radius: var(--radius-base, 8px);
    color: var(--neutral-400, #A0AEC0);
    text-decoration: none;
    transition: all var(--transition-fast, 0.15s ease);
    cursor: pointer;
    position: relative;
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
    margin-bottom: 1px;
    min-height: 44px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.nav-item.active {
    background: rgba(58, 157, 245, 0.15);
    color: var(--primary-300, #A0D1FB);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--primary-500, #3A9DF5);
    border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0;
}

.nav-item .icon {
    width: 20px;
    text-align: center;
    font-size: var(--font-size-base, 1rem);
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent-500, #FF6B35);
    color: white;
    font-size: var(--font-size-xs, 0.75rem);
    padding: 1px 8px;
    border-radius: var(--radius-full, 9999px);
    font-weight: var(--font-weight-semibold, 600);
}

/* ----- Sidebar Footer / User ----- */
.sidebar-footer {
    padding: var(--space-4, 16px) var(--space-6, 32px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full, 9999px);
    background: var(--gradient-primary, linear-gradient(135deg, #0F4C81 0%, #2586D9 100%));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold, 700);
    font-size: var(--font-size-sm, 0.875rem);
    color: white;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-semibold, 600);
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--neutral-400, #A0AEC0);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--neutral-500, #718096);
    cursor: pointer;
    font-size: var(--font-size-base, 1rem);
    transition: color var(--transition-fast, 0.15s ease);
    padding: var(--space-2, 8px);
    border-radius: var(--radius-full, 9999px);
}

.logout-btn:hover {
    color: var(--color-error-500, #E53E3E);
    background: rgba(229, 62, 62, 0.1);
}

/* ----- Main Content ----- */
.main-content {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1;
    padding: var(--space-6, 32px) var(--space-8, 48px);
}

/* ----- Sidebar Overlay (mobile only) ----- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-fixed, 1030) - 1);
}

.sidebar-overlay.active {
    display: block;
}

/* ----- Collapsed Sidebar ----- */
.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}
.sidebar.collapsed > * {
    opacity: 0;
    pointer-events: none;
}

/* Floating toggle button — always visible at the left edge */
.sidebar-collapse-btn {
    position: fixed;
    top: 14px;
    left: 280px;
    z-index: calc(var(--z-fixed, 1030) + 2);
    background: var(--neutral-900);
    border: 1px solid rgba(255,255,255,0.1);
    border-left: none;
    color: var(--neutral-400);
    cursor: pointer;
    font-size: var(--font-size-sm);
    width: 24px;
    height: 48px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.25s ease, background 0.15s, color 0.15s;
}
.sidebar-collapse-btn:hover {
    color: #fff;
    background: var(--neutral-800);
    border-color: rgba(255,255,255,0.2);
}

/* When collapsed, button moves to left edge */
.sidebar.collapsed ~ .sidebar-collapse-btn,
.app-container:has(.sidebar.collapsed) .sidebar-collapse-btn {
    left: 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border-left: 1px solid rgba(255,255,255,0.1);
}

/* Main content expands full width when sidebar collapsed */
.main-content.expanded {
    margin-left: 0;
}

/* Smooth transitions */
.sidebar {
    transition: width var(--transition-base, 0.25s ease);
}
.main-content {
    transition: margin-left var(--transition-base, 0.25s ease);
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-collapse-btn {
        display: none;
    }
    .page-content {
        padding: var(--space-4, 16px);
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        max-width: 280px;
    }
}

/* Desktop: always show sidebar (ignore localStorage collapsed state) */
@media (min-width: 1200px) {
    .sidebar.collapsed {
        width: 280px;
        overflow-y: auto;
    }
    .sidebar.collapsed > * {
        opacity: 1;
        pointer-events: auto;
    }
    .main-content.expanded {
        margin-left: 280px;
    }
    .sidebar-collapse-btn {
        left: 280px;
    }
}

/* ============================================
   SIVRA V9 — Top Bar (header styles)
   ============================================ */

.topbar {
    background: white;
    border-bottom: 1px solid var(--neutral-200);
    padding: var(--space-3) var(--space-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.92);
    gap: var(--space-4);
    min-height: 72px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex: 1;
    min-width: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    color: var(--neutral-600);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-base);
    transition: background var(--transition-fast);
}
.menu-toggle:hover { background: var(--neutral-100); }

.page-header {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.page-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--neutral-800);
    margin: 0;
    line-height: 1.2;
}
.page-title small {
    font-weight: var(--font-weight-regular);
    font-size: var(--font-size-sm);
    color: var(--neutral-500);
    margin-left: var(--space-2);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--neutral-500);
}
.breadcrumb a { color: var(--primary-600); text-decoration: none; transition: color var(--transition-fast); }
.breadcrumb a:hover { color: var(--primary-800); }
.breadcrumb .separator { color: var(--neutral-300); font-size: 8px; }
.breadcrumb .current { color: var(--neutral-700); font-weight: var(--font-weight-medium); }

/* ----- Topbar Right ----- */
.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.topbar-center {
    flex: 1;
    text-align: center;
}
.topbar-center h2 {
    font-size: var(--text-lg, 1.125rem);
    font-weight: var(--font-semibold, 600);
    margin: 0;
    color: var(--color-text-primary, #1E293B);
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    background: var(--neutral-100);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    gap: var(--space-3);
    transition: all var(--transition-base);
    border: 2px solid transparent;
    position: relative;
    min-width: 220px;
}
.search-box:focus-within {
    background: white;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px rgba(58, 157, 245, 0.1);
}
.search-box input {
    border: none; background: none; outline: none;
    font-size: var(--font-size-sm);
    color: var(--neutral-700);
    width: 180px;
    font-family: var(--font-family);
}
.search-box input::placeholder { color: var(--neutral-400); }
.search-icon { color: var(--neutral-400); font-size: var(--font-size-sm); }
.search-shortcut {
    font-size: var(--font-size-xs);
    color: var(--neutral-400);
    background: var(--neutral-200);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-family-mono);
}

/* Icon Buttons */
.icon-btn {
    position: relative;
    background: none;
    border: none;
    width: 40px; height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--neutral-600);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-lg);
}
.icon-btn:hover { background: var(--neutral-100); color: var(--primary-600); }
.icon-btn .notification-count {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--accent-500);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
    border: 2px solid white;
}

/* ----- Notifications Dropdown ----- */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--neutral-200);
    min-width: 380px;
    max-width: 420px;
    max-height: 480px;
    overflow: hidden;
    z-index: var(--z-dropdown);
}
.dropdown-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: var(--font-weight-semibold);
}
.dropdown-body { max-height: 360px; overflow-y: auto; }
.dropdown-footer { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--neutral-200); }
.notification-empty { padding: var(--space-6); text-align: center; color: var(--neutral-400); }
.notification-empty i { font-size: 32px; display: block; margin-bottom: var(--space-2); }

/* ----- Responsive ----- */
@media (max-width: 1024px) {
    .search-box { min-width: 160px; }
    .search-box input { width: 120px; }
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .topbar { padding: var(--space-3) var(--space-4); }
    .page-title small { display: none; }
    .search-box { min-width: auto; padding: var(--space-2); }
    .search-box input { width: 0; padding: 0; opacity: 0; }
    .search-box:focus-within input { width: 140px; padding: 0 var(--space-2); opacity: 1; }
    .search-shortcut { display: none; }
    .dropdown-menu {
        position: fixed;
        top: 72px;
        left: var(--space-4);
        right: var(--space-4);
        min-width: auto;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .topbar .icon-btn { width: 36px; height: 36px; font-size: var(--font-size-base); }
    .page-title { font-size: var(--font-size-lg); }
}/* ============================================
   TOAST — Notification Styles (SIVRA LMS)
   Dependencies: variables.css
   ============================================ */

/* Container — fixed top-right */
.sivra-toast-container {
    position: fixed;
    top: var(--space-5, 24px);
    right: var(--space-5, 24px);
    z-index: var(--z-toast, 1070);
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 12px);
    pointer-events: none;
    max-width: 400px;
    width: 100%;
}

/* Individual toast */
.sivra-toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3, 12px);
    padding: var(--space-4, 16px);
    border-radius: var(--radius-md, 12px);
    background: white;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.08));
    border-left: 4px solid var(--neutral-400, #A0AEC0);
    pointer-events: auto;
    animation: sivra-toast-in 0.3s ease forwards;
    font-family: var(--font-family, 'Inter', sans-serif);
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--neutral-800, #161B22);
    line-height: var(--line-height-base, 1.5);
    word-break: break-word;
}

.sivra-toast-removing {
    animation: sivra-toast-out 0.25s ease forwards;
}

/* Toast icon */
.sivra-toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg, 1.125rem);
    margin-top: 1px;
}

/* Toast message */
.sivra-toast-message {
    flex: 1;
}

/* Toast dismiss button */
.sivra-toast-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--neutral-500, #718096);
    font-size: var(--font-size-lg, 1.125rem);
    transition: color var(--transition-fast, 150ms ease);
    line-height: 1;
}
.sivra-toast-dismiss:hover {
    color: var(--neutral-800, #161B22);
}

/* ----- Type variants ----- */

.sivra-toast--success {
    border-left-color: var(--color-success-500, #38A169);
    background: var(--color-success-100, #F0FFF4);
}
.sivra-toast--success .sivra-toast-icon {
    color: var(--color-success-500, #38A169);
}

.sivra-toast--error {
    border-left-color: var(--color-error-500, #E53E3E);
    background: var(--color-error-100, #FFF5F5);
}
.sivra-toast--error .sivra-toast-icon {
    color: var(--color-error-500, #E53E3E);
}

.sivra-toast--warning {
    border-left-color: var(--color-warning-500, #D69E2E);
    background: var(--color-warning-100, #FFFAF0);
}
.sivra-toast--warning .sivra-toast-icon {
    color: var(--color-warning-500, #D69E2E);
}

.sivra-toast--info {
    border-left-color: var(--primary-500, #3A9DF5);
    background: var(--primary-100, #E6F2FE);
}
.sivra-toast--info .sivra-toast-icon {
    color: var(--primary-500, #3A9DF5);
}

/* ----- Animations ----- */

@keyframes sivra-toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes sivra-toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 150px;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
        max-height: 150px;
    }
}

/* ----- Responsive ----- */

@media (max-width: 480px) {
    .sivra-toast-container {
        top: var(--space-3, 12px);
        right: var(--space-3, 12px);
        left: var(--space-3, 12px);
        max-width: none;
    }
}
/* ============================================
   LOADER — Spinner & Overlay Styles (SIVRA LMS)
   Dependencies: variables.css
   ============================================ */

/* Overlay */
.sivra-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1040);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Spinner container */
.sivra-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4, 16px);
    padding: var(--space-8, 48px);
    border-radius: var(--radius-lg, 16px);
    background: white;
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0,0,0,0.08));
}

/* Spinner circle */
.sivra-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--neutral-200, #E2E8F0);
    border-top-color: var(--primary-500, #3A9DF5);
    border-radius: var(--radius-full, 9999px);
    animation: sivra-spin 0.7s linear infinite;
}

/* Larger spinner variant */
.sivra-spinner-lg {
    width: 56px;
    height: 56px;
    border-width: 5px;
}

/* Smaller spinner variant */
.sivra-spinner-sm {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

/* Message text */
.sivra-loader-message {
    font-family: var(--font-family, 'Inter', sans-serif);
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
    color: var(--neutral-600, #4A5568);
    text-align: center;
    margin: 0;
    max-width: 240px;
    line-height: var(--line-height-base, 1.5);
}

/* ----- Animation ----- */

@keyframes sivra-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ----- Inline spinner (no overlay) ----- */

.sivra-loader-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2, 8px);
}
.sivra-loader-inline .sivra-spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
}
/* ============================================
   MODAL — Dialog Styles (SIVRA LMS)
   Dependencies: variables.css
   ============================================ */

/* Overlay */
.sivra-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1040);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: sivra-modal-fade-in 0.2s ease;
}

/* Dialog */
.sivra-modal {
    background: white;
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(0,0,0,0.15));
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: sivra-modal-scale-in 0.2s ease;
    overflow: hidden;
}

/* Modal sizes */
.sivra-modal-sm { max-width: 400px; }
.sivra-modal-lg { max-width: 720px; }
.sivra-modal-xl { max-width: 960px; }

/* Header */
.sivra-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5, 24px) var(--space-6, 32px);
    border-bottom: 1px solid var(--neutral-200, #E2E8F0);
    flex-shrink: 0;
}

.sivra-modal-title {
    font-family: var(--font-family, 'Inter', sans-serif);
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--neutral-900, #0D1117);
    margin: 0;
    line-height: var(--line-height-tight, 1.25);
}

/* Close button */
.sivra-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-base, 8px);
    color: var(--neutral-500, #718096);
    font-size: 22px;
    line-height: 1;
    transition: all var(--transition-fast, 150ms ease);
    flex-shrink: 0;
}
.sivra-modal-close:hover {
    background: var(--neutral-100, #EDF2F7);
    color: var(--neutral-800, #161B22);
}

/* Body */
.sivra-modal-body {
    padding: var(--space-5, 24px) var(--space-6, 32px);
    overflow-y: auto;
    flex: 1;
    font-family: var(--font-family, 'Inter', sans-serif);
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--neutral-700, #2D333B);
    line-height: var(--line-height-base, 1.5);
}

/* Animations */
@keyframes sivra-modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes sivra-modal-scale-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .sivra-modal {
        width: 96%;
        max-height: 90vh;
    }
    .sivra-modal-header {
        padding: var(--space-4, 16px) var(--space-4, 16px);
    }
    .sivra-modal-body {
        padding: var(--space-4, 16px);
    }
}
/* ============================================
   SIVRA V9 — Progress / Certificates / History
   ============================================ */

/* ── Progress Summary Header ── */
.progress-header-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-base);
}
.progress-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
}
.summary-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
.summary-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    flex-shrink: 0;
}
.summary-icon.blue   { background: var(--primary-100); color: var(--primary-600); }
.summary-icon.green  { background: var(--color-success-100); color: var(--color-success-500); }
.summary-icon.orange { background: var(--accent-100);  color: var(--accent-500); }
.summary-data {
    display: flex;
    flex-direction: column;
}
.summary-value {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--neutral-900);
    line-height: 1.2;
}
.summary-label {
    font-size: var(--font-size-sm);
    color: var(--neutral-500);
    font-weight: var(--font-weight-medium);
}

/* ── Trail Cards (Progress) ── */
.trail-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.trail-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    padding: var(--space-5);
    transition: all var(--transition-base);
}
.trail-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-200);
}
.trail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}
.trail-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--neutral-800);
    margin: 0;
}
.trail-progress-row {
    margin-bottom: var(--space-3);
}
.trail-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
}
.trail-progress-label {
    color: var(--neutral-600);
    font-weight: var(--font-weight-medium);
}
.trail-progress-value {
    color: var(--primary-600);
    font-weight: var(--font-weight-semibold);
}
.trail-meta {
    display: flex;
    gap: var(--space-5);
    font-size: var(--font-size-sm);
    color: var(--neutral-500);
    margin-top: var(--space-3);
}
.trail-meta i {
    width: 16px;
    margin-right: var(--space-1);
}

/* ── Certificate Cards ── */
.certificates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-5);
}
.certificate-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    overflow: hidden;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
}
.certificate-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}
.certificate-ribbon {
    background: linear-gradient(135deg, #D69E2E 0%, #F6E05E 100%);
    padding: var(--space-5);
    text-align: center;
    font-size: 48px;
    color: white;
}
.certificate-body {
    padding: var(--space-5);
    flex: 1;
}
.certificate-trail-name {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--neutral-800);
    margin-bottom: var(--space-4);
}
.certificate-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.certificate-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.detail-label {
    font-size: var(--font-size-sm);
    color: var(--neutral-500);
}
.detail-label i {
    width: 18px;
    margin-right: var(--space-1);
}
.detail-value {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--neutral-700);
}
.detail-value.score {
    color: var(--color-warning-500);
    font-size: var(--font-size-lg);
}
.certificate-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--neutral-100);
}

/* ── History Timeline ── */
.history-timeline {
    position: relative;
    padding-left: var(--space-8);
}
.history-timeline::before {
    content: '';
    position: absolute;
    left: 19px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--neutral-200);
}
.timeline-item {
    position: relative;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-5);
}
.timeline-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
}
.timeline-marker {
    position: absolute;
    left: calc(-1 * var(--space-8) + 4px);
    top: 4px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    color: white;
    z-index: 1;
    border: 3px solid white;
}
.marker-accent { background: var(--accent-500); }
.marker-blue   { background: var(--primary-500); }
.marker-green  { background: var(--color-success-500); }
.marker-gold   { background: var(--color-warning-500); }
.timeline-content {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    padding: var(--space-4) var(--space-5);
    transition: all var(--transition-base);
}
.timeline-content:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-200);
}
.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}
.timeline-date {
    font-size: var(--font-size-xs);
    color: var(--neutral-400);
}
.timeline-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--neutral-800);
    margin: 0 0 var(--space-1);
}
.timeline-detail {
    font-size: var(--font-size-sm);
    color: var(--neutral-500);
    margin: 0;
    line-height: 1.5;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .progress-summary-grid {
        grid-template-columns: 1fr;
    }
    .certificates-grid {
        grid-template-columns: 1fr;
    }
    .trail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    .trail-meta {
        flex-direction: column;
        gap: var(--space-1);
    }
    .history-timeline {
        padding-left: var(--space-7);
    }
    .timeline-marker {
        left: calc(-1 * var(--space-7) + 3px);
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
}
/* app/static/css/student-layout.css — SIVRA V9 Student Layout v5 */
/* ================================================================ */
/* Premium sidebar design — PostgreSQL Blue palette                */

:root {
    --sidebar-w: 260px;
    --sidebar-bg: #111b27;
    --sidebar-hover: rgba(255,255,255,.05);
    --sidebar-active: rgba(51,103,145,.30);
    --sidebar-text: rgba(255,255,255,.90);
    --sidebar-muted: rgba(255,255,255,.40);
    --sidebar-border: rgba(255,255,255,.06);
    --sidebar-accent: #5C8DB5;
    --header-h: 56px;
    --header-bg: #fff;
    --header-shadow: 0 1px 2px rgba(0,0,0,.04);
    --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ═══════════════════════════════════════ */
/* App Container                           */
/* ═══════════════════════════════════════ */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

.d-flex {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ═══════════════════════════════════════ */
/* Header                                  */
/* ═══════════════════════════════════════ */

.student-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 1.5rem;
    background: var(--header-bg);
    box-shadow: var(--header-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    min-width: 0;
    border-bottom: 1px solid var(--color-border-light);
    backdrop-filter: blur(8px);
}

.student-header .sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    padding: .4rem .5rem;
    margin-right: .75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
    min-width: 36px;
    min-height: 36px;
}

.student-header .sidebar-toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-primary);
}

.student-header .page-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.01em;
}

.student-header .header-right {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
}

.student-header .icon-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: .45rem;
    border-radius: 8px;
    position: relative;
    transition: background var(--transition), color var(--transition);
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.student-header .icon-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

.student-header .search-box {
    display: flex;
    align-items: center;
    gap: .4rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    padding: .4rem .75rem;
    transition: var(--transition);
}

.student-header .search-box:focus-within {
    background: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(51,103,145,.12);
}

.student-header .search-box i { color: var(--color-text-tertiary); font-size: .85rem; }

.student-header .search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: .85rem;
    width: 160px;
    color: var(--color-text-primary);
    font-family: var(--font-family);
}

.student-header .search-box input::placeholder { color: var(--color-text-tertiary); }
.student-header .search-box input:focus { width: 220px; }

.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ═══════════════════════════════════════ */
/* Sidebar                                 */
/* ═══════════════════════════════════════ */

.student-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    max-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(.4,0,.2,1), min-width 0.3s cubic-bezier(.4,0,.2,1), max-width 0.3s cubic-bezier(.4,0,.2,1), transform 0.3s cubic-bezier(.4,0,.2,1);
    z-index: 200;
}

.student-sidebar.collapsed {
    min-width: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
}

/* ═══════════════════════════════════════ */
/* Sidebar Brand                           */
/* ═══════════════════════════════════════ */

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    min-height: 60px;
}

.sidebar-brand h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    white-space: nowrap;
    letter-spacing: -.01em;
}

.sidebar-brand small {
    display: block;
    font-size: .65rem;
    color: var(--sidebar-muted);
    font-weight: 400;
    margin-top: 2px;
    letter-spacing: .02em;
}

/* ═══════════════════════════════════════ */
/* Sidebar Collapse Button                 */
/* ═══════════════════════════════════════ */

.sidebar-collapse-btn {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.06);
    color: var(--sidebar-muted);
    font-size: .85rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
    border-color: rgba(255,255,255,.12);
}

/* ═══════════════════════════════════════ */
/* Sidebar User                            */
/* ═══════════════════════════════════════ */

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    background: rgba(0,0,0,.12);
}

.sidebar-user-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background .15s ease;
    position: relative;
}

.sidebar-user-link:hover,
.sidebar-user-link.active {
    background: rgba(255,255,255,.08);
}

.sidebar-user-chevron {
    margin-left: auto;
    color: rgba(255,255,255,.35);
    font-size: .7rem;
    flex-shrink: 0;
}

.sidebar-user-link:hover .sidebar-user-chevron {
    color: rgba(255,255,255,.8);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--pg-blue-500), var(--pg-blue-300));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(51,103,145,.3);
}

.sidebar-user-name {
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    letter-spacing: -.01em;
}

.sidebar-user-role {
    font-size: .7rem;
    color: var(--sidebar-muted);
    margin-top: 1px;
}

/* ═══════════════════════════════════════ */
/* Sidebar Menu                            */
/* ═══════════════════════════════════════ */

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .5rem 0 .75rem;
}

.sidebar-section-label {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--sidebar-muted);
    padding: 1rem 1.5rem .35rem;
    white-space: nowrap;
}

.sidebar-section-label:first-child { padding-top: .25rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.5rem;
    margin: 0 .5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition), padding-left var(--transition);
    position: relative;
    white-space: nowrap;
    border-radius: 10px;
    min-height: 44px;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    padding-left: 1.75rem;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 55%;
    background: var(--sidebar-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: .95rem;
    flex-shrink: 0;
    opacity: .80;
    transition: opacity var(--transition), transform var(--transition);
}

.sidebar-link.active i { opacity: 1; }
.sidebar-link:hover i { opacity: 1; transform: scale(1.08); }

.sidebar-link .sidebar-label {
    white-space: nowrap;
}

.sidebar-link .badge {
    margin-left: auto;
    background: var(--sidebar-accent);
    color: #fff;
    font-size: .625rem;
    font-weight: 700;
    padding: .12rem .5rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    line-height: 1.5;
}

/* ═══════════════════════════════════════ */
/* Main Content                            */
/* ═══════════════════════════════════════ */

main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    background: var(--color-bg);
    transition: margin-left var(--transition);
}

body.sidebar-collapsed main { margin-left: 0; }

/* ═══════════════════════════════════════ */
/* Toast                                   */
/* ═══════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.25rem;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: slideIn .3s ease;
}

.toast.success { background: #059669; }
.toast.warning { background: #d97706; }
.toast.error   { background: #dc2626; }
.toast.info    { background: var(--color-primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ═══════════════════════════════════════ */
/* Mobile (< 1024px): overlay             */
/* ═══════════════════════════════════════ */

@media (max-width: 1024px) {
    .student-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: var(--sidebar-w);
        min-width: var(--sidebar-w);
        max-width: var(--sidebar-w);
        z-index: 300;
        box-shadow: 4px 0 24px rgba(0,0,0,.40);
        transform: translateX(-100%);
        margin-left: 0;
        transition: transform var(--transition);
    }

    .student-sidebar.collapsed { transform: translateX(-100%); margin-left: 0; }
    .student-sidebar:not(.collapsed) { transform: translateX(0); margin-left: 0; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 299;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition);
    }

    .sidebar-overlay.active { opacity: 1; pointer-events: auto; }
    main { margin-left: 0 !important; }
    .student-header .search-box input { width: 100px; }
    .student-header .search-box input:focus { width: 140px; }
}

/* ═══════════════════════════════════════ */
/* Desktop (≥ 1025px): slide-left         */
/* ═══════════════════════════════════════ */

@media (min-width: 1025px) {
    .student-sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        height: calc(100vh - var(--header-h));
        transform: translateX(0);
        margin-left: 0;
        box-shadow: none;
        transition: transform var(--transition), margin-left var(--transition),
                    min-width var(--transition), width var(--transition), max-width var(--transition);
    }

    .student-sidebar.collapsed {
        transform: translateX(calc(-1 * var(--sidebar-w)));
        margin-left: calc(-1 * var(--sidebar-w));
        min-width: 0; width: 0; max-width: 0;
    }

    main { margin-left: var(--sidebar-w); transition: margin-left var(--transition); }
}

@media (min-width: 1025px) {
    .student-sidebar.collapsed {
        transform: none !important;
        margin-left: 0 !important;
        min-width: 0 !important;
        width: 0 !important;
        max-width: 0 !important;
    }
}

/* Desktop (>= 1200px): always show sidebar */
@media (min-width: 1200px) {
    .student-sidebar.collapsed {
        transform: none !important;
        margin-left: 0 !important;
        min-width: var(--sidebar-w) !important;
        width: var(--sidebar-w) !important;
        max-width: var(--sidebar-w) !important;
    }
    body.sidebar-collapsed main { margin-left: var(--sidebar-w); }
}

/* ═══════════════════════════════════════ */
/* Layout fixes                            */
/* ═══════════════════════════════════════ */

.d-flex {
    display: flex;
    align-items: flex-start;
    max-width: 100vw;
    overflow: hidden;
}

.student-sidebar {
    padding-top: 0;
    margin-top: 0;
    flex: 0 0 auto;
    transition: width .3s ease, min-width .3s ease;
}

.student-sidebar .sidebar-brand { padding-top: 1.25rem; }

.d-flex > main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    transition: flex .3s ease;
}

.page-content { padding-top: 0 !important; }
.hero-banner, .page-hero { padding-top: 1.25rem !important; margin-top: 0; }

*, *::before, *::after { box-sizing: border-box; }

body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── Accessibility (WCAG 2.1 AA) ── */
:focus-visible { outline: 3px solid #6366f1; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -100px; left: 8px; z-index: 9999; background: #6366f1; color: #fff; padding: 8px 16px; border-radius: 0 0 8px 8px; text-decoration: none; font-weight: 600; transition: top .2s; }
.skip-link:focus { top: 0; }
/* Enhanced contrast — WCAG AA */
.text-muted, [style*="color:#64748b"] { color: #94A3B8 !important; }
/* Keyboard */
*:focus-visible { outline: 3px solid #6366f1 !important; outline-offset: 2px !important; }
