/* ============================================================
   LABSAHAM — Enhanced Design System & UI Improvements
   Modern utilities, components, and accessibility enhancements
   ============================================================ */

/* ============================================================
   ENHANCED CSS VARIABLES — Softer, More Sophisticated Palette
   ============================================================ */
:root {
  /* Softer green/red for financial data */
  --green-soft: #10b981;
  --green-bg: #d1fae5;
  --green-border: #6ee7b7;
  
  --red-soft: #ef4444;
  --red-bg: #fee2e2;
  --red-border: #fca5a5;
  
  /* Extended color palette */
  --purple: #8b5cf6;
  --purple-bg: #ede9fe;
  --purple-border: #c4b5fd;
  
  --cyan: #06b6d4;
  --cyan-bg: #cffafe;
  --cyan-border: #67e8f9;
  
  /* Neutral scale */
  --neutral-50: #f9fafb;
  --neutral-100: #f3f4f6;
  --neutral-200: #e5e7eb;
  --neutral-300: #d1d5db;
  --neutral-400: #9ca3af;
  --neutral-500: #6b7280;
  --neutral-600: #4b5563;
  --neutral-700: #374151;
  --neutral-800: #1f2937;
  --neutral-900: #111827;
  
  /* Enhanced shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --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.08), 0 4px 6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 8px 10px rgba(0,0,0,0.04);
  
  /* Spacing scale (4px base) */
  --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;
  
  /* Border radius scale */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 100ms ease;
  --transition-base: 150ms ease;
  --transition-slow: 300ms ease;
  
  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-toast: 600;
}

/* Dark mode enhancements */
.dark-mode {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --border: #334155;
  --border2: #475569;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --green-bg: #064e3b;
  --green-bdr: #059669;
  --red-bg: #7f1d1d;
  --red-bdr: #dc2626;
  --blue-bg: #1e3a8a;
  --blue-bdr: #2563eb;
  --amber-bg: #78350f;
  --amber-bdr: #d97706;
}

/* ============================================================
   TOAST NOTIFICATION SYSTEM
   ============================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideIn 300ms ease;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
}

.toast.toast-success::before { background: var(--green); }
.toast.toast-error::before { background: var(--red); }
.toast.toast-warning::before { background: var(--amber); }

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

.toast-success .toast-icon { color: var(--green); }
.toast-error .toast-icon { color: var(--red); }
.toast-warning .toast-icon { color: var(--amber); }
.toast-info .toast-icon { color: var(--blue); }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: var(--transition-fast);
}

.toast-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--blue);
  animation: progress 5s linear forwards;
}

.toast-success .toast-progress { background: var(--green); }
.toast-error .toast-progress { background: var(--red); }
.toast-warning .toast-progress { background: var(--amber); }

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

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

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

.toast.removing {
  animation: slideOut 300ms ease forwards;
}

/* Mobile toast */
@media (max-width: 640px) {
  .toast-container {
    right: 8px;
    left: 8px;
    max-width: none;
  }
  
  .toast {
    padding: 12px 14px;
  }
}

/* ============================================================
   SKELETON LOADING COMPONENTS
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface2) 0%,
    var(--border) 50%,
    var(--surface2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 8px;
}

.skeleton-text:last-child {
  margin-bottom: 0;
  width: 75%;
}

.skeleton-heading {
  height: 1.5em;
  width: 60%;
  margin-bottom: 12px;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-rect {
  height: 120px;
  width: 100%;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

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

.skeleton-table th,
.skeleton-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.skeleton-table th {
  background: var(--surface2);
}

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

/* ============================================================
   COMMAND PALETTE (Ctrl+K)
   ============================================================ */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  animation: fadeIn 150ms ease;
}

.command-palette {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: scaleIn 200ms ease;
}

.command-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.command-palette-input-wrap i {
  color: var(--text-3);
  font-size: 1.1rem;
}

.command-palette-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text);
  font-family: var(--font-ui);
}

.command-palette-input::placeholder {
  color: var(--text-3);
}

.command-palette-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.command-palette-group-label {
  padding: 8px 12px 4px;
  font-size: 0.65rem;
  font-family: var(--font-data);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.command-palette-item:hover,
.command-palette-item.active {
  background: var(--surface2);
}

.command-palette-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
}

.command-palette-item-text {
  flex: 1;
  min-width: 0;
}

.command-palette-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.command-palette-item-subtitle {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 1px;
}

.command-palette-item-shortcut {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.command-palette-item-shortcut kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--font-data);
  color: var(--text-3);
  line-height: 1.4;
}

.command-palette-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
}

.command-palette-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.7rem;
  color: var(--text-3);
}

.command-palette-footer kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.65rem;
  font-family: var(--font-data);
  margin: 0 2px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .command-palette-overlay {
    padding-top: 0;
    align-items: flex-end;
  }
  
  .command-palette {
    max-width: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 80vh;
  }
}

/* ============================================================
   EMPTY STATE COMPONENTS
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 16px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: 50%;
  color: var(--text-3);
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-2);
  max-width: 400px;
  line-height: 1.5;
}

.empty-state-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .empty-state {
    padding: 48px 16px;
  }
  
  .empty-state-icon {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}

/* ============================================================
   IMPROVED MODAL STYLES
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 200ms ease;
}

.modal-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 300ms ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-header-enhanced {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header-enhanced h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface2);
  color: var(--text-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body-enhanced {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer-enhanced {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  background: var(--surface2);
}

/* Mobile bottom sheet modal */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  
  .modal-container {
    max-width: none;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: modalSlideUp 300ms ease;
  }
  
  @keyframes modalSlideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  .modal-body-enhanced {
    padding: 20px 16px;
  }
  
  .modal-footer-enhanced {
    padding: 16px;
  }
}

/* ============================================================
   DATA DENSITY CONTROL
   ============================================================ */
.density-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.density-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-ui);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.density-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.density-btn.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* Density variants for tables */
.table-density-compact table.dt-table tbody td,
.table-density-compact table.dt-table thead th {
  padding: 6px 8px;
  font-size: 0.75rem;
}

.table-density-comfortable table.dt-table tbody td,
.table-density-comfortable table.dt-table thead th {
  padding: 10px 12px;
  font-size: 0.85rem;
}

/* ============================================================
   KEYBOARD SHORTCUT HINTS
   ============================================================ */
.kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--font-data);
  color: var(--text-3);
  line-height: 1.4;
  box-shadow: 0 1px 0 var(--border2);
}

/* ============================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================ */

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Better button disabled states */
.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  z-index: 999;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

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

/* Better form control error states */
.form-control-error {
  border-color: var(--red) !important;
}

.form-error-message {
  color: var(--red);
  font-size: 0.75rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   PULL TO REFRESH INDICATOR
   ============================================================ */
.pull-to-refresh {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: 0.8rem;
  color: var(--text-2);
  transition: var(--transition-base);
  z-index: 10;
}

.pull-to-refresh.visible {
  top: 60px;
}

.pull-to-refresh .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   BACKGROUND DATA REFRESH INDICATOR
   ============================================================ */
.refresh-indicator {
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-size: 0.75rem;
  color: var(--text-2);
  z-index: var(--z-sticky);
  animation: fadeIn 300ms ease;
}

.refresh-indicator .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================
   WHAT'S NEW BADGE
   ============================================================ */
.whats-new-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--purple-bg), var(--blue-bg));
  border: 1px solid var(--purple-border);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--purple);
  cursor: pointer;
  transition: var(--transition-base);
}

.whats-new-badge:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.whats-new-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--purple);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* ============================================================
   IMPROVED BUTTONS & INTERACTIONS
   ============================================================ */

/* Better hover states */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: var(--transition-fast);
}

.btn:hover::after {
  opacity: 0.05;
}

.btn:active::after {
  opacity: 0.1;
}

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

.btn-loading::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  color: white;
}

/* ============================================================
   IMPROVED CARDS
   ============================================================ */
.card-enhanced {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.card-enhanced:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border2);
}

/* ============================================================
   MICRO-INTERACTIONS
   ============================================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 400ms ease;
}

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

.animate-scale-in {
  animation: scaleIn 300ms ease;
}

/* Success animation */
@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.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-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.m-0 { margin: 0; }
.m-2 { margin: var(--space-2); }
.m-4 { margin: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }

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

.font-mono { font-family: var(--font-data); }
.font-sans { font-family: var(--font-ui); }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

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

.rounded { border-radius: var(--radius); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.transition { transition: var(--transition-base); }
.transition-fast { transition: var(--transition-fast); }

/* ============================================================
   RESPONSIVE IMPROVEMENTS
   ============================================================ */
@media (min-width: 641px) and (max-width: 1024px) {
  .page {
    padding: 12px 16px 40px;
  }
}

@media (min-width: 1025px) {
  .page {
    padding: 16px 24px 48px;
  }
}

/* ============================================================
   BETTER TABLE STYLES
   ============================================================ */
.table-enhanced {
  width: 100%;
  border-collapse: collapse;
}

.table-enhanced thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface2);
  backdrop-filter: blur(8px);
}

.table-enhanced thead th::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

/* Column visibility controls */
.column-visibility-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}

.column-visibility-toggle label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-2);
  transition: var(--transition-fast);
}

.column-visibility-toggle label:hover {
  border-color: var(--border2);
  color: var(--text);
}

.column-visibility-toggle input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ============================================================
   THEME CUSTOMIZATION PANEL
   ============================================================ */
.theme-panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.theme-color-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.theme-color-option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.theme-color-option:hover {
  transform: scale(1.1);
}

.theme-color-option.active {
  border-color: var(--text);
  box-shadow: var(--shadow-md);
}

.theme-color-option.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ============================================================
   ONBOARDING TOUR STYLES
   ============================================================ */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: var(--z-overlay);
}

.onboarding-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 20px;
  max-width: 400px;
  z-index: calc(var(--z-overlay) + 10);
  animation: fadeInUp 400ms ease;
}

.onboarding-tooltip h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.onboarding-tooltip p {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 16px;
}

.onboarding-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.onboarding-progress {
  display: flex;
  gap: 4px;
  margin-top: 16px;
}

.onboarding-progress-step {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

.onboarding-progress-step.active {
  background: var(--accent);
}

/* ============================================================
   IMPROVED NAVBAR STYLES
   ============================================================ */
.nav-enhanced {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--nav-h);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

/* Mobile bottom navigation */
@media (max-width: 640px) {
  .nav-mobile-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: var(--z-sticky);
  }
  
  .nav-mobile-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    color: var(--text-3);
    font-size: 0.65rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border-radius: var(--radius-md);
  }
  
  .nav-mobile-item:hover,
  .nav-mobile-item.active {
    color: var(--accent);
    background: var(--blue-bg);
  }
  
  .nav-mobile-item i {
    font-size: 1.1rem;
  }
  
  /* Add padding to prevent content from being hidden */
  .page {
    padding-bottom: 80px !important;
  }
}

/* ============================================================
   CHART ENHANCEMENTS
   ============================================================ */
.chart-container-enhanced {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chart-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   LOADING STATES
   ============================================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--text-2);
  text-align: center;
}

/* ============================================================
   BADGE IMPROVEMENTS
   ============================================================ */
.badge-enhanced {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-buy {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.badge-sell {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.badge-hold {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-bdr);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-card-label {
  font-size: 0.7rem;
  font-family: var(--font-data);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.stat-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-data);
}

.stat-card-sub {
  font-size: 0.75rem;
  color: var(--text-2);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   BETTER RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .page {
    padding: 10px 8px 32px;
  }
}
