/**
 * Unified Base Styles - Pokemon Card Tracker
 * 
 * This file consolidates:
 * - tokens.css (design tokens)
 * - design-system.css (duplicate tokens + component base styles)
 * - globals.css (resets, Tailwind imports, base styles)
 * - utilities.css (utility classes, animations)
 * - main.css (layout, PWA styles)
 * 
 * Single source of truth for all non-component styles.
 */

/* =============================================================================
   CSS LAYERS ARCHITECTURE
   ============================================================================= */

/* =============================================================================
   DESIGN TOKENS
   ============================================================================= */

:root {
  /* ==================== SAFE AREA INSETS ==================== */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);

  /* ==================== BASE COLORS ==================== */
  --color-white: #ffffff;
  --color-black: #000000;

  /* Primary Color Scale (Blue) */
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-200: #bfdbfe;
  --color-primary-300: #93c5fd;
  --color-primary-400: #60a5fa;
  --color-primary-500: #3b82f6;
  --color-primary-600: #2563eb;
  --color-primary-700: #1d4ed8;
  --color-primary-800: #1e40af;
  --color-primary-900: #1e3a8a;
  --color-primary-950: #172554;

  /* Accent Color Scale (Pink for gradients) */
  --color-accent-50: #fdf2f8;
  --color-accent-100: #fce7f3;
  --color-accent-200: #fbcfe8;
  --color-accent-300: #f9a8d4;
  --color-accent-400: #f472b6;
  --color-accent-500: #ec4899;
  --color-accent-600: #db2777;
  --color-accent-700: #be185d;
  --color-accent-800: #9d174d;
  --color-accent-900: #831843;
  --color-accent-950: #500724;

  /* 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;
  --color-gray-950: #030712;

  /* Semantic Colors - Success */
  --color-success-50: #f0fdf4;
  --color-success-100: #dcfce7;
  --color-success-200: #bbf7d0;
  --color-success-300: #86efac;
  --color-success-400: #4ade80;
  --color-success-500: #22c55e;
  --color-success-600: #16a34a;
  --color-success-700: #15803d;
  --color-success-800: #166534;
  --color-success-900: #14532d;
  --color-success-950: #052e16;

  /* Semantic Colors - Warning */
  --color-warning-50: #fffbeb;
  --color-warning-100: #fef3c7;
  --color-warning-200: #fde68a;
  --color-warning-300: #fcd34d;
  --color-warning-400: #fbbf24;
  --color-warning-500: #f59e0b;
  --color-warning-600: #d97706;
  --color-warning-700: #b45309;
  --color-warning-800: #92400e;
  --color-warning-900: #78350f;
  --color-warning-950: #451a03;

  /* Semantic Colors - Error */
  --color-error-50: #fef2f2;
  --color-error-100: #fee2e2;
  --color-error-200: #fecaca;
  --color-error-300: #fca5a5;
  --color-error-400: #f87171;
  --color-error-500: #ef4444;
  --color-error-600: #dc2626;
  --color-error-700: #b91c1c;
  --color-error-800: #991b1b;
  --color-error-900: #7f1d1d;
  --color-error-950: #450a0a;

  /* Semantic Colors - Info */
  --color-info-50: #eff6ff;
  --color-info-100: #dbeafe;
  --color-info-200: #bfdbfe;
  --color-info-300: #93c5fd;
  --color-info-400: #60a5fa;
  --color-info-500: #3b82f6;
  --color-info-600: #2563eb;
  --color-info-700: #1d4ed8;
  --color-info-800: #1e40af;
  --color-info-900: #1e3a8a;
  --color-info-950: #172554;

  /* Shorthand semantic colors */
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  /* Opacity helpers */
  --color-primary-500-10: rgba(59, 130, 246, 0.1);
  --color-primary-500-20: rgba(59, 130, 246, 0.2);
  --color-error-500-10: rgba(239, 68, 68, 0.1);
  --color-error-500-20: rgba(239, 68, 68, 0.2);

  /* Focus ring shadows */
  --ring-shadow-primary: 0 0 0 3px var(--color-primary-500-20);
  --ring-shadow-error: 0 0 0 3px var(--color-error-500-20);

  /* ==================== SURFACE TOKENS ==================== */

  /* Light Mode Surfaces */
  --surface-light-primary: #f0f1f3;
  --surface-light-secondary: var(--color-white);
  --surface-light-tertiary: var(--color-gray-100);
  --surface-light-quaternary: var(--color-gray-200);

  /* Dark Mode Surfaces */
  --surface-dark-primary: var(--color-black);
  --surface-dark-secondary: #0F0F0F;
  --surface-dark-tertiary: #0F0F0F;
  --surface-dark-quaternary: #0F0F0F;

  /* ==================== TEXT TOKENS ==================== */

  /* Light Mode Text - improved contrast */
  --text-light-primary: var(--color-gray-900);
  --text-light-secondary: var(--color-gray-700);
  --text-light-tertiary: var(--color-gray-600);
  --text-light-quaternary: var(--color-gray-500);

  /* Dark Mode Text */
  --text-dark-primary: var(--color-gray-50);
  --text-dark-secondary: var(--color-gray-300);
  --text-dark-tertiary: var(--color-gray-400);
  --text-dark-quaternary: var(--color-gray-500);

  /* ==================== BORDER TOKENS ==================== */

  --border-light: var(--color-gray-200);
  --border-light-hover: var(--color-gray-300);
  --border-dark: var(--color-gray-700);
  --border-dark-hover: var(--color-gray-600);

  /* ==================== SPACING TOKENS ==================== */

  --space-0: 0;
  --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-8: 2rem; /* 32px */
  --space-10: 2.5rem; /* 40px */
  --space-11: 2.75rem; /* 44px */
  --space-12: 3rem; /* 48px */
  --space-14: 3.5rem; /* 56px */
  --space-16: 4rem; /* 64px */
  --space-20: 5rem; /* 80px */
  --space-24: 6rem; /* 96px */

  /* ==================== TYPOGRAPHY TOKENS ==================== */

  /* Font Sizes */
  --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 */

  /* Font Weights */
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line Heights */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* ==================== BORDER RADIUS TOKENS ==================== */

  --radius-unified: 0.5rem; /* 8px */
  --radius-none: 0;
  --radius-sm: var(--radius-unified);
  --radius-md: var(--radius-unified);
  --radius-lg: var(--radius-unified);
  --radius-xl: var(--radius-unified);
  --radius-2xl: var(--radius-unified);
  --radius-full: 9999px;

  /* Named border radius */
  --border-radius-sm: 0.375rem; /* 6px */
  --border-radius-md: 0.5rem; /* 8px */
  --border-radius-lg: 0.75rem; /* 12px */
  --border-radius-xl: 1rem; /* 16px */
  --border-radius-2xl: 1.5rem; /* 24px */
  --border-radius-full: 9999px;

  /* ==================== SHADOW TOKENS ==================== */

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* ==================== Z-INDEX TOKENS ==================== */

  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
  --z-settings: 2000;
  --z-header: 2500;
  --z-bottom-nav: 3000;

  /* Aliased z-index for compatibility */
  --z-index-base: 1;
  --z-index-dropdown: 1000;
  --z-index-sticky: 1020;
  --z-index-fixed: 1030;
  --z-index-modal-backdrop: 1040;
  --z-index-modal: 1050;
  --z-index-popover: 1060;
  --z-index-tooltip: 1070;
  --z-index-toast: 1080;
  --z-index-settings: 2000;
  --z-index-header: 2500;
  --z-index-bottom-nav: 3000;

  /* ==================== COMPONENT TOKENS ==================== */

  /* Button Tokens */
  --btn-height-sm: 2rem; /* 32px */
  --btn-height-md: 2.5rem; /* 40px */
  --btn-height-lg: 2.75rem; /* 44px */
  --btn-height: var(--space-11); /* 44px */
  --btn-padding-x-sm: 0.75rem; /* 12px */
  --btn-padding-x-md: 1rem; /* 16px */
  --btn-padding-x-lg: 1.25rem; /* 20px */
  --btn-padding-x: var(--space-4); /* 16px */
  --btn-padding-y: var(--space-2-5); /* 10px */
  --btn-font-size: var(--font-size-sm);
  --btn-font-weight: var(--font-weight-medium);
  --btn-radius: var(--border-radius-lg);
  --btn-border-radius: var(--border-radius-lg);
  --btn-icon-size: 1.25rem; /* 20px */

  /* Input Tokens */
  --input-height: var(--space-11); /* 44px */
  --input-padding-x: var(--space-3); /* 12px */
  --input-padding-y: var(--space-2-5); /* 10px */
  --input-border-radius: var(--border-radius-md);

  /* Header Tokens */
  --header-height-mobile: 4rem; /* 64px */
  --header-height-desktop: 5rem; /* 80px */
  --header-total-height-mobile: var(--header-height-mobile);
  --header-total-height-desktop: var(--header-height-desktop);

  /* Bottom Navigation */
  --bottom-nav-height: var(--space-14); /* 56px */

  /* Container max widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;

  /* Modal Tokens */
  --modal-border-radius: var(--border-radius-xl);
  --modal-shadow: var(--shadow-2xl);
  --modal-border: 1px solid;
  --modal-border-color: rgba(229, 231, 235, 0.2);
  --modal-border-color-dark: rgba(55, 65, 81, 0.2);

  /* ==================== GRADIENT TOKENS ==================== */

  --gradient-primary: linear-gradient(to right, var(--color-primary-500), var(--color-accent-600));
  --gradient-primary-hover: linear-gradient(to right, var(--color-primary-600), var(--color-accent-700));

  /* ==================== SEMANTIC THEME TOKENS (Light Mode Default) ==================== */

  --color-surface-primary: var(--surface-light-primary);
  --color-surface-secondary: var(--surface-light-secondary);
  --color-surface-tertiary: var(--surface-light-tertiary);
  --color-surface-quaternary: var(--surface-light-quaternary);

  --color-text-primary: var(--text-light-primary);
  --color-text-secondary: var(--text-light-secondary);
  --color-text-tertiary: var(--text-light-tertiary);
  --color-text-quaternary: var(--text-light-quaternary);

  --color-border: var(--border-light);
  --color-border-hover: var(--border-light-hover);

  /* Extended text tokens — light mode */
  --color-text-muted: rgba(0, 0, 0, 0.35);
  --color-text-icon: rgba(0, 0, 0, 0.4);

  /* Background opacity tokens — light mode */
  --color-bg-subtle: rgba(0, 0, 0, 0.03);
  --color-bg-hover: rgba(0, 0, 0, 0.06);
  --color-bg-active: rgba(0, 0, 0, 0.1);
  --color-bg-progress-track: rgba(0, 0, 0, 0.12);

  /* Extended border tokens — light mode */
  --color-border-subtle: rgba(0, 0, 0, 0.06);
  --color-border-input: rgba(0, 0, 0, 0.18);

  /* Opaque background tokens — light mode */
  --color-bg-base: #f0f1f3;
  --color-bg-surface: rgba(255, 255, 255, 1);
  --color-bg-secondary: rgba(243, 244, 246, 1);
  --color-bg-tertiary: rgba(229, 231, 235, 1);
  --color-bg-overlay: rgba(255, 255, 255, 0.98);
  --color-bg-placeholder: rgba(249, 250, 251, 1);

  /* Selected item highlight — light mode */
  --color-bg-selected: rgba(239, 246, 255, 1);

  /* Additional opaque background pairs — light mode */
  --color-bg-panel: rgba(255, 255, 255, 1);
  --color-bg-inset: rgba(243, 244, 246, 1);
  --color-bg-hover-opaque: rgba(249, 250, 251, 1);

  /* Opaque border tokens — light mode */
  --color-border-default: rgba(229, 231, 235, 1);
  --color-border-strong: rgba(209, 213, 219, 1);

  /* Opaque text tokens — light mode */
  --color-text-on-surface: rgba(55, 65, 81, 1);
  --color-text-disabled: rgba(156, 163, 175, 1);
  --color-text-chat: rgba(107, 114, 128, 1);

  /* Semantic color tokens — light mode */
  --color-profit: #16a34a;
  --color-loss: #dc2626;
  --color-value-locked-bg: rgba(251, 191, 36, 0.2);
  --color-value-locked-text: rgba(180, 83, 9, 1);

  --color-profit-glow: rgba(22, 163, 74, 0.2);
  --color-profit-glow-strong: rgba(22, 163, 74, 0.3);

  /* Status badge tokens — light mode */
  --color-status-sold-bg: rgba(254, 226, 226, 1);
  --color-status-sold-text: rgba(153, 27, 27, 1);
  --color-status-pending-bg: rgba(254, 249, 195, 1);
  --color-status-pending-text: rgba(133, 77, 14, 1);
  --color-status-active-bg: rgba(220, 252, 231, 1);
  --color-status-active-text: rgba(22, 101, 52, 1);

  /* Warning tokens — light mode */
  --color-warning-bg: rgba(254, 249, 195, 1);
  --color-warning-text: rgba(133, 77, 14, 1);

  /* Alert message tokens — light mode */
  --color-alert-success-bg: rgba(22, 163, 74, 0.1);
  --color-alert-success-text: #16a34a;
  --color-alert-success-border: rgba(22, 163, 74, 0.2);
  --color-alert-info-bg: rgba(37, 99, 235, 0.1);
  --color-alert-info-text: #2563eb;
  --color-alert-info-border: rgba(37, 99, 235, 0.2);
  --color-alert-error-bg: rgba(220, 38, 38, 0.1);
  --color-alert-error-text: #dc2626;
  --color-alert-error-border: rgba(220, 38, 38, 0.2);
  --color-border-error: rgba(220, 38, 38, 0.5);

  /* Leave/danger button tokens — light mode */
  --color-danger-bg: rgba(254, 242, 242, 1);
  --color-danger-bg-hover: rgba(254, 226, 226, 1);
  --color-danger-text: rgba(220, 38, 38, 1);

  /* Glassmorphism tokens — light mode */
  --glass-bg-default: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.75) 100%);
  --glass-border-default: rgba(0, 0, 0, 0.10);
  --glass-shadow-default: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --glass-bg-prominent: linear-gradient(135deg, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0.80) 100%);
  --glass-border-prominent: rgba(0, 0, 0, 0.10);
  --glass-bg-card: linear-gradient(135deg, rgba(255, 255, 255, 0.80) 0%, rgba(255, 255, 255, 0.70) 100%);
  --glass-border-card: rgba(0, 0, 0, 0.08);

  /* Empty state icon bg tokens — light mode */
  --color-empty-default-bg: rgba(0, 0, 0, 0.08);
  --color-empty-info-bg: rgba(59, 130, 246, 0.15);
  --color-empty-success-bg: rgba(34, 197, 94, 0.15);
  --color-empty-warning-bg: rgba(251, 146, 60, 0.15);

  /* Brand / FollowButton tokens — light mode */
  --color-follow-bg: rgba(255, 255, 255, 1);
  --color-follow-text: rgba(147, 51, 234, 1);
  --color-follow-hover-bg: rgba(250, 245, 255, 1);

  /* Chart semantic tokens (JS-readable, not CSS-only) — light mode */
  --color-chart-grid: rgba(0, 0, 0, 0.1);
  --color-chart-dot-border: rgba(255, 255, 255, 1);
  --color-chart-tooltip-bg: rgba(255, 255, 255, 0.95);
  --color-chart-tooltip-border: rgba(0, 0, 0, 0.1);
  --color-chart-fill-up: rgba(22, 163, 74, 0.1);
  --color-chart-fill-down: rgba(220, 38, 38, 0.1);

  /* Theme aliases - light mode */
  --bg-primary: #f0f1f3;
  --bg-secondary: var(--color-white);
  --bg-tertiary: var(--color-gray-100);
  --text-primary: var(--color-gray-900);
  --text-secondary: var(--color-gray-700);
  --text-tertiary: var(--color-gray-600);
  --border-primary: var(--color-gray-300);
  --border-secondary: var(--color-gray-400);
  --placeholder-color: var(--color-gray-500);
}

/* ==================== DARK MODE THEME SWITCHING ==================== */

.dark,
html.dark {
  --color-surface-primary: var(--surface-dark-primary);
  --color-surface-secondary: var(--surface-dark-secondary);
  --color-surface-tertiary: var(--surface-dark-tertiary);
  --color-surface-quaternary: var(--surface-dark-quaternary);

  --color-text-primary: var(--text-dark-primary);
  --color-text-secondary: var(--text-dark-secondary);
  --color-text-tertiary: var(--text-dark-tertiary);
  --color-text-quaternary: var(--text-dark-quaternary);

  --color-border: var(--border-dark);
  --color-border-hover: var(--border-dark-hover);

  /* Extended text tokens — dark mode */
  --color-text-muted: rgba(255, 255, 255, 0.35);
  --color-text-icon: rgba(255, 255, 255, 0.4);

  /* Background opacity tokens — dark mode */
  --color-bg-subtle: rgba(255, 255, 255, 0.04);
  --color-bg-hover: rgba(255, 255, 255, 0.08);
  --color-bg-active: rgba(255, 255, 255, 0.12);
  --color-bg-progress-track: rgba(255, 255, 255, 0.18);

  /* Extended border tokens — dark mode */
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-border-input: rgba(255, 255, 255, 0.18);

  /* Opaque background tokens — dark mode */
  --color-bg-base: rgba(15, 15, 15, 1);
  --color-bg-surface: rgba(30, 30, 30, 1);
  --color-bg-secondary: rgba(31, 41, 55, 1);
  --color-bg-tertiary: rgba(55, 65, 81, 1);
  --color-bg-overlay: rgba(15, 15, 15, 0.98);
  --color-bg-placeholder: rgba(38, 42, 51, 1);

  /* Selected item highlight — dark mode */
  --color-bg-selected: rgba(59, 130, 246, 0.2);

  /* Additional opaque background pairs — dark mode */
  --color-bg-panel: rgba(15, 15, 15, 1);
  --color-bg-inset: rgba(15, 15, 15, 1);
  --color-bg-hover-opaque: rgba(55, 65, 81, 1);

  /* Opaque border tokens — dark mode */
  --color-border-default: rgba(55, 65, 81, 1);
  --color-border-strong: rgba(75, 85, 99, 1);

  /* Opaque text tokens — dark mode */
  --color-text-on-surface: rgba(209, 213, 219, 1);
  --color-text-disabled: rgba(156, 163, 175, 1);
  --color-text-chat: rgba(156, 163, 175, 1);

  /* Semantic color tokens — dark mode */
  --color-profit: #4ade80;
  --color-loss: #f87171;
  --color-value-locked-bg: rgba(251, 191, 36, 0.15);
  --color-value-locked-text: rgba(252, 211, 77, 1);

  --color-profit-glow: rgba(74, 222, 128, 0.2);
  --color-profit-glow-strong: rgba(74, 222, 128, 0.3);

  /* Status badge tokens — dark mode */
  --color-status-sold-bg: rgba(153, 27, 27, 0.2);
  --color-status-sold-text: rgba(252, 165, 165, 1);
  --color-status-pending-bg: rgba(133, 77, 14, 0.2);
  --color-status-pending-text: rgba(253, 224, 71, 1);
  --color-status-active-bg: rgba(22, 101, 52, 0.2);
  --color-status-active-text: rgba(134, 239, 172, 1);

  /* Warning tokens — dark mode */
  --color-warning-bg: rgba(133, 77, 14, 0.2);
  --color-warning-text: rgba(253, 224, 71, 1);

  /* Alert message tokens — dark mode */
  --color-alert-success-bg: rgba(34, 197, 94, 0.15);
  --color-alert-success-text: #4ade80;
  --color-alert-success-border: rgba(34, 197, 94, 0.2);
  --color-alert-info-bg: rgba(59, 130, 246, 0.15);
  --color-alert-info-text: #60a5fa;
  --color-alert-info-border: rgba(59, 130, 246, 0.2);
  --color-alert-error-bg: rgba(239, 68, 68, 0.15);
  --color-alert-error-text: #f87171;
  --color-alert-error-border: rgba(239, 68, 68, 0.2);
  --color-border-error: rgba(239, 68, 68, 0.5);

  /* Leave/danger button tokens — dark mode */
  --color-danger-bg: rgba(127, 29, 29, 0.2);
  --color-danger-bg-hover: rgba(127, 29, 29, 0.3);
  --color-danger-text: rgba(248, 113, 113, 1);

  /* Glassmorphism tokens — dark mode */
  --glass-bg-default: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
  --glass-border-default: rgba(255, 255, 255, 0.1);
  --glass-shadow-default: 0 4px 16px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --glass-bg-prominent: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  --glass-border-prominent: rgba(255, 255, 255, 0.12);
  --glass-bg-card: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
  --glass-border-card: rgba(255, 255, 255, 0.08);

  /* Empty state icon bg tokens — dark mode */
  --color-empty-default-bg: rgba(255, 255, 255, 0.12);
  --color-empty-info-bg: rgba(59, 130, 246, 0.2);
  --color-empty-success-bg: rgba(34, 197, 94, 0.2);
  --color-empty-warning-bg: rgba(251, 146, 60, 0.2);

  /* Brand / FollowButton tokens — dark mode */
  --color-follow-bg: rgba(31, 41, 55, 1);
  --color-follow-text: rgba(196, 181, 253, 1);
  --color-follow-hover-bg: rgba(88, 28, 135, 0.2);

  /* Chart semantic tokens — dark mode */
  --color-chart-grid: rgba(255, 255, 255, 0.15);
  --color-chart-dot-border: rgba(31, 31, 31, 1);
  --color-chart-tooltip-bg: rgba(31, 41, 55, 0.95);
  --color-chart-tooltip-border: rgba(255, 255, 255, 0.2);
  --color-chart-fill-up: rgba(74, 222, 128, 0.1);
  --color-chart-fill-down: rgba(248, 113, 113, 0.1);

  /* Theme aliases */
  --bg-primary: var(--color-black);
  --bg-secondary: var(--color-black);
  --bg-tertiary: var(--color-black);
  --text-primary: var(--color-white);
  --text-secondary: var(--color-gray-300);
  --text-tertiary: var(--color-gray-400);
  --border-primary: var(--color-gray-700);
  --border-secondary: var(--color-gray-600);
  --placeholder-color: var(--color-gray-500);
}

/* =============================================================================
   PREFLIGHT / MODERN RESET
   (Previously provided by @tailwind base — Tailwind's preflight CSS)
   ============================================================================= */

/*
 * 1. Prevent padding and border from affecting element width.
 * 2. Allow adding a border to an element by just adding a border-width.
 */
*,
::before,
::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: currentColor;
}

/*
 * 1. Use a consistent sensible line-height in all browsers.
 * 2. Prevent adjustments of font size after orientation changes in iOS.
 * 3. Use a more readable tab size.
 */
html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

/*
 * 1. Remove the margin in all browsers.
 * 2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
 */
body {
  margin: 0;
  line-height: inherit;
}

/*
 * Add the correct height in Firefox.
 */
hr {
  height: 0;
  color: inherit;
  border-top-width: 1px;
}

/*
 * Add the correct text decoration in Chrome, Edge, and Safari.
 */
abbr:where([title]) {
  -webkit-text-decoration: underline dotted;
          text-decoration: underline dotted;
}

/*
 * Remove the default font size and weight for headings.
 */
h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

/*
 * Reset links to optimize for opt-in styling instead of opt-out.
 */
a {
  color: inherit;
  text-decoration: inherit;
}

/*
 * Add the correct font weight in Edge and Safari.
 */
b, strong {
  font-weight: bolder;
}

/*
 * 1. Use the user's configured `mono` font family by default.
 * 2. Correct the odd `em` font sizing in all browsers.
 */
code, kbd, samp, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 1em;
}

/*
 * Add the correct font size in all browsers.
 */
small {
  font-size: 80%;
}

/*
 * Prevent `sub` and `sup` elements from affecting the line height in all browsers.
 */
sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
sub { bottom: -0.25em; }
sup { top: -0.5em; }

/*
 * 1. Remove text indentation from table contents in Chrome and Safari.
 * 2. Correct table border color inheritance in all Chrome and Safari.
 * 3. Remove gaps between table borders by default.
 */
table {
  text-indent: 0;
  border-color: inherit;
  border-collapse: collapse;
}

/*
 * 1. Change the font styles in all browsers.
 * 2. Remove the margin in Firefox and Safari.
 * 3. Remove default padding in all browsers.
 */
button, input, optgroup, select, textarea {
  font-family: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

/*
 * Remove the inheritance of text transform in Edge and Firefox.
 */
button, select {
  text-transform: none;
}

/*
 * 1. Correct the inability to style clickable types in iOS and Safari.
 * 2. Remove default button styles.
 */
button,
[type='button'],
[type='reset'],
[type='submit'] {
  -webkit-appearance: button;
  appearance: button;
  background-color: transparent;
  background-image: none;
}

/*
 * Use the modern Firefox focus style for all focusable elements.
 */
:-moz-focusring {
  outline: auto;
}

/*
 * Remove the additional `:invalid` styles in Firefox.
 */
:-moz-ui-invalid {
  box-shadow: none;
}

/*
 * Correct the cursor style of increment and decrement buttons in Safari.
 */
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
  height: auto;
}

/*
 * 1. Correct the odd appearance in Chrome and Safari.
 * 2. Correct the outline style in Safari.
 */
[type='search'] {
  -webkit-appearance: textfield;
  appearance: textfield;
  outline-offset: -2px;
}

/*
 * Remove the inner padding in Chrome and Safari on macOS.
 */
::-webkit-search-decoration {
  -webkit-appearance: none;
}

/*
 * 1. Correct the inability to style clickable types in iOS and Safari.
 * 2. Change font properties to `inherit` in Safari.
 */
::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

/*
 * Add the correct display in Chrome and Safari.
 */
summary {
  display: list-item;
}

/*
 * Removes the default spacing and border for appropriate elements.
 */
blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

ol, ul, menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/*
 * Reset default styling for dialogs.
 */
dialog {
  padding: 0;
}

/*
 * Prevent resizing textareas horizontally by default.
 */
textarea {
  resize: vertical;
}

/*
 * 1. Reset the default placeholder opacity in Firefox.
 * 2. Set the default placeholder color.
 */
input::placeholder,
textarea::placeholder {
  opacity: 1;
  color: #9ca3af;
}

/*
 * Set the default cursor for buttons.
 */
button, [role="button"] {
  cursor: pointer;
}

/*
 * Make sure disabled buttons don't get the pointer cursor.
 */
:disabled {
  cursor: default;
}

/*
 * 1. Make replaced elements `display: block` by default.
 * 2. Add `vertical-align: middle` to align replaced elements more sensibly by default.
 */
img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

/*
 * Constrain images and videos to the parent width and preserve their intrinsic aspect ratio.
 */
img, video {
  max-width: 100%;
  height: auto;
}

/*
 * Make elements with the HTML hidden attribute stay hidden by default.
 */
[hidden] {
  display: none;
}

/* =============================================================================
   GLOBAL RESETS & BASE STYLES
   ============================================================================= */

/* Prevent pinch-to-zoom and unwanted touch gestures */
html {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection in content areas */
body,
input,
textarea,
select,
button,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* Prevent horizontal scrolling */
body {
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

/* Ensure inputs have adequate font size to prevent iOS zoom */
input,
textarea,
select {
  font-size: 16px !important;
}

/* Fix date input width */
input[type="date"] {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding-right: 12px !important;
}

/* iOS-specific date input fixes */
@supports (-webkit-touch-callout: none) {
  input[type="date"] {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    flex-shrink: 1 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    padding-right: 12px !important;
  }
}

/* Allow normal touch actions for scrollable content */
main,
.modal-content {
  touch-action: auto;
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-y: none;
}

body {
  background-color: #f0f1f3;
  background-color: var(--color-surface-primary);
  color: #111827;
  color: var(--color-text-primary);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  padding-right: 0 !important;
  transition: background-color 0.3s ease, color 0.3s ease;
}

* {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}

/* Hide scrollbars globally */
*::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  font-weight: var(--font-weight-semibold);
  line-height: 1.25;
  line-height: var(--line-height-tight);
  letter-spacing: -0.01em;
}

h1 { font-size: 1.5rem; font-size: var(--font-size-2xl); }
h2 { font-size: 1.25rem; font-size: var(--font-size-xl); }
h3 { font-size: 1.125rem; font-size: var(--font-size-lg); }
h4 { font-size: 1rem; font-size: var(--font-size-base); }

p {
  line-height: 1.5;
  line-height: var(--line-height-normal);
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Line clamp utilities */
.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* Scrollbar hide utility */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

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

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

/* Page layout utilities */
.page-no-padding {
  padding: 0;
  margin: 0;
}

/* Dashboard layouts */
.dashboard-page {
  background-color: #f0f1f3;
  background-color: var(--color-surface-primary);
  min-height: 100vh;
}

.mobile-dashboard {
  padding-bottom: 4rem;
}

@media (min-width: 769px) {
  .mobile-dashboard {
    padding-bottom: 1.5rem;
    padding-bottom: var(--space-6);
  }
}

/* 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: 0;
}

/* =============================================================================
   LAYOUT CLASSES
   ============================================================================= */

/* Header height compensation */
@media (min-width: 769px) {
  .content-with-header {
    padding-top: 5rem;
    padding-top: var(--header-total-height-desktop);
  }
}

/* Main content layout */
.main-content {
  padding-top: 4rem;
  padding-top: var(--header-total-height-mobile);
  padding-bottom: 4rem;
}

@media (min-width: 769px) {
  .main-content {
    padding-top: 5rem;
    padding-top: var(--header-total-height-desktop);
    padding-bottom: 1rem;
  }
}

.main-content.content-with-header {
  padding-top: 4rem;
  padding-top: var(--header-total-height-mobile);
}

@media (min-width: 769px) {
  .main-content.content-with-header {
    padding-top: 5rem;
    padding-top: var(--header-total-height-desktop);
  }
}

/* Header responsive height */
.header-responsive {
  height: 4rem;
  height: var(--header-total-height-mobile);
}

@media (min-width: 769px) {
  .header-responsive {
    height: 5rem;
    height: var(--header-total-height-desktop);
  }
}

/* Mobile dashboard layouts */
.main-content.mobile-dashboard {
  padding-top: 0.5rem;
  padding-top: var(--space-2);
  padding-bottom: 3.5rem;
  padding-bottom: var(--bottom-nav-height);
}

@media (min-width: 769px) {
  .main-content.mobile-dashboard {
    padding-top: 5rem;
    padding-top: var(--header-total-height-desktop);
    padding-bottom: 1rem;
    padding-bottom: var(--space-4);
  }
}

/* Mobile layout variations */
@media (max-width: 768px) {
  .main-content.mobile-dashboard.no-header {
    padding-top: 0.5rem !important;
    padding-top: var(--space-2) !important;
    margin-top: 0 !important;
  }
  
  .main-content.mobile-dashboard.with-header {
    padding-top: 4rem !important;
    padding-top: var(--header-total-height-mobile) !important;
    margin-top: 0 !important;
  }
  
  body.pwa .main-content.mobile-dashboard.no-header {
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px)) !important;
    padding-top: calc(var(--space-2) + var(--safe-area-top)) !important;
  }
  
  body.pwa .main-content.mobile-dashboard.with-header {
    padding-top: calc(4rem + env(safe-area-inset-top, 0px)) !important;
    padding-top: calc(var(--header-total-height-mobile) + var(--safe-area-top)) !important;
  }
  
  .settings-mobile .header-responsive {
    top: 0;
    top: var(--space-0);
  }
  
  .settings-mobile .header-responsive + div {
    padding-top: calc(4rem + 0.5rem);
    padding-top: calc(var(--header-total-height-mobile) + var(--space-2));
  }
}

/* Logged-out page layout */
.logged-out-page {
  min-height: 100vh;
  padding-top: 5rem;
  padding-bottom: 0;
}

/* =============================================================================
   Z-INDEX MANAGEMENT
   ============================================================================= */

.header,
.header button[aria-label='Settings'],
.header button[aria-label='Toggle theme'] {
  position: relative;
  z-index: 2500;
  z-index: var(--z-index-header);
  pointer-events: auto;
}

.header .flex-shrink-0 button {
  pointer-events: auto;
}

.modal-open .header button {
  position: relative;
  z-index: calc(2500 + 10);
  z-index: calc(var(--z-index-header) + 10);
}

.sort-dropdown,
.dropdown,
.sort-dropdown,
.dropdown {
  overflow: visible;
  max-width: calc(100vw - 2rem);
}

/* =============================================================================
   MODAL UTILITIES
   ============================================================================= */

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  touch-action: none;
  overscroll-behavior: none;
}

.modal-content {
  touch-action: auto;
  overscroll-behavior: contain;
}

.modal-open .main-content,
.modal-open main,
.modal-open [role="main"] {
  z-index: 1;
  position: relative;
}

.modal-open .header button {
  pointer-events: none;
}

/* Contextual modals */
@media (max-width: 768px) {
  .modal-contextual {
    height: auto !important;
    max-height: calc(100vh - 1rem) !important;
    margin: 0.5rem !important;
    align-self: center !important;
    min-height: auto !important;
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
  }
  
  .modal-contextual.modal-container {
    position: relative !important;
    inset: auto !important;
  }
}

/* Focus trap */
/* =============================================================================
   FORM UTILITIES
   ============================================================================= */

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

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

.financial-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  grid-gap: 1rem;
  grid-gap: var(--space-4);
  gap: var(--space-4);
}

@media (max-width: 640px) {
  .financial-details-grid {
    grid-template-columns: 1fr;
  }
}

/* Collection selector fixes */
.collection-selector .absolute {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.collection-selector .absolute::-webkit-scrollbar {
  display: none;
}

header .max-h-60.overflow-y-auto {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

header .max-h-60.overflow-y-auto::-webkit-scrollbar {
  display: none;
}

/* Card details modal fix */
.card-details-modal #modal-title {
  display: flex !important;
  width: 100% !important;
}

/* =============================================================================
   MOBILE SCROLL UTILITIES
   ============================================================================= */

.mobile-scroll {
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.mobile-scroll > div {
  scroll-snap-align: start;
}

.mobile-scroll > div > * {
  scroll-snap-align: start;
}

@supports (-webkit-overflow-scrolling: touch) {
  .mobile-scroll {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 640px) {
  .mobile-scroll {
    scroll-snap-type: x mandatory;
    scroll-snap-stop: always;
  }
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

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

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Modal animations */
@keyframes backdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

@keyframes modalSlideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes modalExitRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(30px); }
}

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

.animate-modal-scale-in { animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.animate-modal-exit { animation: modalExit 0.2s ease-in forwards; }
.animate-modal-slide-in-right { animation: modalSlideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-modal-exit-right { animation: modalExitRight 0.2s ease-in forwards; }

/* =============================================================================
   GRADIENT & GLASS UTILITIES
   ============================================================================= */

.hover\:bg-primary-gradient-hover:hover {
  background: linear-gradient(to right, #2563eb, #be185d);
  background: var(--gradient-primary-hover);
}

.hover\:glass-border-hover:hover { border-color: rgba(255, 255, 255, 0.3); }
.hover\:glass-bg-hover:hover { background-color: rgba(255, 255, 255, 0.2); }
/* =============================================================================
   FOCUS & SELECTION STYLES
   ============================================================================= */

:focus {
  outline: 2px solid #3b82f6;
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

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

:focus-visible {
  outline: 2px solid #3b82f6;
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

::selection {
  background-color: #bfdbfe;
  background-color: var(--color-info-200);
  color: #1e3a8a;
  color: var(--color-info-900);
}

.dark ::selection {
  background-color: #1d4ed8;
  background-color: var(--color-info-700);
  color: #dbeafe;
  color: var(--color-info-100);
}

/* =============================================================================
   DARK MODE OVERRIDES
   ============================================================================= */

html.dark body {
  background-color: #0b0f19;
  color: white;
}

.dark .settings-button-class svg {
  fill: white;
}

/* =============================================================================
   PWA-SPECIFIC STYLES
   ============================================================================= */

@media (display-mode: standalone) {
  body {
    /* Safe-area top/bottom handled by header position + main-content padding, not body */
    padding-left: env(safe-area-inset-left, 0px);
    padding-left: var(--safe-area-left);
    padding-right: env(safe-area-inset-right, 0px);
    padding-right: var(--safe-area-right);
    background-color: #000000 !important;
  }

  .main-content {
    padding-top: calc(4rem + env(safe-area-inset-top, 0px));
    padding-top: calc(var(--header-total-height-mobile) + var(--safe-area-top));
    padding-bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  }

  @media (min-width: 769px) {
    .main-content {
      padding-top: calc(5rem + env(safe-area-inset-top, 0px));
      padding-top: calc(var(--header-total-height-desktop) + var(--safe-area-top));
      padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
      padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
    }
  }

  body.pwa header.fixed,
  body.pwa .header-responsive.fixed,
  header.header-pwa {
    top: env(safe-area-inset-top, 0px);
    top: var(--safe-area-top);
  }

  body.pwa .bottom-navigation.fixed {
    bottom: env(safe-area-inset-bottom, 0px);
    bottom: var(--safe-area-bottom);
  }

  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    height: var(--safe-area-top);
    background-color: #000000 !important;
    z-index: 2500;
    z-index: var(--z-index-header);
  }

  /* Shared collection page has no .main-content or fixed header — needs its own safe-area handling */
  .shared-collection-page {
    padding-top: env(safe-area-inset-top, 0px);
    padding-top: var(--safe-area-top);
  }
}

/* Capacitor native app — ensure modals and overlays cover safe area regions with dark backgrounds */
body.capacitor {
  background-color: #000000 !important;
}

body.capacitor html,
html:has(body.capacitor) {
  background-color: #000000 !important;
}

/* Ensure the root app container fills the entire viewport including safe areas */
body.capacitor #root {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #f0f1f3;
  background-color: var(--color-surface-primary, #1B2131);
}

/* Capacitor: duplicate the standalone media-query rules that don't fire in WKWebView */
body.capacitor header.fixed,
body.capacitor .header-responsive.fixed {
  top: env(safe-area-inset-top, 0px);
  top: var(--safe-area-top);
}

body.capacitor .bottom-navigation.fixed {
  bottom: env(safe-area-inset-bottom, 0px);
  bottom: var(--safe-area-bottom);
}

/* Capacitor: black bar behind status bar (mirrors PWA body::before) */
body.capacitor::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  height: var(--safe-area-top);
  background-color: #000000 !important;
  z-index: 2500;
  z-index: var(--z-index-header);
}

/* Capacitor: safe-area padding for dashboard and content (mirrors body.pwa rules) */
body.capacitor .main-content {
  padding-top: calc(5rem + env(safe-area-inset-top, 0px));
  padding-top: calc(var(--header-total-height-desktop) + var(--safe-area-top));
}

@media (max-width: 768px) {
  body.capacitor .main-content {
    padding-top: calc(4rem + env(safe-area-inset-top, 0px)) !important;
    padding-top: calc(var(--header-total-height-mobile) + var(--safe-area-top)) !important;
  }
  body.capacitor .main-content.mobile-dashboard.no-header {
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px)) !important;
    padding-top: calc(var(--space-2) + var(--safe-area-top)) !important;
  }
  body.capacitor .main-content.mobile-dashboard.with-header {
    padding-top: calc(4rem + env(safe-area-inset-top, 0px)) !important;
    padding-top: calc(var(--header-total-height-mobile) + var(--safe-area-top)) !important;
  }
}

/* iOS-specific styles — only apply rounded corners to modals that opt-in via .ios-modal-radius,
   NOT to full-screen modals (which use border-radius: 0 on mobile via ModalGlass.module.css) */
@media screen and (max-width: 640px) {
  .ios-modal-radius > div {
    border-radius: 20px !important;
  }
}

@supports (-webkit-touch-callout: none) {
  body {
    background-color: #000000 !important;
  }
  
  body::before {
    background-color: #000000 !important;
  }
}

/* =============================================================================
   PRINT UTILITIES
   ============================================================================= */

@media print {
  .no-print {
    display: none;
  }

  .print-only {
    display: block;
  }

  body {
    background: white !important;
    color: black !important;
  }
}

/* =============================================================================
   COMPONENT BASE STYLES
   ============================================================================= */

/* Card component base */
/* Button base */
.btn-base:focus {
  outline: none;
  box-shadow: 0 0 0 2px #93c5fd;
  box-shadow: 0 0 0 2px var(--color-primary-300);
}

/* Form input base */
.input-base:focus {
  outline: none;
  border-color: #3b82f6;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 1px #3b82f6;
  box-shadow: 0 0 0 1px var(--color-primary-500);
}

.input-base::placeholder {
  color: #6b7280;
  color: var(--placeholder-color);
}

/* Modal base */
.modal-base.dark {
  border-color: rgba(55, 65, 81, 0.2);
  border-color: var(--modal-border-color-dark);
}

/**
 * Toast System Styles
 * 
 * Unified styling for all toast notifications.
 * Import this in your main CSS file or App.js
 */

/* =============================================================================
   CSS VARIABLES (Design Tokens)
   ============================================================================= */

:root {
  /* Toast Colors — liquid glass */
  --toast-bg: rgba(18, 18, 18, 0.65);
  --toast-bg-success: rgba(5, 150, 105, 0.55);
  --toast-bg-error: rgba(220, 38, 38, 0.55);
  --toast-bg-warning: rgba(217, 119, 6, 0.55);
  --toast-bg-info: rgba(18, 18, 18, 0.65);
  --toast-text: #FFFFFF;
  
  /* Toast Dimensions */
  --toast-radius: 16px;
  --toast-padding: 12px 16px;
  --toast-max-width: 400px;
  --toast-min-width: 200px;
  
  /* Toast Effects */
  --toast-shadow: 0 1px 0 rgba(255, 255, 255, 0.20) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  --toast-border: 1px solid rgba(255, 255, 255, 0.10);
  --toast-z-index: 99999;
  
  /* Toast Typography */
  --toast-font-size: 14px;
  --toast-font-weight: 500;
  --toast-line-height: 1.4;
}

/* Dark mode — same glass values */
.dark {
  --toast-bg: rgba(18, 18, 18, 0.65);
  --toast-bg-success: rgba(5, 150, 105, 0.55);
  --toast-bg-error: rgba(220, 38, 38, 0.55);
  --toast-bg-warning: rgba(217, 119, 6, 0.55);
  --toast-bg-info: rgba(18, 18, 18, 0.65);
  --toast-text: #FFFFFF;
}

/* =============================================================================
   TOAST CONTAINER
   ============================================================================= */

/* Ensure toast container is above everything */
.react-hot-toast,
div[style*="z-index: 99999"] {
  z-index: 99999 !important;
  z-index: var(--toast-z-index) !important;
}

/* =============================================================================
   LOADING SPINNER ANIMATION
   ============================================================================= */

@keyframes toast-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.toast-spinner {
  animation: toast-spin 1s linear infinite;
}

/* Alternative class name for the spinner */
svg.toast-spinner,
.toast-loading-icon {
  animation: toast-spin 1s linear infinite;
}

/* =============================================================================
   TOAST ENTER/EXIT ANIMATIONS
   ============================================================================= */

@keyframes toast-enter {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

/* Apply animations to react-hot-toast */
[data-hot-toast] {
  animation: toast-enter 0.2s ease-out;
}

[data-hot-toast][data-removed="true"] {
  animation: toast-exit 0.15s ease-in forwards;
}

/* =============================================================================
   TOAST DISMISS BUTTON
   ============================================================================= */

/* Style for dismiss button inside toasts */
.toast-dismiss-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  opacity: 0.7;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.toast-dismiss-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.toast-dismiss-btn:focus {
  outline: none;
  opacity: 1;
}

/* =============================================================================
   TOAST CONTENT LAYOUT
   ============================================================================= */

/* Ensure proper layout inside toasts */
.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

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

.toast-message {
  flex: 1 1;
  word-break: break-word;
}

/* =============================================================================
   MOBILE RESPONSIVENESS
   ============================================================================= */

@media (max-width: 768px) {
  :root {
    --toast-max-width: calc(100vw - 32px);
    --toast-font-size: 13px;
  }
  
  /* Push toasts above the mobile bottom nav bar (~60px + 12px gap) */
  div[style*="z-index: 99999"] {
    bottom: 72px !important;
  }
  
  /* Center toasts on mobile with proper margins */
  .react-hot-toast > div {
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
  }
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .toast-spinner {
    animation: none;
  }
  
  [data-hot-toast] {
    animation: none;
  }
  
  [data-hot-toast][data-removed="true"] {
    animation: none;
    opacity: 0;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --toast-shadow: 0 0 0 2px currentColor;
  }
}

/* =============================================================================
   LEGACY CLASS CLEANUP
   These override any old toast styles that might conflict
   ============================================================================= */

/* Override old design-system toast classes */
.design-system-toast,
.success-toast,
.error-toast,
.info-toast,
.warning-toast,
.loading-toast {
  /* Reset any conflicting styles */
  all: unset;
  display: flex;
  align-items: center;
  gap: 10px;
}

