@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-deep: #080c12;
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #1c2330;
  --bg-card: #21262d;
  --border: #30363d;
  --border-subtle: #21262d;

  --accent: #e8a020;
  --accent-dim: rgba(232, 160, 32, 0.15);
  --accent-glow: rgba(232, 160, 32, 0.3);
  --accent-bright: #f0b940;

  --blue: #58a6ff;
  --blue-dim: rgba(88, 166, 255, 0.12);
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.12);
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, 0.12);
  --purple: #a371f7;
  --purple-dim: rgba(163, 113, 247, 0.12);

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --text-accent: var(--accent);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 0 24px rgba(232, 160, 32, 0.2);

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

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

/* ── Background grid ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(232, 160, 32, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 160, 32, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 12, 18, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-accent);
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(232, 160, 32, 0.3);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.error { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.processing { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse-dot 1s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Layout ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  position: relative;
  z-index: 1;
}

/* ── Page title ── */
.page-title {
  margin-bottom: 32px;
}

.page-title h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.page-title h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-title p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Pipeline steps ── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  overflow-x: auto;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  flex: 1;
  position: relative;
}

.pipeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 20px;
  right: -50%;
  width: 100%;
  height: 1px;
  background: var(--border);
  z-index: 0;
  transition: var(--transition-slow);
}

.pipeline-step.done:not(:last-child)::after {
  background: linear-gradient(90deg, var(--accent), rgba(232, 160, 32, 0.3));
}

.step-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  position: relative;
  z-index: 1;
  transition: var(--transition-slow);
}

.pipeline-step.active .step-icon {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 16px var(--accent-glow);
}

.pipeline-step.done .step-icon {
  border-color: var(--green);
  background: var(--green-dim);
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.3);
}

.pipeline-step.error .step-icon {
  border-color: var(--red);
  background: var(--red-dim);
}

.step-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  transition: var(--transition);
  white-space: nowrap;
}

.pipeline-step.active .step-label { color: var(--accent); }
.pipeline-step.done .step-label { color: var(--green); }
.pipeline-step.error .step-label { color: var(--red); }

/* ── Main grid ── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

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

/* ── Card ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

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

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.card-icon.amber { background: var(--accent-dim); border: 1px solid rgba(232, 160, 32, 0.25); }
.card-icon.blue { background: var(--blue-dim); border: 1px solid rgba(88, 166, 255, 0.25); }
.card-icon.green { background: var(--green-dim); border: 1px solid rgba(63, 185, 80, 0.25); }
.card-icon.purple { background: var(--purple-dim); border: 1px solid rgba(163, 113, 247, 0.25); }

.card-title h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, var(--accent-dim) 0%, transparent 70%);
  opacity: 0;
  transition: var(--transition-slow);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(232, 160, 32, 0.04);
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
  opacity: 1;
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-icon {
  font-size: 40px;
  margin-bottom: 16px;
  display: block;
  transition: var(--transition);
  position: relative;
  z-index: 1;
}

.drop-zone:hover .drop-icon { transform: translateY(-4px); }

.drop-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.drop-desc {
  font-size: 13px;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
}

.drop-desc span {
  color: var(--accent);
  font-weight: 500;
}

.drop-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  position: relative;
  z-index: 1;
}

#fileInput {
  display: none;
}

/* ── File info ── */
.file-info {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.file-info.visible { display: block; }

.file-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon-wrap {
  width: 44px;
  height: 44px;
  background: var(--accent-dim);
  border: 1px solid rgba(232, 160, 32, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.file-details { flex: 1; min-width: 0; }

.file-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-size: 16px;
}

.file-remove:hover { color: var(--red); background: var(--red-dim); }

/* ── MVR contents ── */
.mvr-contents {
  display: none;
  margin-top: 16px;
}

.mvr-contents.visible { display: block; }

.mvr-contents-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.mvr-files-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mvr-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}

.mvr-file-item:hover {
  border-color: var(--border);
  color: var(--text-primary);
}

.mvr-file-item.highlight {
  border-color: rgba(232, 160, 32, 0.3);
  background: var(--accent-dim);
  color: var(--accent);
}

.mvr-file-size {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
}

/* ── Processing options ── */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.option-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.option-item input[type="checkbox"] {
  display: none;
}

.option-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 11px;
  color: transparent;
}

.option-item input:checked ~ .option-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-deep);
}

.option-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.option-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Input fields ── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field-input::placeholder {
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: var(--transition);
}

.btn:hover::after { background: rgba(255, 255, 255, 0.05); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: var(--bg-deep);
  box-shadow: 0 2px 8px rgba(232, 160, 32, 0.3);
  width: 100%;
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(232, 160, 32, 0.4);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-success {
  background: linear-gradient(135deg, #238636, var(--green));
  color: #fff;
  width: 100%;
  box-shadow: 0 2px 8px rgba(63, 185, 80, 0.3);
}

.btn-success:hover {
  box-shadow: 0 4px 16px rgba(63, 185, 80, 0.4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
}

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

/* ── Progress & Status ── */
.progress-section {
  display: none;
  margin-top: 20px;
}

.progress-section.visible { display: block; }

.progress-bar-wrap {
  background: var(--bg-card);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  border-radius: 999px;
  width: 0%;
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 8px var(--accent);
}

.progress-bar.indeterminate {
  width: 40% !important;
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

.progress-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Log ── */
.log-section {
  margin-top: 20px;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.log-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.log-container {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  height: 180px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
}

.log-container::-webkit-scrollbar {
  width: 4px;
}

.log-container::-webkit-scrollbar-track { background: transparent; }
.log-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.log-entry {
  display: flex;
  gap: 10px;
  animation: log-slide 200ms ease;
}

@keyframes log-slide {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-time { color: var(--text-muted); flex-shrink: 0; }
.log-msg.info { color: var(--text-secondary); }
.log-msg.success { color: var(--green); }
.log-msg.error { color: var(--red); }
.log-msg.warn { color: var(--accent); }

/* ── Result card ── */
.result-card {
  display: none;
  background: var(--green-dim);
  border: 1px solid rgba(63, 185, 80, 0.25);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  text-align: center;
}

.result-card.visible { display: block; }

.result-icon { font-size: 36px; margin-bottom: 10px; }

.result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 4px;
}

.result-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.result-meta-item {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.result-meta-item span {
  color: var(--text-secondary);
}

/* ── Sidebar ── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Info sections ── */
.info-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.info-block:last-child { margin-bottom: 0; }

.info-block-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-muted); }
.info-row-value { color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.info-row-value.green { color: var(--green); }
.info-row-value.amber { color: var(--accent); }

/* ── Instructions ── */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Test connection ── */
.test-result {
  display: none;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.test-result.visible { display: block; }
.test-result.ok { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.2); }
.test-result.fail { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248, 81, 73, 0.2); }

/* ── Tag ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag-amber { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(232, 160, 32, 0.3); }
.tag-blue { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(88, 166, 255, 0.3); }

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

/* ── Animations ── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fade-in 300ms ease forwards; }

/* ── Spinner ── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(8, 12, 18, 0.3);
  border-top-color: var(--bg-deep);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

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

/* ── XML Preview ── */
.xml-preview {
  display: none;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre;
  line-height: 1.6;
}

.xml-preview.visible { display: block; }
.xml-tag { color: var(--blue); }
.xml-attr { color: var(--purple); }
.xml-val { color: var(--accent); }
