:root {
  font-family: "Inter", "Segoe UI", sans-serif;
  line-height: 1.5;
  color-scheme: light;
  --bg: #f6f8fa;
  --bg-alt: #ffffff;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-alt: rgba(255, 255, 255, 0.65);
  --table-bg: #ffffff;
  --table-bg-hover: #e8f2ff;
  --border: rgba(27, 31, 35, 0.1);
  --text: #1f2328;
  --text-muted: rgba(31, 35, 40, 0.55);
  --text-label: rgba(31, 35, 40, 0.85);
  --accent: #0969da;
  --accent-muted: rgba(9, 105, 218, 0.2);
  --success: #1a7f37;
  --danger: #cf222e;

  /* ============================================
     TABLE CONFIGURATION - ADJUST HERE FOR SPACING
     ============================================
     
     🎨 QUICK TUNING GUIDE:
     
     To reduce crowding, increase:
       • --table-cell-padding-horizontal (space left/right in cells)
       • --table-col-default-min (minimum width for all columns)
     
     To make table more compact, decrease:
       • --table-cell-padding-vertical (row height)
       • --table-font-size (text size)
     
     To adjust specific columns, modify:
       • --table-col-rank, --table-col-ticker, etc.
     
     ============================================ */
  
  /* Font sizes */
  --table-font-size: 0.8rem;
  --table-header-font-size: 0.85rem;
  
  /* Cell padding - INCREASE horizontal padding to reduce crowding */
  --table-cell-padding-vertical: 0.5rem;
  --table-cell-padding-horizontal: 1rem;  /* ← Increase this to add more space between columns */
  --table-header-padding-vertical: 0.6rem;
  --table-header-padding-horizontal: 1rem;
  
  /* Sticky column widths */
  --table-col-visibility: 40px;
  --table-col-rank: 80px;
  --table-col-ticker: 90px;
  
  /* Regular column widths - INCREASE to prevent crowding */
  --table-col-default-min: 100px;  /* ← Minimum width for ALL columns */
  --table-col-price: 80px;
  --table-col-marketcap: 110px;
  --table-col-range: 160px;
  
  /* Preset return columns (multi-period returns) */
  --table-col-preset-return: 105px;  /* ← ADJUST THIS to make preset columns wider/narrower */
  --table-col-preset-summary: 120px;  /* ← Multi-period visual summary column width */
  --table-preset-summary-height: 28px;  /* ← Height of the bar chart in each cell */
  --table-preset-bar-gap: 1px;  /* ← Gap between bars */
  
  /* Borders */
  --table-border-width: 1px;
  --table-border-color: rgba(31, 35, 40, 0.032);
  --table-border-vertical: rgba(31, 35, 40, 0.08);
  
  /* Table Category Colors (for column headers and toggle buttons) */
  /* Basic - Blue */
  --category-basic-bg: rgba(59, 130, 246, 0.08);
  --category-basic-border: rgba(59, 130, 246, 0.3);
  --category-basic-text: rgb(37, 99, 235);
  
  /* Quant Metrics (special) - Purple */
  --category-special-bg: rgba(139, 92, 246, 0.08);
  --category-special-border: rgba(139, 92, 246, 0.3);
  --category-special-text: rgb(124, 58, 237);
  
  /* Multi-Period - Green */
  --category-multi-period-bg: rgba(16, 185, 129, 0.08);
  --category-multi-period-border: rgba(16, 185, 129, 0.3);
  --category-multi-period-text: rgb(5, 150, 105);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-alt: rgba(13, 17, 23, 0.85);
  --panel: #161b22;
  --panel-alt: rgba(22, 27, 34, 0.65);
  --table-bg: #161b22;
  --table-bg-hover: #1c2530;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e6edf3;
  --text-muted: rgba(230, 237, 243, 0.65);
  --text-label: rgba(230, 237, 243, 0.90);
  --accent: #58a6ff;
  --accent-muted: rgba(88, 166, 255, 0.35);
  --success: #2ea043;
  --danger: #f85149;
  
  /* Dark mode table borders */
  --table-border-color: rgba(255, 255, 255, 0.05);
  --table-border-vertical: rgba(255, 255, 255, 0.05);
  
  /* Table Category Colors - Dark Theme */
  /* Basic - Blue */
  --category-basic-bg: rgba(96, 165, 250, 0.12);
  --category-basic-border: rgba(96, 165, 250, 0.35);
  --category-basic-text: rgb(147, 197, 253);
  
  /* Quant Metrics (special) - Purple */
  --category-special-bg: rgba(167, 139, 250, 0.12);
  --category-special-border: rgba(167, 139, 250, 0.35);
  --category-special-text: rgb(196, 181, 253);
  
  /* Multi-Period - Green */
  --category-multi-period-bg: rgba(52, 211, 153, 0.12);
  --category-multi-period-border: rgba(52, 211, 153, 0.35);
  --category-multi-period-text: rgb(110, 231, 183);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(to right, #f9fdff, #e9f3fe);
  color: var(--text);
}

[data-theme="dark"] body {
  background: radial-gradient(120% 120% at 80% 0%, rgba(88, 166, 255, 0.16), transparent),
    radial-gradient(140% 140% at 0% 100%, rgba(248, 81, 73, 0.12), transparent),
    var(--bg);
}

.app-shell {
  width: 85vw;
  max-width: none; /* No artificial cap - use full width on ultrawides */
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Limit width on ultrawide screens when feature is not available */
.app-shell.no-ultrawide {
  max-width: 1600px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.title-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 720px;
  align-items: flex-start;
}

.header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Auth button container */
#auth-container {
  display: flex;
  align-items: center;
}

/* Session buttons - hidden by default, shown for anonymous users via JS */
#copy-session-link,
#new-session-button {
  display: none;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
}

.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

[data-theme="dark"] .auth-btn {
  background: var(--panel);
  border-color: rgba(230, 237, 243, 0.35);
  color: var(--text);
}

[data-theme="dark"] .auth-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Tier badge */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
}

.tier-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tier-badge.free {
  background: var(--panel);
  border-color: rgba(31, 35, 40, 0.25);
  color: var(--text);
}

[data-theme="dark"] .tier-badge.free {
  background: var(--panel);
  border-color: rgba(230, 237, 243, 0.35);
  color: var(--text);
}

.tier-badge.professional {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.tier-badge .tier-icon {
  display: none;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke-width: 2.4;
  color: currentColor;
}

.tier-badge.has-icon .tier-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Beta Badge */
.beta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
  border: 2px solid #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  color: #667eea;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .beta-badge {
  border-color: #8b9eff;
  color: #8b9eff;
  background: linear-gradient(135deg, rgba(139, 158, 255, 0.2) 0%, rgba(148, 103, 192, 0.2) 100%);
}

[data-theme="dark"] .beta-badge:hover {
  background: linear-gradient(135deg, rgba(139, 158, 255, 0.3) 0%, rgba(148, 103, 192, 0.3) 100%);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 450px;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-show {
  opacity: 1;
  transform: translateY(0);
}

.toast-hide {
  opacity: 0;
  transform: translateY(10px) scale(0.95);
}

[data-theme="dark"] .toast {
  background: var(--panel);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast-content {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
}

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

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

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

.toast-message strong {
  color: var(--text);
  font-weight: 600;
}

.toast-upgrade-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.toast-upgrade-link:hover {
  color: #0860ca;
  text-decoration: underline;
}

[data-theme="dark"] .toast-upgrade-link:hover {
  color: #6eb5ff;
}

/* Toast Types */
.toast-limit {
  border-left: 4px solid #f59e0b;
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}

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

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

/* Mobile responsiveness */
@media (max-width: 640px) {
  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }
  
  .toast {
    min-width: auto;
    max-width: none;
  }
}

/* Cancellation Banner */
.cancellation-banner {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.cancellation-banner-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.cancellation-banner-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  opacity: 0.8;
}

.cancellation-banner-text {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.9rem;
  min-width: 300px;
}

.cancellation-banner-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.cancellation-banner-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cancellation-banner-btn.primary {
  background: var(--accent);
  color: white;
}

.cancellation-banner-btn.primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cancellation-banner-btn.dismiss {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 700;
}

.cancellation-banner-btn.dismiss:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .cancellation-banner-content {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .cancellation-banner-text {
    min-width: 0;
    width: 100%;
  }
  
  .cancellation-banner-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .cancellation-banner-btn.primary {
    flex: 1;
  }
}

.app-header h1 {
  font-size: 2.5rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.app-logo {
  max-height: 50px;
  height: auto;
  width: auto;
  display: block;
  margin: 0;
  object-fit: contain;
}

.app-header p {
  margin: 0;
  color: var(--text-muted);
}

.theme-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-select label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.theme-select select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  background: var(--panel-alt);
  color: var(--text);
  font-weight: 500;
  font-size: 0.875rem;
  min-width: 90px;
  cursor: pointer;
}

.copy-feedback {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================================
   Loading Modal
   ============================================================================ */

.loading-modal {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99999;
  animation: slideUpFade 0.3s ease;
  pointer-events: none;
}

.loading-modal[hidden] {
  display: none;
}

.loading-modal.fade-out {
  animation: fadeOut 0.3s ease;
}

.loading-modal-content {
  background: var(--panel);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: #0969da;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

[data-theme="dark"] .loading-spinner {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: #58a6ff;
}

.loading-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

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

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

/* Status Indicators (kept for save indicator) */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  margin-right: 8px;
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.status-indicator[hidden] {
  display: none;
}

/* Spinner animation */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.save-icon {
  font-size: 14px;
  animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}


/* Pin button */
.pin-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--background);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  z-index: 2;
}

.pin-btn:hover {
  color: var(--text);
  background: var(--panel);
}

.pin-btn.active {
  color: #f39c12;
}

[data-theme="dark"] .pin-btn {
  background: #161b22;
  color: var(--text-muted);
}

[data-theme="dark"] .pin-btn:hover {
  background: #21262d;
  color: var(--text);
}

[data-theme="dark"] .pin-btn.active {
  color: #f1c40f;
}


/* ============================================================================
   Comparison Sets UI
   ============================================================================ */

.comparison-sets-row {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.comparison-sets-container {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: center;
}

.comparison-sets-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--text-label);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: help;
}

.comparison-sets-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  align-items: center;
  flex: 1;
}

/* Target the TomSelect wrapper for proper width */
#comparison-set-selector,
.comparison-sets-controls .ts-wrapper {
  flex: 1;
  min-width: 300px;
  max-width: 500px;
}

.set-btn {
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: linear-gradient(to bottom, var(--panel), var(--background));
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.set-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #ffffff, #f6f8fa);
  border-color: #0969da;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(9, 105, 218, 0.15);
}

.set-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.set-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--background);
}

/* Dark theme adjustments */
[data-theme="dark"] .set-btn {
  background: linear-gradient(to bottom, #21262d, #161b22);
}

[data-theme="dark"] .set-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #30363d, #21262d);
  border-color: #58a6ff;
  box-shadow: 0 2px 6px rgba(88, 166, 255, 0.15);
}

/* TomSelect customization for comparison sets */
.comparison-set-option {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
}

.comparison-set-option .set-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.comparison-set-option .set-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.comparison-set-item {
  font-weight: 500;
}

/* TomSelect no results message */
.ts-dropdown .no-results {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Ticker dropdown option styling */
.ticker-option {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.15rem 0;
}

.ticker-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.ticker-symbol {
  font-weight: 600;
  color: var(--text);
}

.ticker-mcap {
  font-size: 0.85em;
  font-weight: 600;
  color: #16a34a;
  background: rgba(22, 163, 74, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

[data-theme="dark"] .ticker-mcap {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
}

.ticker-company {
  color: var(--text-muted);
  font-size: 0.9em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8em;
}

.ticker-sector {
  color: var(--text-muted);
}

.ticker-separator {
  color: var(--text-muted);
  opacity: 0.5;
  font-size: 0.85em;
}

.ticker-industry {
  color: var(--accent);
  font-weight: 500;
}

/* Dark theme adjustments for ticker dropdown */
[data-theme="dark"] .ticker-industry {
  color: #58a6ff;
}

/* ============================================================================
   Tabs
   ============================================================================ */

.controls-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0;
  border-bottom: 2px solid var(--border);
}

.tab-button {
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
}

.tab-button:hover:not(.active) {
  color: var(--text);
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .tab-button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.03);
}

.tab-button.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}

.tab-content {
  display: none;
  padding: 1.5rem;
  background: var(--panel);
}

.tab-content.active {
  display: block;
}

/* Section styling within tabs */
.control-section {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.control-section:last-child {
  margin-bottom: 0;
}

[data-theme="dark"] .control-section {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

.section-title {
  margin: 0 0 1rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Add spacing between rows within sections */
.control-section .controls-row {
  margin-bottom: 1rem;
}

.control-section .controls-row:last-child {
  margin-bottom: 0;
}

/* ============================================================================
   Configuration Tab Layout
   ============================================================================ */

/* Row with label and control side-by-side (e.g., Top Performers) */
.config-control-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.config-control-row label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--text-label);
  white-space: nowrap;
  flex-shrink: 0;
}

.config-control-row select {
  flex: 0 0 auto;
  min-width: 150px;
}

/* Block with label above control (e.g., Quant Metrics, Multi-Period) */
.config-control-block {
  margin-bottom: 1.5rem;
}

.config-control-block:last-child {
  margin-bottom: 0;
}

.config-control-block label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--text-label);
}

.config-control-block .label-with-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.config-control-block select {
  width: 100%;
}

/* ============================================================================
   Triple-Dot Menu
   ============================================================================ */

.set-menu-container {
  position: relative;
}

.set-menu-btn {
  padding: 0.5rem 0.75rem;
  font-size: 1.2rem;
  font-weight: bold;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: linear-gradient(to bottom, var(--panel), var(--background));
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.set-menu-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #ffffff, #f6f8fa);
  border-color: #0969da;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(9, 105, 218, 0.15);
}

.set-menu-btn:active:not(:disabled) {
  transform: translateY(0);
}

.set-menu-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

[data-theme="dark"] .set-menu-btn {
  background: linear-gradient(to bottom, #21262d, #161b22);
}

[data-theme="dark"] .set-menu-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #30363d, #21262d);
  border-color: #58a6ff;
}

.set-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
}

[data-theme="dark"] .set-menu-dropdown {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.set-menu-item {
  width: 100%;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.set-menu-item:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .set-menu-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.set-menu-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.set-menu-item.danger {
  color: #d1242f;
}

.set-menu-item.danger:hover:not(:disabled) {
  background: rgba(209, 36, 47, 0.08);
}

.set-menu-item .menu-icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* Modal for add/rename */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(12, 17, 29, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

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

.modal-dialog {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 80px rgba(7, 15, 35, 0.35);
  width: 90%;
  max-width: 450px;
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

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

.modal-header {
  padding: 1.75rem 1.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
}

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

.modal-body {
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--panel);
}

.modal-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  display: block;
}

.modal-input:focus {
  outline: none;
  border-color: #0969da;
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
  background: var(--panel);
}

.modal-char-count {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
  letter-spacing: 0.02em;
}

.modal-error {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #d1242f;
  min-height: 1.2rem;
}

.modal-footer {
  padding: 1.25rem 1.75rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0.03));
}

.modal-btn {
  padding: 0.625rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 96px;
}

.modal-btn-cancel {
  background: var(--background);
  color: var(--text);
  border: 1px solid var(--border);
}

.modal-btn-cancel:hover {
  background: var(--panel);
  border-color: var(--text-muted);
}

.modal-btn-save {
  background: linear-gradient(135deg, #0a74ef, #0a63d1);
  color: white;
  box-shadow: 0 6px 18px rgba(9, 105, 218, 0.35);
}

.modal-btn-save:hover {
  background: linear-gradient(135deg, #0a6ae0, #095cc0);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(9, 105, 218, 0.3);
}

.modal-btn-save:active {
  transform: translateY(0);
}

.status-section {
  margin-top: 0;
  max-height: 100px;
  overflow: hidden;
  transition: max-height 0.3s ease;
  cursor: pointer;
  position: relative;
}

.status-section:hover,
.status-section.expanded {
  max-height: 600px;
  cursor: default;
}

.status-section::after {
  content: "▼ Click or hover to expand";
  position: absolute;
  bottom: 0.5rem;
  right: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #57606a;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  z-index: 100;
  white-space: nowrap;
}

.status-section:hover::after,
.status-section.expanded::after {
  opacity: 0;
}

.status-box {
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.status-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
}

.status-icon {
  font-size: 1.125rem;
}

#status-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-message {
  padding: 0.5rem 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.5;
  border-left: 3px solid var(--border);
}

.status-message.warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.status-message.info {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.status-message.guidance {
  border-left-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  padding: 0.75rem 1rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.guidance-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1.5;
}

.status-message strong {
  font-weight: 600;
  color: var(--text);
}

.controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.controls-row:first-of-type {
  align-items: stretch;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 220px;
  align-items: flex-start;
}

.control-group label,
.control-label,
h2[data-help] {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: help;
  position: relative;
}

/* Ticker label row with Apply button */
.ticker-label-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.ticker-apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ticker-apply-btn:hover {
  background: var(--accent-hover, #0056cc);
  transform: translateY(-1px);
}

.ticker-apply-btn:active {
  transform: translateY(0);
}

.ticker-apply-btn .shortcut-hint {
  opacity: 0.75;
  font-size: 0.65rem;
  font-weight: 500;
}

/* Random tickers button */
.random-tickers-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  margin-left: auto;
}

.random-tickers-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text-muted);
}

.random-tickers-btn .random-icon {
  font-size: 0.8rem;
}

.control-group label,
.control-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--text-label);
}

h2[data-help] {
  font-size: inherit;
  font-weight: inherit;
}

th[data-help] {
  position: relative;
  cursor: help;
  white-space: nowrap;
}

h2[data-help] .help-icon,
th[data-help] .help-icon {
  margin-left: 0.25rem;
  position: relative;
  top: -1px;
}

.label-with-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.label-actions {
  display: flex;
  gap: 0.5rem;
}

.link-button {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  text-decoration: none;
  transition: all 0.2s;
  border-radius: 4px;
}

.link-button:hover {
  background: rgba(88, 166, 255, 0.1);
  color: var(--primary-dark);
}

.link-button:active {
  transform: scale(0.95);
}

.advanced-metrics-control {
  flex: 1;
}

.advanced-metrics-control[hidden] {
  display: none;
}

.controls-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0;
  opacity: 0.5;
}

.timeframe-row {
  align-items: stretch;
}

.timeframe-group {
  flex: 1;
  min-width: auto;
}

.timeframe-group .preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.custom-range-row {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2rem;
}

.custom-range-group {
  flex: 1;
}

.custom-range-group .control-label {
  margin-bottom: 0rem;
}

.custom-range-row .date-inputs {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.date-inputs input[type="date"] {
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  padding: 0 0.75rem;
  font-size: 0.9rem;
  line-height: normal;
  cursor: pointer;
}

.date-inputs input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.date-separator {
  font-size: 0.9rem;
  color: var(--text-muted);
}

#apply-range {
  height: 38px;
  border-radius: 12px;
  padding: 0 1rem;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

#ticker-select {
  background: var(--panel-alt);
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--text);
  min-height: 3rem;
  width: 80%;
  max-width: 1200px;
}

#top-performers-select,
#important-period-select {
  background: var(--panel-alt);
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 160px;
  height: 38px;
  line-height: 38px;
}

#important-period-select {
  min-width: 280px;
}

#important-period-select optgroup {
  font-weight: 700;
  color: var(--text);
  padding: 8px 0 4px 0;
  font-size: 0.85rem;
}

#important-period-select option {
  font-weight: 400;
  padding: 4px 8px;
}

.ts-control {
  background: var(--panel-alt) !important;
  border-radius: 12px !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  min-height: 38px !important;
  display: flex !important;
  align-items: center !important;
  padding: 0.15rem 0.4rem !important;
}

.ts-wrapper.multi .ts-control {
  border-radius: 12px !important;
}

.ts-wrapper.multi .ts-control > div {
  margin: 0.1rem 0.2rem !important;
  background: var(--accent-muted) !important;
  border: 1px solid rgba(9, 105, 218, 0.35) !important;
  border-radius: 999px !important;
  color: var(--accent) !important;
  padding: 0.25rem 0.75rem !important;
}

/* ============================================================================
   METRICS TEASER (Pro feature preview)
   ============================================================================ */

.teaser-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.teaser-label .help-icon {
  margin-right: 0.25rem;
}

.pro-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  margin-left: 0.25rem;
  background: linear-gradient(135deg, #93c5fd 0%, #c4b5fd 100%);
  color: #1e3a5f;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metrics-teaser-control {
  margin-top: 1rem;
  padding-top: 0.5rem;
}

/* ============================================================================
   PRO SPARKLE BUTTON (upgrade trigger)
   ============================================================================ */

.pro-sparkle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  margin-left: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #64748b;
  opacity: 0.7;
  transition: all 0.2s ease;
  vertical-align: middle;
  flex-shrink: 0;
}

.pro-sparkle-btn:hover {
  opacity: 1;
  color: #a5b4fc;
  transform: scale(1.15);
}

.pro-sparkle-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================================================
   UPGRADE SUMMARY MODAL
   ============================================================================ */

.upgrade-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upgrade-modal[hidden] {
  display: none;
}

.upgrade-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.upgrade-modal-container {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.upgrade-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 10;
  color: white;
}

.upgrade-modal-close:hover {
  background: rgba(255, 255, 255, 0.4);
}

.upgrade-modal-close svg {
  width: 16px;
  height: 16px;
}

.upgrade-modal-header {
  padding: 1.5rem 1.5rem 1rem;
  background: linear-gradient(135deg, #93c5fd 0%, #c4b5fd 100%);
  text-align: center;
}

.upgrade-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  margin: 0;
}

.upgrade-modal-icon {
  width: 28px;
  height: 28px;
  color: white;
  margin-bottom: 0.35rem;
}

.upgrade-modal-content {
  padding: 1.25rem 1.5rem 1.5rem;
}

.upgrade-features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem 0;
}

.upgrade-features-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0;
  color: #4b5563;
  font-size: 0.9rem;
  line-height: 1.4;
}

.upgrade-features-list li svg {
  width: 16px;
  height: 16px;
  color: #7dd3fc;
  flex-shrink: 0;
  margin-top: 2px;
}

.upgrade-features-list li strong {
  color: #1f2937;
}

.upgrade-modal-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #93c5fd 0%, #c4b5fd 100%);
  color: #1e3a5f;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(147, 197, 253, 0.3);
  box-sizing: border-box;
}

.upgrade-modal-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(147, 197, 253, 0.45);
}

.upgrade-modal-cta svg {
  width: 14px;
  height: 14px;
}

[data-theme="dark"] .upgrade-modal-container {
  background: #1c1c1e;
}

[data-theme="dark"] .upgrade-features-list li {
  color: #e4e6eb;
}

[data-theme="dark"] .upgrade-features-list li strong {
  color: #ffffff;
}

.metrics-teaser {
  position: relative;
  width: 100%;
}

.teaser-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.teaser-trigger:hover {
  border-color: rgba(102, 126, 234, 0.5);
  background: var(--panel);
}

.teaser-placeholder {
  font-style: italic;
  opacity: 0.8;
}

.teaser-chevron {
  width: 16px;
  height: 16px;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.teaser-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 100;
  overflow: hidden;
}

[data-theme="dark"] .teaser-dropdown {
  background: #1c1c1e;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.teaser-metrics-list {
  list-style: none;
  padding: 0.5rem 0;
  margin: 0;
}

.teaser-metrics-list li {
  padding: 0.5rem 1rem;
  color: var(--text);
  font-size: 0.85rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.teaser-metrics-list li:last-child {
  border-bottom: none;
}

.teaser-metric-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.teaser-metric-name::before {
  content: "";
  width: 5px;
  height: 5px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  flex-shrink: 0;
}

.teaser-metric-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.teaser-upgrade-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  border-top: 1px solid var(--border);
  color: #667eea;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.teaser-upgrade-link:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
}

.teaser-upgrade-link svg {
  width: 14px;
  height: 14px;
}

[data-theme="dark"] .teaser-upgrade-link {
  color: #a5b4fc;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.preset-button {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-button.active {
  background: #0969da;
  border-color: #0969da;
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(9, 105, 218, 0.3);
}

.preset-button:hover:not(.active) {
  background: var(--panel);
  border-color: #0969da;
}

[data-theme="dark"] .preset-button.active {
  background: #58a6ff;
  border-color: #58a6ff;
  color: #0d1117;
}

.date-inputs {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.date-inputs input[type="date"] {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.0rem 0.75rem;
  color: var(--text);
}

.date-inputs input[type="date"]:focus {
  outline: 1px solid rgba(88, 166, 255, 0.6);
}

.primary {
  background: transparent;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
  font-size: inherit;
  transition: all 0.2s;
}

.primary:hover {
  border-color: rgba(88, 166, 255, 0.4);
  background: rgba(88, 166, 255, 0.05);
}

.primary.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.secondary {
  background: transparent;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.secondary:hover {
  border-color: rgba(88, 166, 255, 0.4);
}

.secondary.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-header {
  margin-bottom: 1.5rem;
  padding-top: 0.5rem;
}

.chart-section-title {
  margin: 0 0 1.25rem 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.chart-title-preset {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border: 1.5px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  vertical-align: middle;
}

[data-theme="dark"] .chart-title-preset {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.35);
}

.chart-title-period {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.1);
  border: 1.5px solid rgba(124, 58, 237, 0.3);
  border-radius: 6px;
  vertical-align: middle;
}

[data-theme="dark"] .chart-title-period {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.35);
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.chart-clipping-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--panel-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.chart-clipping-info span {
  font-weight: 600;
  color: var(--text);
}

.log-scale-toggle {
  display: flex;
  align-items: center;
}

.log-scale-toggle label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.log-scale-toggle input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.section-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.baseline-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.baseline-selector[hidden] {
  display: none;
}

.baseline-selector label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.baseline-selector select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  background: var(--panel-alt);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 200px;
}

.baseline-selector select:focus {
  outline: 2px solid rgba(88, 166, 255, 0.5);
  outline-offset: 1px;
}

/* ============================================================================
   CHART PLAYBACK CONTROLS (Ticker Tour)
   ============================================================================ */

.chart-playback-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-play-btn,
.chart-stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-play-btn:hover,
.chart-stop-btn:hover {
  background: var(--bg-alt);
  color: var(--text);
  border-color: var(--text-muted);
}

.chart-play-btn.playing {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #3b82f6;
}

.chart-play-btn.playing:hover {
  background: rgba(59, 130, 246, 0.25);
}

.chart-play-btn svg,
.chart-stop-btn svg {
  width: 16px;
  height: 16px;
}

.chart-stop-btn svg {
  width: 12px;
  height: 12px;
}

.chart-stop-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

[data-theme="dark"] .chart-play-btn.playing {
  background: rgba(96, 165, 250, 0.2);
  border-color: rgba(96, 165, 250, 0.4);
  color: #60a5fa;
}

[data-theme="dark"] .chart-stop-btn:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

/* Legend badge highlight during playback */
.legend-item-playing {
  background: rgba(59, 130, 246, 0.2) !important;
  border: 2px solid rgba(59, 130, 246, 0.5) !important;
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
  transition: all 0.3s ease;
}

[data-theme="dark"] .legend-item-playing {
  background: rgba(96, 165, 250, 0.25) !important;
  border-color: rgba(96, 165, 250, 0.5) !important;
  box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);
}

/* ============================================================================
   TICKER HEADLINE OVERLAY (HTML-based, no Plotly relayout)
   ============================================================================ */

.ticker-headline-overlay {
  position: absolute;
  top: 10px;
  left: 80px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #3b82f6;
  border-radius: 8px;
  padding: 10px 14px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 260px;
}

[data-theme="dark"] .ticker-headline-overlay {
  background: rgba(28, 28, 30, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ticker-headline-overlay .headline-ticker {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.ticker-headline-overlay .headline-perf {
  font-size: 20px;
  font-weight: 600;
  margin-top: 2px;
}

.ticker-headline-overlay .headline-company {
  font-size: 13px;
  color: #6b7280;
  margin-top: 6px;
  line-height: 1.3;
}

[data-theme="dark"] .ticker-headline-overlay .headline-company {
  color: #9ca3af;
}

.ticker-headline-overlay .headline-info {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

[data-theme="dark"] .ticker-headline-overlay .headline-info {
  color: #6b7280;
}

.chart-section,
.table-section,
.controls-panel {
  background: var(--panel);
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 0 24px 48px -32px rgba(15, 23, 42, 0.2);
}

[data-theme="dark"] .chart-section,
[data-theme="dark"] .table-section,
[data-theme="dark"] .controls-panel {
  box-shadow: 0 24px 48px -32px rgba(0, 0, 0, 0.6);
}

/* Controls Panel specific: Collapse & Pin behavior */
.controls-panel {
  position: relative;
  max-height: 80px;
  overflow: hidden;
  /* Delay collapse by 2.5s after mouse leaves, smooth 0.35s animation */
  transition: max-height 0.35s ease 2.5s;
}

.controls-panel:hover,
.controls-panel.pinned,
.controls-panel.tooltip-active {
  max-height: 2000px; /* effectively unlimited */
  overflow: visible;
  /* No delay when expanding - instant response on hover */
  transition: max-height 0.35s ease 0s;
}

#chart {
  position: relative;
  width: 100%;
  height: 560px;
  margin-top: 1.5rem;
}

/* Hide plot lines in the rangeslider to reduce visual clutter */
#chart .rangeslider-bg {
  fill: var(--bg-alt) !important;
}

#chart .rangeslider-rangeplot {
  opacity: 0 !important;
  pointer-events: none;
}

.chart-crosshair-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.05s linear;
}

.chart-crosshair-line {
  position: absolute;
  width: 1px;
  background: rgba(87, 96, 106, 0.6);
  border: none;
  border-left: 1px dashed rgba(87, 96, 106, 0.6);
}

.chart-crosshair-label {
  position: absolute;
  transform: translate(-50%, -120%);
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(87, 96, 106, 0.4);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
  white-space: nowrap;
}

[data-theme="dark"] .chart-crosshair-line {
  border-left-color: rgba(196, 205, 214, 0.6);
}

[data-theme="dark"] .chart-crosshair-label {
  background: rgba(22, 27, 34, 0.92);
  border-color: rgba(196, 205, 214, 0.4);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.chart-range-label {
  margin-top: -0.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted-text, rgba(31, 35, 40, 0.65));
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.5rem;
  row-gap: 0.35rem;
  justify-content: center;
  font-size: 0.85rem;
  padding: 0.5rem 0 0 0;
  margin-top: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.8rem;
  height: 24px;
  flex-shrink: 0;
}

[data-theme="dark"] .legend-item {
  background: rgba(255, 255, 255, 0.06);
}

/* Rank badge in legend (replaces color swatch) */
.legend-rank-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

/* Legacy swatch (if still used anywhere) */
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-item-hover {
  background: rgba(59, 130, 246, 0.15) !important;
  border: 1px solid rgba(59, 130, 246, 0.3);
  transition: all 0.15s ease;
}

[data-theme="dark"] .legend-item-hover {
  background: rgba(96, 165, 250, 0.2) !important;
  border: 1px solid rgba(96, 165, 250, 0.4);
}

.legend-date-indicator {
  flex-basis: 100%;
  font-size: .85rem;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  text-align: center;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

[data-theme="dark"] .legend-date-indicator {
  background: rgba(96, 165, 250, 0.15);
}

/* Prominent legend header */
.legend-header {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.legend-header-date {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.legend-header-sort {
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  background: #16a34a; /* Green for both CAGR and Performance */
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.legend-header-hover {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.08);
}

[data-theme="dark"] .legend-header {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .legend-header-hover {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
}

/* Legend help text */
.legend-help-text {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 9px;
  padding: 3px 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(131, 78, 184, 0.08) 100%);
  border-radius: 8px;
  border: 1px solid rgba(102, 126, 234, 0.15);
  text-align: center;
  line-height: 1.5;
}

.legend-help-text .help-tip-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.legend-help-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

[data-theme="dark"] .legend-help-text {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
  border-color: rgba(102, 126, 234, 0.2);
}

/* Top scrollbar - mirrors bottom scrollbar for better UX */
.table-top-scrollbar {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  height: 12px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.table-top-scrollbar > div {
  height: 1px;
}

.table-top-scrollbar::-webkit-scrollbar {
  height: 12px;
}

.table-top-scrollbar::-webkit-scrollbar-track {
  background: var(--bg-alt);
  border-radius: 6px;
}

.table-top-scrollbar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}

.table-top-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
  
/* Table scroll wrapper for horizontal scrolling */
.table-scroll-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  /* Smooth scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

/* Ensure scrollbar is always visible for clarity */
.table-scroll-wrapper::-webkit-scrollbar {
  height: 12px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
  background: var(--bg-alt);
  border-radius: 6px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

#ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--table-font-size);
  /* Prevent table from shrinking below content width */
  min-width: max-content;
}

#ranking-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: var(--table-header-font-size);
  padding: var(--table-header-padding-vertical) var(--table-header-padding-horizontal);
  border-bottom: var(--table-border-width) solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
  background-color: var(--table-bg);
  min-width: var(--table-col-default-min);
}

/* Add vertical grid lines - all columns except the first get a left border */
#ranking-table thead th:not(:first-child) {
  border-left: var(--table-border-width) solid var(--table-border-vertical);
}

#ranking-table tbody td {
  padding: var(--table-cell-padding-vertical) var(--table-cell-padding-horizontal);
  border-bottom: var(--table-border-width) solid var(--table-border-color);
  vertical-align: middle;
  box-sizing: border-box;
  height: auto;
  background-color: var(--table-bg);
  min-width: var(--table-col-default-min);
  white-space: nowrap;  /* Prevent wrapping of content and badges */
}

/* Add vertical grid lines - all columns except the first get a left border */
#ranking-table tbody td:not(:first-child) {
  border-left: var(--table-border-width) solid var(--table-border-vertical);
}

#ranking-table th.latest-price-header,
#ranking-table td.latest-price-cell {
  min-width: var(--table-col-price);
  text-align: right;
  white-space: nowrap;
}

#ranking-table th.market-cap-header,
#ranking-table td.market-cap-cell {
  min-width: var(--table-col-marketcap);
  text-align: right;
  white-space: nowrap;
}

#ranking-table th.range-header {
  min-width: var(--table-col-range);
}

/* Right-align all numeric/metric columns that contain values with badges */
#ranking-table thead th:nth-child(n+4):not(.range-header) {
  text-align: right;  /* Right-align headers for numeric columns */
}

#ranking-table tbody td:nth-child(n+4):not(.ticker-cell):not(.range-band-cell) {
  text-align: right;  /* Right-align all columns after Ticker (numeric metrics) */
}

/* Preset return columns - compact width, controlled by CSS variable */
#ranking-table th.preset-return-header {
  min-width: var(--table-col-preset-return);
  max-width: var(--table-col-preset-return);
  width: var(--table-col-preset-return);
  text-align: right;
  white-space: nowrap;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  cursor: pointer;
}

#ranking-table td.preset-return-cell {
  min-width: var(--table-col-preset-return);
  max-width: var(--table-col-preset-return);
  width: var(--table-col-preset-return);
  text-align: right;
  white-space: nowrap;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

/* Multi-period summary column (visual bar chart) */
#ranking-table th.preset-summary-header {
  min-width: var(--table-col-preset-summary);
  max-width: var(--table-col-preset-summary);
  width: var(--table-col-preset-summary);
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

#ranking-table td.preset-summary-cell {
  min-width: var(--table-col-preset-summary);
  max-width: var(--table-col-preset-summary);
  width: var(--table-col-preset-summary);
  text-align: center;
  padding: 0.5rem;
}

.preset-summary-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--table-preset-bar-gap);
  height: var(--table-preset-summary-height);
  width: 100%;
  position: relative;
}

/* Gray dashed line at top to show max rank (rank 1) reference line */
.preset-summary-chart::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px dashed var(--text-muted);
  opacity: 0.8;
  pointer-events: none;
}

.preset-summary-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  transition: opacity 0.2s;
}

.preset-summary-bar:hover {
  opacity: 0.8;
}

/* Preset summary tooltip */
.preset-summary-tooltip {
  display: none;
  position: fixed; /* Changed from absolute to fixed to escape stacking context */
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99999; /* Much higher z-index to ensure it's always on top */
  white-space: nowrap;
  min-width: 200px;
  pointer-events: none;
}

/* Tooltip visibility and positioning handled by JavaScript */

[data-theme="dark"] .preset-summary-tooltip {
  background: #161b22;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Sticky columns - first 3 columns stay visible during horizontal scroll */
/* Visibility column (1st column) - sticky at left: 0 */
#ranking-table thead th.visibility-header {
  position: sticky;
  left: 0;
  z-index: 4; /* Higher z-index for headers */
  background-color: var(--table-bg) !important;
  width: var(--table-col-visibility);
  max-width: var(--table-col-visibility);
  min-width: var(--table-col-visibility);
  text-align: center;
  padding: var(--table-header-padding-vertical) 0.25rem;
}

#ranking-table tbody td.visibility-cell {
  position: sticky;
  left: 0;
  z-index: 2; /* Lower z-index for body cells */
  background-color: var(--table-bg) !important;
  width: var(--table-col-visibility);
  max-width: var(--table-col-visibility);
  min-width: var(--table-col-visibility);
  text-align: center;
  padding: var(--table-cell-padding-vertical) 0.25rem;
  cursor: pointer;
  transition: transform 0.1s;
}

/* Apply opacity to the icon content, not the cell background */
#ranking-table tbody td.visibility-cell > * {
  opacity: 0.6;
  transition: opacity 0.2s;
}

#ranking-table tbody td.visibility-cell:hover {
  transform: scale(1.1);
}

#ranking-table tbody td.visibility-cell:hover > * {
  opacity: 1;
}

#ranking-table tbody td.visibility-cell:active {
  transform: scale(0.95);
}

/* Rank column (2nd column) - sticky at left: visibility column width */
#ranking-table thead th:nth-child(2) {
  position: sticky;
  left: var(--table-col-visibility);
  z-index: 4;
  background-color: var(--table-bg) !important;
  width: var(--table-col-rank);
  min-width: var(--table-col-rank);
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

#ranking-table tbody td:nth-child(2) {
  position: sticky;
  left: var(--table-col-visibility);
  z-index: 2;
  background-color: var(--table-bg) !important;
  width: var(--table-col-rank);
  min-width: var(--table-col-rank);
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Ticker column (2nd column) - sticky at left: visibility width */
#ranking-table thead th:nth-child(2) {
  position: sticky;
  left: var(--table-col-visibility);
  z-index: 4;
  background-color: var(--table-bg) !important;
  min-width: var(--table-col-ticker);
}

#ranking-table tbody td:nth-child(2) {
  position: sticky;
  left: var(--table-col-visibility);
  z-index: 2;
  background-color: var(--table-bg) !important;
  min-width: var(--table-col-ticker);
}

/* Add shadow on right edge of last sticky column to show separation */
#ranking-table thead th:nth-child(2)::after,
#ranking-table tbody td:nth-child(2)::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  bottom: 0;
  width: 8px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.05), transparent);
  pointer-events: none;
}

/* Disable sticky columns when feature is not available */
#ranking-table.no-sticky thead th.visibility-header,
#ranking-table.no-sticky tbody td.visibility-cell,
#ranking-table.no-sticky thead th:nth-child(2),
#ranking-table.no-sticky tbody td:nth-child(2) {
  position: static;
}

#ranking-table.no-sticky thead th:nth-child(2)::after,
#ranking-table.no-sticky tbody td:nth-child(2)::after {
  display: none;
}

#ranking-table tbody tr:hover {
  background: rgba(88, 166, 255, 0.06);
}

/* Ensure sticky cells get solid hover background to prevent transparency issues */
#ranking-table tbody tr:hover td.visibility-cell,
#ranking-table tbody tr:hover td:nth-child(2),
#ranking-table tbody tr:hover td:nth-child(3) {
  background-color: var(--table-bg-hover) !important;
}

.performance-positive {
  color: var(--success);
  text-align: right;  /* Right-align positive performance values */
}

.performance-negative {
  color: var(--danger);
  text-align: right;  /* Right-align negative performance values */
}

.metric-rank-capsule {
  display: inline-block;
  padding: 0.12rem 0.35rem;
  border-radius: 10px;
  border: 1.5px solid;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.3rem;  /* Increased from 0.35rem for better separation */
  vertical-align: middle;
  line-height: 1;
  white-space: nowrap;  /* Prevent badge from wrapping */
  flex-shrink: 0;  /* Prevent badge from shrinking */
  min-width: 15px;  /* Ensure badges have minimum width */
  text-align: center;  /* Center the rank number inside badge */
}

/* Range Band Visualization */
.range-band-cell {
  min-width: 170px;
  padding: 0.75rem 2.5rem 0.75rem 1.1rem !important;
  position: relative;
}

.range-band {
  position: relative;
  margin-bottom: 0.35rem;
  padding: 0 0.35rem;
}

.range-track {
  position: relative;
  height: 8px;
  background: linear-gradient(to right, 
    rgba(220, 38, 38, 0.15), 
    rgba(250, 204, 21, 0.15), 
    rgba(34, 197, 94, 0.15)
  );
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .range-track {
  background: linear-gradient(to right, 
    rgba(220, 38, 38, 0.25), 
    rgba(250, 204, 21, 0.25), 
    rgba(34, 197, 94, 0.25)
  );
  border-color: rgba(255, 255, 255, 0.1);
}

.range-indicator {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 16px;
  background: var(--text);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.range-badge {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(88, 166, 255, 0.12);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
}

.range-badge-left {
  transform: translate(-100%, -50%);
  margin-left: -6px;
}

.range-badge-right {
  transform: translate(0%, -50%);
  margin-left: 6px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding: 0 0.45rem;
}

.range-label-low,
.range-label-high {
  font-weight: 500;
}

/* Sortable table columns */
#ranking-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
  position: relative;
}

#ranking-table th.sortable:hover {
  background-color: rgba(88, 166, 255, 0.1);
}

#ranking-table th.sortable .sort-icon {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

#ranking-table th.sorted-asc .sort-icon,
#ranking-table th.sorted-desc .sort-icon {
  color: var(--text);
}

/* Ticker cell with info icon */
.ticker-cell {
  position: relative;
  vertical-align: middle;
  min-width: 70px;
  max-width: 70px;
}

.ticker-cell-content {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(88, 166, 255, 0.2);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: bold;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}

.info-icon:hover {
  background: rgba(88, 166, 255, 0.3);
}

/* Table title row */
.table-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.table-title-left {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex: 1 1 auto;
}

.table-date-range {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Tooltip */
.ticker-tooltip {
  display: none;
  position: fixed; /* Changed from absolute to fixed to escape stacking context */
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99999; /* Much higher z-index to ensure it's always on top */
  white-space: nowrap;
  min-width: 200px;
  max-width: 320px;
  word-break: break-word;
  pointer-events: none; /* Prevent interference with mouse events */
}

[data-theme="dark"] .ticker-tooltip {
  background: #161b22;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

.ticker-tooltip-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  white-space: normal;
}

.ticker-tooltip-title strong {
  font-size: 1rem;
}

.ticker-tooltip-name {
  font-weight: 500;
  color: var(--text-muted);
  flex: 1 1 auto;
  min-width: 0;
}

/* Tooltip visibility now handled by JavaScript for proper positioning */

/* Range tooltip */
.range-tooltip {
  display: none;
  position: fixed; /* Changed from absolute to fixed to escape stacking context */
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99999; /* Much higher z-index to ensure it's always on top */
  white-space: nowrap;
  min-width: 200px;
  pointer-events: none;  /* Prevent tooltip from interfering with scrolling */
}

/* Tooltip visibility and positioning handled by JavaScript */

[data-theme="dark"] .range-tooltip {
  background: #161b22;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Drawdown tooltip */
.drawdown-tooltip {
  display: none;
  position: fixed; /* Changed from absolute to fixed to escape stacking context */
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99999; /* Much higher z-index to ensure it's always on top */
  white-space: nowrap;
  min-width: 200px;
  pointer-events: none;  /* Prevent tooltip from interfering with scrolling */
}

/* Tooltip visibility and positioning handled by JavaScript */

[data-theme="dark"] .drawdown-tooltip {
  background: #161b22;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

.trend-score-tooltip {
  display: none;
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 240px;
  max-width: 320px;
  font-size: 0.85rem;
  pointer-events: none;
}

[data-theme="dark"] .trend-score-tooltip {
  background: #161b22;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Trend interval rows - tighter spacing for many intervals */
.trend-interval-row {
  padding: 0.15rem 0 !important;
  font-size: 0.82rem;
}

.trend-date-range {
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.tooltip-row:first-child {
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.tooltip-label {
  color: var(--text-muted);
  font-weight: 500;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-legal {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.footer-legal a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-legal a:hover {
  color: var(--accent);
}

.footer-separator {
  opacity: 0.5;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.45);
}

[data-theme="dark"] .status::before {
  box-shadow: 0 0 12px rgba(9, 105, 218, 0.45);
}

.status.error::before {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(248, 81, 73, 0.35);
}

@media (min-width: 900px) {
  .controls-row:first-of-type {
    justify-content: space-between;
  }

  .timeframe-row {
    align-items: center;
  }

  #chart {
    height: 640px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1.5rem 1rem;
  }

  .controls-panel {
    padding: 1rem;
  }

  .date-inputs {
    flex-wrap: wrap;
  }

  .header-controls {
    width: 100%;
  }

  .session-link {
    flex-direction: column;
    align-items: stretch;
  }

  .session-code {
    justify-content: flex-start;
  }
}

/* Help Tooltips */
.help-tooltip-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.25); /* Adjust this value to control darkness (0.0 to 1.0) */
  z-index: 99999; /* Higher than command palette (50000) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  cursor: pointer; /* Indicate clickable to dismiss */
}

.help-tooltip-backdrop.active {
  opacity: 1;
  pointer-events: auto; /* Allow clicking to dismiss */
}

[data-theme="dark"] .help-tooltip-backdrop {
  background: rgba(0, 0, 0, 0.45); /* Slightly darker for dark theme */
}

/* Custom animated cursor for help tooltips */
.help-cursor {
  position: fixed;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
  
  /* Animated gradient background - soft pastel colors */
  background: linear-gradient(135deg, #a8b4f0 0%, #b8a4d9 25%, #e8c4f0 50%, #f0b8c4 75%, #a8b4f0 100%);
  background-size: 300% 300%;
  animation: helpCursorGradient 2s ease infinite;
  
  /* Subtle glow effect */
  box-shadow: 0 0 10px rgba(168, 180, 240, 0.5),
              0 0 20px rgba(184, 164, 217, 0.3);
}

.help-cursor.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@keyframes helpCursorGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Dark theme adjustments - softer colors */
[data-theme="dark"] .help-cursor {
  background: linear-gradient(135deg, #8ac4ff 0%, #c4a8f7 25%, #ffc4e8 50%, #f0a8d0 75%, #8ac4ff 100%);
  box-shadow: 0 0 10px rgba(138, 196, 255, 0.4),
              0 0 20px rgba(196, 168, 247, 0.3);
}

/* Help label styles - hide real cursor for custom animated cursor */
.has-help-tooltip {
  cursor: none;
}

/* Restore normal cursor for interactive elements inside help labels */
.has-help-tooltip input,
.has-help-tooltip select,
.has-help-tooltip button {
  cursor: pointer;
}

.has-help-tooltip:hover {
  color: rgba(9, 105, 218, 0.9);
}

.has-help-tooltip:hover .help-icon {
  background: rgba(9, 105, 218, 0.25);
  border-color: rgba(9, 105, 218, 0.7);
  color: rgb(9, 105, 218);
  transform: scale(1.1);
}

[data-theme="dark"] .has-help-tooltip:hover {
  color: rgba(88, 166, 255, 0.9);
}

[data-theme="dark"] .has-help-tooltip:hover .help-icon {
  background: rgba(88, 166, 255, 0.25);
  border-color: rgba(88, 166, 255, 0.7);
  color: rgb(88, 166, 255);
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: rgba(9, 105, 218, 0.12);
  border: 1.5px solid rgba(9, 105, 218, 0.4);
  color: rgba(9, 105, 218, 0.85);
  font-size: 9px;
  font-weight: 700;
  cursor: none; /* Hide real cursor, custom animated cursor shown instead */
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s ease;
  vertical-align: middle;
  line-height: 1;
}

.help-icon:hover {
  background: rgba(9, 105, 218, 0.25);
  border-color: rgba(9, 105, 218, 0.7);
  color: rgb(9, 105, 218);
  transform: scale(1.1);
}

.help-icon.active {
  background: rgba(9, 105, 218, 0.3);
  border-color: rgb(9, 105, 218);
  color: rgb(9, 105, 218);
  transform: scale(1.1);
}

[data-theme="dark"] .help-icon {
  background: rgba(88, 166, 255, 0.12);
  border: 1.5px solid rgba(88, 166, 255, 0.4);
  color: rgba(88, 166, 255, 0.85);
}

[data-theme="dark"] .help-icon:hover {
  background: rgba(88, 166, 255, 0.25);
  border-color: rgba(88, 166, 255, 0.7);
  color: rgb(88, 166, 255);
}

[data-theme="dark"] .help-icon.active {
  background: rgba(88, 166, 255, 0.3);
  border-color: rgb(88, 166, 255);
  color: rgb(88, 166, 255);
}

.help-tooltip {
  position: fixed;
  top: auto;
  left: auto;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 100000; /* Higher than command palette (50000) */
  width: 420px;
  max-width: calc(100vw - 40px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  box-sizing: border-box;
}

/* Tooltip visible state (controlled via JS - fixes transform containment issues in modals) */
.help-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Markdown content in tooltips */
.help-tooltip h1,
.help-tooltip h2,
.help-tooltip h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.help-tooltip p {
  margin: 0 0 0.75rem 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.help-tooltip p:last-child {
  margin-bottom: 0;
}

.help-tooltip strong {
  font-weight: 600;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.help-tooltip ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.help-tooltip li {
  margin: 0.35rem 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.help-tooltip code {
  background: var(--bg);
  padding: 0.125rem 0.35rem;
  border-radius: 4px;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.85em;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.help-tooltip em {
  font-style: italic;
  color: var(--text-muted);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================
   Freshness Status Bar
   ============================================ */

.freshness-status-bar {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-right: none;
  border-top-left-radius: 8px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.freshness-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.freshness-compact:hover {
  background: var(--bg-alt);
}

.freshness-icon {
  font-size: 16px;
  line-height: 1;
}

.freshness-text {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.freshness-countdown {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
  opacity: 0.8;
}

.freshness-expand-icon {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Status indicator colors */
.freshness-compact.fresh {
  border-top-color: var(--success);
}

.freshness-compact.aging {
  border-top-color: #d97706;
}

.freshness-compact.stale {
  border-top-color: var(--danger);
}

/* Expanded details */
.freshness-details {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-alt);
  transition: all 0.3s ease;
}

.freshness-details.hidden {
  display: none;
}

.freshness-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.freshness-detail-row:last-child {
  border-bottom: none;
}

.freshness-label {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.freshness-value {
  color: var(--text);
  text-align: right;
  flex: 1;
}

.freshness-warning {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text);
}

.freshness-warning strong {
  color: #d97706;
}

.error-text {
  color: var(--danger);
  font-size: 11px;
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  font-size: 14px;
  min-width: 280px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.toast-message {
  color: var(--text);
  flex: 1;
  line-height: 1.4;
}

/* Toast types */
.toast-success {
  border-left: 3px solid var(--success);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-info .toast-icon {
  color: var(--accent);
}

.toast-warning {
  border-left: 3px solid #d97706;
}

.toast-warning .toast-icon {
  color: #d97706;
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-error .toast-icon {
  color: var(--danger);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .freshness-status-bar {
    right: 0;
    left: 0;
    border-left: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }
  
  .freshness-compact {
    justify-content: center;
  }
  
  .freshness-detail-row {
    flex-direction: column;
    gap: 4px;
  }
  
  .freshness-value {
    text-align: left;
  }
  
  .toast-container {
    right: 12px;
    left: 12px;
  }
  
  .toast {
    min-width: auto;
    max-width: none;
  }
}

/* ============================================
   Site Password Protection
   ============================================ */

/* ============================================================================
   Confirmation Modals
   ============================================================================ */

#password-lock-modal,
.confirmation-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

#password-lock-modal {
  background: var(--bg);
}

.confirmation-modal[hidden] {
  display: none;
}

.confirmation-modal:not([hidden]) {
  display: flex;
}

.password-lock-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 3rem 2.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideUp 0.4s ease;
}

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

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

.password-lock-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.password-lock-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.password-lock-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 2rem 0;
}

.password-lock-input-wrapper {
  margin-bottom: 1.5rem;
}

#password-lock-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

#password-lock-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

#password-lock-input.shake {
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

#password-lock-error {
  display: none;
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  animation: fadeIn 0.3s ease;
}

#password-lock-submit {
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#password-lock-submit:hover {
  background: #0860ca;
  transform: translateY(-1px);
}

#password-lock-submit:active {
  transform: translateY(0);
}

[data-theme="dark"] #password-lock-submit:hover {
  background: #4a9eff;
}

/* ============================================
   Landing Page (Beta Access)
   ============================================ */

.landing-page {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

/* Animated background */
.landing-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.landing-bg-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg, 
    #eff6ff 0%,      /* blue-50 */
    #f5f3ff 20%,     /* violet-50 */
    #eef2ff 40%,     /* indigo-50 */
    #ecfeff 60%,     /* cyan-50 */
    #f0fdfa 80%,     /* teal-50 */
    #eff6ff 100%     /* blue-50 */
  );
  background-size: 300% 300%;
  animation: gradientFlow 8s ease-in-out infinite;
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Ripple effects - like gentle lake waves */
.landing-bg-ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.25) 0%, rgba(139, 92, 246, 0.15) 40%, transparent 70%);
  animation: ripple 6s ease-in-out infinite;
}

.landing-bg-ripple-1 {
  width: 900px;
  height: 900px;
  top: -300px;
  right: -300px;
  animation-delay: 0s;
}

.landing-bg-ripple-2 {
  width: 700px;
  height: 700px;
  bottom: -200px;
  left: -200px;
  animation-delay: -2s;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, rgba(59, 130, 246, 0.12) 40%, transparent 70%);
}

.landing-bg-ripple-3 {
  width: 600px;
  height: 600px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: rippleCenter 7s ease-in-out infinite;
  animation-delay: -3s;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, rgba(236, 72, 153, 0.1) 40%, transparent 70%);
}

@keyframes ripple {
  0%, 100% { 
    transform: scale(1);
    opacity: 0.6;
  }
  50% { 
    transform: scale(1.2);
    opacity: 1;
  }
}

@keyframes rippleCenter {
  0%, 100% { 
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.5;
  }
  50% { 
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0.9;
  }
}

[data-theme="dark"] .landing-bg-gradient {
  background: linear-gradient(
    135deg, 
    #1e1b4b 0%,      /* indigo-950 */
    #312e81 20%,     /* indigo-900 */
    #1e3a5f 40%,     /* blue-900 */
    #134e4a 60%,     /* teal-900 */
    #1e1b4b 80%,     /* indigo-950 */
    #312e81 100%     /* indigo-900 */
  );
  background-size: 300% 300%;
  animation: gradientFlow 8s ease-in-out infinite;
}

[data-theme="dark"] .landing-bg-ripple {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.2) 40%, transparent 70%);
}

[data-theme="dark"] .landing-bg-ripple-2 {
  background: radial-gradient(circle, rgba(20, 184, 166, 0.25) 0%, rgba(59, 130, 246, 0.15) 40%, transparent 70%);
}

[data-theme="dark"] .landing-bg-ripple-3 {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.25) 0%, rgba(236, 72, 153, 0.15) 40%, transparent 70%);
}

.landing-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  text-align: center;
  animation: fadeInUp 0.8s ease;
}

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

.landing-logo {
  max-width: 280px;
  height: auto;
  margin-bottom: 2rem;
}

.landing-headline {
  font-size: 2.25rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 1rem 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

[data-theme="dark"] .landing-headline {
  color: #f1f5f9;
}

.landing-subheadline {
  font-size: 1.1rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0 auto 2.5rem auto;
  max-width: 600px;
}

[data-theme="dark"] .landing-subheadline {
  color: #94a3b8;
}

/* Feature cards grid */
.landing-features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.landing-feature-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: left;
  transition: all 0.3s ease;
  animation: fadeInUp 0.6s ease backwards;
}

.landing-feature-card:nth-child(1) { animation-delay: 0.1s; }
.landing-feature-card:nth-child(2) { animation-delay: 0.15s; }
.landing-feature-card:nth-child(3) { animation-delay: 0.2s; }
.landing-feature-card:nth-child(4) { animation-delay: 0.25s; }
.landing-feature-card:nth-child(5) { animation-delay: 0.3s; }
.landing-feature-card:nth-child(6) { animation-delay: 0.35s; }

.landing-feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.feature-card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.feature-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.5rem 0;
}

.feature-card-desc {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

[data-theme="dark"] .landing-feature-card {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(71, 85, 105, 0.5);
}

[data-theme="dark"] .landing-feature-card:hover {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .feature-card-title {
  color: #f1f5f9;
}

[data-theme="dark"] .feature-card-desc {
  color: #94a3b8;
}

/* Legacy single-line features (keep for backwards compatibility) */
.landing-features {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.landing-feature {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1rem;
  color: #475569;
}

[data-theme="dark"] .landing-feature {
  color: #cbd5e1;
}

.feature-icon {
  font-size: 1.25rem;
}

.landing-cta-section {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
}

[data-theme="dark"] .landing-cta-section {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.25);
}

.landing-access-note {
  font-size: 0.95rem;
  color: #64748b;
  margin: 0 0 0.75rem 0;
}

[data-theme="dark"] .landing-access-note {
  color: #94a3b8;
}

.landing-contact-link {
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  color: #6366f1;
  text-decoration: none;
  transition: color 0.2s;
}

.landing-contact-link:hover {
  color: #4f46e5;
  text-decoration: underline;
}

[data-theme="dark"] .landing-contact-link {
  color: #818cf8;
}

[data-theme="dark"] .landing-contact-link:hover {
  color: #a5b4fc;
}

.landing-footer {
  font-size: 0.85rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.landing-footer-separator {
  opacity: 0.5;
}

.landing-footer-link {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s ease;
}

.landing-footer-link:hover {
  color: #3b82f6;
}

[data-theme="dark"] .landing-footer {
  color: #64748b;
}

[data-theme="dark"] .landing-footer-link {
  color: #64748b;
}

[data-theme="dark"] .landing-footer-link:hover {
  color: #60a5fa;
}

@media (max-width: 900px) {
  .landing-features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .landing-page {
    padding: 1.5rem;
    align-items: flex-start;
    padding-top: 2rem;
  }
  
  .landing-content {
    max-width: 100%;
  }
  
  .landing-logo {
    max-width: 180px;
  }
  
  .landing-headline {
    font-size: 1.5rem;
  }
  
  .landing-subheadline {
    font-size: 0.95rem;
  }
  
  .landing-features-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .landing-feature-card {
    padding: 1.25rem;
  }
  
  .feature-card-icon {
    font-size: 1.5rem;
  }
  
  .feature-card-title {
    font-size: 0.95rem;
  }
  
  .feature-card-desc {
    font-size: 0.85rem;
  }
  
  .landing-cta-section {
    padding: 1.25rem 1.5rem;
  }
  
  .landing-footer {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ============================================
   New Session Confirmation Modal
   ============================================ */

.confirmation-modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideUp 0.4s ease;
}

.confirmation-modal-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: var(--text);
}

.confirmation-modal-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.confirmation-modal-link-wrapper {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.confirmation-modal-link-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.confirmation-modal-link-display {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#new-session-modal-link {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: 'Monaco', 'Courier New', monospace;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: text;
}

#new-session-modal-link:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  line-height: 1;
}

.icon-button:hover {
  background: #0860ca;
  transform: scale(1.05);
}

.icon-button:active {
  transform: scale(0.98);
}

[data-theme="dark"] .icon-button:hover {
  background: #4a9eff;
}

.lucide-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.confirmation-modal-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.confirmation-modal-buttons button {
  flex: 1;
  max-width: 200px;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.confirmation-modal-buttons .secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.confirmation-modal-buttons .secondary:hover {
  background: var(--panel-alt);
  border-color: var(--text-muted);
}

.confirmation-modal-buttons .primary {
  background: var(--accent);
  color: white;
}

.confirmation-modal-buttons .primary:hover {
  background: #0860ca;
  transform: translateY(-1px);
}

.confirmation-modal-buttons .primary:active {
  transform: translateY(0);
}

[data-theme="dark"] .confirmation-modal-buttons .primary:hover {
  background: #4a9eff;
}

/* ============================================
   Table Category Toggles
   ============================================ */

.table-category-toggles {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.category-toggle {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

/* Category-specific colors - Basic (Blue) */
.category-toggle[data-category="basic"].active {
  background: var(--category-basic-bg);
  border: 1.5px solid var(--category-basic-border);
  color: var(--category-basic-text);
}

.category-toggle[data-category="basic"].active:hover {
  background: rgba(59, 130, 246, 0.15);
}

/* Category-specific colors - Quant Metrics (Purple) */
.category-toggle[data-category="special"].active {
  background: var(--category-special-bg);
  border: 1.5px solid var(--category-special-border);
  color: var(--category-special-text);
}

.category-toggle[data-category="special"].active:hover {
  background: rgba(139, 92, 246, 0.15);
}

/* Category-specific colors - Multi-Period (Green) */
.category-toggle[data-category="multi-period"].active {
  background: var(--category-multi-period-bg);
  border: 1.5px solid var(--category-multi-period-border);
  color: var(--category-multi-period-text);
}

.category-toggle[data-category="multi-period"].active:hover {
  background: rgba(16, 185, 129, 0.15);
}

/* Inactive state - gray */
.category-toggle:not(.active) {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

.category-toggle:not(.active):hover {
  background: var(--bg-alt);
  border-color: var(--text-muted);
}

/* Disabled state - when category has no columns */
.category-toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.category-toggle.disabled:hover {
  background: var(--bg);
  border-color: var(--border);
}

/* Smooth column transitions when toggling */
#ranking-table th.category-hidden,
#ranking-table td.category-hidden {
  display: none !important;  /* Completely remove from layout */
}

/* ============================================
   Category-specific header background colors
   ============================================ */

/* Basic category - Blue tint */
#ranking-table thead th[data-category="basic"] {
  background-color: var(--category-basic-bg);
  border-bottom-color: var(--category-basic-border);
}

/* Quant Metrics category - Purple tint */
#ranking-table thead th[data-category="special"] {
  background-color: var(--category-special-bg);
  border-bottom-color: var(--category-special-border);
}

/* Multi-Period category - Green tint */
#ranking-table thead th[data-category="multi-period"] {
  background-color: var(--category-multi-period-bg);
  border-bottom-color: var(--category-multi-period-border);
}

/* Ensure sticky columns maintain their category colors */
#ranking-table thead th[data-category="basic"].visibility-header,
#ranking-table thead th[data-category="basic"]:nth-child(2) {
  background-color: var(--category-basic-bg) !important;
}

/* ============================================
   Admin Dashboard
   ============================================ */

/* Endpoint Table of Contents - Horizontal navigation */
.endpoint-toc {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.toc-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
  white-space: nowrap;
}

.toc-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.toc-separator {
  color: var(--text-muted);
  opacity: 0.4;
  user-select: none;
}

.endpoint-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
  scroll-margin-top: 20px;  /* Offset for anchor links */
}

.endpoint-card:hover {
  border-color: var(--accent-muted);
}

.endpoint-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.endpoint-info {
  flex: 1;
}

.endpoint-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.endpoint-method {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: monospace;
}

.endpoint-path {
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.endpoint-description {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.endpoint-actions {
  flex-shrink: 0;
}

.endpoint-result {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.result-header.status-success {
  background: rgba(42, 157, 143, 0.1);
  color: var(--success);
  border: 1px solid rgba(42, 157, 143, 0.3);
}

.result-header.status-error {
  background: rgba(248, 81, 73, 0.1);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
}

.fetch-time {
  font-weight: 600;
  color: var(--text);
}

.json-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  max-height: 600px;
  overflow-y: auto;
}

/* Collapsible JSON viewer container */
.json-viewer-container {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  max-height: 600px;
  overflow-y: auto;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.85rem;
  line-height: 1.8;
}

/* renderjson styling to match theme */
.json-viewer-container .disclosure {
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  margin-left: 0.25rem;
  margin-right: 0.25rem;
}

.json-viewer-container .disclosure:hover {
  color: var(--accent);
}

.json-viewer-container .key {
  color: #0969da;
  font-weight: 500;
}

[data-theme="dark"] .json-viewer-container .key {
  color: #58a6ff;
}

.json-viewer-container .string {
  color: #1a7f37;
}

[data-theme="dark"] .json-viewer-container .string {
  color: #2ea043;
}

.json-viewer-container .number {
  color: #8250df;
}

[data-theme="dark"] .json-viewer-container .number {
  color: #a371f7;
}

.json-viewer-container .boolean {
  color: #cf222e;
  font-weight: 600;
}

[data-theme="dark"] .json-viewer-container .boolean {
  color: #f85149;
}

.json-viewer-container .null {
  color: var(--text-muted);
  font-style: italic;
}

.json-viewer-container a {
  color: var(--accent);
  text-decoration: none;
}

.json-viewer-container a:hover {
  text-decoration: underline;
}

/* Indent guides */
.json-viewer-container .syntax {
  color: var(--text-muted);
}

.loading-message {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error-message {
  padding: 1rem;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
  color: var(--danger);
  font-weight: 500;
}

.copy-json-btn,
.collapse-all-btn,
.expand-all-btn {
  padding: 0.25rem 0.75rem !important;
  font-size: 0.75rem !important;
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  cursor: pointer;
}

.copy-json-btn:hover,
.collapse-all-btn:hover,
.expand-all-btn:hover {
  background: var(--accent-muted) !important;
  border-color: var(--accent) !important;
}

/* Dark theme adjustments */
[data-theme="dark"] .result-header.status-success {
  background: rgba(46, 160, 67, 0.15);
  border-color: rgba(46, 160, 67, 0.4);
}

[data-theme="dark"] .result-header.status-error {
  background: rgba(248, 81, 73, 0.15);
  border-color: rgba(248, 81, 73, 0.4);
}

/* ============================================
   TUTORIAL CAROUSEL
   ============================================ */

.tutorial-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  background: var(--accent-muted);
  border-radius: 12px;
  margin-left: 0.5rem;
  transition: all 0.2s ease;
  vertical-align: middle;
}

.tutorial-link:hover {
  background: var(--accent);
  color: white;
}

.tutorial-link i {
  width: 12px;
  height: 12px;
}

/* Tutorial Overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tutorial-overlay.open {
  opacity: 1;
  visibility: visible;
}

.tutorial-backdrop {
  position: absolute;
  inset: 0;
  /* Tune this value: 0.0 = fully visible, 1.0 = fully black */
  /* Current: 0.35 = mostly visible with subtle darkening */
  background: rgba(0, 0, 0, 0.45);
}

.tutorial-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* Carousel layout */
.tutorial-carousel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

.tutorial-viewport {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.tutorial-track {
  display: flex;
  gap: 60px;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 2rem 0;
}

/* Tutorial Cards */
.tutorial-card {
  flex-shrink: 0;
  width: 60vw;
  max-width: 900px;
  min-width: 500px;
  transform: scale(0.85);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.tutorial-card.active {
  transform: scale(1);
  cursor: default;
  z-index: 10;
}

.tutorial-card.active .tutorial-card-inner {
  /* Enhanced shadow for active card - more prominent pop effect */
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.06),
    0 12px 24px rgba(0, 0, 0, 0.1),
    0 32px 64px rgba(0, 0, 0, 0.14),
    0 64px 128px rgba(0, 0, 0, 0.18);
}

.tutorial-card.prev,
.tutorial-card.next {
  transform: scale(0.88);
  z-index: 5;
}

.tutorial-card.prev:hover,
.tutorial-card.next:hover {
  transform: scale(0.9);
}

.tutorial-card-inner {
  border-radius: 24px;
  padding: 2rem 2.5rem 2.5rem;
  /* 3D layered shadow effect */
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 8px 16px rgba(0, 0, 0, 0.08),
    0 24px 48px rgba(0, 0, 0, 0.12),
    0 48px 96px rgba(0, 0, 0, 0.16);
  /* Subtle border for definition */
  border: 1px solid rgba(255, 255, 255, 0.6);
  /* Default white background - will be overridden by inline gradient */
  background: white;
  /* Slight 3D transform for depth */
  transform-style: preserve-3d;
}

/* Card header with title and close button */
.tutorial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.tutorial-headline {
  font-size: 1.85rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  letter-spacing: -0.5px;
  flex: 1;
  text-align: center;
  padding-left: 40px; /* Balance for close button */
}

/* Close button on card */
.tutorial-close {
  width: 36px;
  height: 36px;
  border: none;
  background: #f3f4f6;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tutorial-close:hover {
  background: #e5e7eb;
}

.tutorial-close i {
  width: 20px;
  height: 20px;
  color: #6b7280;
}

.tutorial-media {
  width: 100%;
  height: 340px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.75rem;
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
}

.tutorial-media video,
.tutorial-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tutorial-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #9ca3af;
}

.tutorial-image-placeholder i {
  width: 56px;
  height: 56px;
  opacity: 0.4;
}

.tutorial-image-placeholder span {
  font-size: 0.9rem;
  font-weight: 500;
}

.tutorial-text {
  font-size: 1.1rem;
  line-height: 1.75;
  color: #4b5563;
  text-align: center;
  margin: 0;
}

/* Progress dots */
.tutorial-progress {
  display: flex;
  gap: 0.625rem;
  margin-top: 2rem;
}

.tutorial-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}

.tutorial-dot:hover {
  background: rgba(255, 255, 255, 0.6);
  transform: scale(1.1);
}

.tutorial-dot.active {
  background: white;
  transform: scale(1.3);
}

/* Dark theme support */
[data-theme="dark"] .tutorial-card-inner {
  background: #242526;
}

[data-theme="dark"] .tutorial-headline {
  color: #e4e6eb;
}

[data-theme="dark"] .tutorial-text {
  color: #b0b3b8;
}

[data-theme="dark"] .tutorial-media {
  background: linear-gradient(135deg, #3a3b3c 0%, #2d2e2f 100%);
}

[data-theme="dark"] .tutorial-close {
  background: #3a3b3c;
}

[data-theme="dark"] .tutorial-close:hover {
  background: #4a4b4c;
}

[data-theme="dark"] .tutorial-close i {
  color: #9ca3af;
}

/* Mobile responsive */
@media (max-width: 900px) {
  .tutorial-card {
    width: 70vw;
    min-width: 400px;
  }
  
  .tutorial-media {
    height: 280px;
  }
  
  .tutorial-headline {
    font-size: 1.5rem;
  }
  
  .tutorial-text {
    font-size: 1rem;
  }
}

@media (max-width: 640px) {
  .tutorial-track {
    gap: 30px;
  }
  
  .tutorial-card {
    width: 85vw;
    min-width: 280px;
    max-width: none;
  }
  
  .tutorial-card-inner {
    padding: 1.5rem;
  }
  
  .tutorial-media {
    height: 200px;
  }
  
  .tutorial-headline {
    font-size: 1.35rem;
    padding-left: 32px;
  }
  
  .tutorial-close {
    width: 32px;
    height: 32px;
  }
  
  .tutorial-close i {
    width: 18px;
    height: 18px;
  }
  
  .tutorial-text {
    font-size: 0.95rem;
  }
}

/* ============================================
   Command Palette (Cmd+K)
   ============================================ */

.command-palette-modal {
  position: fixed;
  inset: 0;
  z-index: 50000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

.command-palette-modal.open {
  opacity: 1;
  visibility: visible;
}

.command-palette-modal.closing {
  opacity: 0;
  transition: opacity 0.6s ease-in, visibility 0.6s ease-in;
}

.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.6s ease-out;
}

.command-palette-modal.open .command-palette-backdrop {
  opacity: 1;
}

.command-palette-modal.closing .command-palette-backdrop {
  opacity: 0;
  transition: opacity 0.6s ease-in;
}

[data-theme="dark"] .command-palette-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.command-palette-wrapper {
  position: relative;
  z-index: 1;
  width: 90vw;
  max-width: 1200px;
  max-height: 80vh;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  transform: translateY(-30px) scale(0.95);
  opacity: 0;
  transition: 
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.25s ease-out;
}

.command-palette-modal.open .command-palette-wrapper {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.command-palette-modal.closing .command-palette-wrapper {
  transform: translateY(-15px) scale(0.97);
  opacity: 0;
  transition: 
    transform 0.2s ease-in,
    opacity 0.15s ease-in;
}

.command-palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent);
}

.command-palette-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.command-palette-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.command-palette-shortcuts kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.command-palette-container {
  padding: 0;
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

/* When controls panel is inside modal, adjust its styling */
.controls-panel.in-modal {
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-height: none !important;
  padding: 1.5rem;
}

/* Prevent body scroll when palette is open */
body.command-palette-open {
  overflow: hidden;
}

/* Cmd+K Hint Badge */
.cmd-k-hint {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.2s, background 0.2s, box-shadow 0.2s;
  z-index: 5;
}

.cmd-k-hint:hover {
  opacity: 1;
  background: var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cmd-k-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.cmd-k-hint .hint-text {
  color: var(--text-muted);
  font-weight: 500;
}

[data-theme="dark"] .cmd-k-hint kbd {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Hide hint when controls panel is in modal */
.controls-panel.in-modal .cmd-k-hint {
  display: none;
}

/* Mobile: hide the hint (no keyboard shortcut) */
@media (max-width: 768px) {
  .cmd-k-hint {
    display: none;
  }
}

/* Ensure controls panel has relative positioning for hint */
.controls-panel {
  position: relative;
}

