/**
 * NOMAD DESIGN SYSTEM v6.0
 * Based on Setproduct Design System Architecture
 * https://www.setproduct.com
 * 
 * Architecture: 3-Layer Token System
 * - Primitive Tokens (raw values)
 * - Semantic Tokens (roles)  
 * - Component Tokens (specific)
 * 
 * Features:
 * - Interface Grammar (spacing, sizing, radii)
 * - Typography Roles
 * - Component States Matrix
 * - Density System (Comfort/Compact)
 * - Liquid Glass Material
 * - Locked Light Model
 */

/* ============================================
   1. PRIMITIVE TOKENS
   Raw values - stable foundation
   ============================================ */
:root {
  /* Color Primitives - Neutral Ramp */
  --color-neutral-0: #FFFFFF;
  --color-neutral-50: #F8FAFC;
  --color-neutral-100: #F1F5F9;
  --color-neutral-200: #E2E8F0;
  --color-neutral-300: #CBD5E1;
  --color-neutral-400: #94A3B8;
  --color-neutral-500: #64748B;
  --color-neutral-600: #475569;
  --color-neutral-700: #334155;
  --color-neutral-800: #1E293B;
  --color-neutral-900: #0F172A;
  
  /* Color Primitives - Brand/Accent */
  --color-accent-50: #EFF6FF;
  --color-accent-100: #DBEAFE;
  --color-accent-200: #BFDBFE;
  --color-accent-300: #93C5FD;
  --color-accent-400: #60A5FA;
  --color-accent-500: #3B82F6;
  --color-accent-600: #2563EB;
  --color-accent-700: #1D4ED8;
  --color-accent-800: #1E40AF;
  --color-accent-900: #1E3A8A;
  
  /* Color Primitives - Status */
  --color-success-500: #10B981;
  --color-success-600: #059669;
  --color-warning-500: #F59E0B;
  --color-warning-600: #D97706;
  --color-danger-500: #EF4444;
  --color-danger-600: #DC2626;
  --color-purple-500: #8B5CF6;
  --color-purple-600: #7C3AED;
  
  /* Opacity Primitives */
  --opacity-0: 0;
  --opacity-10: 0.1;
  --opacity-20: 0.2;
  --opacity-30: 0.3;
  --opacity-40: 0.4;
  --opacity-50: 0.5;
  --opacity-60: 0.6;
  --opacity-70: 0.7;
  --opacity-80: 0.8;
  --opacity-90: 0.9;
  --opacity-100: 1;
  
  /* Shadow Primitives */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glass: 0 8px 32px rgba(31, 38, 135, 0.1);
  --shadow-glass-lg: 0 12px 40px rgba(31, 38, 135, 0.15);
  
  /* Blur Primitives */
  --blur-sm: blur(8px);
  --blur-md: blur(16px);
  --blur-lg: blur(24px);
  --blur-xl: blur(32px);
}

/* ============================================
   2. SEMANTIC TOKENS
   UI Roles - themeable layer
   ============================================ */
:root {
  /* Background Roles */
  --bg-canvas: var(--color-neutral-50);
  --bg-surface: var(--color-neutral-0);
  --bg-surface-raised: var(--color-neutral-0);
  --bg-surface-pressed: var(--color-neutral-100);
  --bg-overlay: rgba(15, 23, 42, 0.5);
  
  /* Text Roles */
  --text-primary: var(--color-neutral-900);
  --text-secondary: var(--color-neutral-600);
  --text-muted: var(--color-neutral-500);
  --text-inverse: var(--color-neutral-0);
  --text-accent: var(--color-accent-600);
  
  /* Border Roles */
  --border-default: var(--color-neutral-200);
  --border-subtle: var(--color-neutral-100);
  --border-divider: var(--color-neutral-200);
  --border-strong: var(--color-neutral-300);
  
  /* Accent Roles */
  --accent-primary: var(--color-accent-600);
  --accent-primary-hover: var(--color-accent-700);
  --accent-primary-pressed: var(--color-accent-800);
  --accent-primary-subtle: var(--color-accent-50);
  
  /* Status Roles */
  --state-success: var(--color-success-500);
  --state-success-bg: rgba(16, 185, 129, 0.1);
  --state-warning: var(--color-warning-500);
  --state-warning-bg: rgba(245, 158, 11, 0.1);
  --state-danger: var(--color-danger-500);
  --state-danger-bg: rgba(239, 68, 68, 0.1);
  --state-info: var(--color-accent-500);
  --state-info-bg: rgba(59, 130, 246, 0.1);
  
  /* Focus Ring */
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.3);
  --focus-ring-inner: inset 0 0 0 2px rgba(37, 99, 235, 0.2);
  
  /* Selection */
  --selection-bg: var(--color-accent-100);
  --selection-text: var(--color-accent-900);
}

/* Dark Mode Semantic Mapping */
[data-theme="dark"] {
  --bg-canvas: var(--color-neutral-900);
  --bg-surface: var(--color-neutral-800);
  --bg-surface-raised: var(--color-neutral-700);
  --bg-surface-pressed: var(--color-neutral-800);
  --bg-overlay: rgba(0, 0, 0, 0.7);
  
  --text-primary: var(--color-neutral-0);
  --text-secondary: var(--color-neutral-300);
  --text-muted: var(--color-neutral-500);
  --text-inverse: var(--color-neutral-900);
  
  --border-default: rgba(255, 255, 255, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-divider: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.25);
  
  --accent-primary: var(--color-accent-500);
  --accent-primary-hover: var(--color-accent-400);
  --accent-primary-pressed: var(--color-accent-300);
  --accent-primary-subtle: rgba(37, 99, 235, 0.15);
}

/* ============================================
   3. INTERFACE GRAMMAR
   Spacing, Sizing, Radii, Elevation
   ============================================ */

/* Spacing Scale (Base 4) */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
}

/* Control Heights */
:root {
  --control-height-sm: 32px;
  --control-height-md: 40px;
  --control-height-lg: 48px;
}

/* Radii Mapping */
:root {
  --radius-1: 6px;   /* Small controls: chips, toggles */
  --radius-2: 10px;  /* Inputs, buttons */
  --radius-3: 16px;  /* Cards, panels */
  --radius-4: 24px;  /* Modals, large surfaces */
}

/* Elevation Levels */
:root {
  --elevation-0: 0 0 0 0 transparent; /* Canvas */
  --elevation-1: var(--shadow-sm);    /* Raised card */
  --elevation-2: var(--shadow-md);    /* Popovers */
  --elevation-3: var(--shadow-lg);    /* Modals */
}

/* Density Presets */
[data-density="comfort"] {
  --density-control-height: var(--control-height-md);
  --density-padding: var(--space-4);
  --density-gap: var(--space-4);
  --density-line-height: 1.5;
}

[data-density="compact"] {
  --density-control-height: var(--control-height-sm);
  --density-padding: var(--space-3);
  --density-gap: var(--space-3);
  --density-line-height: 1.3;
}

/* ============================================
   4. TYPOGRAPHY ROLES
   Not just sizes - semantic roles
   ============================================ */
:root {
  /* Font Family */
  --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Font Sizes */
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;
  --font-size-4xl: 32px;
  
  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  
  /* Line Heights */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
}

/* Typography Roles */
.type-caption {
  font-size: var(--font-size-xs);
  line-height: var(--line-height-normal);
  font-weight: var(--font-weight-normal);
  color: var(--text-muted);
}

.type-body {
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  font-weight: var(--font-weight-normal);
  color: var(--text-secondary);
}

.type-label {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.type-title {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.type-headline {
  font-size: var(--font-size-3xl);
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.type-numeric {
  font-family: var(--font-family-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ============================================
   5. LIQUID GLASS MATERIAL
   Two-layer stack system
   ============================================ */

/* Glass Shell - Outer Layer */
.glass-shell {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  box-shadow: 
    var(--shadow-glass),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

/* Light Highlight - Locked Direction (Top-Left) */
.glass-shell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.9) 0%, 
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0.1) 100%
  );
  pointer-events: none;
}

/* Glass Thickness - Edge Cue */
.glass-shell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-3);
  padding: 1px;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.4), 
    transparent 50%,
    rgba(0, 0, 0, 0.02)
  );
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Stabilized Plate - Inner Layer */
.glass-plate {
  background: var(--bg-surface);
  border-radius: calc(var(--radius-3) - 4px);
  padding: var(--space-6);
  position: relative;
  z-index: 1;
}

/* Dense Plate for Tables/Forms */
.glass-plate-dense {
  background: var(--bg-surface-pressed);
  border: 1px solid var(--border-subtle);
}

/* Dark Mode Glass Adjustments */
[data-theme="dark"] .glass-shell {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .glass-shell::before {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.15) 0%, 
    rgba(255, 255, 255, 0.05) 50%,
    transparent 100%
  );
}

/* ============================================
   6. COMPONENT STATES MATRIX
   Standardized state system
   ============================================ */

/* Base State Transitions */
.state-transition {
  transition: 
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Default State */
.state-default {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
}

/* Hover State - Lift */
.state-hover:hover {
  background: var(--bg-surface-raised);
  border-color: var(--border-strong);
  box-shadow: var(--elevation-1);
  transform: translateY(-1px);
}

/* Pressed State - Compress */
.state-pressed:active {
  background: var(--bg-surface-pressed);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  transform: translateY(0);
}

/* Focus State - Crisp Ring */
.state-focus:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Disabled State - Muted */
.state-disabled:disabled,
.state-disabled.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.5);
}

/* Loading State */
.state-loading {
  position: relative;
  pointer-events: none;
}

.state-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Error State */
.state-error {
  border-color: var(--state-danger) !important;
  background: var(--state-danger-bg);
}

.state-error .helper-text {
  color: var(--state-danger);
}

/* Selected State */
.state-selected {
  background: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
}

/* ============================================
   7. BUTTON COMPONENT
   Complete contract implementation
   ============================================ */

/* Button Base Contract */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--density-control-height);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-2);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: 
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: var(--text-inverse);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-primary-hover), var(--accent-primary-pressed));
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-surface-raised);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

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

.btn-ghost:hover {
  background: var(--bg-surface-pressed);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--state-danger-bg);
  color: var(--state-danger);
  border-color: var(--state-danger);
}

.btn-danger:hover {
  background: var(--state-danger);
  color: var(--text-inverse);
}

/* Button Sizes */
.btn-sm { height: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--font-size-sm); }
.btn-md { height: var(--control-height-md); padding: 0 var(--space-4); }
.btn-lg { height: var(--control-height-lg); padding: 0 var(--space-6); font-size: var(--font-size-md); }

/* Icon Button */
.btn-icon {
  width: var(--density-control-height);
  height: var(--density-control-height);
  padding: 0;
  border-radius: var(--radius-2);
}

/* ============================================
   8. INPUT COMPONENT
   Complete with states and helper text
   ============================================ */

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.input-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-field {
  width: 100%;
  height: var(--density-control-height);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-2);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  transition: 
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.input-field::placeholder {
  color: var(--text-muted);
}

/* Input States */
.input-field:hover {
  border-color: var(--border-strong);
}

.input-field:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
}

.input-field:disabled {
  background: var(--bg-surface-pressed);
  opacity: 0.6;
  cursor: not-allowed;
}

/* Input with Icon */
.input-field.has-leading-icon {
  padding-left: var(--space-10);
}

.input-field.has-trailing-icon {
  padding-right: var(--space-10);
}

.input-icon {
  position: absolute;
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

.input-icon.leading { left: var(--space-3); }
.input-icon.trailing { right: var(--space-3); }

/* Helper Text */
.helper-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  line-height: var(--line-height-normal);
  min-height: 18px;
}

/* ============================================
   9. CARD COMPONENT
   Glass and solid variants
   ============================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  overflow: hidden;
  transition: box-shadow 200ms ease, transform 200ms ease;
}

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

.card-glass {
  composes: glass-shell;
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-divider);
  background: var(--bg-surface-pressed);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-divider);
  background: var(--bg-surface-pressed);
}

/* ============================================
   10. TABLE COMPONENT
   Dense data display
   ============================================ */

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-3);
  border: 1px solid var(--border-default);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-base);
}

.table th {
  background: var(--bg-surface-pressed);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-divider);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-divider);
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.table tr:hover td {
  background: var(--bg-surface-pressed);
}

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

/* Numeric Cells */
.table td.numeric {
  font-family: var(--font-family-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ============================================
   11. BADGE & STATUS
   Semantic status indicators
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.badge-success {
  background: var(--state-success-bg);
  color: var(--state-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
  background: var(--state-warning-bg);
  color: var(--state-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
  background: var(--state-danger-bg);
  color: var(--state-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-info {
  background: var(--state-info-bg);
  color: var(--state-info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Status Dot */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px currentColor;
  opacity: 0.3;
}

.badge-success .status-dot { color: var(--state-success); }
.badge-warning .status-dot { color: var(--state-warning); }
.badge-danger .status-dot { color: var(--state-danger); }

/* ============================================
   12. LAYOUT COMPONENTS
   Sidebar, Header, Grid
   ============================================ */

/* Layout Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-canvas);
}

/* Sidebar */
.sidebar {
  width: 280px;
  position: fixed;
  height: 100vh;
  z-index: 100;
  padding: var(--space-4);
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--color-purple-500));
  border-radius: var(--radius-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-bold);
}

.brand-text {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-extrabold);
  background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Navigation */
.nav {
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
  transition: all 150ms ease;
}

.nav-item:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  font-weight: var(--font-weight-semibold);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 24px;
  background: var(--accent-primary);
  border-radius: 0 3px 3px 0;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: var(--space-6);
}

.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-size: var(--font-size-lg);
  color: var(--text-muted);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-6);
}

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

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================
   13. STAT CARDS
   Dashboard metrics
   ============================================ */

.stat-card {
  composes: glass-shell;
  padding: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon-blue {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(37, 99, 235, 0.05));
  color: var(--accent-primary);
}

.stat-icon-green {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
  color: var(--state-success);
}

.stat-icon-purple {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05));
  color: var(--color-purple-600);
}

.stat-icon-orange {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
  color: var(--state-warning);
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-extrabold);
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: 9999px;
  background: var(--bg-surface-pressed);
}

/* ============================================
   14. ALERTS & FEEDBACK
   User notifications
   ============================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-2);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
}

.alert-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

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

.alert-message {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.alert-success {
  background: var(--state-success-bg);
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--state-success);
}

.alert-danger {
  background: var(--state-danger-bg);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--state-danger);
}

.alert-warning {
  background: var(--state-warning-bg);
  border-color: rgba(245, 158, 11, 0.2);
  color: var(--state-warning);
}

.alert-info {
  background: var(--state-info-bg);
  border-color: rgba(59, 130, 246, 0.2);
  color: var(--state-info);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--elevation-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  z-index: 9999;
  animation: slideInRight 0.3s ease;
}

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

/* ============================================
   15. LOGIN PAGE
   Specialized layout
   ============================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(37, 99, 235, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(220, 38, 38, 0.08) 0%, transparent 50%),
    var(--bg-canvas);
}

.login-card {
  width: 100%;
  max-width: 420px;
  composes: glass-shell;
  padding: var(--space-10);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-primary), var(--color-purple-600));
  border-radius: var(--radius-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: white;
  font-size: 32px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.login-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.login-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-muted);
}

/* ============================================
   16. UTILITY CLASSES
   Helper utilities
   ============================================ */

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

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.font-mono { font-family: var(--font-family-mono); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

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

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ============================================
   17. ANIMATIONS
   Micro-interactions
   ============================================ */

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}

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

/* Staggered animation for lists */
.stagger-children > * {
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }

/* ============================================
   18. ACCESSIBILITY
   Focus and reduced motion
   ============================================ */

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

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-default: #000;
    --text-secondary: #000;
  }
}

/* ============================================
   19. FALLBACKS
   No backdrop-filter support
   ============================================ */

@supports not (backdrop-filter: blur(20px)) {
  .glass-shell,
  .glass-plate {
    background: var(--bg-surface);
    backdrop-filter: none;
  }
  
  .glass-shell::before,
  .glass-shell::after {
    display: none;
  }
}

/* ============================================
   20. SCROLLBAR STYLING
   Custom scrollbar
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface-pressed);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection styling */
::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}
