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

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:       #0C0C0C;
  --bg1:      #034651;
  --bg2:      #053d4a;
  --bg3:      #064050;
  --bg4:      #074858;
  --line:     #0a5f72;
  --line2:    #0d7289;
  --amber:    #069CB5;
  --amber-d:  #047d93;
  --amber-g:  rgba(6,156,181,0.12);
  --amber-gs: rgba(6,156,181,0.06);
  --green:    #3DD68C;
  --red:      #F5564A;
  --blue:     #7CF7F7;
  --ink:      #E0F7FA;
  --ink2:     #a8e8ef;
  --ink3:     #5da8b5;
  --mono:     'IBM Plex Mono', monospace;
  --sans:     'IBM Plex Sans', sans-serif;
  --display:  'Bebas Neue', sans-serif;
  --radius:   6px;
}

/* ── Base ──────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

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

/* scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.07) 3px,
    rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* noise texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ────────────────────────────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--line);
}
.brand-eyebrow {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}
.brand-name {
  font-family: var(--display);
  font-size: 32px;
  letter-spacing: .04em;
  color: var(--ink);
  line-height: 1;
}
.brand-name span { color: var(--amber); }
.brand-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink3);
  margin-top: 5px;
}

/* Step nav */
.step-nav { padding: 20px 0; flex: 1; }

.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  position: relative;
  transition: background .15s;
}
.step-item.active  { background: var(--bg2); }
.step-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--amber);
}
.step-item.done .step-pip {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
  font-weight: 700;
}

.step-pip {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line2);
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink3);
  flex-shrink: 0;
  transition: all .2s;
}
.step-item.active .step-pip {
  border-color: var(--amber);
  color: var(--amber);
}

.step-info { flex: 1; }
.step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  line-height: 1.2;
}
.step-item.active .step-label { color: var(--ink); }
.step-desc {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink3);
  margin-top: 2px;
}

/* Sidebar progress meter */
.sidebar-progress {
  padding: 20px 24px;
  border-top: 1px solid var(--line);
}
.sp-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.sp-label span { color: var(--amber); font-weight: 600; }
.sp-track {
  height: 3px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
}
.sp-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 2px;
  transition: width .4s ease;
  width: 0%;
}

.sidebar-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink3);
}

/* ── Main ──────────────────────────────────────────────────────────── */
.main {
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 18px 36px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg1);
}
.topbar-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink3);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink3);
  background: var(--bg3);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 100px;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink3);
}
.status-dot.running { background: var(--amber); animation: blink 1s infinite; }
.status-dot.done    { background: var(--green); animation: none; }
.status-dot.error   { background: var(--red);   animation: none; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

.content {
  flex: 1;
  padding: 36px;
  max-width: 760px;
}

/* ── Panels ────────────────────────────────────────────────────────── */
.panel { display: none; animation: panelIn .25s ease; }
.panel.active { display: block; }
@keyframes panelIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

.panel-heading { margin-bottom: 28px; }
.panel-title {
  font-family: var(--display);
  font-size: 42px;
  letter-spacing: .03em;
  color: var(--ink);
  line-height: 1;
}
.panel-title span { color: var(--amber); }
.panel-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink3);
  margin-top: 8px;
  line-height: 1.6;
}

/* ── Upload zone ───────────────────────────────────────────────────── */
.drop-zone {
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: var(--bg1);
  padding: 52px 32px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all .2s;
  overflow: hidden;
}
.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--amber-gs);
  opacity: 0;
  transition: opacity .2s;
}
.drop-zone:hover::before,
.drop-zone.over::before { opacity: 1; }
.drop-zone:hover,
.drop-zone.over { border-color: var(--amber-d); }
.drop-zone input {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

.dz-icon {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
}
.dz-icon svg { width: 24px; height: 24px; stroke: var(--amber); }
.dz-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.dz-hint  { font-family: var(--mono); font-size: 10px; color: var(--ink3); }

/* ── File card ─────────────────────────────────────────────────────── */
.file-card {
  display: none;
  background: var(--bg2);
  border: 1px solid var(--amber-d);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 12px;
  gap: 14px;
  align-items: center;
}
.file-card.show { display: flex; }
.fc-icon { font-size: 20px; }
.fc-info { flex: 1; min-width: 0; }
.fc-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-meta { font-family: var(--mono); font-size: 10px; color: var(--amber); margin-top: 2px; }
.fc-remove {
  background: none; border: none;
  color: var(--ink3); cursor: pointer; font-size: 20px;
  line-height: 1; padding: 0; transition: color .15s;
}
.fc-remove:hover { color: var(--red); }

/* ── Column map chips ──────────────────────────────────────────────── */
.col-grid {
  display: none;
  grid-template-columns: repeat(3,1fr);
  gap: 6px;
  margin-top: 12px;
}
.col-grid.show { display: grid; }
.col-chip {
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--line2);
  color: var(--ink3);
  background: var(--bg2);
  display: flex; align-items: center; gap: 5px;
}
.col-chip.hit {
  border-color: var(--amber-d);
  color: var(--amber);
  background: var(--amber-gs);
}
.col-chip.miss { opacity: .5; }

/* ── Divider ───────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--line); margin: 28px 0; }

/* ── Primary button ────────────────────────────────────────────────── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px;
  background: var(--amber);
  color: #000;
  border: none; border-radius: var(--radius);
  font-family: var(--display);
  font-size: 18px; letter-spacing: .06em;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary:hover:not(:disabled) {
  background: #7CF7F7;
  box-shadow: 0 4px 28px rgba(6,156,181,.35);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  background: var(--bg4); color: var(--ink3);
  cursor: not-allowed; transform: none; box-shadow: none;
}
.btn-primary svg { width: 16px; height: 16px; }

/* ── Slider ────────────────────────────────────────────────────────── */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--amber); cursor: pointer; }
.slider-val { font-family: var(--mono); font-size: 12px; color: var(--amber); min-width: 30px; text-align: right; font-weight: 600; }

/* ── Field ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.field-lbl {
  font-family: var(--mono); font-size: 9.5px;
  text-transform: uppercase; letter-spacing: .1em; color: var(--ink3);
}
.field-note { font-family: var(--mono); font-size: 9.5px; color: var(--ink3); }
.field-note a { color: var(--blue); text-decoration: none; }
.field-note a:hover { text-decoration: underline; }

/* ── Progress panel ────────────────────────────────────────────────── */
.prog-stat-row {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 8px; margin-bottom: 24px;
}
.prog-stat {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.ps-val { font-family: var(--display); font-size: 32px; color: var(--ink); line-height: 1; }
.ps-val.amber { color: var(--amber); }
.ps-val.green { color: var(--green); }
.ps-val.red   { color: var(--red);   }
.ps-lbl { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); margin-top: 4px; }

.prog-url-strip {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink2);
  margin-bottom: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prog-url-strip span { color: var(--amber); margin-right: 6px; }

/* ── Log console ───────────────────────────────────────────────────── */
.log-wrap {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.log-bar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2);
}
.log-bar-label { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink3); flex: 1; }
.log-led { width: 7px; height: 7px; border-radius: 50%; background: var(--ink3); flex-shrink: 0; }
.log-led.on { background: var(--amber); animation: blink 1s infinite; }
.log-led.ok { background: var(--green); animation: none; }

.log-body {
  padding: 12px 14px;
  max-height: 280px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
}
.ll { display: flex; gap: 10px; }
.ll-ts      { color: var(--ink3); flex-shrink: 0; }
.ll-info    { color: var(--ink2); }
.ll-success { color: var(--green); }
.ll-error   { color: var(--red); }
.ll-dim     { color: var(--ink3); }

/* ── Download panel ────────────────────────────────────────────────── */
.result-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 10px; margin-bottom: 24px;
}
.rg-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.rg-num { font-family: var(--display); font-size: 48px; line-height: 1; margin-bottom: 4px; }
.rg-num.g { color: var(--green); }
.rg-num.a { color: var(--amber); }
.rg-num.r { color: var(--red); }
.rg-lbl { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); }

.btn-dl {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 18px;
  background: transparent;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  font-family: var(--display);
  font-size: 20px; letter-spacing: .06em;
  cursor: pointer; text-decoration: none;
  transition: all .15s;
  position: relative; overflow: hidden;
}
.btn-dl::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--amber-g);
  transform: scaleX(0); transform-origin: left;
  transition: transform .2s ease;
}
.btn-dl:hover::before { transform: scaleX(1); }
.btn-dl:hover { box-shadow: 0 0 32px rgba(6,156,181,.2); }
.btn-dl svg { width: 18px; height: 18px; position: relative; z-index: 1; }
.btn-dl-label { position: relative; z-index: 1; }

.dl-note { font-family: var(--mono); font-size: 10px; color: var(--ink3); text-align: center; margin-top: 14px; }

/* ── Error box ─────────────────────────────────────────────────────── */
.err-box {
  display: none;
  background: #1a0a09;
  border: 1px solid rgba(245,86,74,.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--mono); font-size: 11px; color: var(--red);
  margin-top: 12px;
}
.err-box.show { display: block; }

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 2px; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .content { padding: 24px; }
}