/* Olympus Bets - Steve Jobs-Inspired Design System */
/* Simplicity. Elegance. Perfection. */
/* Every pixel tells a story of precision and purpose. */
/* ────────────────────────────────────────────────────────────────────────
   ⚠ NAME COLLISION: this is the LARGE (~48KB) HUB sheet at the REPO ROOT,
   loaded via raw open('app_theme.css') in app.py (main hub) and
   marketing/app.py (EvanMiya, port 8502). It is NOT the same file as
   `style/app_theme.css` (the small design-token sheet loaded through the
   css_parts list in load_css()/page_bootstrap). Edit the right one.
   A physical rename is deferred: it needs a synchronized restart of the
   separate EvanMiya service, so it isn't a safe standalone change.
   ──────────────────────────────────────────────────────────────────────── */

/* Use the system fallbacks below; production CSP intentionally blocks remote fonts. */

:root {
  /* Steve Jobs-Inspired Palette - Precision & Elegance */
  --royal-primary: #1E3A8A;
  --royal-hover: #2B4BC2;
  --royal-light: #3B5BB8;
  --royal-subtle: #1E293B;
  /* Legacy accent, remapped Sep 29 2026: this theme's "gold" painted buttons, focus rings,
     sliders, spinners, progress bars and section rules — interface chrome, which is ROYAL's
     job in the brand system (docs/PRODUCT_DESIGN_SYSTEM.md). Gold is kept only for the
     premium-tier mark (--ob-warn / --ob-accent-premium). Names kept so nothing else breaks. */
  --gold-primary: var(--ob-royal-500);
  --gold-hover: var(--ob-royal-700);
  --gold-light: var(--ob-royal-300);
  --gold-subtle: var(--ob-royal-700);
  --platinum: #F1F5F9;
  --silver: #E2E8F0;
  --titanium: #94A3B8;

  /* Sophisticated Background Layers */
  --dark-bg: #0A0A0F;
  --surface: #0F1419;
  --surface-elevated: #1A1A2E;
  --surface-hover: #1F1F3F;
  --surface-active: #242448;

  /* Premium Text Hierarchy */
  --text-primary: #FFFFFF;
  --text-secondary: #F8FAFC;
  --text-muted: #CBD5E1;
  --text-subtle: #94A3B8;
  --text-on-dark: #0A0A0F;
  --text-on-royal: #FFFFFF;

  /* Status Colors - Refined */
  --accent-success: #22C55E;
  --accent-success-subtle: #16A34A;
  --accent-warning: #F59E0B;
  --accent-warning-subtle: #D97706;
  --accent-error: #EF4444;
  --accent-error-subtle: #DC2626;
  --accent-info: #3B82F6;
  --accent-info-subtle: #2563EB;
  
  /* Typography - Refined Scale */
  --font-heading: 'Cinzel', serif;
  --font-body: 'Inter', sans-serif;
  
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */
  
  /* Spacing - Perfect 8px Grid */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  
  /* Legacy spacing for compatibility */
  --space-xs: var(--space-2);
  --space-sm: var(--space-4);
  --space-md: var(--space-6);
  --space-lg: var(--space-8);
  --space-xl: var(--space-12);
  
  /* Elevation - Sophisticated Shadow System */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.08);
  --shadow-base: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 12px -2px rgba(0, 0, 0, 0.15), 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 20px -4px rgba(0, 0, 0, 0.2), 0 8px 12px -2px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 32px -8px rgba(0, 0, 0, 0.25), 0 12px 16px -4px rgba(0, 0, 0, 0.15);
  --shadow-2xl: 0 32px 48px -12px rgba(0, 0, 0, 0.3), 0 20px 24px -8px rgba(0, 0, 0, 0.2);
  --shadow-card: var(--shadow-lg);
  --shadow-glow-gold: 0 0 40px rgba(93, 169, 218, 0.2), 0 0 20px rgba(93, 169, 218, 0.1);
  --shadow-glow-royal: 0 0 40px rgba(30, 58, 138, 0.2), 0 0 20px rgba(30, 58, 138, 0.1);
  --shadow-glow-success: 0 0 40px rgba(34, 197, 94, 0.2), 0 0 20px rgba(34, 197, 94, 0.1);
  
  /* Borders - Refined */
  --border-gold: 1px solid var(--gold-primary);
  --border-gold-subtle: 1px solid rgba(93, 169, 218, 0.2);
  --border-surface: 1px solid rgba(93, 169, 218, 0.15);
  --border-radius-sm: 0.375rem;  /* 6px */
  --border-radius-md: 0.5rem;    /* 8px */
  --border-radius-lg: 0.75rem;   /* 12px */
  --border-radius-xl: 1rem;      /* 16px */
  
  /* Transitions - Smooth and purposeful */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Global Theme Overrides - Steve Jobs Precision */
.stApp {
  background: linear-gradient(145deg,
    var(--dark-bg) 0%,
    rgba(15, 20, 25, 0.95) 25%,
    rgba(15, 20, 25, 0.98) 50%,
    rgba(15, 20, 25, 0.95) 75%,
    var(--dark-bg) 100%);
  background-attachment: fixed;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1, 'pnum' 1, 'tnum' 0, 'onum' 1, 'lnum' 0, 'dlig' 0;
  font-variant-numeric: oldstyle-nums;
}

/* Hero Section - Ultra-Premium Landing Experience */
.hero-container {
  position: relative;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  margin-bottom: var(--space-12);
  border-bottom: 1px solid rgba(93, 169, 218, 0.2);
  background:
    radial-gradient(ellipse at top, rgba(30, 58, 138, 0.08) 0%, transparent 40%),
    radial-gradient(ellipse at center, rgba(93, 169, 218, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse at bottom, rgba(15, 23, 42, 0.95) 0%, transparent 30%);
  animation: hero-fade-in 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  overflow: hidden;
}

.hero-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(93, 169, 218, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(30, 58, 138, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(34, 197, 94, 0.02) 0%, transparent 50%);
  pointer-events: none;
}

@keyframes hero-fade-in {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  60% {
    opacity: 0.8;
    transform: translateY(-5px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--gold-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
  margin: 0 auto var(--space-3);
  max-width: 42rem;
  line-height: 1.6;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.hero-caption {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin: 0 auto;
  max-width: 36rem;
  line-height: 1.5;
  font-weight: 400;
  opacity: 0.8;
}

/* Section Headers - Clear Hierarchy */
.section-header {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--font-size-3xl);
  color: var(--text-primary);
  margin-bottom: var(--space-6);
  margin-top: var(--space-10);
  letter-spacing: -0.01em;
  line-height: 1.2;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--gold-primary) 0%, transparent 100%) 1;
  padding-bottom: var(--space-3);
  position: relative;
}

.section-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--gold-primary);
  box-shadow: var(--shadow-glow-gold);
}

.section-subheader {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  margin-top: var(--space-6);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

/* Cards - Ultra-Premium Depth & Elegance */
.royal-card {
  background: linear-gradient(145deg,
    var(--surface-elevated) 0%,
    rgba(26, 33, 66, 0.98) 25%,
    rgba(30, 41, 59, 0.95) 50%,
    rgba(26, 33, 66, 0.98) 75%,
    var(--surface-elevated) 100%);
  border: 1px solid rgba(93, 169, 218, 0.2);
  border-radius: 20px;
  padding: var(--space-8);
  margin-bottom: var(--space-8);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.25),
    0 4px 16px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

.royal-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(93, 169, 218, 0.4) 20%,
    rgba(93, 169, 218, 0.6) 50%,
    rgba(93, 169, 218, 0.4) 80%,
    transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.royal-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(30, 58, 138, 0.3) 50%,
    transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.royal-card:hover {
  transform: translateY(-6px) scale(1.005);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.35),
    0 12px 24px rgba(0, 0, 0, 0.25),
    0 0 32px rgba(93, 169, 218, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  border-color: rgba(93, 169, 218, 0.4);
}

.royal-card:hover::before {
  opacity: 1;
}

.royal-card:hover::after {
  opacity: 0.8;
}

.royal-card-header {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  letter-spacing: -0.01em;
}

/* Metric Tiles - Ultra-Sophisticated Data Visualization */
.metric-tile {
  background: linear-gradient(145deg,
    rgba(30, 58, 138, 0.95) 0%,
    rgba(39, 69, 161, 0.9) 25%,
    rgba(43, 75, 194, 0.85) 50%,
    rgba(39, 69, 161, 0.9) 75%,
    rgba(30, 58, 138, 0.95) 100%);
  border: 1px solid rgba(93, 169, 218, 0.25);
  border-radius: 16px;
  padding: var(--space-6);
  text-align: center;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.2),
    0 4px 12px rgba(30, 58, 138, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.metric-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg,
    rgba(93, 169, 218, 0.08) 0%,
    transparent 30%,
    rgba(30, 58, 138, 0.05) 70%,
    transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.metric-tile::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(93, 169, 218, 0.1) 90deg,
    transparent 180deg,
    rgba(30, 58, 138, 0.1) 270deg,
    transparent 360deg
  );
  animation: metric-glow 8s linear infinite;
  pointer-events: none;
}

@keyframes metric-glow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.metric-tile:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 12px 24px rgba(30, 58, 138, 0.25),
    0 0 32px rgba(93, 169, 218, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-color: rgba(93, 169, 218, 0.5);
}

.metric-tile:hover::before {
  opacity: 1;
}

.metric-value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--font-size-3xl);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.metric-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  opacity: 0.9;
}

/* Buttons - Ultra-Premium Interaction Design */
.stButton > button {
  background: linear-gradient(145deg,
    var(--royal-primary) 0%,
    var(--royal-hover) 50%,
    var(--royal-primary) 100%) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(93, 169, 218, 0.3) !important;
  border-radius: 12px !important;
  font-family: var(--font-body) !important;
  font-weight: 600 !important;
  padding: 0.875rem 2rem !important;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  box-shadow:
    0 4px 16px rgba(30, 58, 138, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  min-height: 48px !important;
  font-size: var(--font-size-base) !important;
  letter-spacing: 0.015em !important;
  position: relative !important;
  overflow: hidden !important;
  text-transform: none !important;
}

.stButton > button::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: -100% !important;
  width: 100% !important;
  height: 100% !important;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 30%,
    rgba(255, 255, 255, 0.25) 50%,
    rgba(255, 255, 255, 0.15) 70%,
    transparent 100%) !important;
  transition: left 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.stButton > button::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 0 !important;
  height: 0 !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.1) !important;
  transform: translate(-50%, -50%) !important;
  transition: width 0.6s ease, height 0.6s ease !important;
}

.stButton > button:hover {
  transform: translateY(-3px) scale(1.02) !important;
  box-shadow:
    0 12px 32px rgba(30, 58, 138, 0.4),
    0 0 24px rgba(93, 169, 218, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  background: linear-gradient(145deg,
    var(--royal-hover) 0%,
    var(--royal-light) 50%,
    var(--royal-hover) 100%) !important;
  border-color: rgba(93, 169, 218, 0.6) !important;
}

.stButton > button:hover::before {
  left: 100% !important;
}

.stButton > button:hover::after {
  width: 300px !important;
  height: 300px !important;
}

.stButton > button:active {
  transform: translateY(-1px) scale(0.98) !important;
  transition-duration: 0.1s !important;
}

.stButton > button:focus {
  outline: 2px solid var(--gold-primary) !important;
  outline-offset: 2px !important;
}

/* Primary CTA Button - Gold Accent */
.primary-cta,
.stButton > button[kind="primary"] {
  background: linear-gradient(135deg, 
    var(--gold-primary) 0%, 
    var(--gold-hover) 100%) !important;
  color: var(--text-on-light) !important;
  font-weight: 700 !important;
  box-shadow: var(--shadow-lg), var(--shadow-glow-gold) !important;
  border-color: var(--gold-primary) !important;
}

.primary-cta:hover,
.stButton > button[kind="primary"]:hover {
  background: linear-gradient(135deg, 
    var(--gold-hover) 0%, 
    var(--gold-primary) 100%) !important;
  box-shadow: var(--shadow-2xl), 
    0 8px 32px rgba(93, 169, 218, 0.4) !important;
  transform: translateY(-2px) scale(1.02) !important;
}

/* Info Pills - Refined Badges */
.info-pill {
  background: rgba(30, 58, 138, 0.25);
  border: 1px solid rgba(30, 58, 138, 0.4);
  border-radius: 9999px;
  padding: var(--space-2) var(--space-4);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) var(--space-1);
  backdrop-filter: blur(8px);
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

.info-pill:hover {
  background: rgba(30, 58, 138, 0.4);
  border-color: var(--royal-primary);
  transform: translateY(-1px);
}

/* Quick Pick Button Styling */
.stButton > button {
  background: rgba(30, 58, 138, 0.15) !important;
  border: 1px solid rgba(30, 58, 138, 0.3) !important;
  border-radius: 6px !important;
  color: var(--text-primary) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  padding: 6px 8px !important;
  transition: all 0.2s ease !important;
  backdrop-filter: blur(4px) !important;
  min-height: 32px !important;
  width: 100% !important;
}

.stButton > button:hover {
  background: rgba(30, 58, 138, 0.25) !important;
  border: 1px solid var(--royal-primary) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.2) !important;
}

.stButton > button:active {
  background: rgba(93, 169, 218, 0.2) !important;
  border: 1px solid var(--gold-primary) !important;
  color: var(--gold-primary) !important;
}

/* Quick Pick Container */
.quick-pick-container {
  background: rgba(15, 22, 46, 0.4);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid rgba(30, 58, 138, 0.2);
}

.quick-pick-label {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}

/* Compact button layout */
.quick-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

/* Sidebar Enhancements */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 12px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.sidebar-nav-item.active {
  background: rgba(93, 169, 218, 0.15);
  border-left: 4px solid var(--gold-primary);
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-nav-item:hover:not(.active) {
  background: rgba(30, 58, 138, 0.1);
}

/* Form Controls */
.stSelectbox > div > div {
  background: var(--surface-elevated) !important;
  border: var(--border-surface) !important;
  border-radius: 8px !important;
  color: var(--text-primary) !important;
}

/* Form Labels */
.stSelectbox label, .stNumberInput label, .stSlider label {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
  font-size: 16px !important;
}

.stNumberInput > div > div > input {
  background: var(--surface-elevated) !important;
  border: var(--border-surface) !important;
  border-radius: 8px !important;
  color: var(--text-primary) !important;
}

/* Step Buttons */
.step-button {
  background: var(--surface-elevated) !important;
  border: var(--border-surface) !important;
  border-radius: 6px !important;
  color: var(--text-primary) !important;
  padding: 8px 12px !important;
  font-weight: 600 !important;
  min-width: 44px !important;
  min-height: 44px !important;
}

.step-button:hover {
  background: var(--royal-primary) !important;
  border-color: var(--gold-primary) !important;
}

/* Accessibility - Steve Jobs Attention to Detail */
*:focus {
  outline: none !important;
  box-shadow:
    0 0 0 2px rgba(93, 169, 218, 0.5),
    0 0 0 4px rgba(93, 169, 218, 0.2) !important;
  border-radius: 4px !important;
  transition: box-shadow 0.2s ease !important;
}

*:focus:not(:focus-visible) {
  box-shadow: none !important;
}

/* Focus within for better UX */
.royal-card:focus-within,
.metric-tile:focus-within {
  border-color: rgba(93, 169, 218, 0.6) !important;
  box-shadow:
    0 0 32px rgba(93, 169, 218, 0.2),
    var(--shadow-xl) !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .hero-container {
    animation: none !important;
  }

  .stSpinner > div {
    animation: none !important;
  }
}

/* Mobile Gesture Support - iOS/Android Native Feel */
/* Touch interactions that feel like native apps */

/* iOS-style pull-to-refresh hint */
.pull-refresh-hint {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(93, 169, 218, 0.9);
  color: var(--text-on-dark);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.pull-refresh-hint.show {
  opacity: 1;
}

/* Mobile-optimized loading states */
@media (max-width: 768px) {
  .stSpinner {
    padding: 2rem 1rem !important;
  }

  .stSpinner > div {
    width: 28px !important;
    height: 28px !important;
    border-width: 3px !important;
  }
}

/* Mobile swipe gestures for tabs */
@media (hover: none) and (pointer: coarse) {
  .stTabs [data-baseweb="tab"] {
    transition: transform 0.15s ease, background-color 0.15s ease;
  }

  .stTabs [data-baseweb="tab"]:active {
    transform: scale(0.95);
    background: rgba(59, 130, 246, 0.15) !important;
  }
}

/* iOS-specific haptic feedback simulation */
@supports (-webkit-touch-callout: none) {
  .stButton > button:active,
  .royal-card:active,
  .metric-tile:active {
    animation: iOS-haptic 0.1s ease;
  }

  @keyframes iOS-haptic {
    0% { transform: scale(1); }
    50% { transform: scale(0.97); }
    100% { transform: scale(1); }
  }
}

/* Android Material Design touch ripples */
@supports (-webkit-appearance: none) and (not (-webkit-touch-callout: none)) {
  .stButton > button,
  .royal-card,
  .metric-tile {
    position: relative;
    overflow: hidden;
  }

  .stButton > button::after,
  .royal-card::after,
  .metric-tile::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    pointer-events: none;
  }

  .stButton > button:active::after,
  .royal-card:active::after,
  .metric-tile:active::after {
    width: 300px;
    height: 300px;
  }
}

/* Mobile keyboard optimizations */
@media (max-width: 768px) {
  /* Prevent zoom on input focus for iOS */
  @supports (-webkit-touch-callout: none) {
    .stTextInput > div > div > input,
    .stSelectbox > div > div > select {
      font-size: 16px !important; /* Prevents zoom on iOS */
    }
  }

  /* Android keyboard optimizations */
  @supports (-webkit-appearance: none) and (not (-webkit-touch-callout: none)) {
    .stTextInput > div > div > input,
    .stSelectbox > div > div > select {
      font-size: 15px !important; /* Android optimized */
    }
  }
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
  /* Reduce motion for battery saving */
  @media (prefers-reduced-motion: reduce) {
    .royal-card,
    .metric-tile,
    .stButton > button {
      transition: none !important;
    }
  }

  /* Disable expensive effects on low-end devices */
  @media (max-resolution: 150dpi) {
    .royal-card::before,
    .royal-card::after,
    .metric-tile::before,
    .metric-tile::after {
      display: none !important;
    }

    .stButton > button::before,
    .stButton > button::after {
      display: none !important;
    }
  }
}

/* Dark mode optimizations for mobile */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .stApp {
    background: linear-gradient(145deg,
      #000000 0%,
      #0a0a0f 25%,
      #0f0f14 50%,
      #0a0f14 75%,
      #050507 100%);
  }
}

/* iPhone SE and small device optimizations */
@media (max-width: 375px) and (-webkit-min-device-pixel-ratio: 2) {
  .hero-title {
    font-size: 1.625rem !important;
    line-height: 1.3 !important;
  }

  .royal-card {
    margin: 0.5rem !important;
    padding: 1rem !important;
    border-radius: 16px !important;
  }

  .stButton > button {
    font-size: 0.875rem !important;
    padding: 0.75rem 1rem !important;
  }

  .metric-value {
    font-size: 1.75rem !important;
  }
}

/* iPhone Pro Max and large device optimizations */
@media (min-width: 428px) and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 3) {
  .hero-title {
    font-size: 2.5rem !important;
  }

  .royal-card {
    padding: 2rem !important;
    margin: 1.5rem 1rem !important;
  }

  .stButton > button {
    padding: 1rem 1.5rem !important;
    font-size: 1.0625rem !important;
  }
}

/* Samsung Galaxy and Android large screens */
@media (min-width: 360px) and (max-width: 420px) and (not (-webkit-touch-callout: none)) {
  .royal-card {
    border-radius: 12px !important; /* Material Design corners */
  }

  .stButton > button {
    border-radius: 8px !important; /* Material Design button radius */
  }

  /* Android-specific font stack */
  * {
    font-family: 'Roboto', 'Noto Sans', 'Helvetica Neue', sans-serif !important;
  }
}

/* Foldable device support */
@media (max-width: 600px) and (max-height: 300px) and (orientation: landscape) {
  /* Samsung Fold, etc. in landscape */
  .hero-container {
    display: none !important; /* Too cramped, hide hero */
  }

  .royal-card {
    margin: 0.25rem !important;
    padding: 0.75rem !important;
  }

  .stButton > button {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8125rem !important;
    min-height: 36px !important;
  }
}

/* iPad and tablet optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
  .hero-container {
    padding: 4rem 2rem !important;
  }

  .royal-card {
    padding: 2.5rem !important;
    max-width: 800px;
    margin: 2rem auto !important;
  }

  .stButton > button {
    padding: 1rem 2rem !important;
    font-size: 1.125rem !important;
    min-height: 56px !important;
  }

  /* Enable hover effects on tablets */
  .royal-card:hover,
  .metric-tile:hover,
  .stButton > button:hover {
    transform: translateY(-4px) !important;
  }
}

/* High-refresh rate mobile displays (120Hz+) */
@media (max-width: 768px) and (min-resolution: 2.5dppx) {
  .royal-card,
  .metric-tile,
  .stButton > button {
    transition-duration: 0.08s !important;
  }

  .stSpinner > div {
    animation-duration: 0.8s !important;
  }
}

/* Low-end mobile device optimizations */
@media (max-width: 768px) and (max-resolution: 1.5dppx) {
  /* Simplify animations for performance */
  .royal-card,
  .metric-tile,
  .stButton > button {
    transition-duration: 0.2s !important;
  }

  /* Reduce shadow complexity */
  .royal-card,
  .metric-tile {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }

  .stButton > button {
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2) !important;
  }

  /* Disable complex pseudo-elements */
  .royal-card::before,
  .royal-card::after,
  .metric-tile::before,
  .metric-tile::after {
    display: none !important;
  }
}

/* Mobile landscape optimizations */
@media (max-width: 896px) and (max-height: 500px) and (orientation: landscape) {
  .hero-container {
    padding: var(--space-3) var(--space-4) var(--space-4);
  }

  .hero-title {
    font-size: 1.5rem !important;
  }

  .royal-card {
    padding: var(--space-3);
    margin: var(--space-2) var(--space-2) var(--space-3);
  }

  .stButton > button {
    padding: 0.5rem 0.875rem !important;
    min-height: 40px !important;
  }
}

/* Ultra-small screens (320px and below) */
@media (max-width: 320px) {
  .hero-container {
    padding: var(--space-4) var(--space-3);
  }

  .royal-card {
    margin: var(--space-2);
    padding: var(--space-3);
  }

  .stButton > button {
    padding: 0.625rem 0.875rem !important;
    font-size: var(--font-size-sm) !important;
  }

  .metric-value {
    font-size: var(--font-size-xl);
  }
}

/* Mobile notch and dynamic island support */
@supports (padding: max(0px)) {
  /* CSS env() support for modern mobile */
  .main {
    padding-top: max(0px, env(safe-area-inset-top)) !important;
    padding-bottom: max(0px, env(safe-area-inset-bottom)) !important;
    padding-left: max(0px, env(safe-area-inset-left)) !important;
    padding-right: max(0px, env(safe-area-inset-right)) !important;
  }

  .hero-container {
    padding-top: calc(var(--space-6) + max(0px, env(safe-area-inset-top))) !important;
  }
}

/* Mobile PWA support */
@media all and (display-mode: standalone) {
  /* Running as PWA */
  .main {
    padding-top: env(safe-area-inset-top) !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  /* Hide browser UI when in PWA mode */
  header, footer, .stDeployButton {
    display: none !important;
  }
}

/* Battery-conscious animations on mobile */
@media (max-width: 768px) {
  /* Reduce animation complexity on mobile for battery life */
  .royal-card,
  .metric-tile,
  .stButton > button {
    will-change: auto;
  }

  /* Simplify shadows on low-power mode hint */
  @media (prefers-reduced-motion: reduce) {
    .royal-card,
    .metric-tile,
    .stButton > button {
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
  }
}

/* Performance optimizations */
.stApp, .royal-card, .metric-tile {
  will-change: transform;
}

/* Settings gear button */
.settings-gear {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--surface-elevated);
  border: var(--border-surface);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-gear:hover {
  background: var(--royal-primary);
  border-color: var(--gold-primary);
  transform: rotate(90deg);
}

/* Ultra-Mobile UX - Steve Jobs iOS/Android Perfection */
/* Mobile-first, platform-aware, gesture-optimized */

/* iOS Safari Detection & Optimizations */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific */
  .stApp {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: rgba(93, 169, 218, 0.1);
    -webkit-user-select: none;
    user-select: none;
  }

  /* iOS momentum scrolling */
  .main {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* iOS input styling */
  .stTextInput > div > div > input,
  .stSelectbox > div > div > select {
    -webkit-appearance: none;
    appearance: none;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  }
}

/* Android Chrome Detection & Optimizations */
@supports (-webkit-appearance: none) and (not (-webkit-touch-callout: none)) {
  /* Android Chrome specific */
  .stApp {
    font-family: 'Roboto', 'Noto Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Android touch feedback */
  .stButton > button {
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1) !important;
  }
}

/* Mobile-First Responsive Design - Pixel Perfect */
@media (max-width: 768px) {
  :root {
    /* Mobile-optimized spacing - tighter for small screens */
    --space-2: 0.375rem;  /* 6px */
    --space-3: 0.5rem;    /* 8px */
    --space-4: 0.75rem;   /* 12px */
    --space-6: 1rem;      /* 16px */
    --space-8: 1.5rem;    /* 24px */
    --space-10: 2rem;     /* 32px */
    --space-12: 2.5rem;   /* 40px */

    /* Mobile typography scale */
    --font-size-sm: 0.8125rem;   /* 13px */
    --font-size-base: 0.9375rem; /* 15px */
    --font-size-lg: 1.0625rem;   /* 17px */
    --font-size-xl: 1.1875rem;   /* 19px */
    --font-size-2xl: 1.375rem;  /* 22px */
    --font-size-3xl: 1.625rem;  /* 26px */
    --font-size-4xl: 2rem;      /* 32px */

    /* Mobile border radius - more rounded for touch */
    --border-radius-sm: 0.5rem;   /* 8px */
    --border-radius-md: 0.75rem;  /* 12px */
    --border-radius-lg: 1rem;     /* 16px */
    --border-radius-xl: 1.25rem;  /* 20px */
  }

  /* Mobile app container */
  .main {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }

  /* Mobile hero - optimized for small screens */
  .hero-container {
    padding: var(--space-6) var(--space-4) var(--space-8);
    margin-bottom: var(--space-4);
    background: linear-gradient(145deg,
      rgba(15, 23, 42, 0.95) 0%,
      rgba(15, 23, 42, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .hero-title {
    font-size: clamp(1.5rem, 10vw, 2.25rem);
    line-height: 1.2;
    margin-bottom: var(--space-3);
    letter-spacing: -0.03em;
  }

  .hero-subtitle {
    font-size: var(--font-size-base);
    line-height: 1.4;
    margin-bottom: var(--space-4);
  }

  /* Mobile cards - touch-optimized */
  .royal-card {
    margin: var(--space-3) var(--space-3) var(--space-4);
    padding: var(--space-5);
    border-radius: var(--border-radius-lg);
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.15),
      0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .royal-card:hover {
    transform: none; /* Disable hover transforms on touch */
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.15),
      0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* Mobile buttons - touch-friendly */
  .stButton > button {
    min-height: 48px !important; /* iOS/Android minimum touch target */
    padding: 0.75rem 1rem !important;
    font-size: var(--font-size-base) !important;
    font-weight: 600 !important;
    border-radius: var(--border-radius-md) !important;
    width: 100% !important;
    margin: var(--space-2) 0 !important;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1) !important;
  }

  .stButton > button:hover {
    transform: none !important; /* Disable hover effects on touch */
  }

  .stButton > button:active {
    transform: scale(0.98) !important;
    transition-duration: 0.1s !important;
  }

  /* Mobile tabs - swipe-friendly */
  .stTabs [data-baseweb="tab-list"] {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    margin: 0 calc(-1 * var(--space-3));
  }

  .stTabs [data-baseweb="tab-list"]::-webkit-scrollbar {
    display: none;
  }

  .stTabs [data-baseweb="tab"] {
    white-space: nowrap;
    flex-shrink: 0;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 600;
    min-width: 80px;
    text-align: center;
  }

  /* Mobile metric tiles */
  .metric-tile {
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    border-radius: var(--border-radius-md);
  }

  .metric-value {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-1);
  }

  .metric-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
  }

  /* Mobile typography */
  h1 { font-size: var(--font-size-3xl); }
  h2 { font-size: var(--font-size-2xl); }
  h3 { font-size: var(--font-size-xl); }

  /* Mobile form controls */
  .stTextInput > div > div > input,
  .stSelectbox > div > div > select {
    padding: var(--space-3) var(--space-4) !important;
    font-size: var(--font-size-base) !important;
    border-radius: var(--border-radius-md) !important;
    min-height: 48px !important;
  }

  /* Mobile columns - full width */
  div[data-testid="column"] {
    padding: var(--space-1) !important;
    margin: 0 !important;
  }

  /* Mobile dataframes */
  .stDataFrame {
    font-size: var(--font-size-xs) !important;
    overflow-x: auto;
  }

  .stDataFrame table {
    min-width: 600px;
  }
}

/* iPhone-specific optimizations */
@media (max-width: 428px) and (-webkit-min-device-pixel-ratio: 2) {
  /* iPhone SE and similar small devices */
  .hero-title {
    font-size: 1.75rem !important;
  }

  .royal-card {
    margin: var(--space-2) var(--space-2) var(--space-3);
    padding: var(--space-4);
  }

  .stButton > button {
    font-size: var(--font-size-sm) !important;
  }
}

/* Android-specific touch optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Pure touch devices (most Android phones) */
  .royal-card:hover,
  .metric-tile:hover,
  .stButton > button:hover {
    transform: none !important;
    box-shadow: none !important;
  }

  .stButton > button:active {
    background: rgba(59, 130, 246, 0.1) !important;
    transform: scale(0.98) !important;
  }

  /* Remove hover effects on touch */
  .stTabs [data-baseweb="tab"]:hover:not([aria-selected="true"]) {
    background: transparent !important;
    transform: none !important;
  }
}

/* iOS-specific gesture support */
@supports (-webkit-touch-callout: none) {
  /* iOS momentum scrolling for better performance */
  .main {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* iOS Safari bottom bar avoidance */
  @media screen and (max-height: 850px) {
    .hero-container {
      padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom)) !important;
    }
  }

  /* iOS notch support */
  .main {
    padding-top: env(safe-area-inset-top) !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    padding-left: env(safe-area-inset-left) !important;
    padding-right: env(safe-area-inset-right) !important;
  }
}

/* Android Chrome specific */
@supports (-webkit-appearance: none) and (not (-webkit-touch-callout: none)) {
  /* Android Chrome scrollbar hiding */
  .stTabs [data-baseweb="tab-list"] {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .stTabs [data-baseweb="tab-list"]::-webkit-scrollbar {
    display: none;
  }
}

/* High-refresh rate displays (120Hz+) */
@media (min-resolution: 120dpi) {
  .royal-card:hover,
  .metric-tile:hover,
  .stButton > button:hover {
    transition-duration: 0.08s !important;
  }
}

/* Foldable devices and large phones */
@media (min-width: 400px) and (max-width: 600px) {
  .hero-title {
    font-size: clamp(1.875rem, 12vw, 2.5rem);
  }

  .royal-card {
    padding: var(--space-6);
  }

  .stButton > button {
    padding: 0.875rem 1.25rem !important;
  }
}

/* Ultra-small screens (320px and below) */
@media (max-width: 320px) {
  .hero-container {
    padding: var(--space-4) var(--space-3);
  }

  .royal-card {
    margin: var(--space-2);
    padding: var(--space-3);
  }

  .stButton > button {
    padding: 0.625rem 0.875rem !important;
    font-size: var(--font-size-sm) !important;
  }

  .metric-value {
    font-size: var(--font-size-xl);
  }
}

/* Desktop Enhancements */
@media (min-width: 1024px) {
  .hero-container {
    padding: var(--space-16) var(--space-4);
  }
  
  .royal-card:hover {
    transform: translateY(-4px);
  }
  
  .metric-tile {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .hero-title,
  .section-header,
  .royal-card-header {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Print Styles - Professional Documentation */
@media print {
  @page {
    margin: 0.75in;
    size: A4;
  }

  body {
    background: white !important;
    color: black !important;
    font-family: 'Times New Roman', serif !important;
  }

  .stButton,
  section[data-testid="stSidebar"],
  .settings-gear,
  .stTabs,
  .stSpinner,
  .hero-container {
    display: none !important;
  }

  .royal-card,
  .metric-tile {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin: 20px 0 !important;
    color: black !important;
  }

  .royal-card h1, .royal-card h2, .royal-card h3,
  .metric-tile h1, .metric-tile h2, .metric-tile h3 {
    color: black !important;
  }

  .metric-value, .metric-label {
    color: black !important;
  }

  .stDataFrame {
    background: white !important;
    border: 1px solid #ddd !important;
    page-break-inside: avoid;
  }

  .stDataFrame thead th {
    background: #f5f5f5 !important;
    color: black !important;
    border: 1px solid #ddd !important;
  }

  .stDataFrame tbody td {
    border: 1px solid #ddd !important;
    color: black !important;
  }

  .section-header::after {
    display: none !important;
  }

  .section-header {
    border-bottom: 2px solid #000 !important;
    padding-bottom: 8px !important;
  }
}

/* Animation Performance */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark Mode Support (already dark, but future-proof) */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* Streamlit specific overrides - Ultra-Premium */
.stTabs [data-baseweb="tab-list"] {
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 6px;
  border: 1px solid rgba(93, 169, 218, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.stTabs [data-baseweb="tab"] {
  height: 48px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  padding: 12px 20px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

.stTabs [data-baseweb="tab"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(145deg,
    rgba(30, 58, 138, 0.1) 0%,
    rgba(43, 75, 194, 0.15) 50%,
    rgba(30, 58, 138, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stTabs [aria-selected="true"] {
  background: linear-gradient(145deg,
    var(--royal-primary) 0%,
    var(--royal-hover) 50%,
    var(--royal-primary) 100%);
  color: var(--text-primary);
  border-color: rgba(93, 169, 218, 0.4);
  box-shadow:
    0 4px 16px rgba(30, 58, 138, 0.3),
    0 0 20px rgba(93, 169, 218, 0.1);
  font-weight: 700;
  transform: scale(1.02);
}

.stTabs [aria-selected="true"]::before {
  opacity: 1;
}

.stTabs [data-baseweb="tab"]:hover:not([aria-selected="true"]) {
  background: rgba(30, 58, 138, 0.1);
  border-color: rgba(93, 169, 218, 0.2);
  color: var(--text-secondary);
  transform: translateY(-1px);
}

/* Charts and Plots - Premium Visualization */
.js-plotly-plot {
  background: var(--surface-elevated) !important;
  border-radius: var(--border-radius-lg) !important;
  border: var(--border-surface) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: var(--space-4) !important;
}

/* Data Tables - Clean and Readable */
.stDataFrame {
  border-radius: var(--border-radius-md) !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-lg) !important;
}

.stDataFrame table {
  font-size: var(--font-size-sm) !important;
}

.stDataFrame thead {
  background: linear-gradient(135deg, 
    var(--royal-primary) 0%, 
    var(--royal-hover) 100%) !important;
  color: var(--text-primary) !important;
}

.stDataFrame thead th {
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  text-transform: uppercase !important;
  font-size: var(--font-size-xs) !important;
  padding: var(--space-3) var(--space-4) !important;
}

.stDataFrame tbody tr {
  transition: background-color var(--transition-fast) !important;
}

.stDataFrame tbody tr:hover {
  background-color: rgba(30, 58, 138, 0.1) !important;
}

/* Expander - Collapsible Sections */
.streamlit-expanderHeader {
  background: var(--surface-elevated) !important;
  border: var(--border-surface) !important;
  border-radius: var(--border-radius-md) !important;
  font-weight: 600 !important;
  transition: all var(--transition-fast) !important;
  padding: var(--space-4) !important;
}

.streamlit-expanderHeader:hover {
  background: var(--surface-hover) !important;
  border-color: var(--royal-primary) !important;
}

/* Alerts and Messages */
.stAlert {
  border-radius: var(--border-radius-md) !important;
  border-left-width: 4px !important;
  padding: var(--space-4) !important;
  backdrop-filter: blur(8px) !important;
}

/* Success Alert */
div[data-testid="stNotification"][data-baseweb="notification"] > div[role="alert"] {
  border-radius: var(--border-radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* Loading Spinner - Elegant Animation */
.stSpinner > div {
  border: 3px solid rgba(93, 169, 218, 0.2) !important;
  border-top: 3px solid var(--gold-primary) !important;
  border-right: 3px solid rgba(93, 169, 218, 0.4) !important;
  border-radius: 50% !important;
  width: 32px !important;
  height: 32px !important;
  animation: elegant-spin 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite !important;
}

@keyframes elegant-spin {
  0% {
    transform: rotate(0deg) scale(1);
    border-width: 3px;
  }
  50% {
    transform: rotate(180deg) scale(1.1);
    border-width: 4px;
    border-color: rgba(93, 169, 218, 0.3);
    border-top-color: var(--gold-light);
  }
  100% {
    transform: rotate(360deg) scale(1);
    border-width: 3px;
  }
}

/* Progress Bar - Sophisticated */
.stProgress > div > div {
  background: linear-gradient(90deg,
    var(--gold-primary) 0%,
    var(--gold-light) 50%,
    var(--gold-primary) 100%) !important;
  border-radius: 9999px !important;
  box-shadow: 0 0 20px rgba(93, 169, 218, 0.3) !important;
  height: 8px !important;
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Progress Bar */
.stProgress > div > div {
  background: var(--gold-primary) !important;
  border-radius: 9999px !important;
}

/* Sidebar Enhancement */
section[data-testid="stSidebar"] {
  background: linear-gradient(180deg, 
    var(--dark-bg) 0%, 
    var(--surface) 100%) !important;
  border-right: 1px solid var(--border-surface) !important;
}

section[data-testid="stSidebar"] .stSelectbox > div > div {
  background: var(--surface) !important;
}

/* Metric Cards - Enhanced */
div[data-testid="stMetric"] {
  background: var(--surface-elevated);
  border: var(--border-surface);
  border-radius: var(--border-radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

div[data-testid="stMetric"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gold-primary);
}

div[data-testid="stMetric"] label {
  color: var(--text-muted) !important;
  font-size: var(--font-size-sm) !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em !important;
}

div[data-testid="stMetric"] [data-testid="stMetricValue"] {
  color: var(--text-primary) !important;
  font-weight: 700 !important;
  font-size: var(--font-size-3xl) !important;
}

/* Column Layouts - Balanced Spacing */
div[data-testid="column"] {
  padding: var(--space-2) !important;
}

/* Divider */
hr {
  border-color: var(--border-surface) !important;
  margin: var(--space-8) 0 !important;
  opacity: 0.5 !important;
}

/* Markdown Content */
.stMarkdown {
  color: var(--text-primary) !important;
}

.stMarkdown h1 {
  color: var(--text-primary) !important;
  font-family: var(--font-heading) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
}

.stMarkdown h2, .stMarkdown h3 {
  color: var(--text-primary) !important;
  font-family: var(--font-heading) !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
}

/* Decoration applies to ALL anchors: classed CTAs (.ob-chip, .premium-cta-button,
   …) declare `text-decoration:none` themselves but lose to Streamlit's own
   `.st-emotion-cache-… a` rule on specificity, so they need this !important to
   stay un-underlined. */
.stMarkdown a {
  text-decoration: none !important;
  transition: color var(--transition-fast) !important;
}

/* Color is bare-links-only. Without `:not([class])` this repainted every classed
   CTA anchor gold, overriding .obh-cta's near-black label on a royal-500 fill
   (1.22:1 contrast). Classed anchors own their color. */
.stMarkdown a:not([class]) {
  color: var(--gold-primary) !important;
}

.stMarkdown a:not([class]):hover {
  color: var(--gold-light) !important;
  text-decoration: underline !important;
}

.stMarkdown code {
  background: var(--surface-elevated) !important;
  color: var(--ob-royal-300) !important;  /* was gold: gold is the premium-tier mark only */
  border-radius: var(--border-radius-sm) !important;
  padding: var(--space-1) var(--space-2) !important;
  font-size: 0.9em !important;
}

/* Scrollbar Styling - Ultra-Elegant */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(93, 169, 218, 0.1);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg,
    rgba(30, 58, 138, 0.6) 0%,
    rgba(43, 75, 194, 0.7) 50%,
    rgba(30, 58, 138, 0.6) 100%);
  border-radius: 8px;
  border: 2px solid rgba(15, 23, 42, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg,
    var(--royal-primary) 0%,
    var(--royal-hover) 50%,
    var(--royal-primary) 100%);
  border-color: rgba(93, 169, 218, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 12px rgba(30, 58, 138, 0.3);
}

::-webkit-scrollbar-corner {
  background: var(--dark-bg);
}

/* Selection - Elegant Highlighting */
::selection {
  background: linear-gradient(135deg,
    rgba(93, 169, 218, 0.4) 0%,
    rgba(93, 169, 218, 0.6) 50%,
    rgba(93, 169, 218, 0.4) 100%);
  color: var(--text-on-dark);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

::-moz-selection {
  background: linear-gradient(135deg,
    rgba(93, 169, 218, 0.4) 0%,
    rgba(93, 169, 218, 0.6) 50%,
    rgba(93, 169, 218, 0.4) 100%);
  color: var(--text-on-dark);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
