:root {
  /* Primary Brand Colors - Blue Theme */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #3b82f6;
  --color-accent: #0061ff;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-cyan: #06b6d4;
  
  /* Light Theme (Default) */
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-secondary: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --color-text-primary: #0f172a;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  
  /* Sidebar Light */
  --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  --sidebar-text: #f8fafc;
  --sidebar-text-muted: #94a3b8;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(37, 99, 235, 0.2);
  
  /* Gray Scale */
  --color-gray-50: #F8FAFC;
  --color-gray-100: #F1F5F9;
  --color-gray-200: #E2E8F0;
  --color-gray-300: #CBD5E1;
  --color-gray-400: #94a3b8;
  --color-gray-500: #64748B;
  --color-gray-600: #475569;
  --color-gray-700: #334155;
  --color-gray-800: #1E293B;
  --color-gray-900: #0F172A;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  --gradient-blue: linear-gradient(135deg, #2563eb 0%, #0061ff 100%);
  --gradient-sidebar: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 24px;
  --radius-full: 50%;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 40px rgba(37, 99, 235, 0.15);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0.0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  
  /* Fonts */
  --font-system: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-surface: rgba(255, 255, 255, 0.05);
  --color-surface-secondary: rgba(255, 255, 255, 0.08);
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-light: rgba(255, 255, 255, 0.05);
  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  
  /* Sidebar Dark */
  --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  --sidebar-text: #f8fafc;
  --sidebar-text-muted: #94a3b8;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(37, 99, 235, 0.3);
  
  /* Dark shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px rgba(37, 99, 235, 0.3);
}

/* Legacy variable aliases for backwards compatibility */
:root {
  --color-surface-dark: var(--color-surface);
  --color-border-dark: var(--color-border);
  --gradient-dark: var(--color-bg-secondary);
}

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

body {
  font-family: var(--font-system);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scroll-behavior: smooth;
}

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

::selection {
  background: rgba(99, 102, 241, 0.3);
  color: white;
}

/* Buttons */
.btn {
  height: 44px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

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

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

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

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}

.btn-outline:hover {
  background: rgba(99, 102, 241, 0.1);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.btn-link:hover {
  color: var(--color-primary-light);
  text-decoration: underline;
}

.btn-link:disabled {
  color: var(--color-gray-300);
  cursor: not-allowed;
}

.btn-destructive {
  background: var(--color-error);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn-ghost:hover {
  background: rgba(99, 102, 241, 0.1);
}

.btn-sm {
  height: 36px;
  padding: 8px 16px;
  font-size: 14px;
}

.btn-lg {
  height: 52px;
  padding: 14px 32px;
  font-size: 17px;
}

/* Card Component */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

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

.card-static:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
}

/* Input Fields */
.input {
  height: 48px;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font-system);
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: all var(--transition-normal);
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  outline: none;
}

.input.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.input-group {
  margin-bottom: var(--space-md);
}

.input-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

/* Dark mode input adjustments */
[data-theme="dark"] .input {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .input:focus {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

/* Sidebar */
.sidebar {
  width: 260px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: var(--space-lg) var(--space-md);
  z-index: 40;
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.sidebar-logo img {
  width: 40px;
  height: 40px;
}

.sidebar-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--sidebar-text);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-normal);
  margin-bottom: var(--space-xs);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  margin-left: -3px;
}

.nav-link svg {
  width: 20px;
  height: 20px;
}

/* Main Content */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  padding: var(--space-xl);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  transition: background var(--transition-normal);
}

.topbar {
  height: 56px;
  background: var(--color-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  margin: calc(-1 * var(--space-xl));
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .topbar {
  background: rgba(15, 23, 42, 0.9);
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-lg);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-label {
  font-size: 14px;
  color: var(--color-text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-change {
  font-size: 14px;
  font-weight: 500;
  margin-top: var(--space-xs);
}

.stat-change.positive {
  color: var(--color-success);
}

.stat-change.negative {
  color: var(--color-error);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-error);
}

.badge-info {
  background: rgba(99, 102, 241, 0.2);
  color: var(--color-primary-light);
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.2);
  color: var(--color-text-secondary);
}

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

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

.table th {
  background: var(--color-surface-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

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

.table tr:hover {
  background: var(--color-surface-secondary);
}

[data-theme="dark"] .table th {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .table tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-xl);
  transform: scale(0.95) translateY(20px);
  transition: all var(--transition-normal);
}

[data-theme="dark"] .modal {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

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

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--space-lg);
  color: var(--color-text-primary);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-xl);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  animation: slideIn 0.3s ease;
  color: var(--color-text-primary);
}

[data-theme="dark"] .toast {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

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

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

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

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

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
}

.empty-state svg {
  width: 96px;
  height: 96px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.empty-state h3 {
  font-size: 20px;
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border-dark);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Chart Container */
.chart-container {
  background: var(--color-surface-dark);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: var(--space-md);
  }
  
  .page-title {
    font-size: 24px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .card {
    padding: var(--space-md);
  }
  
  .modal {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: fixed;
    bottom: 0;
  }
  
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    border-top: 1px solid var(--color-border-dark);
    z-index: 40;
    justify-content: space-around;
    align-items: center;
    padding: 0 var(--space-md);
  }
  
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
  }
  
  .bottom-nav a.active {
    color: var(--color-primary-light);
  }
  
  .bottom-nav svg {
    width: 24px;
    height: 24px;
  }
}

/* Auth Pages - Light Theme for better contrast */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-dark);
  padding: var(--space-lg);
}

.auth-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.auth-logo img {
  width: 48px;
  height: 48px;
}

.auth-logo h1 {
  font-size: 32px;
  font-weight: 700;
  color: #0f172a;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
  margin-bottom: var(--space-sm);
}

.auth-subtitle {
  text-align: center;
  color: #64748b;
  margin-bottom: var(--space-xl);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-xl);
  color: #64748b;
}

.auth-footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  color: var(--color-primary-dark);
}

.auth-card .btn-primary {
  background: var(--gradient-primary);
  color: white;
}

.auth-card .btn-primary:hover {
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.auth-card .btn-secondary {
  background: transparent;
  border: 1.5px solid #e2e8f0;
  color: #0f172a;
}

.auth-card .btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--color-primary);
}

.auth-card .btn-link {
  color: var(--color-primary);
}

.auth-card .btn-link:hover {
  color: var(--color-primary-dark);
}

.auth-card .input {
  background: white;
  border-color: #e2e8f0;
  color: #0f172a;
}

.auth-card .input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.auth-card .input-label {
  color: #334155;
}

/* Section Headers */
.section-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.section-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

/* Quick Actions Card */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.action-card {
  background: var(--color-surface-dark);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.action-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.action-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
}

.action-card-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.action-card h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.action-card p {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
  color: var(--sidebar-text-muted);
  background: transparent;
  border: none;
  width: 100%;
  font-size: 14px;
  font-weight: 500;
}

.theme-toggle:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.theme-toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: all var(--transition-normal);
  margin-left: auto;
}

.theme-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all var(--transition-normal);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .theme-toggle-switch::after {
  left: 22px;
}

[data-theme="dark"] .theme-toggle-switch {
  background: var(--color-primary);
}

/* Utility Classes */
[x-cloak] {
  display: none !important;
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glow {
  box-shadow: var(--shadow-glow);
}

/* Chart styling for light mode */
.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}
