/* ══════════════════════════════════════════════════════════════
   CSVDB Design System
   Dark glassmorphism theme with vibrant accents
   ══════════════════════════════════════════════════════════════ */

/* Self-hosted fonts (no external CDN dependency) */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/inter-400.ttf') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/inter-500.ttf') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/inter-600.ttf') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/static/fonts/inter-700.ttf') format('truetype'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/jetbrainsmono-400.ttf') format('truetype'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/jetbrainsmono-500.ttf') format('truetype'); }

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-elevated: #1a2236;
  --bg-glass: rgba(26, 34, 54, 0.7);
  --bg-glass-hover: rgba(30, 42, 68, 0.8);
  --bg-input: rgba(15, 20, 35, 0.8);

  --border-subtle: rgba(99, 115, 160, 0.15);
  --border-medium: rgba(99, 115, 160, 0.25);
  --border-focus: rgba(99, 145, 255, 0.5);

  --text-primary: #e8ecf4;
  --text-secondary: #8b95b0;
  --text-muted: #5a647d;
  --text-inverse: #0a0e1a;

  --accent-blue: #6391ff;
  --accent-blue-dim: rgba(99, 145, 255, 0.15);
  --accent-purple: #a78bfa;
  --accent-purple-dim: rgba(167, 139, 250, 0.15);
  --accent-teal: #2dd4bf;
  --accent-teal-dim: rgba(45, 212, 191, 0.12);
  --accent-amber: #fbbf24;
  --accent-amber-dim: rgba(251, 191, 36, 0.12);
  --accent-rose: #fb7185;
  --accent-rose-dim: rgba(251, 113, 133, 0.12);
  --accent-green: #4ade80;
  --accent-green-dim: rgba(74, 222, 128, 0.12);

  --gradient-primary: linear-gradient(135deg, #6391ff 0%, #a78bfa 100%);
  --gradient-header: linear-gradient(135deg, rgba(99,145,255,0.08) 0%, rgba(167,139,250,0.05) 100%);

  --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 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(99,145,255,0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --transition-fast: 150ms ease;
  --transition-med: 250ms ease;
  --transition-slow: 400ms ease;

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

  --sidebar-width: 280px;
}

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

html { font-size: 14px; -webkit-font-smoothing: antialiased; }

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

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(99,145,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(167,139,250,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(99,115,160,0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(99,115,160,0.5); }

/* ── Layout ─────────────────────────────────────────────────── */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Top Bar ────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.top-bar__logo {
  width: 28px; height: 28px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: #fff;
}

.top-bar__actions { display: flex; align-items: center; gap: 8px; }

.top-bar__status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 12px;
}

.top-bar__status span { color: var(--accent-teal); font-weight: 600; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-med);
}

.sidebar__header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.file-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.file-item:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-subtle);
}

.file-item.active {
  background: var(--accent-blue-dim);
  border-color: rgba(99,145,255,0.2);
}

.file-item__name {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-item__icon {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.file-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

.file-item__columns {
  padding: 6px 0 0 14px;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-med);
}

.file-item.expanded .file-item__columns {
  max-height: 360px;
}

.file-item__col-tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ── Work Area ──────────────────────────────────────────────── */
.work-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 16px;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tab-btn {
  padding: 8px 18px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.tab-btn.active {
  background: var(--accent-blue-dim);
  border-color: rgba(99,145,255,0.3);
  color: var(--accent-blue);
}

.tab-btn__badge {
  background: var(--accent-blue);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.tab-panel {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ── Glass Panel ────────────────────────────────────────────── */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gradient-header);
}

.panel-header__title {
  font-size: 0.9rem;
  font-weight: 600;
}

.panel-body {
  padding: 16px;
}

/* ── Query Builder ──────────────────────────────────────────── */
.query-builder {
  flex-shrink: 0;
}

.query-options {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.condition-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  animation: slideIn var(--transition-med) ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.condition-row__logic {
  min-width: 56px;
  text-align: center;
}

.condition-row__logic select {
  width: 56px;
}

.condition-row:first-child .condition-row__logic {
  visibility: hidden;
}

/* ── Form Controls ──────────────────────────────────────────── */
select, input[type="text"], input[type="search"] {
  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: 0.85rem;
  padding: 7px 10px;
  transition: all var(--transition-fast);
  outline: none;
}

select:focus, input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-dim);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b95b0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}

select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

input[type="text"]::placeholder,
input[type="search"]::placeholder {
  color: var(--text-muted);
}

.input-wide { flex: 1; min-width: 160px; }

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-input { display: none; }

.toggle-track {
  width: 34px;
  height: 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: 9px;
  position: relative;
  transition: all var(--transition-fast);
}

.toggle-track::after {
  content: '';
  width: 12px; height: 12px;
  background: var(--text-secondary);
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
  transition: all var(--transition-fast);
}

.toggle-input:checked + .toggle-track {
  background: var(--accent-blue-dim);
  border-color: var(--accent-blue);
}

.toggle-input:checked + .toggle-track::after {
  background: var(--accent-blue);
  transform: translateX(16px);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.btn--primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover {
  opacity: 0.9;
  box-shadow: var(--shadow-glow);
}

.btn--danger {
  color: var(--accent-rose);
  border-color: rgba(251,113,133,0.2);
}

.btn--danger:hover {
  background: var(--accent-rose-dim);
}

.btn--success {
  color: var(--accent-green);
  border-color: rgba(74,222,128,0.2);
}

.btn--success:hover {
  background: var(--accent-green-dim);
}

.btn--small {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.btn--icon {
  padding: 6px;
  min-width: 30px;
  justify-content: center;
}

.btn-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Results Table ──────────────────────────────────────────── */
.results-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.results-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.results-stats__count span {
  font-weight: 600;
  color: var(--accent-blue);
}

.results-scroll {
  flex: 1;
  overflow: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.results-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.results-table th {
  background: var(--bg-elevated);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.results-table th:hover { color: var(--accent-blue); }
.results-table th.sorted { color: var(--accent-blue); }
.results-table th .sort-icon { margin-left: 4px; font-size: 0.7rem; }

.results-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-subtle);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-table tbody tr {
  transition: background var(--transition-fast);
}

.results-table tbody tr:hover {
  background: var(--bg-glass-hover);
}

.results-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.01);
}

.results-table tbody tr:nth-child(even):hover {
  background: var(--bg-glass-hover);
}

/* Source file badge */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.pagination__btn {
  padding: 4px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination__btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.pagination__btn.active { background: var(--accent-blue-dim); color: var(--accent-blue); border-color: rgba(99,145,255,0.3); }
.pagination__btn:disabled { opacity: 0.3; cursor: default; }

.pagination__info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 8px;
}

/* ── Pivot Builder ──────────────────────────────────────────── */
.pivot-section {
  flex-shrink: 0;
}

.pivot-values-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

.pivot-value-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.pivot-value-chip:hover {
  border-color: var(--border-focus);
}

.pivot-value-chip.selected {
  background: var(--accent-blue-dim);
  border-color: rgba(99,145,255,0.3);
  color: var(--accent-blue);
}

.pivot-value-chip input[type="checkbox"] { display: none; }

/* ── Empty / Loading States ─────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.empty-state__icon {
  font-size: 2.5rem;
  opacity: 0.4;
}

.empty-state__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state__sub {
  font-size: 0.85rem;
  max-width: 400px;
}

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

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,14,26,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--transition-med) ease;
  max-width: 360px;
}

.toast--success { border-color: rgba(74,222,128,0.3); }
.toast--error { border-color: rgba(251,113,133,0.3); }
.toast--info { border-color: rgba(99,145,255,0.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── File color palette for badges ──────────────────────────── */
.file-color-0 { background: rgba(99,145,255,0.15); color: #6391ff; }
.file-color-1 { background: rgba(167,139,250,0.15); color: #a78bfa; }
.file-color-2 { background: rgba(45,212,191,0.15); color: #2dd4bf; }
.file-color-3 { background: rgba(251,191,36,0.15); color: #fbbf24; }
.file-color-4 { background: rgba(251,113,133,0.15); color: #fb7185; }
.file-color-5 { background: rgba(74,222,128,0.15); color: #4ade80; }
.file-color-6 { background: rgba(244,114,182,0.15); color: #f472b6; }
.file-color-7 { background: rgba(129,140,248,0.15); color: #818cf8; }
.file-color-8 { background: rgba(34,211,238,0.15); color: #22d3ee; }
.file-color-9 { background: rgba(253,164,175,0.15); color: #fda4af; }

/* ── Preview Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast) ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 90vw;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--transition-med) ease;
}

.modal__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__title { font-weight: 600; font-size: 1rem; }

.modal__body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .condition-row { flex-wrap: wrap; }
  .top-bar__status { display: none; }
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }

/* Select all / Deselect all buttons for pivots */
.pivot-select-actions {
  display: flex; gap: 6px; margin: 4px 0;
}

/* ── Workflow Footer ───────────────────────────────────────── */
.workflow-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.workflow-step:hover {
  background: var(--bg-glass-hover);
}

.workflow-step.active {
  background: var(--accent-blue-dim);
  border-color: rgba(99,145,255,0.2);
}

.workflow-step.completed {
  border-color: rgba(74,222,128,0.15);
}

.workflow-step__num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.workflow-step.active .workflow-step__num {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.workflow-step.completed .workflow-step__num {
  background: var(--accent-green-dim);
  border-color: rgba(74,222,128,0.3);
  color: var(--accent-green);
}

.workflow-step__label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.workflow-step.active .workflow-step__label {
  color: var(--accent-blue);
}

.workflow-step.completed .workflow-step__label {
  color: var(--text-secondary);
}

.workflow-step__arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  opacity: 0.4;
  user-select: none;
}

/* ── Upload Zone ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-med);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-blue);
  background: var(--accent-blue-dim);
}

.upload-zone__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-zone__text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  padding: 20px;
}

.upload-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--bg-input);
}

.upload-result--success { border-left: 3px solid var(--accent-green); }
.upload-result--error { border-left: 3px solid var(--accent-rose); }

/* ── Password Input ────────────────────────────────────────── */
input[type="password"] {
  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: 0.85rem;
  padding: 7px 10px;
  transition: all var(--transition-fast);
  outline: none;
}

input[type="password"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-dim);
}

input[type="password"]::placeholder {
  color: var(--text-muted);
}

/* ── Sidebar File Actions ──────────────────────────────────── */
.file-item__actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.file-item:hover .file-item__actions {
  opacity: 1;
}

.file-item__actions .btn {
  padding: 2px 8px;
  font-size: 0.72rem;
}

/* ── Custom Tooltip ────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all var(--transition-fast);
  z-index: 50;
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Responsive additions ──────────────────────────────────── */
@media (max-width: 768px) {
  .workflow-footer {
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
  }
  .workflow-step__label { display: none; }
  .workflow-step__arrow { font-size: 0.7rem; }
}

/* ── Table Search Bar ──────────────────────────────────────── */
.table-search-bar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.table-search-bar__inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-search-bar__input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.table-search-bar__icon {
  position: absolute;
  left: 10px;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0.5;
}

.table-search-bar__input-wrap input {
  width: 100%;
  padding-left: 32px;
}

/* Match highlighting */
mark {
  background: var(--accent-amber-dim);
  color: var(--accent-amber);
  padding: 0 2px;
  border-radius: 2px;
}

/* ── Pivot Free-Type & Autocomplete ────────────────────────── */
.pivot-freetype {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pivot-freetype__wrap {
  flex: 1;
  position: relative;
}

.pivot-freetype__wrap input {
  width: 100%;
}

.pivot-autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

.pivot-autocomplete__item {
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pivot-autocomplete__item:hover,
.pivot-autocomplete__item--highlight {
  background: var(--bg-glass-hover);
}

.pivot-autocomplete__item--selected {
  color: var(--accent-blue);
}

.pivot-autocomplete__item--empty {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}

/* ── Pivot Selected Tags ───────────────────────────────────── */
.pivot-selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  min-height: 28px;
  align-items: center;
}

.pivot-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
  border: 1px solid rgba(99,145,255,0.2);
  animation: slideIn var(--transition-fast) ease;
}

.pivot-tag--custom {
  background: var(--accent-purple-dim);
  color: var(--accent-purple);
  border-color: rgba(167,139,250,0.2);
}

.pivot-tag__remove {
  cursor: pointer;
  font-size: 0.65rem;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
  margin-left: 2px;
}

.pivot-tag__remove:hover {
  opacity: 1;
}

/* ── Pivot Divider ─────────────────────────────────────────── */
.pivot-divider {
  padding: 4px 0;
  margin: 4px 0;
  border-top: 1px solid var(--border-subtle);
}

/* ── Pivot Chips Scroll ────────────────────────────────────── */
.pivot-chips-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px;
}

/* ── Column Stats Icon & Popover ───────────────────────────── */
.col-stats-btn {
  font-size: 0.65rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast);
  margin-left: 4px;
  vertical-align: middle;
}

th:hover .col-stats-btn { opacity: 0.6; }
.col-stats-btn:hover { opacity: 1 !important; }

.col-stats-popover {
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 16px;
  min-width: 240px;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--transition-fast) ease;
}

.col-stats-popover__title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.col-stats-popover__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.col-stats-popover__item {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 3px 0;
}

.col-stats-popover__label {
  color: var(--text-muted);
}

.col-stats-popover__subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 10px;
  margin-bottom: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.col-stats-popover__top {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.col-stats-popover__topval {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-input);
}

/* ── CSV Cleaner ───────────────────────────────────────────── */
.clean-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clean-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.clean-option:hover {
  background: var(--bg-glass-hover);
}

.clean-option input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent-blue);
}

.clean-option__title {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
}

.clean-option__desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.clean-results {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.clean-result {
  font-size: 0.82rem;
  padding: 6px 0;
}

.clean-result--info { color: var(--accent-blue); }
.clean-result--success { color: var(--accent-emerald); }
.clean-result--ok { color: var(--accent-emerald); }
.clean-result--error { color: var(--accent-rose); }

.clean-result__item {
  font-size: 0.78rem;
  padding: 3px 0 3px 16px;
  color: var(--text-secondary);
}