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

:root {
  --bg:       #0d0f14;
  --surface:  #141720;
  --card:     #1c2030;
  --border:   #252a3a;
  --blue:     #4f8ef7;
  --purple:   #7c3aed;
  --green:    #22c55e;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --fg:       #e2e8f0;
  --sub:      #64748b;
  --hover:    #1e2540;
  --sel:      #1a1f32;
  --mono:     'IBM Plex Mono', monospace;
  --sans:     'IBM Plex Sans', sans-serif;
}

html { font-size: 13px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  color: var(--blue);
  font-size: 20px;
  line-height: 1;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--fg);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.global-stats {
  font-size: 11px;
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 6px;
}

#stat-total { color: var(--blue); font-weight: 600; }
.stat-sep   { color: var(--border); }

/* Pipeline */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 28px;
  background: var(--surface);
  overflow-x: auto;
}

.pipeline-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sub);
  letter-spacing: 0.1em;
  margin-right: 16px;
  white-space: nowrap;
}

.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.step {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--sub);
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.2s;
}

.step.done { color: var(--green); }
.step.done .dot { color: var(--green); }
.dot { font-size: 14px; line-height: 1; }

.arrow { color: var(--border); font-size: 11px; padding: 0 2px; }

.pipeline-export {
  margin-left: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Main ────────────────────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Panel ───────────────────────────────────────────────────────────── */
.panel {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}

.panel-header {
  display: flex;
  align-items: stretch;
  cursor: pointer;
  background: var(--card);
  user-select: none;
  transition: background 0.15s;
}
.panel-header:hover { background: var(--hover); }

.panel-accent {
  width: 3px;
  flex-shrink: 0;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex: 1;
  flex-wrap: wrap;
}

.panel-arrow { color: var(--blue); font-size: 14px; line-height: 1; }
.panel-num   { font-size: 10px; font-weight: 600; color: var(--sub); letter-spacing: 0.1em; }
.panel-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; }
.panel-sub   { font-size: 11px; color: var(--sub); margin-left: 4px; }

.panel-body {
  padding: 16px 20px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.panel-body.collapsed { display: none; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--blue);   color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3a70d4; }

.btn-green   { background: var(--green);  color: #fff; }
.btn-green:hover:not(:disabled) { background: #16a34a; }

.btn-danger  { background: var(--red);    color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c03a3a; }

.btn-ghost {
  background: var(--card);
  color: var(--blue);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--hover); }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ml-auto { margin-left: auto; }
.mt-12   { margin-top: 12px; }
.flex    { display: flex; align-items: center; }
.gap-8   { gap: 8px; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
}
.badge-red  { background: #3b1a1a; color: var(--red); }
.badge-green{ background: #14352a; color: var(--green); }
.badge-amber{ background: #3b2a0e; color: var(--amber); }
.badge-warn { background: #3b2a0e; color: var(--amber); }

.count-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}

.status-text {
  font-size: 11px;
  color: var(--sub);
  padding-left: 4px;
}

/* ── File list ───────────────────────────────────────────────────────── */
.file-list {
  margin-top: 10px;
  min-height: 60px;
  background: var(--sel);
  border-radius: 3px;
  overflow: hidden;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--hover); }
.file-item.selected { background: #1e3a5f; }

.file-name  { flex: 1; font-size: 12px; }
.file-count { font-size: 11px; color: var(--sub); margin-left: 12px; }

.empty-state {
  padding: 20px;
  text-align: center;
  color: var(--sub);
  font-size: 11px;
}

/* ── Info bar ────────────────────────────────────────────────────────── */
.info-bar {
  background: var(--sel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--sub);
  margin-bottom: 12px;
  line-height: 1.6;
}

.info-warn { border-color: var(--amber); color: var(--amber); }

/* ── Fields ──────────────────────────────────────────────────────────── */
.field-group  { margin-bottom: 0; }
.field-label  { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: var(--sub); margin-bottom: 6px; }
.field-hint   { font-weight: 400; color: var(--border); }

.textarea {
  width: 100%;
  background: var(--sel);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.6;
}
.textarea:focus { border-color: var(--blue); }
.textarea::placeholder { color: var(--sub); }

/* ── Table ───────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  background: var(--sel);
  border-radius: 3px;
  margin-top: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--card);
  color: var(--blue);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 6px 12px;
  font-size: 11px;
  border-bottom: 1px solid #1a1f2e;
  color: var(--fg);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }

.sources-cell { color: var(--sub); font-size: 10px; }

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
}

/* ── Result columns ──────────────────────────────────────────────────── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.result-col { display: flex; flex-direction: column; gap: 6px; }

.result-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--sub);
}
.result-green { color: var(--green); }
.result-red   { color: var(--red);   }
.result-amber { color: var(--amber); }

.result-list {
  background: var(--sel);
  border-radius: 3px;
  height: 160px;
  overflow-y: auto;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.8;
  color: var(--fg);
  white-space: nowrap;
  overflow-x: hidden;
  text-overflow: ellipsis;
}

/* ── Progress ────────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--card);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 11px;
  color: var(--sub);
  white-space: nowrap;
  min-width: 80px;
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--fg);
  max-width: 360px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red);   }
.toast.info    { border-color: var(--blue);  color: var(--blue);  }

/* ── Drag-over ───────────────────────────────────────────────────────── */
body.drag-over::after {
  content: 'Drop files to upload';
  position: fixed;
  inset: 0;
  background: rgba(79,142,247,0.08);
  border: 2px dashed var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--blue);
  z-index: 9999;
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
  .pipeline-steps { gap: 2px; }
  .step { font-size: 10px; padding: 2px 3px; }
  main { padding: 12px 10px 40px; }
}

code {
  background: var(--sel);
  padding: 1px 5px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 11px;
}
