/* ══════════════════════════════════════════════
   CSS VARIABLES — LIGHT MODE
══════════════════════════════════════════════ */
:root {
  --bg:        #f7f6f2;
  --surface:   #ffffff;
  --card:      #ffffff;
  --border:    #e4dfd7;
  --border2:   #ccc8bf;
  --ink:       #18161280;
  --ink-full:  #181612;
  --ink2:      #374151; /* Refined Slate */
  --muted:     #6b7280; /* Elegant Muted Gray */
  --accent:    #1d4ed8;
  --accent-l:  #dbeafe;
  --accent-d:  #1e3a8a;
  --green:     #15803d;
  --green-l:   #dcfce7;
  --red:       #b91c1c;
  --red-l:     #fee2e2;
  --amber:     #b45309;
  --amber-l:   #fef3c7;
  --purple:    #6d28d9;
  --purple-l:  #ede9fe;

  /* Landing specific */
  --land-bg:       #f7f6f2;
  --land-surface:  #ffffff;
  --land-border:   #e4dfd7;
  --land-ink:      #181612;
  --land-ink2:     #000000; /* High visibility black */
  --land-accent:   #8b7355;
  --land-accent-rgb: 139, 115, 85;
  --land-accent2:  #c8b89a;
  --land-accent-hover: #a3875f;
  --land-shadow-glow: 0 24px 64px rgba(0,0,0,0.08), 0 0 0 1px rgba(var(--land-accent-rgb),0.15);

  --sans:      'Inter', sans-serif;
  --serif:     'DM Serif Display', serif;
  --mono:      'DM Mono', monospace;
  --r:         8px;
  --r2:        14px;
  --shadow:    0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.06);
  --shadow2:   0 8px 32px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ══════════════════════════════════════════════
   DARK MODE (dashboard)
══════════════════════════════════════════════ */
[data-theme="dark"] {
  --bg:        #111009;
  --surface:   #1c1a15;
  --card:      #1c1a15;
  --border:    #2c2922;
  --border2:   #3a3630;
  --ink:       #e2ddd580;
  --ink-full:  #e2ddd5;
  --ink2:      #e5e7eb; 
  --muted:     #9ca3af;
  --accent:    #5b8af0;
  --accent-l:  #1a2545;
  --accent-d:  #4070d8;
  --green:     #22c55e;
  --green-l:   #0b2818;
  --red:       #f87171;
  --red-l:     #2d0f0f;
  --amber:     #fbbf24;
  --amber-l:   #2a1c00;
  --purple:    #a78bfa;
  --purple-l:  #1e1540;
  --shadow:    0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.35);
  --shadow2:   0 8px 32px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.3);

  /* Landing specific */
  --land-bg:       #0d0c09;
  --land-surface:  #141310;
  --land-border:   #2a2720;
  --land-ink:      #f0ece4;
  --land-ink2:     #ffffff; /* High visibility white */
  --land-accent:   #c8b89a;
  --land-accent-rgb: 200, 184, 154;
  --land-accent2:  #8b7355;
  --land-accent-hover: #d4c4a8;
  --land-shadow-glow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(var(--land-accent-rgb),0.15);
}
[data-theme="dark"] tbody tr:hover td { background: rgba(91,138,240,0.08); }
[data-theme="dark"] tbody tr.active-row td { background: rgba(91,138,240,0.16); }
[data-theme="dark"] .upload-card:hover,
[data-theme="dark"] .upload-card.drag { border-color: var(--land-accent); }
[data-theme="dark"] .chart-hint { background: var(--amber-l); border-color: #6b4e10; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink-full);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

/* ── ACCESSIBILITY ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  z-index: 9999;
  border-radius: 0 0 var(--r) var(--r);
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: var(--r); font-size: 0.82rem;
  font-family: var(--sans); font-weight: 500; box-shadow: var(--shadow2);
  pointer-events: all; animation: toast-in 0.25s ease forwards;
  display: flex; align-items: center; gap: 10px; max-width: 340px;
}
.toast.info    { background: #1d4ed8; color: #fff; }
.toast.success { background: #15803d; color: #fff; }
.toast.error   { background: #b91c1c; color: #fff; }
.toast.warning { background: #b45309; color: #fff; }
.toast.out     { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in  { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }
@keyframes toast-out { from{opacity:1;transform:translateX(0)}    to{opacity:0;transform:translateX(20px)} }

/* ══════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════ */
header {
  background: var(--land-bg);
  border-bottom: 1px solid var(--land-border);
  padding: 0 40px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 200;
  transition: background 0.25s, border-color 0.25s;
}
/* After upload, header switches to surface */
body.dashboard-active header {
  background: var(--surface);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 0 var(--border), 0 2px 12px rgba(0,0,0,.04);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; background: var(--land-accent); border-radius: 9px;
  display: grid; place-items: center; color: var(--land-bg); font-family: var(--serif);
  font-size: 1.1rem; font-style: italic; flex-shrink: 0; transition: background 0.25s;
}
body.dashboard-active .brand-mark { background: var(--ink-full); color: var(--bg); }
.brand-name {
  font-family: var(--serif); font-size: 1.2rem; color: var(--land-ink);
  letter-spacing: -0.2px; font-weight: 400; display: flex; align-items: baseline; gap: 8px;
}
body.dashboard-active .brand-name { color: var(--ink-full); }
.brand-name span {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 500; color: var(--land-ink2);
  letter-spacing: 0.5px; text-transform: uppercase; font-style: normal;
}
body.dashboard-active .brand-name span { color: var(--muted); }
.brand-tag {
  font-family: var(--mono); font-size: 0.65rem; font-weight: 500;
  color: var(--land-accent2); letter-spacing: 1.2px; text-transform: uppercase;
}
body.dashboard-active .brand-tag { color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }

.file-badge {
  display: none; align-items: center; gap: 8px; background: var(--green-l);
  color: var(--green); padding: 4px 12px; border-radius: 100px;
  font-size: 0.73rem; font-family: var(--mono); font-weight: 500;
}

/* 6c: Tabs Styling */
.dataset-tabs {
  display: none; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 40px; gap: 4px; overflow-x: auto;
}
body.dashboard-active .dataset-tabs { display: flex; }
.tab-item {
  padding: 8px 16px; font-size: 0.75rem; font-family: var(--mono); color: var(--muted);
  border: 1px solid transparent; border-bottom: none; border-radius: var(--r) var(--r) 0 0;
  cursor: pointer; transition: all 0.2s; white-space: nowrap; margin-top: 6px;
}
.tab-item:hover { background: var(--bg); color: var(--ink-full); }
.tab-item.active {
  background: var(--bg); color: var(--accent); border-color: var(--border);
  font-weight: 600; box-shadow: 0 -2px 0 var(--accent) inset;
}
.file-badge.show { display: flex; }
.file-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── THEME TOGGLE ── */
#theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--land-border);
  background: var(--land-surface); color: var(--land-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
  transition: all var(--transition); flex-shrink: 0;
}
#theme-toggle:hover { border-color: var(--land-accent); background: rgba(var(--land-accent-rgb),0.12); }
body.dashboard-active #theme-toggle {
  border-color: var(--border2); background: var(--bg); color: var(--ink-full);
}
body.dashboard-active #theme-toggle:hover { border-color: var(--accent); background: var(--accent-l); }

/* ── BUTTONS (dashboard) ── */
.btn {
  padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--border2);
  background: var(--surface); color: var(--ink-full); font-family: var(--sans);
  font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: var(--ink2); }
.btn-primary { background: var(--ink-full); color: var(--bg); border-color: var(--ink-full); }
.btn-primary:hover { opacity: 0.88; }
.btn-accent { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-d); }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-ghost {
  background: transparent; border: none; color: var(--muted); font-size: 1rem;
  cursor: pointer; padding: 5px 9px; border-radius: 6px; line-height: 1; transition: all var(--transition);
}
.btn-ghost:hover { background: var(--bg); color: var(--ink-full); }

/* ── QUICK FIX BUTTONS ── */
.btn-qf {
  padding: 5px 13px; border-radius: var(--r); border: 1px solid var(--border2);
  background: var(--surface); color: var(--ink2); font-family: var(--sans);
  font-size: 0.74rem; font-weight: 500; cursor: pointer; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.btn-qf:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.btn-qf:disabled { opacity: 0.55; cursor: wait; pointer-events: none; }
.btn-qf.red   { border-color: var(--red);   color: var(--red); }
.btn-qf.red:hover   { background: var(--red);   color: var(--bg); }
.btn-qf.green { border-color: var(--green); color: var(--green); }
.btn-qf.green:hover { background: var(--green); color: var(--bg); }
.btn-qf.purple { border-color: var(--purple); color: var(--purple); }
.btn-qf.purple:hover { background: var(--purple); color: var(--bg); }

.checkbox-group { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-family: var(--sans); font-size: 0.85rem; color: var(--ink-full); cursor: pointer; }
.checkbox-group input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ══════════════════════════════════════════════
   UPLOAD / LANDING SCREEN — PREMIUM REDESIGN
══════════════════════════════════════════════ */
#upload-screen {
  display: none; /* hidden until JS shows, override below */
  min-height: calc(100vh - 60px);
  background: var(--land-bg);
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 60px 60px;
  align-items: center;
  justify-content: center;
  gap: 80px;
}
#upload-screen.visible {
  display: flex;
}

/* Subtle dot-grid background */
.upload-bg-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(var(--land-accent-rgb),0.10) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}
/* Radial vignette on top of grid */
.upload-bg-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 70% at 50% 50%, transparent 30%, var(--land-bg) 100%);
}

/* ── LEFT: HERO COPY ── */
.upload-left {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 520px;
  animation: fade-up 0.55s cubic-bezier(0.16,1,0.3,1) both;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--land-accent2);
  margin-bottom: 28px;
}
.eyebrow-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--land-accent);
  animation: pulse 2.5s infinite;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(3rem, 5.5vw, 4.4rem);
  line-height: 1.05;
  color: var(--land-ink);
  font-weight: 400;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}
.hero-title em {
  font-style: italic;
  color: var(--land-accent);
}

.hero-sub {
  font-size: 1.35rem; /* Increased definition font size */
  color: var(--ink-full);
  line-height: 1.75;
  font-weight: 300;
  max-width: 420px;
  margin-bottom: 16px;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--land-border);
  border-bottom: 1px solid var(--land-border);
}
.hstat {
  flex: 1;
  text-align: center;
}
.hstat-num {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--land-ink);
  line-height: 1;
  margin-bottom: 6px;
  font-weight: 400;
}
.hstat-lbl {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--land-ink2);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.hstat-divider {
  width: 1px;
  height: 40px;
  background: var(--land-border);
}

.social-links {
  display: flex;
  gap: 20px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
}
.social-links a {
  color: var(--land-ink2);
  text-decoration: none;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  gap: 7px;
}
.social-links a:hover { color: var(--land-accent); }

/* ── RIGHT: UPLOAD CARD ── */
.upload-right {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 420px;
  animation: fade-up 0.65s 0.1s cubic-bezier(0.16,1,0.3,1) both;
}

.upload-card {
  background: var(--land-surface);
  border: 1px solid var(--land-border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}
/* Ambient glow top edge */
.upload-card::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--land-accent), transparent);
  opacity: 0.6;
  transition: opacity 0.3s;
}
.upload-card:hover::before,
.upload-card.drag::before { opacity: 1; }

.upload-card:hover,
.upload-card.drag {
  border-color: var(--land-accent2);
  transform: translateY(-3px);
  box-shadow: var(--land-shadow-glow);
}

.upload-card-inner {
  padding: 44px 36px;
  text-align: center;
}

.upload-icon-box {
  width: 60px; height: 60px;
  border-radius: 14px;
  background: rgba(var(--land-accent-rgb),0.08);
  border: 1px solid rgba(var(--land-accent-rgb),0.18);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--land-accent);
  transition: all 0.25s;
}
.upload-card:hover .upload-icon-box {
  background: rgba(var(--land-accent-rgb),0.14);
  border-color: rgba(var(--land-accent-rgb),0.3);
}

.upload-card-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--land-ink);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.upload-card-sub {
  font-size: 0.82rem;
  color: var(--land-ink2);
  margin-bottom: 24px;
  font-weight: 300;
}

.format-chips {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}
.chip {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 100px;
  letter-spacing: 0.6px;
}
.chip-blue  { background: rgba(29,78,216,0.15); color: var(--accent); border: 1px solid rgba(29,78,216,0.3); }
.chip-green { background: rgba(21,128,61,0.15);  color: var(--green); border: 1px solid rgba(21,128,61,0.3); }
.chip-amber { background: rgba(180,83,9,0.15);   color: var(--amber); border: 1px solid rgba(180,83,9,0.3); }
.chip-purple { background: rgba(109,40,217,0.15); color: var(--purple); border: 1px solid rgba(109,40,217,0.3); }

.btn-upload-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: var(--land-accent);
  color: var(--land-bg);
  border: none;
  border-radius: var(--r);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.btn-upload-primary:hover {
  background: var(--land-accent-hover);
  transform: translateY(-1px);
}

#file-input { display: none; }

.sample-btn {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 24px;
  border: 1px solid var(--land-border);
  border-radius: var(--r);
  background: var(--land-surface);
  font-size: 0.82rem;
  color: var(--land-ink);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.sample-btn:hover {
  border-color: var(--land-accent);
  background: rgba(var(--land-accent-rgb), 0.04);
  color: var(--land-accent);
  transform: translateY(-1px);
}

/* Feature pills below upload card */
.feature-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.fpill {
  background: var(--land-surface);
  border: 1px solid var(--land-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--land-ink2);
  font-family: var(--sans);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
.fpill:hover {
  background: rgba(var(--land-accent-rgb),0.06);
  border-color: rgba(var(--land-accent-rgb),0.2);
  color: var(--land-ink);
}
.fpill-icon { font-size: 0.9rem; }

@keyframes fade-up {
  from { opacity:0; transform:translateY(20px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ── LOADER ── */
#loader {
  display: none; flex-direction: column; align-items: center;
  justify-content: center; min-height: calc(100vh - 60px);
  background: var(--land-bg); gap: 16px;
}
.loader-spinner {
  width: 42px; height: 42px; border: 2px solid var(--land-border);
  border-top-color: var(--land-accent); border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-msg  { font-family: var(--mono); font-size: 0.78rem; color: var(--land-ink2); min-width: 280px; text-align: center; }
.loader-sub  { font-family: var(--mono); font-size: 0.66rem; color: var(--land-ink2); text-align: center; opacity: 0.6; }
.loader-track { width: 280px; height: 2px; background: var(--land-border); border-radius: 2px; overflow: hidden; }
.loader-fill  { height: 100%; background: var(--land-accent); animation: progress 1.4s ease-in-out infinite; }
@keyframes progress { 0%{width:0%;margin-left:0} 50%{width:65%;margin-left:0} 100%{width:0%;margin-left:100%} }

/* ══════════════════════════════════════════════
   EXPORT BANNER
══════════════════════════════════════════════ */
#export-banner {
  display: none; align-items: center; gap: 12px; padding: 10px 20px;
  background: var(--green-l); border: 1px solid var(--green); border-radius: var(--r);
  margin-bottom: 16px; font-size: 0.82rem; color: var(--green); animation: fade-up 0.25s ease;
  max-width: 1420px; margin-left: auto; margin-right: auto; margin-top: 16px;
}
#export-banner.show { display: flex; }

/* ══════════════════════════════════════════════
   DASHBOARD LAYOUT
══════════════════════════════════════════════ */
#dashboard {
  display: none; max-width: 1420px; margin: 0 auto;
  padding: 28px 24px 60px;
}
#dashboard.visible { display: block; animation: fade-up 0.3s ease; }

.sec-label {
  font-family: var(--mono); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 1.8px; text-transform: uppercase; color: var(--ink-full);
  margin-bottom: 14px; display: flex; align-items: center; gap: 10px;
}
.sec-label::after { content:''; flex:1; height:1px; background:var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); }

.top-bar {
  display: flex; align-items: center; gap: 14px; margin-bottom: 28px;
  padding: 14px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r2); box-shadow: var(--shadow);
}
.top-bar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-l); flex-shrink:0; }
.top-bar .fname { font-weight: 600; font-size: 0.9rem; font-family: var(--serif); }
.top-bar .fmeta { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.top-bar .spacer { flex: 1; }

#overview-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 28px; }
.ov-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2);
  padding: 18px 16px; text-align: center; box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition); position: relative; overflow: hidden;
}
.ov-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background:var(--accent); opacity:0; transition:opacity var(--transition); }
.ov-card:hover { box-shadow: var(--shadow2); transform: translateY(-2px); }
.ov-card:hover::before { opacity: 1; }
.ov-card.warn::before   { background: var(--amber); opacity: 1; }
.ov-card.danger::before { background: var(--red);   opacity: 1; }
.ov-val   { font-family: var(--serif); font-size: 2.1rem; color: var(--ink-full); line-height: 1; margin-bottom: 5px; font-weight: 400; }
.ov-label { font-family: var(--mono);  font-size: 0.7rem; font-weight: 600; color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase; }

.two-col { display: grid; grid-template-columns: 400px 1fr; gap: 20px; margin-bottom: 28px; align-items: start; }

.col-explorer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); overflow: hidden; }
.col-explorer-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col-explorer-header h2 { font-size: 0.92rem; font-weight: 600; font-family: var(--serif); }
.col-search {
  flex: 1; padding: 5px 10px; border: 1px solid var(--border2); border-radius: var(--r);
  font-family: var(--mono); font-size: 0.75rem; background: var(--bg); color: var(--ink-full);
  outline: none; transition: border-color var(--transition); max-width: 160px;
}
.col-search:focus { border-color: var(--accent); }
.col-sort-btns { display: flex; gap: 4px; }
.sort-btn {
  padding: 4px 8px; font-size: 0.65rem; font-family: var(--mono); border: 1px solid var(--border2);
  border-radius: 5px; background: var(--bg); cursor: pointer; color: var(--muted); transition: all var(--transition); white-space: nowrap;
}
.sort-btn:hover, .sort-btn.active { background: var(--ink-full); color: var(--bg); border-color: var(--ink-full); }
.col-table-wrap { overflow-x: auto; max-height: 500px; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg); font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 1.1px; text-transform: uppercase; color: var(--ink-full); padding: 10px 14px;
  text-align: left; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  z-index: 1; cursor: pointer; user-select: none; white-space: nowrap;
}
thead th:hover { color: var(--ink-full); }
thead th .sort-arrow { margin-left: 4px; opacity: 0.4; }
thead th.sorted .sort-arrow { opacity: 1; }
tbody td { padding: 9px 14px; font-size: 0.8rem; border-bottom: 1px solid var(--border); color: var(--ink2); transition: background var(--transition); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f0f5ff; cursor: pointer; }
tbody tr.active-row td { background: #dbeafe; }
tbody td:first-child { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-full); font-weight: 500; }

.type-badge { display: inline-block; padding: 2px 8px; border-radius: 100px; font-family: var(--mono); font-size: 0.65rem; font-weight: 600; letter-spacing: 0.4px; }
.type-num { background: var(--accent-l); color: var(--accent); }
.type-cat { background: var(--purple-l); color: var(--purple); }
.type-dt  { background: var(--green-l);  color: var(--green); }

.stats-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); overflow: hidden; }
.stats-panel-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.stats-panel-header h2 { font-size: 0.92rem; font-weight: 600; font-family: var(--serif); }
.col-pills { display: flex; flex-wrap: wrap; gap: 5px; padding: 12px 16px; border-bottom: 1px solid var(--border); max-height: 110px; overflow-y: auto; }
.col-pill-btn {
  padding: 4px 12px; border-radius: 100px; border: 1px solid var(--border2);
  background: var(--bg); font-family: var(--mono); font-size: 0.75rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition); color: var(--ink2);
}
.col-pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.col-pill-btn.active { background: var(--ink-full); color: var(--bg); border-color: var(--ink-full); }
.stats-content { padding: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; text-align: center; transition: box-shadow var(--transition); }
.stat-item:hover { box-shadow: var(--shadow); }
.stat-val { font-family: var(--serif); font-size: 1.3rem; color: var(--ink-full); line-height: 1; margin-bottom: 4px; font-weight: 400; }
.stat-lbl { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.chart-area { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; height: 230px; display: flex; align-items: center; justify-content: center; }
.chart-area canvas { max-height: 200px; }
.no-col { color: var(--muted); font-size: 0.82rem; text-align: center; padding: 60px 20px; font-weight: 300; }

#preview-section { margin-bottom: 28px; }
.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); overflow: hidden; }
.preview-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.preview-header h2 { font-size: 0.92rem; font-weight: 600; font-family: var(--serif); }
.preview-table-wrap { overflow-x: auto; max-height: 280px; overflow-y: auto; }
.preview-table { font-size: 0.76rem; }
.preview-table thead th { font-size: 0.7rem; }
.preview-table tbody td { font-family: var(--mono); font-size: 0.72rem; }
.row-num { color: var(--muted); font-family: var(--mono); font-size: 0.75rem; background: var(--bg); }

#corr-section { margin-bottom: 28px; }
.corr-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); overflow: hidden; }
.corr-card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.corr-card-header h2 { font-size: 0.92rem; font-weight: 600; font-family: var(--serif); }
.corr-body { padding: 18px; }
.corr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.corr-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; transition: box-shadow var(--transition); cursor: pointer; }
.corr-item:hover { box-shadow: var(--shadow); }
.corr-pair { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; color: var(--ink-full); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.corr-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.corr-bar { height: 100%; border-radius: 3px; transition: width 0.8s cubic-bezier(0.16,1,0.3,1); }
.corr-val { font-family: var(--serif); font-size: 1rem; font-weight: 400; }
.corr-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 0.85rem; }


#outlier-section { margin-bottom: 28px; }
.outlier-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); overflow: hidden; }
.outlier-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.outlier-header h2 { font-size: 0.92rem; font-weight: 600; font-family: var(--serif); }
.outlier-body { padding: 18px; }
.outlier-col-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.outlier-tab { padding: 4px 12px; border-radius: 100px; border: 1px solid var(--border2); background: var(--bg); font-family: var(--mono); font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: all var(--transition); color: var(--ink2); }
.outlier-tab.active { background: var(--red); color: var(--bg); border-color: var(--red); }
.outlier-table-wrap { overflow-x: auto; max-height: 280px; overflow-y: auto; }
.outlier-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 0.85rem; }

#boxplot-echart { margin-top: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.boxplot-stats { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.bstat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 12px; font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--ink2); }
.bstat strong { color: var(--ink-full); }

#quality-section { margin-bottom: 28px; }
.quality-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow); overflow: hidden; }
.quality-card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.quality-card-header h2 { font-size: 0.92rem; font-weight: 600; font-family: var(--serif); }
.qf-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.quality-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 16px; }
.q-item { padding: 18px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); transition: transform var(--transition), box-shadow var(--transition); }
.q-item:hover { background: var(--bg); }
.q-name { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; color: var(--ink-full); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-bar-wrap { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 5px; }
.q-bar { height: 100%; border-radius: 3px; transition: width 0.9s cubic-bezier(0.16,1,0.3,1); }
.q-pct { font-family: var(--mono); font-size: 0.7rem; font-weight: 500; color: var(--muted); }

/* ── VIS MODAL ── */
#vis-modal { display: none; position: fixed; inset: 0; background: rgba(10,8,5,.55); z-index: 999; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(5px); }
#vis-modal.open { display: flex; }
.vis-modal-inner { background: var(--surface); border-radius: 18px; box-shadow: 0 32px 100px rgba(0,0,0,.25); width: 100%; max-width: 1200px; height: 85vh; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; animation: modal-in 0.22s ease; }
@keyframes modal-in { from{opacity:0;transform:translateY(14px) scale(0.97)} to{opacity:1;transform:translateY(0) scale(1)} }
.vis-modal-head { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.vis-modal-head h2 { font-size: 1rem; font-weight: 600; flex: 1; font-family: var(--serif); }
.vis-modal-head p { font-size: 0.78rem; color: var(--muted); }
.vis-modal-body { display: grid; grid-template-columns: 300px 1fr; flex: 1; overflow: hidden; }
.vis-controls { border-right: 1px solid var(--border); padding: 24px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; min-width: 300px; background: var(--bg); }
.ctrl-group { display: flex; flex-direction: column; gap: 10px; }
.ctrl-group label { display: block; font-family: var(--mono); font-size: 0.73rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-full); }
.ctrl-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border2); border-radius: var(--r);
  font-family: var(--sans); font-size: 0.88rem; background: var(--surface); color: var(--ink-full);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a857c'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; outline: none; transition: border-color var(--transition);
}
.ctrl-group select:focus { border-color: var(--accent); }
.chart-type-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.ct-btn { padding: 14px 10px; border: 1px solid var(--border2); border-radius: var(--r); background: var(--surface); cursor: pointer; text-align: center; transition: all var(--transition); font-size: 0.9rem; color: var(--ink2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 72px; }
.ct-btn .ct-icon { font-size: 1.4rem; }
.ct-btn:hover { border-color: var(--accent); color: var(--accent); }
.ct-btn.active { background: var(--ink-full); color: var(--bg); border-color: var(--ink-full); }
.chart-hint, .vis-helper { background: var(--amber-l); border: 1px solid #fbbf24; border-radius: var(--r); padding: 12px 14px; font-size: 0.82rem; color: var(--amber); line-height: 1.5; }
.vis-helper { background: var(--accent-l); border: 1px solid var(--accent); color: var(--accent-d); }
.vis-canvas-area { display: flex; flex-direction: column; padding: 20px; overflow-y: auto; }
.vis-chart-wrap { flex: 1; min-height: 450px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r2); padding: 16px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; position: relative; }
.vis-chart-wrap canvas { max-height: 100%; max-width: 100%; }
.vis-chart-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.vis-empty { text-align: center; color: var(--muted); font-size: 0.84rem; font-weight: 300; }
.vis-empty .vis-empty-icon { font-size: 2.6rem; margin-bottom: 10px; display: block; }
.vis-insights { display: flex; gap: 8px; flex-wrap: wrap; }
.insight-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 100px; padding: 4px 12px; font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--ink2); }

/* ── REPORT MODAL ── */
#report-modal { display: none; position: fixed; inset: 0; background: rgba(10,8,5,.55); z-index: 999; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(5px); }
#report-modal.open { display: flex; }
.report-modal-inner { background: var(--surface); border-radius: 18px; box-shadow: 0 32px 100px rgba(0,0,0,.25); width: 100%; max-width: 720px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; animation: modal-in 0.22s ease; }
.report-head { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.report-head h2 { font-size: 1rem; font-weight: 600; flex: 1; font-family: var(--serif); }
#report-content { flex: 1; overflow-y: auto; padding: 24px; font-size: 0.84rem; line-height: 1.8; font-weight: 300; }
#report-content h3 { font-family: var(--serif); font-size: 1.05rem; font-weight: 400; margin: 20px 0 8px; color: var(--ink-full); }
#report-content h3:first-child { margin-top: 0; }
#report-content p { color: var(--ink2); margin-bottom: 10px; }
#report-content .report-kv { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 12px 0; }
#report-content .report-kv-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; }
#report-content .report-kv-val { font-family: var(--serif); font-size: 1.2rem; font-weight: 400; color: var(--ink-full); }
.report-kv-lbl { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.report-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.ai-box { background: var(--accent-l); border: 1px solid var(--accent); border-radius: var(--r); padding: 18px; margin-bottom: 24px; }
.ai-box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ai-box-head h3 { margin: 0 !important; color: var(--accent-d) !important; font-size: 1.1rem !important; }
.ai-content { font-size: 0.85rem; color: var(--ink-full); line-height: 1.6; }

/* ── ML PREP MODAL ── */
#ml-modal { display: none; position: fixed; inset: 0; background: rgba(10,8,5,.55); z-index: 999; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(5px); }
#ml-modal.open { display: flex; }
.ml-modal-inner { background: var(--surface); border-radius: 18px; box-shadow: 0 32px 100px rgba(0,0,0,.25); width: 100%; max-width: 600px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; animation: modal-in 0.22s ease; }
.ml-section { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.ml-section:last-child { border-bottom: none; }
.ml-section h3 { font-family: var(--serif); font-size: 1rem; margin-bottom: 10px; }
.ml-section p { font-size: 0.8rem; color: var(--muted); margin-bottom: 14px; }
.col-drop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 150px; overflow-y: auto; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); }

/* ── SCROLL TO TOP ── */
#scroll-top { position: fixed; bottom: 28px; left: 28px; width: 40px; height: 40px; background: var(--ink-full); color: var(--bg); border: none; border-radius: 50%; cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 1rem; box-shadow: var(--shadow2); z-index: 100; transition: all var(--transition); }
#scroll-top.show { display: flex; }
#scroll-top:hover { transform: translateY(-2px); }

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 1100px) {
  #upload-screen { flex-direction: column; padding: 60px 40px 80px; gap: 48px; align-items: center; }
  .upload-right { width: 100%; max-width: 480px; }
  .upload-left { max-width: 100%; }
  .two-col { grid-template-columns: 1fr; }
  #overview-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  html, body { font-size: 15px; }
  button, select, .btn-qf { min-height: 40px; }
  #upload-screen {
    flex-direction: column;
    padding: 32px 20px 60px;
    gap: 28px;
    align-items: center;
    justify-content: flex-start;
  }
  .upload-left {
    max-width: 100%;
    text-align: center;
  }
  .hero-eyebrow { justify-content: center; }
  .hero-title { font-size: clamp(2.2rem, 8vw, 2.8rem); margin-bottom: 16px; }
  .hero-sub { font-size: 1.05rem; max-width: 100%; margin-bottom: 12px; }
  .hero-stats { padding: 12px 0; margin-bottom: 16px; }
  .hstat-num { font-size: 1.6rem; }
  .social-links { justify-content: center; }
  .upload-right { width: 100%; max-width: 100%; }
  .upload-card-inner { padding: 24px 20px; }
  .feature-pills { grid-template-columns: 1fr 1fr; }
  #overview-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .vis-modal-body { grid-template-columns: 1fr; }
  .vis-modal-inner, .ml-modal-inner, .report-modal-inner { max-height: 100vh; height: 100vh; border-radius: 0; width: 100vw; max-width: 100vw; }
  .vis-controls { border-right: none; border-bottom: 1px solid var(--border); }
  header { padding: 0 16px; }
  #dashboard { padding: 16px 12px 48px; }
  .brand-tag { display: none; }
  .qf-actions { justify-content: flex-start; }
  .top-bar { flex-wrap: wrap; }
  .top-bar .spacer { display: none; }
  .top-bar button { flex: 1; justify-content: center; }
}

.skip-link { position: absolute; top: -100%; left: 16px; background: var(--accent); color: #fff; padding: 8px 16px; z-index: 9999; border-radius: 0 0 8px 8px; font-weight: 600; text-decoration: none; transition: top 0.2s; }
.skip-link:focus { top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
