/* ============================================
   BAR CHART RACE PORTAL — Design System
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Design Tokens --- */
:root {
  /* Colors — Dark Theme */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2235;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.06);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(99, 102, 241, 0.4);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #0a0e1a;

  /* Accent Colors */
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #06b6d4;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6, #06b6d4);
  --gradient-header: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-card: linear-gradient(145deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.04));
  --gradient-glow: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(99, 102, 241, 0.08), transparent 40%);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  --shadow-glow-accent: 0 0 20px rgba(99, 102, 241, 0.3);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index layers */
  --z-base: 1;
  --z-dropdown: 10;
  --z-modal: 100;
  --z-toast: 200;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Force dark color scheme on all browsers */
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Force dark backgrounds on all native form controls for cross-browser consistency */
input, textarea, select {
  color-scheme: dark;
  background-color: var(--bg-input);
  color: var(--text-primary);
}

select option {
  background-color: #1a2235;
  color: var(--text-primary);
}

select optgroup {
  background-color: #111827;
  color: var(--text-secondary);
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(99, 102, 241, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(6, 182, 212, 0.06), transparent),
    radial-gradient(ellipse 50% 50% at 50% 0%, rgba(139, 92, 246, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* --- Layout --- */
.app-container {
  position: relative;
  z-index: var(--z-base);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6);
}

/* --- Header --- */
.app-header {
  text-align: center;
  padding: var(--space-12) var(--space-4) var(--space-8);
  position: relative;
}

.app-header__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.app-header__icon {
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-glow);
  animation: pulse-glow 3s ease-in-out infinite;
}

.app-header__title {
  font-size: var(--text-3xl);
  font-weight: 800;
  background: var(--gradient-header);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.app-header__subtitle {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  font-weight: 400;
  max-width: 600px;
  margin: 0 auto;
}

/* --- Step Navigation --- */
.steps-nav {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.step-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.step-tab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.step-tab:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.step-tab.active {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: var(--shadow-glow-accent);
}

.step-tab.active::before {
  opacity: 0.1;
}

.step-tab__number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  transition: all var(--transition-base);
}

.step-tab.active .step-tab__number {
  background: var(--accent-primary);
  color: white;
}

.step-tab.completed .step-tab__number {
  background: var(--accent-success);
  color: white;
}

.step-tab.completed .step-tab__number::after {
  content: '✓';
}

/* Connector lines between steps */
.step-connector {
  width: 40px;
  height: 2px;
  background: var(--border-subtle);
  align-self: center;
  border-radius: 1px;
  transition: background var(--transition-base);
}

.step-connector.active {
  background: var(--accent-primary);
}

/* --- Card / Panel --- */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-base);
  animation: fadeSlideUp 0.5s ease-out;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.3), transparent);
}

.panel:hover {
  border-color: var(--border-medium);
}

.panel--hidden {
  display: none;
}

.panel__title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.panel__title-icon {
  font-size: var(--text-2xl);
}

.panel__description {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

/* --- Drag & Drop Zone --- */
.dropzone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-16) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  background: var(--bg-glass);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.06);
  box-shadow: inset 0 0 40px rgba(99, 102, 241, 0.05);
}

.dropzone.dragover {
  transform: scale(1.01);
}

.dropzone__icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  display: block;
  animation: float 3s ease-in-out infinite;
}

.dropzone__text {
  font-size: var(--text-lg);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.dropzone__subtext {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.dropzone__or {
  color: var(--text-tertiary);
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow-accent);
}

.btn--primary:hover {
  box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-accent);
}

.btn--success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: var(--shadow-md), 0 0 20px rgba(16, 185, 129, 0.2);
}

.btn--danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

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

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-group {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* --- Form Controls --- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.763L10.825 4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Range slider */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.range-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent-primary);
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

.range-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Checkbox / toggle */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch__slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-switch__slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-switch__slider {
  background: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-switch__slider::before {
  transform: translateX(20px);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
}

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

/* Color picker */
.color-picker-input {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

.color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-input::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

/* --- Data Preview Table --- */
.data-preview {
  margin-top: var(--space-6);
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-preview th {
  background: var(--bg-tertiary);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
}

.data-preview td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.data-preview tr:hover td {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.data-preview__info {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
}

/* --- Color Palettes --- */
.palette-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.palette-section-header .settings-section__title {
  margin-bottom: 0;
}

.palette-toolbar {
  display: flex;
  gap: var(--space-2);
}

.palette-tool-btn {
  padding: 4px 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

.palette-tool-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.map-color-scale-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.palette-option {
  padding: var(--space-3);
  background: var(--bg-glass);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.palette-option:hover {
  border-color: var(--border-accent);
  background: var(--bg-glass-hover);
}

.palette-option.selected {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow-accent);
}

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

.palette-option__name {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.palette-option__actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}

.palette-option:hover .palette-option__actions {
  opacity: 1;
}

.palette-action-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.palette-action-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.palette-option__colors {
  display: flex;
  gap: 3px;
  height: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.palette-option__swatch {
  flex: 1;
  border-radius: 2px;
}

/* Map scale items are compact */
.map-color-scale-grid .palette-option__name {
  max-width: none;
  font-size: 10px;
}

/* --- Palette Editor --- */
.palette-editor {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.palette-editor__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.palette-editor__name {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 6px 10px;
  outline: none;
}

.palette-editor__name:focus {
  border-color: var(--accent-primary);
}

.palette-editor__done {
  padding: 6px 14px;
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.palette-editor__done:hover {
  background: var(--accent-primary-hover);
}

.palette-editor__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.palette-editor__swatch-wrap {
  position: relative;
  cursor: pointer;
}

.palette-editor__swatch-wrap input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.palette-editor__swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.15);
  position: relative;
  transition: border-color 0.15s;
}

.palette-editor__swatch-wrap:hover .palette-editor__swatch {
  border-color: rgba(255,255,255,0.5);
}

.palette-editor__remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  background: var(--accent-danger);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.palette-editor__swatch-wrap:hover .palette-editor__remove {
  display: flex;
}

.palette-editor__add-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border-medium);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

.palette-editor__add-swatch:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Gradient stop swatches (for map scales) */
.palette-editor__gradient-preview {
  height: 20px;
  border-radius: var(--radius-sm);
  margin-top: var(--space-3);
}

/* --- Entity Color List --- */
.entity-colors {
  max-height: 300px;
  overflow-y: auto;
  margin-top: var(--space-4);
}

.entity-color-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.entity-color-row:hover {
  background: var(--bg-glass-hover);
}

.entity-color-row__name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* --- Data Filters (Step 1) --- */
.entity-filter-list {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-content: start;
}

.entity-filter-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: background var(--transition-fast);
  user-select: none;
}

.entity-filter-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.entity-filter-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* --- Entity Logo List --- */
.entity-logos {
  max-height: 400px;
  overflow-y: auto;
  margin-top: var(--space-3);
}

.entity-logo-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.entity-logo-row:hover {
  background: var(--bg-glass-hover);
}

.entity-logo-row__preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

.entity-logo-row__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.entity-logo-row__name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-logo-row__upload {
  display: none;
}

.entity-logo-row__btn {
  padding: 3px 8px;
  font-size: var(--text-xs);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  flex-shrink: 0;
}

.entity-logo-row__btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.entity-logo-row__status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
  font-weight: 600;
  flex-shrink: 0;
}

/* --- Settings Grid --- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
}

.settings-section {
  padding: var(--space-5);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.settings-section__title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

/* --- Chart Type Selector --- */
.chart-type-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.chart-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  background: var(--bg-glass);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  text-align: center;
}

.chart-type-btn:hover {
  border-color: var(--border-accent);
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.chart-type-btn.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow-accent);
}

.chart-type-btn__icon {
  font-size: 2rem;
  display: block;
  transition: transform var(--transition-base);
}

.chart-type-btn:hover .chart-type-btn__icon {
  transform: scale(1.15);
}

.chart-type-btn__label {
  font-size: var(--text-base);
  font-weight: 700;
}

.chart-type-btn__desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.chart-type-btn.active .chart-type-btn__desc {
  color: var(--text-secondary);
}

/* --- Canvas Preview --- */
.preview-container {
  position: relative;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

.preview-container canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Playback Controls --- */
.playback-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
  backdrop-filter: blur(20px);
}

.playback-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--text-lg);
  transition: all var(--transition-fast);
}

.playback-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.playback-btn--play {
  width: 48px;
  height: 48px;
  font-size: var(--text-xl);
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.playback-btn--play:hover {
  background: var(--accent-primary-hover);
  color: white;
  transform: scale(1.05);
}

.playback-timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.playback-progress {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.playback-progress__fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 100ms linear;
}

.playback-time {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.playback-speed {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* --- Export Panel --- */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.export-card {
  padding: var(--space-6);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.export-card:hover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.export-card__icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
  display: block;
}

.export-card__title {
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.export-card__desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* --- Progress overlay --- */
.export-progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.export-progress-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.export-progress-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  text-align: center;
  min-width: 380px;
  box-shadow: var(--shadow-lg);
}

.export-progress-card__title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-6);
}

.export-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.export-progress-bar__fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 200ms ease;
  width: 0%;
}

.export-progress-card__percent {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: var(--space-4);
}

/* --- Toast / Notifications --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-spring);
}

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

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

/* --- Column Mapping Section --- */
.column-mapping {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding: var(--space-5);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

/* --- Animations --- */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--shadow-glow); }
  50% { box-shadow: 0 0 60px rgba(99, 102, 241, 0.25); }
}

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

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-container {
    padding: var(--space-4);
  }

  .app-header__title {
    font-size: var(--text-2xl);
  }

  .panel {
    padding: var(--space-5);
  }

  .steps-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .step-connector {
    display: none;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .export-grid {
    grid-template-columns: 1fr;
  }

  .playback-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}
