:root {
  /* Color Palette */
  --primary-navy: #001F3F;
  --accent-gold: #CD9703;
  --neutral-gray: #CBCBCB;
  --dark-navy: #000D1A;
  --light-gold: #FFD700;
  --light-gray: #F0F0F0;
  --white: #FFFFFF;
  --black: #000000;
  
  /* Extended Color System */
  --bg-primary: #0a0e1a;
  --bg-secondary: #1a1f2e;
  --bg-tertiary: #242b3e;
  --surface: #2a3441;
  --surface-hover: #364154;
  
  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #b8c5d6;
  --text-muted: #8a9aab;
  --text-inverse: #000000;
  
  /* Status Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --error: #ef4444;
  --error-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --info-light: #dbeafe;
  
  /* Chart Colors */
  --chart-green: #10b981;
  --chart-red: #ef4444;
  --chart-volume: #6366f1;
  --chart-grid: #374151;
  
  /* Typography Scale */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --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;
  
  /* Spacing System (8px base grid) */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  
  /* Border Radius */
  --radius-sm: 0.25rem;  /* 4px */
  --radius-base: 0.5rem; /* 8px */
  --radius-lg: 0.75rem;  /* 12px */
  --radius-xl: 1rem;     /* 16px */
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 31, 63, 0.05);
  --shadow-base: 0 1px 3px 0 rgba(0, 31, 63, 0.1), 0 1px 2px 0 rgba(0, 31, 63, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 31, 63, 0.1), 0 4px 6px -2px rgba(0, 31, 63, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 31, 63, 0.1), 0 10px 10px -5px rgba(0, 31, 63, 0.04);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 300ms ease;
  --transition-slow: 500ms ease;
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal: 1040;
  --z-popover: 1050;
  --z-tooltip: 1060;
}

/* Reset and Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(205, 151, 3, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(0, 31, 63, 0.1) 0%, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
  margin-bottom: var(--space-4);
}

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

p {
  margin-bottom: var(--space-4);
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--light-gold);
}

/* Button Base Styles */
button {
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border: none;
  border-radius: var(--radius-base);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: all var(--transition-fast);
  background-color: var(--surface);
  color: var(--text-primary);
  outline: none;
}

button:hover {
  background-color: var(--surface-hover);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.active {
  background-color: var(--accent-gold);
  color: var(--text-inverse);
}

/* Form Elements */
select, input {
  font-family: inherit;
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--surface);
  border-radius: var(--radius-base);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

select:focus, input:focus {
  border-color: var(--accent-gold);
}

/* Layout Components */
.dashboard-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--surface);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(10px);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
}

.header-left .dashboard-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0;
}

.title-icon {
  color: var(--accent-gold);
  font-size: var(--font-size-3xl);
}

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

.crypto-selector {
  min-width: 200px;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  background-color: var(--surface);
  border: 1px solid var(--chart-grid);
}

.timeframe-selector {
  display: flex;
  background-color: var(--surface);
  border-radius: var(--radius-base);
  padding: var(--space-1);
  gap: var(--space-1);
}

.timeframe-btn {
  padding: var(--space-2) var(--space-4);
  background-color: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--error);
}

.status-indicator.online {
  background-color: var(--success);
}

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

.last-update {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Main Dashboard Layout */
.dashboard-main {
  flex: 1;
  padding: var(--space-6);
}

.dashboard-container {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto auto;
  gap: var(--space-6);
  grid-template-areas:
    "chart metrics"
    "news news";
}

/* Chart Section */
.chart-section {
  grid-area: chart;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.chart-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  margin: 0;
}

.chart-controls {
  display: flex;
  gap: var(--space-2);
}

.chart-type-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
}

.chart-container {
  position: relative;
  height: 400px;
  margin-bottom: var(--space-4);
}

.price-chart {
  width: 100%;
  height: 100%;
}

.volume-chart-container {
  height: 100px;
}

.volume-chart {
  width: 100%;
  height: 100%;
}

/* Metrics Section */
.metrics-section {
  grid-area: metrics;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-6);
  color: var(--text-primary);
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.metric-card {
  background-color: var(--surface);
  border-radius: var(--radius-base);
  padding: var(--space-4);
  transition: transform var(--transition-fast);
}

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

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

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

.metric-change {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

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

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

.metric-value {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.price-card .metric-value {
  font-size: var(--font-size-2xl);
  color: var(--accent-gold);
}

/* News Section */
.news-section {
  grid-area: news;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.news-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.news-controls {
  display: flex;
  gap: var(--space-2);
}

.news-filter-btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

.news-feed {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}

.news-article {
  background-color: var(--surface);
  border-radius: var(--radius-base);
  padding: var(--space-4);
  transition: transform var(--transition-fast);
  cursor: pointer;
}

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

.news-article-header {
  margin-bottom: var(--space-3);
}

.news-article-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.news-article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.news-article-source {
  font-weight: var(--font-weight-medium);
  color: var(--accent-gold);
}

.news-article-excerpt {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Loading States */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface);
  border-top: 2px solid var(--accent-gold);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

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

.loading-spinner.extra-large {
  width: 64px;
  height: 64px;
  border-width: 6px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.chart-loading,
.news-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  height: 200px;
  color: var(--text-secondary);
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(10, 14, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
  opacity: 1;
  transition: opacity var(--transition-base);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base), visibility 0s linear var(--transition-base);
  visibility: hidden;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  text-align: center;
  color: var(--text-primary);
  padding: var(--space-8);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  min-width: 350px;
  max-width: 450px;
  width: 90vw;
  animation: loadingContentAppear 0.3s ease-out;
}

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

.loading-content .loading-spinner {
  margin: 0 auto;
}

.loading-content p {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.loading-progress {
  width: 100%;
  height: 6px;
  background-color: var(--surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-4);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--light-gold));
  border-radius: var(--radius-full);
  transition: width 0.3s ease-out;
  width: 0%;
  position: relative;
  overflow: hidden;
}

.loading-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.loading-steps {
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  min-height: 2em;
  line-height: 1.4;
  font-weight: var(--font-weight-medium);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: var(--z-modal);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

/* Footer */
.dashboard-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--surface);
  padding: var(--space-6);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: var(--space-6);
}

.footer-link {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.footer-link:hover {
  color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .dashboard-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "chart"
      "metrics"
      "news";
  }
  
  .header-container {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
  }
  
  .header-center {
    flex-direction: column;
    gap: var(--space-4);
  }
}

@media (max-width: 768px) {
  .dashboard-main {
    padding: var(--space-4);
  }
  
  .chart-section,
  .metrics-section,
  .news-section {
    padding: var(--space-4);
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .news-feed {
    grid-template-columns: 1fr;
  }
  
  .footer-container {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }
}

@media (max-width: 480px) {
  .timeframe-selector {
    flex-wrap: wrap;
  }
  
  .chart-container {
    height: 300px;
  }
  
  .header-right {
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

.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;
}

/* Fear & Greed Index Specific Styles */
.fear-greed-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}

.fear-greed-label {
  font-size: var(--font-size-xs);
  opacity: 0.8;
  display: block;
  margin-top: var(--space-1);
}

.fear-greed-extreme-fear { color: var(--error); }
.fear-greed-fear { color: #f97316; }
.fear-greed-neutral { color: var(--warning); }
.fear-greed-greed { color: #84cc16; }
.fear-greed-extreme-greed { color: var(--success); }