/* ── FastStats · Design System ── */
/* Dark glassmorphism theme with vibrant accents */
/* Uses the native system font stack — no render-blocking web-font fetch, so the
   app paints instantly and works fully offline. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Core palette */
  --bg-deep: #0a0e1a;
  --bg-base: #0f172a;
  --bg-surface: rgba(15, 23, 42, 0.7);
  --bg-elevated: rgba(30, 41, 59, 0.6);
  --bg-glass: rgba(30, 41, 59, 0.4);
  --bg-glass-hover: rgba(30, 41, 59, 0.6);

  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.1);
  --border-medium: rgba(148, 163, 184, 0.2);
  --border-accent: rgba(99, 102, 241, 0.4);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #818cf8;

  /* Accents */
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #14b8a6;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --accent-success: #10b981;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-accent: linear-gradient(135deg, #6366f1, #14b8a6);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);

  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

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

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

:root { color-scheme: dark; }

/* ── Light theme ── */
[data-theme="light"] {
  color-scheme: light;
  --bg-deep: #eef2f7;
  --bg-base: #ffffff;
  --bg-surface: rgba(255, 255, 255, 0.85);
  --bg-elevated: rgba(241, 245, 249, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-glass-hover: rgba(226, 232, 240, 0.85);
  --border-subtle: rgba(15, 23, 42, 0.09);
  --border-medium: rgba(15, 23, 42, 0.18);
  --border-accent: rgba(79, 70, 229, 0.45);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-accent: #4f46e5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.12);
}
[data-theme="light"] .bg-mesh .orb { opacity: 0.1; }
[data-theme="light"] #loading-overlay { background: rgba(238, 242, 247, 0.9); }
[data-theme="light"] .fs-grid,
[data-theme="light"] .fs-grid-search,
[data-theme="light"] .fs-grid-page-btn,
[data-theme="light"] .code-block { background: var(--bg-base); }
[data-theme="light"] .fs-grid-toolbar,
[data-theme="light"] .fs-grid-pager,
[data-theme="light"] .fs-grid-table thead th { background: #f1f5f9; }
[data-theme="light"] .fs-grid-table tbody tr:nth-child(even) td { background: rgba(15, 23, 42, 0.03); }
[data-theme="light"] .card code { background: rgba(99, 102, 241, 0.1); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover { color: var(--text-accent); border-color: var(--border-accent); background: var(--bg-glass-hover); }
.theme-toggle .fs-icon { width: 17px; height: 17px; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  font-size: 14px;
}

/* ── Background effects ── */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-mesh .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  animation: orbFloat 20s ease-in-out infinite alternate;
}
.bg-mesh .orb-1 { width: 600px; height: 600px; background: #6366f1; top: -15%; left: -10%; }
.bg-mesh .orb-2 { width: 500px; height: 500px; background: #14b8a6; bottom: -15%; right: -10%; animation-delay: -7s; }
.bg-mesh .orb-3 { width: 400px; height: 400px; background: #8b5cf6; top: 50%; left: 40%; animation-delay: -14s; }

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 50px) scale(1.2); }
}

/* ── App layout ── */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.logo .gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.external-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.external-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color var(--transition-fast);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.external-links a:hover { color: var(--text-accent); }

.external-links a svg { width: 18px; height: 18px; }

/* ── Upload bar ── */
.upload-bar {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
}

.upload-bar-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  max-width: 1400px;
  margin: 0 auto;
}

.upload-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.upload-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.upload-label:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.upload-label input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.header-check-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
}

.header-check-label input { accent-color: var(--accent-primary); }

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

.dataset-selector label {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
}

.current-data {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.current-data-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-accent);
  font-weight: 700;
}

#current-data-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

#current-data-dims {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-sample {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-upload {
  background: rgba(20, 184, 166, 0.15);
  color: var(--accent-secondary);
  border: 1px solid rgba(20, 184, 166, 0.2);
}

/* ── Main content ── */
.app-body {
  display: flex;
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* ── Sidebar nav ── */
.sidebar-nav {
  width: 200px;
  min-width: 200px;
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.35rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  font-family: inherit;
}

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

.nav-tab.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
  font-weight: 600;
}

.nav-tab .tab-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ── Main panel ── */
.main-panel {
  flex: 1;
  padding: 1.5rem 2rem;
  min-width: 0;
  overflow-x: hidden;
}

/* ── Cards ── */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition-fast);
}

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

.card h3 {
  color: var(--text-accent);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.card p { color: var(--text-secondary); margin-bottom: 0.5rem; font-size: 0.88rem; }
.card ul { padding-left: 1.25rem; color: var(--text-secondary); font-size: 0.88rem; }
.card li { margin-bottom: 0.35rem; }
.card li strong { color: var(--text-primary); }
.card code { background: rgba(99, 102, 241, 0.15); color: var(--text-accent); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.82rem; }

/* ── Section titles ── */
.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Data tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-medium);
  color: var(--text-accent);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table td.num, .data-table th.num { text-align: right; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(99, 102, 241, 0.04); }

/* ── Data grid (custom, dependency-free) ── */
.grid-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.fs-grid {
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.55);
}
.fs-grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(30, 41, 59, 0.6);
}
.fs-grid-search {
  flex: 0 1 240px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}
.fs-grid-search:focus { outline: none; border-color: var(--border-accent); }
.fs-grid-info { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }
.fs-grid-scroll { flex: 1; overflow: auto; min-height: 0; }
.fs-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.fs-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(30, 41, 59, 0.95);
  color: var(--text-secondary);
  text-align: left;
  padding: 0.5rem 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-medium);
}
.fs-grid-table thead th:hover { color: var(--text-primary); }
.fs-grid-table thead th.sorted { color: var(--accent-primary-hover); }
.fs-grid-table tbody td {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fs-grid-table tbody td.num { text-align: right; }
.fs-grid-table tbody tr:nth-child(even) td { background: rgba(15, 23, 42, 0.35); }
.fs-grid-table tbody tr:hover td { background: rgba(99, 102, 241, 0.1); }
.fs-grid-pager {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(30, 41, 59, 0.5);
}
.fs-grid-page-btn {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.fs-grid-page-btn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-accent); }
.fs-grid-page-btn:disabled { opacity: 0.4; cursor: default; }
.fs-grid-page-label { font-size: 0.75rem; color: var(--text-secondary); margin: 0 0.3rem; }

/* Loader error + plot loading */
.loader-error { text-align: center; max-width: 380px; }
.loader-error p { margin-bottom: 0.6rem; }
.loader-error .btn { margin-top: 0.4rem; }
.plot-box.plot-loading::after {
  content: 'Loading chart engine…';
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ── Forms ── */
.form-group { margin-bottom: 0.85rem; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

.form-textarea { resize: vertical; min-height: 60px; }

.form-range {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.checkbox-option, .radio-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 0.25rem;
}

.checkbox-option input, .radio-option input { accent-color: var(--accent-primary); }

.multi-select-container {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  background: var(--bg-elevated);
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.multi-select-option:hover { background: rgba(99, 102, 241, 0.08); }
.multi-select-option input { accent-color: var(--accent-primary); }

.help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }

/* ── Wrangle ── */
.wrangle-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

.wrangle-sidebar {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  min-width: 0;
}

/* min-width:0 lets grid children shrink instead of pushing past the viewport */
.wrangle-main { min-width: 0; }
.wrangle-step-summary, .multi-select-option { overflow-wrap: anywhere; }

.wrangle-add-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.wrangle-add-row .form-select { flex: 1; }

.wrangle-steps-list { margin-bottom: 1rem; }

.wrangle-step-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.wrangle-step-item:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-sm);
}

.wrangle-step-item.selected {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: var(--shadow-glow);
}

.wrangle-step-item.dragging { opacity: 0.5; }
.wrangle-step-item.drag-over { border-color: var(--accent-secondary); border-style: dashed; }

.wrangle-step-title {
  font-weight: 600;
  color: var(--text-accent);
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
}

.wrangle-step-summary {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.wrangle-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.config-form {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ── Plot ── */
.plot-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
}

.plot-sidebar {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.plot-main { min-width: 0; }

.plot-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  min-height: 500px;
  display: flex;
  overflow: hidden;
}

.plot-box {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.plot-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ── Stats ── */
.stats-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
}

.stats-sidebar {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stats-main { min-width: 0; }

.stat-result-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.stat-result-card h4 {
  color: var(--text-accent);
  font-weight: 700;
  font-size: 0.9rem;
  margin: 1rem 0 0.5rem;
}

.stat-result-card h4:first-child { margin-top: 0; }

.stat-interpretation {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Status messages ── */
.status-success {
  color: var(--accent-success);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.status-error {
  color: var(--accent-danger);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 2rem;
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.empty-state-sm { padding: 1rem; }
.empty-state p { margin: 0; font-size: 0.85rem; }

/* ── Dims label ── */
.dims-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

/* ── Summaries ── */
.view-summaries { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.summary-section { min-width: 0; overflow-x: auto; }
.muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background: var(--bg-base);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1.25rem 1.5rem; }
.modal-body p { color: var(--text-secondary); font-size: 0.88rem; margin-bottom: 0.75rem; }

.modal-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── Code blocks ── */
.code-block {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 0.75rem;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 2000;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: rgba(16, 185, 129, 0.95); color: white; }
.toast-error { background: rgba(239, 68, 68, 0.95); color: white; }

/* ── Loading overlay ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  gap: 1rem;
}

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

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

#loading-overlay p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Footer ── */
.app-footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.app-footer a {
  color: var(--text-accent);
  text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* ── Icons (inline SVG, Lucide) ── */
.fs-icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.18em;
}
.logo-icon { display: inline-flex; color: var(--text-accent); }
.logo-icon .fs-icon { width: 1.4rem; height: 1.4rem; }
.nav-tab .tab-icon { display: inline-flex; }
.nav-tab .fs-icon { width: 1.05rem; height: 1.05rem; }
.report-item-kind { display: inline-flex; color: var(--text-accent); }
.modal-close .fs-icon { width: 1.1rem; height: 1.1rem; }
.upload-label .fs-icon { width: 1rem; height: 1rem; }
.card h3 .fs-icon { margin-right: 0.15rem; color: var(--text-accent); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar-nav { width: 60px; min-width: 60px; }
  .nav-tab span:not(.tab-icon) { display: none; }
  .wrangle-layout, .plot-layout, .stats-layout { grid-template-columns: 1fr; }
  .view-summaries { grid-template-columns: 1fr; }
  .upload-bar-inner { flex-direction: column; align-items: flex-start; }
  .current-data { margin-left: 0; }
  .plot-sidebar, .stats-sidebar { max-height: none; }
}

/* Phones: sidebar becomes a horizontal, scrollable tab strip under the header */
@media (max-width: 768px) {
  body { font-size: 13px; }
  .bg-mesh { display: none; }

  .app-header { padding: 0 0.85rem; }
  .header-top { height: 50px; }
  .logo { font-size: 1.1rem; }
  /* Icon-only external links */
  .external-links { gap: 0.25rem; }
  .external-links a { font-size: 0; gap: 0; padding: 0.45rem; }
  .external-links a svg { width: 20px; height: 20px; }

  .upload-bar { padding: 0.6rem 0.85rem; }
  .upload-bar-inner { flex-direction: row; flex-wrap: wrap; gap: 0.6rem; }
  .upload-group { flex-wrap: wrap; gap: 0.6rem; }
  .dataset-selector { width: 100%; }
  .dataset-selector .form-select { width: 100% !important; min-width: 0 !important; flex: 1; }
  .current-data { width: 100%; flex-wrap: wrap; gap: 0.5rem; }

  .app-body { flex-direction: column; }
  .sidebar-nav {
    width: 100%;
    min-width: 0;
    height: auto;
    top: 50px;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 0.3rem;
    padding: 0.5rem 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    z-index: 90;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .nav-tab {
    width: auto;
    flex: 0 0 auto;
    margin-bottom: 0;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .nav-tab span:not(.tab-icon) { display: inline; }

  .main-panel { padding: 0.85rem; }
  .card { padding: 0.9rem 1rem; }
  .plot-card { min-height: 300px; padding: 0.5rem; }
  .plot-sidebar, .stats-sidebar, .wrangle-sidebar { padding: 1rem; }

  /* Keep wide tables scrollable instead of blowing out the layout */
  .stat-result-card { overflow-x: auto; }
  .report-item-body { padding: 0.75rem; }
  .fs-grid-toolbar { flex-wrap: wrap; }
  .fs-grid-search { flex: 1 1 100%; }

  .report-head { flex-direction: column; align-items: stretch; }
  .report-actions .btn { flex: 1 1 auto; justify-content: center; }

  .modal-dialog { width: 95%; max-height: 92vh; }
  .modal-header, .modal-body { padding-left: 1rem; padding-right: 1rem; }
  .modal-footer { flex-wrap: wrap; }

  .toast { left: 1rem; right: 1rem; bottom: 1rem; text-align: center; }
}

@media (max-width: 480px) {
  .header-check-label { font-size: 0.75rem; }
  .upload-label { font-size: 0.78rem; padding: 0.45rem 0.8rem; }
  .plot-actions .btn, .wrangle-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════ v2 enhancements ══════════ */

/* Scroll long stats sidebar like the plot one */
.stats-sidebar { max-height: calc(100vh - 120px); overflow-y: auto; }

/* Ghost / extra-small buttons */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-accent); background: var(--bg-glass-hover); }
.btn-xs { padding: 0.28rem 0.55rem; font-size: 0.72rem; border-radius: var(--radius-sm); }
.btn-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

/* Inline checkbox labels in sidebars */
.chk-inline { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; margin: 0.35rem 0; color: var(--text-secondary); }
.chk-inline input { accent-color: var(--accent-primary); }

/* Collapsible plot sections */
.plot-section { border-top: 1px solid var(--border-subtle); padding: 0.5rem 0; }
.plot-section:first-of-type { border-top: none; }
.plot-section > summary {
  cursor: pointer; font-weight: 600; font-size: 0.8rem; color: var(--text-primary);
  list-style: none; padding: 0.3rem 0; user-select: none; letter-spacing: 0.01em;
}
.plot-section > summary::-webkit-details-marker { display: none; }
.plot-section > summary::before { content: '▸'; display: inline-block; margin-right: 0.5rem; color: var(--text-muted); transition: transform var(--transition-fast); }
.plot-section[open] > summary::before { transform: rotate(90deg); }
.dl-dims { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.dl-dims input { width: 50%; }

/* Nav badge (report count) */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
  font-size: 0.68rem; font-weight: 700; color: #fff;
  background: var(--gradient-primary); border-radius: var(--radius-full);
}

/* Result blocks + toolbar */
.result-block { margin-bottom: 1.25rem; animation: fadeInUp 0.25s ease; }
.result-toolbar { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.stats-main-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.stats-main-tools { display: flex; gap: 0.4rem; }
.stat-card-head { display: flex; align-items: center; justify-content: space-between; }
.stat-subhead { color: var(--text-secondary); font-size: 0.8rem; font-weight: 600; margin: 0.9rem 0 0.4rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-note { color: var(--text-muted); font-size: 0.8rem; margin: 0.5rem 0 0; }
.stat-interpretation { background: rgba(14,165,233,0.1); border-left: 3px solid var(--accent-secondary); color: var(--text-primary); }

/* Report tab */
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.report-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.report-meta { margin-bottom: 1rem; }
.report-list { display: flex; flex-direction: column; gap: 1rem; }
.report-item { background: var(--bg-glass); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; }
.report-item-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1rem; background: var(--bg-elevated); border-bottom: 1px solid var(--border-subtle); }
.report-item-kind { font-size: 1rem; }
.report-item-title { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-item-tools { display: flex; gap: 0.25rem; }
.report-item-body { padding: 1rem 1.25rem; overflow-x: auto; }
.report-item-body h4 { color: var(--text-accent); font-size: 0.9rem; margin: 0 0 0.5rem; }
.report-item-body img { max-width: 100%; border-radius: var(--radius-sm); }

/* ── WYSIWYG Markdown editor (Notion-style: formatting is applied as you type) ── */
.mde { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface); overflow: hidden; }
.mde:focus-within { border-color: var(--border-accent); }
.mde-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 0.3rem 0.45rem; border-bottom: 1px solid var(--border-subtle); background: var(--bg-elevated);
}
.mde-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  min-width: 28px; height: 28px; padding: 0 0.45rem;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text-secondary); font-family: inherit; font-size: 0.78rem; font-weight: 700;
  cursor: pointer; transition: all var(--transition-fast);
}
.mde-btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.mde-btn.active { color: var(--text-accent); background: rgba(99, 102, 241, 0.14); }
.mde-btn .fs-icon { width: 15px; height: 15px; }
.mde-sep { width: 1px; height: 18px; background: var(--border-medium); margin: 0 0.3rem; flex: 0 0 auto; }
.mde-area {
  min-height: 140px; padding: 0.8rem 1rem; outline: none;
  color: var(--text-primary); overflow-x: auto; cursor: text;
}
.mde-area:empty::before, .mde-area[data-empty="1"]::before {
  content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; position: absolute;
}
.mde-hint { padding: 0.3rem 0.75rem; font-size: 0.7rem; color: var(--text-muted); border-top: 1px solid var(--border-subtle); }
@media (max-width: 768px) { .mde-hint { display: none; } }

.md-block h1, .md-block h2, .md-block h3, .md-block h4, .md-block h5, .md-block h6 {
  color: var(--text-primary); font-weight: 700; margin: 0.9em 0 0.4em; line-height: 1.3;
}
.md-block h1 { font-size: 1.7rem; }
.md-block h2 { font-size: 1.4rem; }
.md-block h3 { font-size: 1.2rem; }
.md-block h4 { font-size: 1.05rem; color: var(--text-primary); }
.md-block :first-child { margin-top: 0; }
.md-block p { margin: 0.6em 0; line-height: 1.6; }
.md-block strong { font-weight: 700; color: var(--text-primary); }
.md-block em { font-style: italic; }
.md-block a { color: var(--text-accent); text-decoration: underline; }
.md-block ul, .md-block ol { margin: 0.5em 0; padding-left: 1.5em; }
.md-block li { margin: 0.2em 0; line-height: 1.5; }
.md-block blockquote {
  margin: 0.6em 0; padding: 0.3em 1em; border-left: 3px solid var(--accent-secondary);
  color: var(--text-secondary); background: rgba(14,165,233,0.08); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md-block code {
  font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 0.85em;
  background: rgba(148,163,184,0.15); padding: 0.15em 0.4em; border-radius: 4px;
}
.md-block pre {
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  padding: 0.75em 1em; overflow-x: auto; margin: 0.6em 0;
}
.md-block pre code { background: none; padding: 0; }
.md-block hr { border: none; border-top: 1px solid var(--border-medium); margin: 1em 0; }
.md-block table { border-collapse: collapse; width: 100%; margin: 0.6em 0; font-size: 0.88rem; }
.md-block th, .md-block td { border: 1px solid var(--border-subtle); padding: 0.4em 0.6em; text-align: left; }
.md-block thead th { background: var(--bg-elevated); }
.md-block img { max-width: 100%; border-radius: var(--radius-sm); }

/* ── Drag & drop upload overlay ── */
.drop-overlay {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(99, 102, 241, 0.12); backdrop-filter: blur(4px);
  border: 3px dashed var(--accent-primary);
  color: var(--text-primary); font-size: 1.1rem; font-weight: 700;
  pointer-events: none;
}

/* ── Printing the app itself (Ctrl+P): compact, ink-friendly ── */
@media print {
  :root { color-scheme: light; }
  body { background: #fff !important; color: #0f172a; font-size: 10pt; }
  .bg-mesh, .app-header, .upload-bar, .sidebar-nav, .app-footer,
  .btn, .result-toolbar, .stats-main-tools, .report-actions, .mde-toolbar, .mde-hint,
  #loading-overlay, .toast, .report-item-tools { display: none !important; }
  .app-body, .main-panel { display: block; padding: 0; max-width: 100%; }
  .card, .report-item, .stat-result-card { background: #fff; border-color: #e2e8f0; break-inside: avoid; box-shadow: none; }
  .data-table { font-size: 8.5pt; }
  .md-block h1 { font-size: 15pt; } .md-block h2 { font-size: 13pt; } .md-block h3 { font-size: 11.5pt; }
}

/* ═══ New feature styles: view toolbar, column profile, data health, shortcuts ═══ */

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.view-tools { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.var-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text-accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.var-link:hover { color: var(--accent-primary-hover); text-decoration-style: solid; }

.col-detail-chart {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.9rem;
}
.col-detail-chart svg { width: 100%; height: auto; display: block; }
.svg-tick { font-size: 11px; fill: var(--text-secondary); font-family: inherit; }

.health-card { margin-bottom: 1.25rem; }
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.health-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  text-align: center;
}
.health-tile.health-warn { border-color: rgba(245, 158, 11, 0.45); }
.health-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.health-warn .health-value { color: var(--accent-warning); }
.health-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.15rem; }
.health-notes { margin: 0.7rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; color: var(--text-secondary); }
.health-notes li { margin: 0.25rem 0; }

kbd {
  display: inline-block;
  padding: 0.1rem 0.42rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78em;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-bottom-width: 2px;
  border-radius: 6px;
}
.shortcuts-table td:first-child { white-space: nowrap; width: 40%; }
.modal-md { max-width: 520px; }

/* ── Command palette (Ctrl/Cmd+K) ── */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  z-index: 1100;
  animation: fadeIn 0.15s ease;
}
.cmdk-box {
  width: min(560px, 92%);
  background: var(--bg-base);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}
.cmdk-input {
  width: 100%;
  padding: 0.9rem 1.1rem;
  font-size: 1rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  outline: none;
}
.cmdk-input::placeholder { color: var(--text-muted); }
.cmdk-list { max-height: 320px; overflow-y: auto; padding: 0.35rem; }
.cmdk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
}
.cmdk-item.active { background: var(--bg-glass-hover); }
.cmdk-hint { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.cmdk-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* ═══ v4: overview dashboard, polish & micro-interactions ═══ */

/* Previously referenced by .result-block but never defined */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Gentle fade when switching tabs (animation restarts on display:none → block) */
.main-panel > div { animation: fadeInUp 0.22s ease; }

/* Visible keyboard-focus ring on interactive elements */
.btn:focus-visible, .nav-tab:focus-visible, .var-link:focus-visible,
.ov-action-card:focus-visible, .ov-sample-card:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ── Overview hero ── */
.ov-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(20, 184, 166, 0.07));
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}
.ov-hero-main { flex: 1 1 300px; min-width: 0; }
.ov-hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-accent); margin-bottom: 0.4rem;
}
.ov-hero-name { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text-primary); margin-bottom: 0.25rem; }
.ov-hero-desc { color: var(--text-secondary); font-size: 0.88rem; margin-bottom: 0.6rem; max-width: 60ch; }
.ov-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 0.6rem;
  align-content: center;
  flex: 0 1 420px;
}

/* ── Overview quick actions ── */
.ov-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.ov-action-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.ov-action-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.ov-action-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.14);
  color: var(--text-accent);
}
.ov-action-icon .fs-icon { width: 1.15rem; height: 1.15rem; }
.ov-action-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.ov-action-title { font-weight: 700; font-size: 0.88rem; }
.ov-action-hint { font-size: 0.76rem; color: var(--text-secondary); }
.ov-action-arrow { margin-left: auto; color: var(--text-muted); font-size: 1rem; transition: transform var(--transition-fast), color var(--transition-fast); }
.ov-action-card:hover .ov-action-arrow { transform: translateX(3px); color: var(--text-accent); }

/* ── Overview sample gallery ── */
.ov-samples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.ov-sample-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.8rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.ov-sample-card:hover { border-color: var(--border-accent); background: var(--bg-glass-hover); }
.ov-sample-card.active { border-color: var(--accent-primary); background: rgba(99, 102, 241, 0.1); }
.ov-sample-name { font-weight: 700; font-size: 0.85rem; color: var(--text-primary); }
.ov-sample-desc { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.45; }

/* ── Overview guide accordion ── */
.ov-guide { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.ov-guide-item {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ov-guide-item[open] { border-color: var(--border-medium); }
.ov-guide-item > summary {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.7rem 1rem;
  cursor: pointer; user-select: none;
  font-weight: 600; font-size: 0.86rem; color: var(--text-primary);
  list-style: none;
  transition: background var(--transition-fast);
}
.ov-guide-item > summary::-webkit-details-marker { display: none; }
.ov-guide-item > summary:hover { background: var(--bg-glass-hover); }
.ov-guide-item > summary::after {
  content: '▸'; margin-left: auto; color: var(--text-muted);
  transition: transform var(--transition-fast);
}
.ov-guide-item[open] > summary::after { transform: rotate(90deg); }
.ov-guide-item > summary .fs-icon { color: var(--text-accent); }
.ov-guide-body { padding: 0 1rem 0.85rem; }
.ov-guide-body ul { padding-left: 1.25rem; color: var(--text-secondary); font-size: 0.85rem; }
.ov-guide-body li { margin-bottom: 0.3rem; }
.ov-guide-body li strong { color: var(--text-primary); }
.ov-guide-body code { background: rgba(99, 102, 241, 0.15); color: var(--text-accent); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.8rem; }

/* ── Session modal ── */
.session-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* ── Grid toolbar tools (info + page size + CSV) ── */
.fs-grid-tools { display: flex; align-items: center; gap: 0.5rem; }
.fs-grid-size {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
  font-family: inherit;
}
.fs-grid-size:focus { outline: none; border-color: var(--border-accent); }
[data-theme="light"] .fs-grid-size { background: var(--bg-base); }

@media (max-width: 768px) {
  .ov-hero { padding: 1rem 1.1rem; gap: 0.9rem; }
  .ov-hero-name { font-size: 1.15rem; }
  .ov-tiles { flex-basis: 100%; }
  .ov-actions, .ov-samples { grid-template-columns: 1fr; }
  .fs-grid-tools { flex-wrap: wrap; }
}

/* ── Filter builder (Wrangle · no-code conditions) ── */
.clause-list { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.6rem; }
.clause-row { display: flex; gap: 0.4rem; align-items: center; }
.clause-row .clause-col { flex: 1.2; min-width: 0; }
.clause-row .clause-op { flex: 1; min-width: 0; }
.clause-row .clause-val { flex: 1; min-width: 0; }
.clause-del { flex: none; padding: 0.3rem 0.5rem; color: var(--text-muted); }
.clause-del:hover { color: var(--accent-danger, #ef4444); }

/* ── Column type override (View · column profile modal) ── */
.col-type-override {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-subtle);
}
.col-type-override .form-label { margin: 0; }
.col-type-override .help-text { width: 100%; margin: 0; }

/* ═══ v5: Insights tab, header polish, sparklines & micro-refinements ═══ */

/* Text selection matches the brand */
::selection { background: rgba(99, 102, 241, 0.35); }

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ── Header: tagline + visible command-palette trigger ── */
.logo-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 0.35rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border-medium);
  white-space: nowrap;
}
.cmdk-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  margin-right: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.cmdk-btn:hover { color: var(--text-primary); border-color: var(--border-accent); background: var(--bg-glass-hover); }
.cmdk-btn:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.cmdk-btn .fs-icon { width: 14px; height: 14px; }
.cmdk-btn-kbd {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
}
@media (max-width: 1000px) { .logo-tag { display: none; } }
@media (max-width: 768px) {
  .cmdk-btn-label, .cmdk-btn-kbd { display: none; }
  .cmdk-btn { padding: 0.45rem; border-radius: var(--radius-full); }
  .cmdk-btn .fs-icon { width: 17px; height: 17px; }
}

/* ── Summary-table sparklines (View tab) ── */
.spark-cell { width: 118px; }
.spark { display: block; width: 110px; height: auto; }

/* ── Insights tab ── */
.ins-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.ins-sub { font-size: 0.82rem; color: var(--text-secondary); margin: 0.25rem 0 0.75rem; max-width: 76ch; }
.ins-section { margin-bottom: 1.5rem; }
.ins-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  font-size: 0.7rem; font-weight: 700; color: var(--text-accent);
  background: rgba(99, 102, 241, 0.14);
  border-radius: var(--radius-full);
}
.ins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.85rem;
}
.ins-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.95rem 1.1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  animation: fadeInUp 0.25s ease;
}
.ins-card:hover { border-color: var(--border-medium); border-left-color: var(--accent-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ins-card.ins-group { border-left-color: var(--accent-secondary); }
.ins-card.ins-dist { border-left-color: var(--accent-warning); }
.ins-card.ins-balance { border-left-color: #ec4899; }
.ins-card-head { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.ins-badge {
  flex: none;
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.14);
  color: var(--text-accent);
  white-space: nowrap;
}
.ins-group .ins-badge { background: rgba(20, 184, 166, 0.14); color: var(--accent-secondary); }
.ins-dist .ins-badge { background: rgba(245, 158, 11, 0.14); color: var(--accent-warning); }
.ins-balance .ins-badge { background: rgba(236, 72, 153, 0.14); color: #ec4899; }
.ins-title { font-weight: 700; font-size: 0.88rem; color: var(--text-primary); overflow-wrap: anywhere; }
.ins-vs { color: var(--text-muted); font-weight: 500; }
.ins-detail { font-size: 0.8rem; color: var(--text-secondary); margin: 0; }
.ins-detail em { color: var(--text-primary); font-style: normal; font-weight: 600; }
.ins-chart {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.55rem;
}
.ins-chart svg { display: block; width: 100%; height: auto; max-height: 130px; }
.ins-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: auto; }
.section-title .fs-icon { color: var(--text-accent); }

@media (max-width: 768px) {
  .ins-grid { grid-template-columns: 1fr; }
}
