
/* === styles/tokens.css === */
/* ============================================================
   SCHOLARIA DESIGN TOKENS
   Single source of truth for all visual values.
   All component and page CSS should reference these variables.

   Breakpoints (mobile-first, use min-width):
     --bp-sm:  640px   (large phones landscape)
     --bp-md:  768px   (tablets)
     --bp-lg:  1024px  (small laptops / desktop nav threshold)
     --bp-xl:  1280px  (desktops)
     --bp-2xl: 1536px  (large monitors)
   ============================================================ */

:root {
  /* ---- Colors: Primary ---- */
  --color-primary: #0066cc;
  --color-primary-dark: #004d99;
  --color-primary-darker: #003d7a;
  --color-primary-light: #e6f0ff;
  --color-primary-hover: #0056b3;

  /* ---- Colors: Secondary ---- */
  --color-secondary: #00ccff;
  --color-secondary-dark: #00a3cc;
  --color-secondary-light: #e0f9ff;

  /* ---- Colors: Status ---- */
  --color-success: #28a745;
  --color-success-dark: #1e7e34;
  --color-success-light: #d4edda;
  --color-success-bg: #f0faf3;

  --color-warning: #ffc107;
  --color-warning-dark: #d39e00;
  --color-warning-light: #fff3cd;
  --color-warning-bg: #fffdf5;

  --color-danger: #dc3545;
  --color-danger-dark: #bd2130;
  --color-danger-light: #f8d7da;
  --color-danger-bg: #fef2f2;

  --color-info: #17a2b8;
  --color-info-dark: #117a8b;
  --color-info-light: #d1ecf1;
  --color-info-bg: #f0f9fb;

  /* ---- Colors: Neutral (Gray scale) ---- */
  --color-gray-50:  #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;

  /* ---- Colors: Semantic ---- */
  --color-surface: #ffffff;
  --color-background: #f9fafb;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-text-tertiary: #9ca3af;
  --color-text-inverse: #ffffff;
  --color-border: #e5e7eb;
  --color-border-dark: #d1d5db;
  --color-overlay: rgba(0, 0, 0, 0.5);

  /* ---- Typography ---- */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  --font-size-xs:  0.75rem;   /* 12px */
  --font-size-sm:  0.875rem;  /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg:  1.125rem;  /* 18px */
  --font-size-xl:  1.25rem;   /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */

  --line-height-tight:   1.25;
  --line-height-snug:    1.375;
  --line-height-normal:  1.5;
  --line-height-relaxed: 1.625;

  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide:   0.025em;

  /* ---- Spacing (4px base) ---- */
  --space-0:  0;
  --space-px: 1px;
  --space-0-5: 0.125rem; /* 2px */
  --space-1:  0.25rem;   /* 4px */
  --space-1-5: 0.375rem; /* 6px */
  --space-2:  0.5rem;    /* 8px */
  --space-2-5: 0.625rem; /* 10px */
  --space-3:  0.75rem;   /* 12px */
  --space-3-5: 0.875rem; /* 14px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-7:  1.75rem;   /* 28px */
  --space-8:  2rem;      /* 32px */
  --space-9:  2.25rem;   /* 36px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-14: 3.5rem;    /* 56px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */

  /* ---- Border Radius ---- */
  --radius-none: 0;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* ---- Shadows (elevation levels) ---- */
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.07), 0 4px 6px rgba(0, 0, 0, 0.04);
  --shadow-xl:  0 20px 25px rgba(0, 0, 0, 0.08), 0 8px 10px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.05);

  /* ---- Transitions ---- */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 500ms ease;

  /* ---- Z-index scale ---- */
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-fixed:     300;
  --z-drawer:    400;
  --z-modal:     500;
  --z-popover:   600;
  --z-toast:     700;
  --z-tooltip:   800;

  /* ---- Layout ---- */
  --container-max: 1280px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --topbar-height: 60px;
  --bottombar-height: 64px;
  --touch-target: 44px;

  /* ---- Focus ring ---- */
  --focus-ring: 0 0 0 3px var(--color-primary-light);
  --focus-ring-danger: 0 0 0 3px var(--color-danger-light);
}

/* ============================================================
   DARK MODE
   Activates via OS preference or manual [data-theme="dark"]
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #4d9fff;
    --color-primary-dark: #3385e6;
    --color-primary-darker: #1a6cd4;
    --color-primary-light: #1a2e4a;
    --color-primary-hover: #66b0ff;

    --color-secondary: #33d6ff;
    --color-secondary-dark: #00b8e6;
    --color-secondary-light: #0d2e3a;

    --color-success: #34d058;
    --color-success-dark: #28a745;
    --color-success-light: #1a3a25;
    --color-success-bg: #0d1f14;

    --color-warning: #ffca28;
    --color-warning-dark: #ffc107;
    --color-warning-light: #3a3018;
    --color-warning-bg: #1f1a0d;

    --color-danger: #f85149;
    --color-danger-dark: #dc3545;
    --color-danger-light: #3a1a1a;
    --color-danger-bg: #1f0d0d;

    --color-info: #33bbcc;
    --color-info-dark: #17a2b8;
    --color-info-light: #0d2e33;
    --color-info-bg: #0d1f22;

    --color-gray-50:  #111827;
    --color-gray-100: #1f2937;
    --color-gray-200: #374151;
    --color-gray-300: #4b5563;
    --color-gray-400: #6b7280;
    --color-gray-500: #9ca3af;
    --color-gray-600: #d1d5db;
    --color-gray-700: #e5e7eb;
    --color-gray-800: #f3f4f6;
    --color-gray-900: #f9fafb;

    --color-surface: #1f2937;
    --color-background: #111827;
    --color-text: #f9fafb;
    --color-text-secondary: #d1d5db;
    --color-text-tertiary: #9ca3af;
    --color-text-inverse: #111827;
    --color-border: #374151;
    --color-border-dark: #4b5563;
    --color-overlay: rgba(0, 0, 0, 0.7);

    --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.2);
    --shadow-xl:  0 20px 25px rgba(0, 0, 0, 0.35), 0 8px 10px rgba(0, 0, 0, 0.2);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.5);

    --focus-ring: 0 0 0 3px var(--color-primary-light);
    --focus-ring-danger: 0 0 0 3px var(--color-danger-light);
  }
}

[data-theme="dark"] {
  --color-primary: #4d9fff;
  --color-primary-dark: #3385e6;
  --color-primary-darker: #1a6cd4;
  --color-primary-light: #1a2e4a;
  --color-primary-hover: #66b0ff;

  --color-secondary: #33d6ff;
  --color-secondary-dark: #00b8e6;
  --color-secondary-light: #0d2e3a;

  --color-success: #34d058;
  --color-success-dark: #28a745;
  --color-success-light: #1a3a25;
  --color-success-bg: #0d1f14;

  --color-warning: #ffca28;
  --color-warning-dark: #ffc107;
  --color-warning-light: #3a3018;
  --color-warning-bg: #1f1a0d;

  --color-danger: #f85149;
  --color-danger-dark: #dc3545;
  --color-danger-light: #3a1a1a;
  --color-danger-bg: #1f0d0d;

  --color-info: #33bbcc;
  --color-info-dark: #17a2b8;
  --color-info-light: #0d2e33;
  --color-info-bg: #0d1f22;

  --color-gray-50:  #111827;
  --color-gray-100: #1f2937;
  --color-gray-200: #374151;
  --color-gray-300: #4b5563;
  --color-gray-400: #6b7280;
  --color-gray-500: #9ca3af;
  --color-gray-600: #d1d5db;
  --color-gray-700: #e5e7eb;
  --color-gray-800: #f3f4f6;
  --color-gray-900: #f9fafb;

  --color-surface: #1f2937;
  --color-background: #111827;
  --color-text: #f9fafb;
  --color-text-secondary: #d1d5db;
  --color-text-tertiary: #9ca3af;
  --color-text-inverse: #111827;
  --color-border: #374151;
  --color-border-dark: #4b5563;
  --color-overlay: rgba(0, 0, 0, 0.7);

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.2);
  --shadow-xl:  0 20px 25px rgba(0, 0, 0, 0.35), 0 8px 10px rgba(0, 0, 0, 0.2);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.5);

  --focus-ring: 0 0 0 3px var(--color-primary-light);
  --focus-ring-danger: 0 0 0 3px var(--color-danger-light);
}

/* === styles/base.css === */
/* ============================================================
   SCHOLARIA BASE STYLES
   Modern CSS reset + sensible defaults consuming design tokens.
   Loaded after tokens.css, before any component or page CSS.
   ============================================================ */

/* ---- Box Model Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ---- Margin / Padding Reset ---- */
* {
  margin: 0;
  padding: 0;
}

/* ---- Document ---- */
html {
  font-size: 100%; /* 16px base for rem calculations */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Body ---- */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

@media (min-width: 768px) {
  h1 { font-size: var(--font-size-4xl); }
  h2 { font-size: var(--font-size-3xl); }
  h3 { font-size: var(--font-size-2xl); }
}

p {
  line-height: var(--line-height-relaxed);
  color: var(--color-text-secondary);
}

small {
  font-size: var(--font-size-sm);
}

strong, b {
  font-weight: var(--font-weight-semibold);
}

/* ---- Links ---- */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* ---- Lists ---- */
ul, ol {
  list-style: none;
}

/* ---- Media ---- */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

/* ---- Form Elements ---- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

input,
textarea,
select {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2-5) var(--space-3);
  min-height: var(--touch-target);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-tertiary);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.22 4.22a.75.75 0 0 1 1.06 0L6 6.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L2.22 5.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-10);
}

label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-1-5);
}

fieldset {
  border: none;
}

/* ---- Table Base ---- */
table {
  border-collapse: collapse;
  width: 100%;
}

th {
  text-align: left;
  font-weight: var(--font-weight-semibold);
}

/* ---- Horizontal Rule ---- */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

/* ---- Code ---- */
code, pre {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
}

pre {
  overflow-x: auto;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background-color: var(--color-gray-100);
}

/* ---- Focus Styles (Accessibility) ---- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Selection ---- */
::selection {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ---- Scrollbar (Webkit) ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

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

/* ---- Print ---- */
@media print {
  body {
    background: white;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }
}

/* === styles/utilities.css === */
/* ============================================================
   SCHOLARIA UTILITY CLASSES
   Small, single-purpose classes that replace inline styles.
   Use sparingly — prefer component classes for complex patterns.
   ============================================================ */

/* ---- Text Colors ---- */
.text-primary   { color: var(--color-primary) !important; }
.text-success   { color: var(--color-success) !important; }
.text-danger    { color: var(--color-danger) !important; }
.text-warning   { color: var(--color-warning-dark) !important; }
.text-info      { color: var(--color-info) !important; }
.text-muted     { color: var(--color-text-tertiary) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-inverse   { color: var(--color-text-inverse) !important; }

/* ---- Background Colors ---- */
.bg-surface     { background-color: var(--color-surface) !important; }
.bg-muted       { background-color: var(--color-gray-100) !important; }
.bg-primary     { background-color: var(--color-primary) !important; }
.bg-success     { background-color: var(--color-success-bg) !important; }
.bg-danger      { background-color: var(--color-danger-bg) !important; }
.bg-warning     { background-color: var(--color-warning-bg) !important; }
.bg-info        { background-color: var(--color-info-bg) !important; }

/* ---- Text Alignment ---- */
.text-left   { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right  { text-align: right !important; }

/* ---- Text Size ---- */
.text-xs   { font-size: var(--font-size-xs) !important; }
.text-sm   { font-size: var(--font-size-sm) !important; }
.text-base { font-size: var(--font-size-base) !important; }
.text-lg   { font-size: var(--font-size-lg) !important; }
.text-xl   { font-size: var(--font-size-xl) !important; }
.text-2xl  { font-size: var(--font-size-2xl) !important; }

/* ---- Font Weight ---- */
.font-normal   { font-weight: var(--font-weight-normal) !important; }
.font-medium   { font-weight: var(--font-weight-medium) !important; }
.font-semibold { font-weight: var(--font-weight-semibold) !important; }
.font-bold     { font-weight: var(--font-weight-bold) !important; }

/* ---- Text Utilities ---- */
.truncate {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.line-clamp-2 {
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden !important;
}

.line-clamp-3 {
  display: -webkit-box !important;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden !important;
}

.uppercase { text-transform: uppercase !important; }
.capitalize { text-transform: capitalize !important; }
.no-wrap { white-space: nowrap !important; }

/* ---- Display ---- */
.d-none    { display: none !important; }
.d-block   { display: block !important; }
.d-flex    { display: flex !important; }
.d-grid    { display: grid !important; }
.d-inline  { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }

/* ---- Responsive Display ---- */
@media (min-width: 640px) {
  .sm\:d-none  { display: none !important; }
  .sm\:d-block { display: block !important; }
  .sm\:d-flex  { display: flex !important; }
}

@media (min-width: 768px) {
  .md\:d-none  { display: none !important; }
  .md\:d-block { display: block !important; }
  .md\:d-flex  { display: flex !important; }
}

@media (min-width: 1024px) {
  .lg\:d-none  { display: none !important; }
  .lg\:d-block { display: block !important; }
  .lg\:d-flex  { display: flex !important; }
}

/* ---- Flexbox Utilities ---- */
.flex-row    { flex-direction: row !important; }
.flex-col    { flex-direction: column !important; }
.flex-wrap   { flex-wrap: wrap !important; }
.flex-1      { flex: 1 1 0% !important; }
.flex-auto   { flex: 1 1 auto !important; }
.flex-none   { flex: none !important; }

.items-start   { align-items: flex-start !important; }
.items-center  { align-items: center !important; }
.items-end     { align-items: flex-end !important; }
.items-stretch { align-items: stretch !important; }

.justify-start   { justify-content: flex-start !important; }
.justify-center  { justify-content: center !important; }
.justify-end     { justify-content: flex-end !important; }
.justify-between { justify-content: space-between !important; }
.justify-around  { justify-content: space-around !important; }

/* ---- Gap ---- */
.gap-1 { gap: var(--space-1) !important; }
.gap-2 { gap: var(--space-2) !important; }
.gap-3 { gap: var(--space-3) !important; }
.gap-4 { gap: var(--space-4) !important; }
.gap-5 { gap: var(--space-5) !important; }
.gap-6 { gap: var(--space-6) !important; }
.gap-8 { gap: var(--space-8) !important; }

/* ---- Margin ---- */
.m-0  { margin: 0 !important; }
.m-auto { margin: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mt-6 { margin-top: var(--space-6) !important; }
.mt-8 { margin-top: var(--space-8) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-3) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }
.mb-6 { margin-bottom: var(--space-6) !important; }
.mb-8 { margin-bottom: var(--space-8) !important; }
.ml-auto { margin-left: auto !important; }
.mr-2 { margin-right: var(--space-2) !important; }
.mr-3 { margin-right: var(--space-3) !important; }

/* ---- Padding ---- */
.p-0 { padding: 0 !important; }
.p-2 { padding: var(--space-2) !important; }
.p-3 { padding: var(--space-3) !important; }
.p-4 { padding: var(--space-4) !important; }
.p-5 { padding: var(--space-5) !important; }
.p-6 { padding: var(--space-6) !important; }
.p-8 { padding: var(--space-8) !important; }
.px-3 { padding-left: var(--space-3) !important; padding-right: var(--space-3) !important; }
.px-4 { padding-left: var(--space-4) !important; padding-right: var(--space-4) !important; }
.px-6 { padding-left: var(--space-6) !important; padding-right: var(--space-6) !important; }
.py-2 { padding-top: var(--space-2) !important; padding-bottom: var(--space-2) !important; }
.py-3 { padding-top: var(--space-3) !important; padding-bottom: var(--space-3) !important; }
.py-4 { padding-top: var(--space-4) !important; padding-bottom: var(--space-4) !important; }

/* ---- Width / Height ---- */
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }
.h-full { height: 100% !important; }
.min-h-screen { min-height: 100vh !important; }

/* ---- Border ---- */
.border     { border: 1px solid var(--color-border) !important; }
.border-0   { border: 0 !important; }
.border-t   { border-top: 1px solid var(--color-border) !important; }
.border-b   { border-bottom: 1px solid var(--color-border) !important; }
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded    { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

/* ---- Shadow ---- */
.shadow-none { box-shadow: none !important; }
.shadow-sm   { box-shadow: var(--shadow-sm) !important; }
.shadow      { box-shadow: var(--shadow-md) !important; }
.shadow-lg   { box-shadow: var(--shadow-lg) !important; }

/* ---- Overflow ---- */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto   { overflow: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }

/* ---- Position ---- */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed    { position: fixed !important; }
.sticky   { position: sticky !important; }

/* ---- Cursor ---- */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }

/* ---- Accessibility ---- */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border-width: 0 !important;
}

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

.visually-hidden:focus,
.visually-hidden:active {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: inherit !important;
}

/* ---- Opacity ---- */
.opacity-0   { opacity: 0 !important; }
.opacity-50  { opacity: 0.5 !important; }
.opacity-75  { opacity: 0.75 !important; }
.opacity-100 { opacity: 1 !important; }

/* ---- Badges (inline status indicators) ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-0-5) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--primary {
  background-color: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.badge--success {
  background-color: var(--color-success-light);
  color: var(--color-success-dark);
}

.badge--danger {
  background-color: var(--color-danger-light);
  color: var(--color-danger-dark);
}

.badge--warning {
  background-color: var(--color-warning-light);
  color: var(--color-warning-dark);
}

.badge--info {
  background-color: var(--color-info-light);
  color: var(--color-info-dark);
}

.badge--neutral {
  background-color: var(--color-gray-200);
  color: var(--color-gray-700);
}

/* ---- Avatar ---- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: var(--font-size-xs);
}

.avatar--md {
  width: 40px;
  height: 40px;
  font-size: var(--font-size-sm);
}

.avatar--lg {
  width: 48px;
  height: 48px;
  font-size: var(--font-size-base);
}

.avatar--xl {
  width: 64px;
  height: 64px;
  font-size: var(--font-size-lg);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

@media (min-width: 640px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

/* ---- Page Content Wrapper (works with sidebar layout) ---- */
.page-content {
  padding: var(--space-4);
  padding-bottom: calc(var(--bottombar-height) + var(--space-4));
}

@media (min-width: 1024px) {
  .page-content {
    margin-left: var(--sidebar-width);
    padding: var(--space-6) var(--space-8);
    padding-bottom: var(--space-6);
  }

  .sidebar-collapsed .page-content {
    margin-left: var(--sidebar-collapsed);
  }
}

/* ---- Page Header (title + actions area) ---- */
.page-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.page-header__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.page-header__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media (min-width: 640px) {
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--color-text-secondary);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.empty-state__description {
  font-size: var(--font-size-sm);
  max-width: 400px;
  margin: 0 auto var(--space-6);
}

/* ---- Divider ---- */
.divider {
  height: 1px;
  background-color: var(--color-border);
  margin: var(--space-4) 0;
}

/* === styles/nav.css === */
/* ============================================================
   SCHOLARIA NAVIGATION SYSTEM
   Mobile: compact top bar + fixed bottom tab bar + drawer
   Desktop: left sidebar + top utility bar
   ============================================================ */

/* ---- Top Bar (mobile + desktop) ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.topbar__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.topbar__school-name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.topbar__spacer {
  flex: 1;
}

/* Top bar actions (notification bell, user avatar) */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.topbar__icon-btn:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
}

.topbar__icon-btn svg {
  width: 22px;
  height: 22px;
}

.topbar__notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background-color: var(--color-danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.topbar__user:hover {
  background-color: var(--color-gray-100);
}

.topbar__user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  display: none;
}

/* ---- Sidebar Toggle Button (mobile) ---- */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: background-color var(--transition-fast);
}

.sidebar-toggle:hover {
  background-color: var(--color-gray-100);
}

.sidebar-toggle svg {
  width: 22px;
  height: 22px;
}

/* ============================================================
   SIDEBAR (desktop, drawer on mobile)
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition-slow), width var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.is-open {
  transform: translateX(0);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: var(--color-overlay);
  z-index: calc(var(--z-drawer) - 1);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.sidebar-overlay.is-visible {
  display: block;
  opacity: 1;
}

/* Sidebar header */
.sidebar__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar__school-info {
  overflow: hidden;
}

.sidebar__school-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  text-transform: capitalize;
}

/* Sidebar navigation groups */
.sidebar__nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
}

.sidebar__group {
  margin-bottom: var(--space-2);
}

.sidebar__group-label {
  padding: var(--space-2) var(--space-5);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-5);
  margin: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  min-height: var(--touch-target);
}

.sidebar__item:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
  text-decoration: none;
}

.sidebar__item.is-active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
}

.sidebar__item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__item-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar__item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar footer */
.sidebar__footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-2);
  flex-shrink: 0;
}

.sidebar__footer .sidebar__item {
  color: var(--color-text-secondary);
}

.sidebar__footer .sidebar__item--danger {
  color: var(--color-danger);
}

.sidebar__footer .sidebar__item--danger:hover {
  background-color: var(--color-danger-bg);
  color: var(--color-danger-dark);
}

/* ============================================================
   BOTTOM TAB BAR (mobile only)
   ============================================================ */
.bottom-tabs {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottombar-height);
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-fixed);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-tabs__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-0-5);
  padding: var(--space-1) 0;
  color: var(--color-text-tertiary);
  text-decoration: none;
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: var(--touch-target);
}

.bottom-tabs__item:hover {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.bottom-tabs__item.is-active {
  color: var(--color-primary);
}

.bottom-tabs__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-tabs__icon svg {
  width: 24px;
  height: 24px;
}

.bottom-tabs__label {
  line-height: 1;
}

/* ============================================================
   MORE DRAWER (mobile: slides up from bottom)
   ============================================================ */
.more-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background-color: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: var(--z-drawer);
  transform: translateY(100%);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
}

.more-drawer.is-open {
  transform: translateY(0);
}

.more-drawer__handle {
  display: flex;
  justify-content: center;
  padding: var(--space-3) 0 var(--space-2);
  cursor: grab;
}

.more-drawer__handle-bar {
  width: 36px;
  height: 4px;
  background-color: var(--color-gray-300);
  border-radius: var(--radius-full);
}

.more-drawer__content {
  padding: 0 var(--space-4) var(--space-6);
}

.more-drawer__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: background-color var(--transition-fast);
  min-height: var(--touch-target);
}

.more-drawer__item:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
  text-decoration: none;
}

.more-drawer__item.is-active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

.more-drawer__item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.more-drawer__item-icon svg {
  width: 20px;
  height: 20px;
}

.more-drawer__section-label {
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.more-drawer__divider {
  height: 1px;
  background-color: var(--color-border);
  margin: var(--space-2) 0;
}

.more-drawer__item--danger {
  color: var(--color-danger);
}

.more-drawer__item--danger:hover {
  background-color: var(--color-danger-bg);
}

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.breadcrumbs {
  margin-bottom: var(--space-4);
}

.breadcrumbs__list {
  display: none;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
}

.breadcrumbs__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.breadcrumbs__link {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumbs__link:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumbs__current {
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.breadcrumbs__separator {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

/* Mobile: show back button instead of full breadcrumb trail */
.breadcrumbs__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  padding: var(--space-1) 0;
  transition: color var(--transition-fast);
}

.breadcrumbs__back:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumbs__back svg {
  flex-shrink: 0;
}

/* ============================================================
   DESKTOP LAYOUT OVERRIDES (>= 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  /* Show sidebar always on desktop */
  .sidebar {
    transform: translateX(0);
  }

  /* Collapsed sidebar */
  .sidebar.is-collapsed {
    width: var(--sidebar-collapsed);
  }

  .sidebar.is-collapsed .sidebar__school-info,
  .sidebar.is-collapsed .sidebar__item-label,
  .sidebar.is-collapsed .sidebar__group-label {
    display: none;
  }

  .sidebar.is-collapsed .sidebar__item {
    justify-content: center;
    padding: var(--space-2-5) var(--space-3);
    margin: var(--space-0-5) var(--space-1);
  }

  .sidebar.is-collapsed .sidebar__header {
    justify-content: center;
    padding: var(--space-4) var(--space-3);
  }

  /* Hide overlay on desktop */
  .sidebar-overlay {
    display: none !important;
  }

  /* Hide bottom tabs on desktop */
  .bottom-tabs {
    display: none;
  }

  /* Hide more drawer on desktop */
  .more-drawer {
    display: none;
  }

  /* Top bar adjustments */
  .topbar {
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
  }

  .sidebar.is-collapsed ~ .topbar,
  .sidebar-collapsed .topbar {
    margin-left: var(--sidebar-collapsed);
  }

  .topbar__school-name {
    display: none; /* shown in sidebar instead */
  }

  .topbar__user-name {
    display: block;
  }

  /* Hide mobile sidebar toggle on desktop */
  .sidebar-toggle {
    display: none;
  }

  /* Show sidebar collapse toggle */
  .sidebar__collapse-btn {
    display: inline-flex;
  }

  /* Breadcrumbs: show full trail on desktop, hide back button */
  .breadcrumbs__list {
    display: flex;
  }

  .breadcrumbs__back {
    display: none;
  }
}

/* Mobile: hide sidebar collapse button, show toggle */
@media (max-width: 1023px) {
  .sidebar__collapse-btn {
    display: none;
  }
}

/* ---- Sidebar collapse toggle button ---- */
.sidebar__collapse-btn {
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--color-text-tertiary);
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  z-index: 1;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.sidebar__collapse-btn:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
}

.sidebar__collapse-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-base);
}

.sidebar.is-collapsed .sidebar__collapse-btn svg {
  transform: rotate(180deg);
}

/* ============================================================
   GLOBAL SEARCH (in topbar)
   ============================================================ */
.global-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: none;
}

.global-search__input {
  width: 100%;
  height: 38px;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-10);
  background-color: var(--color-gray-100);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.global-search__input:focus {
  background-color: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.global-search__icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.global-search__icon svg {
  width: 18px;
  height: 18px;
}

.global-search__shortcut {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  background-color: var(--color-gray-200);
  padding: var(--space-0-5) var(--space-1-5);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

@media (min-width: 768px) {
  .global-search {
    display: block;
  }
}

/* ---- Search Dropdown (desktop) ---- */
.global-search { position: relative; }
.search-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  min-width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
}
.search-dropdown__category { padding: var(--space-1) 0; }
.search-dropdown__category-label {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search-dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  color: var(--color-text-primary);
  transition: background var(--transition-fast);
  cursor: pointer;
}
.search-dropdown__item:hover,
.search-dropdown__item.is-active {
  background: var(--color-hover);
}
.search-dropdown__item-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: var(--color-gray-100);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}
.search-dropdown__item-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}
.search-dropdown__item-subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}
.search-dropdown__empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* ---- Search Overlay (mobile full-screen) ---- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  visibility: hidden;
}
.search-overlay.is-open {
  transform: translateY(0);
  visibility: visible;
}
.search-overlay__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.search-overlay__back {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.search-overlay__back:hover { background: var(--color-hover); }
.search-overlay__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--font-size-base);
  font-family: inherit;
  background: transparent;
  color: var(--color-text-primary);
  padding: var(--space-2);
}
.search-overlay__results {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

/* === styles/components/buttons.css === */
/* ============================================================
   BUTTON COMPONENT
   Touch-friendly (44px min), consistent variants, sizes.
   ============================================================ */

/* ---- Base button ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: var(--space-2-5) var(--space-5);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- Variants ---- */

/* Primary (solid blue) */
.btn--primary {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

.btn--primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  text-decoration: none;
  color: var(--color-text-inverse);
}

.btn--primary:active {
  background-color: var(--color-primary-dark);
}

/* Secondary (outlined) */
.btn--secondary {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn--secondary:hover {
  background-color: var(--color-primary-light);
  text-decoration: none;
  color: var(--color-primary);
}

/* Danger (solid red) */
.btn--danger {
  background-color: var(--color-danger);
  color: var(--color-text-inverse);
  border-color: var(--color-danger);
}

.btn--danger:hover {
  background-color: var(--color-danger-dark);
  border-color: var(--color-danger-dark);
  text-decoration: none;
  color: var(--color-text-inverse);
}

/* Danger outlined */
.btn--danger-outline {
  background-color: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn--danger-outline:hover {
  background-color: var(--color-danger-bg);
  text-decoration: none;
  color: var(--color-danger);
}

/* Success (solid green) */
.btn--success {
  background-color: var(--color-success);
  color: var(--color-text-inverse);
  border-color: var(--color-success);
}

.btn--success:hover {
  background-color: var(--color-success-dark);
  border-color: var(--color-success-dark);
  text-decoration: none;
  color: var(--color-text-inverse);
}

/* Warning */
.btn--warning {
  background-color: var(--color-warning);
  color: var(--color-gray-900);
  border-color: var(--color-warning);
}

.btn--warning:hover {
  background-color: var(--color-warning-dark);
  border-color: var(--color-warning-dark);
  text-decoration: none;
  color: var(--color-gray-900);
}

/* Ghost (transparent) */
.btn--ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn--ghost:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
  text-decoration: none;
}

/* Light (soft background) */
.btn--light {
  background-color: var(--color-gray-100);
  color: var(--color-text);
  border-color: var(--color-gray-100);
}

.btn--light:hover {
  background-color: var(--color-gray-200);
  border-color: var(--color-gray-200);
  text-decoration: none;
  color: var(--color-text);
}

/* ---- Sizes ---- */
.btn--sm {
  min-height: 34px;
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--font-size-xs);
}

.btn--lg {
  min-height: 52px;
  padding: var(--space-3) var(--space-8);
  font-size: var(--font-size-base);
}

/* ---- Icon button (circular) ---- */
.btn--icon {
  width: var(--touch-target);
  height: var(--touch-target);
  padding: 0;
  border-radius: var(--radius-full);
}

.btn--icon svg {
  width: 20px;
  height: 20px;
}

.btn--icon.btn--sm {
  width: 34px;
  height: 34px;
}

.btn--icon.btn--sm svg {
  width: 16px;
  height: 16px;
}

/* ---- Button with icon + text ---- */
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ---- Button group ---- */
.btn-group {
  display: inline-flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-group .btn + .btn {
  margin-left: -1px;
}

/* ---- Full width (mobile default) ---- */
.btn--block {
  width: 100%;
}

@media (min-width: 640px) {
  .btn--block-mobile {
    width: auto;
  }
}

/* ---- Loading state ---- */
.btn.is-loading {
  color: transparent;
  pointer-events: none;
  position: relative;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: btn-spin 0.6s linear infinite;
}

.btn--primary.is-loading::after,
.btn--danger.is-loading::after,
.btn--success.is-loading::after {
  border-color: var(--color-text-inverse);
  border-right-color: transparent;
}

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

/* === styles/components/cards.css === */
/* ============================================================
   CARD COMPONENT
   Base cards, stat cards, interactive cards, grid layout.
   ============================================================ */

/* ---- Base card ---- */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.card__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-0-5);
}

.card__body {
  padding: var(--space-5);
}

.card__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background-color: var(--color-gray-50);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ---- Interactive card (clickable) ---- */
.card--interactive {
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

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

.card--interactive:active {
  transform: translateY(0);
}

/* ---- Card with border instead of shadow ---- */
.card--outlined {
  box-shadow: none;
  border: 1px solid var(--color-border);
}

.card--outlined:hover {
  border-color: var(--color-primary);
}

/* ---- Stat card (dashboard metrics) ---- */
.stat-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

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

.stat-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card__icon svg {
  width: 22px;
  height: 22px;
}

.stat-card__icon--primary {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

.stat-card__icon--success {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.stat-card__icon--danger {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.stat-card__icon--warning {
  background-color: var(--color-warning-light);
  color: var(--color-warning-dark);
}

.stat-card__icon--info {
  background-color: var(--color-info-light);
  color: var(--color-info);
}

.stat-card__value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  line-height: var(--line-height-tight);
}

.stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.stat-card__trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.stat-card__trend--up {
  color: var(--color-success);
}

.stat-card__trend--down {
  color: var(--color-danger);
}

.stat-card__trend svg {
  width: 14px;
  height: 14px;
}

/* ---- Card grid ---- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

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

@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* ---- Stat card grid (dashboard) ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---- Profile card ---- */
.profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
}

.profile-card__info {
  flex: 1;
  min-width: 0;
}

.profile-card__name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-card__detail {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

/* === styles/components/forms.css === */
/* ============================================================
   FORM COMPONENT
   Mobile-first forms with floating labels, touch-friendly sizing,
   validation states, and responsive layout.
   ============================================================ */

/* ---- Form container ---- */
.form {
  width: 100%;
}

.form--card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

@media (min-width: 640px) {
  .form--card {
    padding: var(--space-6) var(--space-8);
  }
}

/* ---- Form section ---- */
.form__section {
  margin-bottom: var(--space-6);
}

.form__section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

/* ---- Form group (label + input + help text) ---- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group__label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-1-5);
}

.form-group__required {
  color: var(--color-danger);
  margin-left: var(--space-0-5);
}

.form-group__help {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

/* ---- Input base overrides ---- */
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-2-5) var(--space-3);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-tertiary);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.22 4.22a.75.75 0 0 1 1.06 0L6 6.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L2.22 5.28a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-10);
}

/* ---- Validation states ---- */
.form-group.is-error .form-input,
.form-group.is-error .form-select,
.form-group.is-error .form-textarea,
.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: var(--color-danger);
}

.form-group.is-error .form-input:focus,
.form-group.is-error .form-select:focus,
.form-group.is-error .form-textarea:focus {
  box-shadow: var(--focus-ring-danger);
}

.form-group__error {
  display: none;
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
}

.form-group.is-error .form-group__error {
  display: block;
}

.form-group.is-success .form-input,
.form-group.is-success .form-select {
  border-color: var(--color-success);
}

/* ---- Floating label pattern ---- */
.form-floating {
  position: relative;
}

.form-floating .form-input,
.form-floating .form-select,
.form-floating .form-textarea {
  padding-top: var(--space-5);
  padding-bottom: var(--space-2);
}

.form-floating .form-floating__label {
  position: absolute;
  top: 0;
  left: 0;
  padding: var(--space-3) var(--space-3);
  font-size: var(--font-size-base);
  color: var(--color-text-tertiary);
  pointer-events: none;
  transform-origin: left top;
  transition: transform var(--transition-fast), font-size var(--transition-fast), color var(--transition-fast);
}

.form-floating .form-input:focus ~ .form-floating__label,
.form-floating .form-input:not(:placeholder-shown) ~ .form-floating__label,
.form-floating .form-select:focus ~ .form-floating__label,
.form-floating .form-select:not([value=""]) ~ .form-floating__label,
.form-floating .form-textarea:focus ~ .form-floating__label,
.form-floating .form-textarea:not(:placeholder-shown) ~ .form-floating__label {
  transform: translateY(-6px);
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
}

/* ---- Form row (side-by-side on desktop) ---- */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media (min-width: 640px) {
  .form-row {
    flex-direction: row;
    gap: var(--space-4);
  }

  .form-row > .form-group {
    flex: 1;
  }
}

/* ---- Checkbox & Radio ---- */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: var(--space-1) 0;
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: auto;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.form-check__label {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}

/* ---- Toggle switch ---- */
.form-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  min-height: var(--touch-target);
}

.form-toggle__track {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: var(--color-gray-300);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

.form-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.form-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: white;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.form-toggle input:checked ~ .form-toggle__track {
  background-color: var(--color-primary);
}

.form-toggle input:checked ~ .form-toggle__track .form-toggle__thumb {
  transform: translateX(20px);
}

.form-toggle input:focus-visible ~ .form-toggle__track {
  box-shadow: var(--focus-ring);
}

.form-toggle__label {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

/* ---- File upload ---- */
.form-file {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: var(--space-6);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-gray-50);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  text-align: center;
}

.form-file:hover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.form-file.is-dragover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.form-file input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  min-height: auto;
}

.form-file__icon {
  width: 32px;
  height: 32px;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
}

.form-file__text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.form-file__text strong {
  color: var(--color-primary);
}

.form-file__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

/* ---- Form actions (submit/cancel row) ---- */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-6);
}

@media (min-width: 640px) {
  .form-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .form-actions .btn {
    width: auto;
  }
}

/* ---- Disabled state ---- */
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background-color: var(--color-gray-100);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
  opacity: 0.7;
}

/* === styles/components/data-table.css === */
/* ============================================================
   DATA TABLE COMPONENT
   Desktop: standard table with sticky header, sorting, bulk select
   Mobile: transforms into stacked card layout via CSS
   ============================================================ */

/* ---- Table wrapper ---- */
.data-table-wrapper {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ---- Toolbar (above table: filters, search, bulk actions) ---- */
.data-table__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.data-table__toolbar-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.data-table__toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.data-table__search {
  min-width: 200px;
  height: 38px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-gray-50);
}

.data-table__search:focus {
  background-color: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
  outline: none;
}

/* ---- Filter panel (collapsible on mobile) ---- */
.data-table__filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-gray-50);
}

.data-table__filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.data-table__filter-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.data-table__filter-toggle svg {
  width: 16px;
  height: 16px;
}

.data-table__filters.is-collapsed {
  display: none;
}

/* ---- Table base (desktop) ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background-color: var(--color-gray-50);
  border-bottom: 2px solid var(--color-border);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-secondary);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background-color: var(--color-gray-50);
  z-index: 1;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: var(--color-gray-50);
}

.data-table tbody tr:nth-child(even) {
  background-color: var(--color-gray-50);
}

.data-table tbody tr:nth-child(even):hover {
  background-color: var(--color-gray-100);
}

/* Sortable column header */
.data-table__sortable {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.data-table__sortable:hover {
  color: var(--color-primary);
}

.data-table__sort-icon {
  width: 14px;
  height: 14px;
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.data-table__sortable:hover .data-table__sort-icon,
.data-table__sortable.is-sorted .data-table__sort-icon {
  opacity: 1;
}

.data-table__sortable.is-sorted-desc .data-table__sort-icon {
  transform: rotate(180deg);
}

/* Checkbox column */
.data-table__checkbox {
  width: 44px;
  text-align: center;
}

.data-table__checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: auto;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* Selected row */
.data-table tbody tr.is-selected {
  background-color: var(--color-primary-light);
}

/* ---- Bulk actions bar ---- */
.data-table__bulk-bar {
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-primary-light);
  border-bottom: 1px solid var(--color-border);
}

.data-table__bulk-bar.is-visible {
  display: flex;
}

.data-table__bulk-count {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}

/* ---- Pagination ---- */
.data-table__pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.data-table__page-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.data-table__page-size {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  min-height: 32px;
  width: auto;
}

.data-table__page-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.data-table__page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background-color: var(--color-surface);
  transition: all var(--transition-fast);
}

.data-table__page-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.data-table__page-btn.is-active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.data-table__page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Empty state ---- */
.data-table__empty {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--color-text-tertiary);
}

.data-table__empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
  opacity: 0.3;
}

/* ---- Cell helpers ---- */
.data-table__cell--primary {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.data-table__cell--actions {
  white-space: nowrap;
  text-align: right;
}

.data-table__cell--actions a,
.data-table__cell--actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.data-table__cell--actions a:hover,
.data-table__cell--actions button:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
}

/* ---- Compact variant ---- */
.data-table--compact th,
.data-table--compact td {
  padding: var(--space-2) var(--space-3);
}

/* ============================================================
   JS-ENHANCED DATA TABLE (scripts/data-table.js)
   ============================================================ */

/* Controls bar (search + page size) */
.dt-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.dt-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.dt-search:focus-within {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.dt-search svg { flex-shrink: 0; color: var(--color-text-secondary); }

.dt-search__input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  min-height: auto;
  padding: 0;
}

.dt-page-size {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.dt-page-size__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.dt-page-size__select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  min-height: 32px;
  width: auto;
  background: var(--color-surface);
  color: var(--color-text);
}

/* Sort icon in headers */
.dt-sort-icon {
  display: inline-flex;
  margin-left: var(--space-1);
  opacity: 0.3;
  transition: all var(--transition-fast);
  vertical-align: middle;
}

.dt-sort-icon.is-active { opacity: 1; color: var(--color-primary); }

th:hover .dt-sort-icon { opacity: 0.6; }

/* JS-driven pagination */
.dt-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  margin-top: var(--space-3);
}

.dt-pagination__info {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.dt-pagination__nav {
  display: flex;
  gap: var(--space-1);
}

.dt-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dt-pagination__btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.dt-pagination__btn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.dt-pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Bulk bar */
.dt-bulk-bar {
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-light, rgba(0, 102, 204, 0.08));
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.dt-bulk-bar__count {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}

/* ============================================================
   MOBILE: Card layout (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  .data-table__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table__toolbar-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .data-table__search {
    min-width: 0;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3);
  }

  .data-table tbody tr {
    display: block;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-xs);
  }

  .data-table tbody tr:nth-child(even) {
    background-color: var(--color-surface);
  }

  .data-table tbody tr:hover {
    box-shadow: var(--shadow-sm);
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-gray-100);
  }

  .data-table td:last-child {
    border-bottom: none;
  }

  /* Column label from data-label attribute */
  .data-table td::before {
    content: attr(data-label);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    flex-shrink: 0;
    margin-right: var(--space-3);
  }

  /* Hide checkbox column label on mobile */
  .data-table td.data-table__checkbox::before {
    display: none;
  }

  /* Actions cell: full width row */
  .data-table td.data-table__cell--actions {
    justify-content: flex-end;
    padding-top: var(--space-3);
    border-bottom: none;
  }

  .data-table td.data-table__cell--actions::before {
    display: none;
  }

  /* Pagination stacks on mobile */
  .data-table__pagination {
    flex-direction: column;
    align-items: center;
  }

  /* Bulk bar sticks to bottom on mobile */
  .data-table__bulk-bar.is-visible {
    position: fixed;
    bottom: var(--bottombar-height);
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    border-top: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
  }
}

/* === styles/components/alerts.css === */
/* ============================================================
   ALERT COMPONENT
   Contextual messages with left border accent.
   Replaces duplicate .success-message/.error-message patterns.
   ============================================================ */

/* ---- Base alert ---- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid transparent;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  margin-bottom: var(--space-4);
}

.alert__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert__icon svg {
  width: 20px;
  height: 20px;
}

.alert__content {
  flex: 1;
  min-width: 0;
}

.alert__title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-1);
}

.alert__message {
  color: inherit;
  opacity: 0.9;
}

.alert__dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: inherit;
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity var(--transition-fast), background-color var(--transition-fast);
}

.alert__dismiss:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.05);
}

.alert__dismiss svg {
  width: 16px;
  height: 16px;
}

/* ---- Variants ---- */
.alert--success {
  background-color: var(--color-success-bg);
  border-left-color: var(--color-success);
  color: var(--color-success-dark);
}

.alert--danger,
.alert--error {
  background-color: var(--color-danger-bg);
  border-left-color: var(--color-danger);
  color: var(--color-danger-dark);
}

.alert--warning {
  background-color: var(--color-warning-bg);
  border-left-color: var(--color-warning);
  color: var(--color-warning-dark);
}

.alert--info {
  background-color: var(--color-info-bg);
  border-left-color: var(--color-info);
  color: var(--color-info-dark);
}

/* ---- Inline alert (no background, minimal) ---- */
.alert--inline {
  background-color: transparent;
  padding: var(--space-2) 0;
  border-left: none;
  border-radius: 0;
  margin-bottom: var(--space-2);
}

/* ---- Banner alert (full-width, top of page) ---- */
.alert--banner {
  border-radius: 0;
  border-left: none;
  margin-bottom: 0;
  padding: var(--space-3) var(--space-4);
  justify-content: center;
  text-align: center;
}

/* ---- Alert animation ---- */
.alert.is-entering {
  animation: alert-enter var(--transition-slow) ease forwards;
}

.alert.is-leaving {
  animation: alert-leave var(--transition-fast) ease forwards;
}

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

@keyframes alert-leave {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }
}

/* === styles/components/modal.css === */
/* ============================================================
   MODAL / BOTTOM SHEET COMPONENT
   Desktop: centered dialog with backdrop blur
   Mobile: bottom sheet with drag handle and swipe-to-dismiss
   Uses native <dialog> element for accessibility.
   ============================================================ */

/* ---- Dialog base ---- */
.modal {
  border: none;
  padding: 0;
  max-width: min(500px, calc(100vw - var(--space-8)));
  width: 100%;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  background-color: var(--color-surface);
  color: var(--color-text);
  overflow: visible;
}

.modal::backdrop {
  background: var(--color-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Slide-down animation (desktop) */
.modal[open] {
  animation: modal-slide-down var(--transition-slow) ease forwards;
}

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

/* ---- Modal structure ---- */
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.modal__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.modal__close:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

.modal__body {
  padding: var(--space-5);
  overflow-y: auto;
  max-height: 60vh;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ---- Size variants ---- */
.modal--sm {
  max-width: min(380px, calc(100vw - var(--space-8)));
}

.modal--lg {
  max-width: min(720px, calc(100vw - var(--space-8)));
}

.modal--xl {
  max-width: min(960px, calc(100vw - var(--space-8)));
}

/* ---- Confirm dialog (small, centered) ---- */
.modal--confirm .modal__body {
  text-align: center;
  padding: var(--space-6) var(--space-5);
}

.modal--confirm .modal__body p {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
}

.modal--confirm .modal__footer {
  justify-content: center;
}

/* ---- Drag handle (mobile bottom sheet) ---- */
.modal__drag-handle {
  display: none;
  justify-content: center;
  padding: var(--space-3) 0 var(--space-1);
}

.modal__drag-handle-bar {
  width: 36px;
  height: 4px;
  background-color: var(--color-gray-300);
  border-radius: var(--radius-full);
}

/* ============================================================
   MOBILE: Bottom sheet
   ============================================================ */
@media (max-width: 767px) {
  .modal {
    max-width: 100%;
    max-height: 85vh;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin: auto 0 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  .modal[open] {
    animation: modal-slide-up var(--transition-slow) ease forwards;
  }

  @keyframes modal-slide-up {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .modal__drag-handle {
    display: flex;
  }

  .modal__header {
    padding: var(--space-2) var(--space-4) var(--space-3);
  }

  .modal__body {
    padding: var(--space-4);
  }

  .modal__footer {
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0));
    flex-direction: column;
  }

  .modal__footer .btn {
    width: 100%;
  }
}

/* === styles/components/toast.css === */
/* ============================================================
   TOAST / SNACKBAR COMPONENT
   Non-blocking notifications. Replaces alert()/confirm().
   Mobile: bottom-center (above tab bar)
   Desktop: top-right
   ============================================================ */

/* ---- Toast container ---- */
.toast-container {
  position: fixed;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  /* Mobile default: bottom center above tab bar */
  bottom: calc(var(--bottombar-height) + var(--space-3));
  left: var(--space-3);
  right: var(--space-3);
  align-items: center;
}

@media (min-width: 1024px) {
  .toast-container {
    /* Desktop: top-right */
    top: calc(var(--topbar-height) + var(--space-3));
    right: var(--space-4);
    bottom: auto;
    left: auto;
    align-items: flex-end;
    width: 400px;
  }
}

/* ---- Individual toast ---- */
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  pointer-events: auto;
  width: 100%;
  max-width: 400px;
  position: relative;
  overflow: hidden;
  animation: toast-enter var(--transition-slow) ease forwards;
}

.toast.is-leaving {
  animation: toast-leave var(--transition-fast) ease forwards;
}

/* ---- Toast icon ---- */
.toast__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast__icon svg {
  width: 20px;
  height: 20px;
}

/* ---- Toast content ---- */
.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-0-5);
}

.toast__message {
  color: var(--color-text-secondary);
  line-height: var(--line-height-snug);
}

/* ---- Toast dismiss ---- */
.toast__dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--color-text-tertiary);
  flex-shrink: 0;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.toast__dismiss:hover {
  background-color: var(--color-gray-100);
  color: var(--color-text);
}

.toast__dismiss svg {
  width: 16px;
  height: 16px;
}

/* ---- Progress bar (auto-dismiss timer) ---- */
.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  animation: toast-progress linear forwards;
}

.toast--success .toast__progress { background-color: var(--color-success); }
.toast--error .toast__progress   { background-color: var(--color-danger); }
.toast--warning .toast__progress { background-color: var(--color-warning); }
.toast--info .toast__progress    { background-color: var(--color-primary); }

/* ---- Variants ---- */
.toast--success {
  border-left: 4px solid var(--color-success);
}

.toast--success .toast__icon { color: var(--color-success); }

.toast--error {
  border-left: 4px solid var(--color-danger);
}

.toast--error .toast__icon { color: var(--color-danger); }

.toast--warning {
  border-left: 4px solid var(--color-warning);
}

.toast--warning .toast__icon { color: var(--color-warning-dark); }

.toast--info {
  border-left: 4px solid var(--color-primary);
}

.toast--info .toast__icon { color: var(--color-primary); }

/* ---- Confirm toast (with action buttons) ---- */
.toast--confirm {
  flex-direction: column;
}

.toast__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.toast__actions .btn {
  min-height: 36px;
  font-size: var(--font-size-xs);
}

/* ---- Animations ---- */
@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Desktop animation: slide from right */
@media (min-width: 1024px) {
  @keyframes toast-enter {
    from {
      opacity: 0;
      transform: translateX(40px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes toast-leave {
    from {
      opacity: 1;
      transform: translateX(0);
    }
    to {
      opacity: 0;
      transform: translateX(40px);
    }
  }
}

/* === styles/components/skeleton.css === */
/* ============================================================
   SKELETON / LOADING COMPONENT
   Shimmer placeholders for loading states.
   Top-of-page progress bar for full page loads.
   ============================================================ */

/* ---- Shimmer animation ---- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---- Skeleton base ---- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-gray-200) 25%,
    var(--color-gray-100) 50%,
    var(--color-gray-200) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ---- Skeleton variants ---- */
.skeleton--text {
  height: 14px;
  margin-bottom: var(--space-2);
  width: 100%;
}

.skeleton--text:last-child {
  width: 60%;
}

.skeleton--heading {
  height: 24px;
  width: 40%;
  margin-bottom: var(--space-3);
}

.skeleton--circle {
  border-radius: var(--radius-full);
}

.skeleton--avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.skeleton--btn {
  height: var(--touch-target);
  width: 120px;
  border-radius: var(--radius-md);
}

.skeleton--card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton--stat {
  height: 100px;
  border-radius: var(--radius-lg);
}

.skeleton--table-row {
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton--image {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
}

/* ---- Skeleton row (flex container for inline elements) ---- */
.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ---- Skeleton group (for card-like placeholders) ---- */
.skeleton-group {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

/* ---- Page progress bar (top of page, for full page loads) ---- */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: var(--z-toast);
  background-color: transparent;
  overflow: hidden;
  pointer-events: none;
}

.page-progress.is-active {
  background-color: var(--color-primary-light);
}

.page-progress__bar {
  height: 100%;
  width: 0;
  background-color: var(--color-primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  animation: progress-indeterminate 2s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    width: 0%;
    margin-left: 0%;
  }
  50% {
    width: 60%;
    margin-left: 20%;
  }
  100% {
    width: 0%;
    margin-left: 100%;
  }
}

/* Determinate progress bar */
.page-progress__bar.is-determinate {
  animation: none;
  transition: width var(--transition-slow);
}

/* ---- Content loading placeholder ---- */
.loading-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  width: 100%;
}

.loading-spinner__circle {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spinner-rotate 0.8s linear infinite;
}

.loading-spinner--sm .loading-spinner__circle {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loading-spinner--lg .loading-spinner__circle {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

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

/* ---- Full-page loading overlay ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.loading-overlay .loading-spinner__circle {
  width: 48px;
  height: 48px;
  border-width: 4px;
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
}

/* === styles/responsive.css === */
/* =============================================================================
 * responsive.css — global mobile responsive defaults.
 *
 * Most Scholaria admin pages were built desktop-first and overflow on phones.
 * This sheet sets up sensible mobile defaults so individual pages don't have
 * to. Lives at the END of the build bundle so it can override page-specific
 * rules where needed.
 *
 * Breakpoints:
 *   ≤  768px (tablet)   — most layout shifts
 *   ≤  480px (phone)    — final compaction
 * ============================================================================= */

/* --- Tables --------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Make every .data-table horizontally scrollable inside its container so
     12-column admin tables don't blow up the viewport. The data-table cells
     already use data-label so we'll use that for stacked layout below. */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
  /* Phone: actually stack the table cells. Each cell is a row with the
     data-label as a left-side header. Works because the existing markup
     already uses <td data-label="..."> throughout the codebase. */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }
  .data-table tr {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--color-surface);
  }
  .data-table td {
    border: none;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex: none;
  }
  /* If the cell has no data-label, render normally (fallback). */
  .data-table td:not([data-label])::before { content: ''; display: none; }
}

/* --- Forms ---------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Two-column form grids collapse to one column. Many pages use inline
     style="grid-template-columns:1fr 1fr" — this targets that pattern. */
  .form-group[style*="grid-template-columns"],
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Make every form input fill the row at this width. */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"],  input[type="number"], input[type="url"],
  input[type="date"], input[type="time"],   select, textarea,
  .form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* --- Page header -------------------------------------------------------- */

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header__actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header__title {
    font-size: 1.5rem !important;
  }
}

/* --- Card grids --------------------------------------------------------- */

@media (max-width: 768px) {
  /* Common pattern: card-grid with 2/3/4 columns set inline. Override to
     single-column on tablet/phone. */
  .card-grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Stat grids — already responsive via auto-fill in most pages, but
     enforce single column on small phones */
}

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

/* --- Quick action card grids on Class Management & similar ---------- */

@media (max-width: 768px) {
  .quick-actions {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 480px) {
  .quick-actions {
    grid-template-columns: 1fr !important;
  }
}

/* --- Calendar grid (school_calendar.php) --------------------------- */

@media (max-width: 480px) {
  /* Calendar 7-column grid is too tight on phone — let cells wrap text
     and shrink. Day headers stay as 7 columns. */
  .calendar-grid {
    font-size: var(--font-size-xs);
  }
}

/* --- Buttons ------------------------------------------------------- */

@media (max-width: 480px) {
  /* On tiny screens, let button rows wrap and stretch */
  .btn { white-space: normal; }
  .page-header__actions .btn,
  .form-actions .btn {
    flex: 1 1 auto;
    min-width: 120px;
  }
}

/* --- Print (already in generate_report.php; here for global defaults) -- */

@media print {
  .sidebar, .nav, .more-drawer, .breadcrumbs, .skip-to-content { display: none !important; }
  .page-content { padding: 0 !important; }
}
