:root {
  color-scheme: light;
  --slate-950: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-600: #57534e;
  --amber-50: #fffbeb;
  --amber-500: #f59e0b;
  --amber-700: #b45309;
  --emerald-50: #ecfdf5;
  --emerald-600: #059669;
  --rose-50: #fff1f2;
  --rose-600: #e11d48;
  --blue-50: #eff6ff;
  --blue-700: #1d4ed8;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--stone-50);
  color: var(--slate-950);
}

button, input, select {
  font: inherit;
}

.topbar {
  align-items: center;
  background: var(--slate-950);
  color: white;
  display: flex;
  height: 68px;
  justify-content: space-between;
  padding: 0 40px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand small {
  color: #94a3b8;
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  border-radius: 12px;
  color: #111827;
  display: inline-flex;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  letter-spacing: -0.05em;
  width: 38px;
}

.tabs {
  display: flex;
  gap: 22px;
}

.tab {
  background: transparent;
  border: 0;
  color: #94a3b8;
  cursor: pointer;
  height: 68px;
  padding: 0 4px;
  position: relative;
}

.tab.is-active {
  color: white;
}

.tab.is-active::after {
  background: var(--amber-500);
  bottom: 0;
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  right: 0;
}

main {
  padding: 32px 40px 56px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.hero, .history-head {
  margin: 0 auto 28px;
  max-width: 1040px;
}

.hero h1, .history-head h1 {
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin: 6px 0 12px;
  max-width: 860px;
}

.hero p:last-child {
  color: var(--stone-600);
  font-size: 17px;
  line-height: 1.7;
  max-width: 760px;
}

.eyebrow {
  color: var(--amber-700);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0;
  text-transform: uppercase;
}

.stepper {
  display: flex;
  gap: 12px;
  justify-content: center;
  list-style: none;
  margin: 0 auto 24px;
  max-width: 1040px;
  padding: 0;
}

.stepper li {
  align-items: center;
  color: var(--slate-500);
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

.stepper li:not(:last-child)::after {
  background: var(--stone-200);
  content: "";
  flex: 1;
  height: 2px;
}

.step-dot {
  align-items: center;
  border: 2px solid var(--stone-300);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 34px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
}

.stepper .done .step-dot {
  background: var(--slate-700);
  border-color: var(--slate-700);
  color: white;
}

.stepper .active .step-dot {
  background: var(--amber-500);
  border-color: var(--amber-500);
  color: #111827;
}

.stepper .active span:last-child {
  color: var(--slate-950);
  font-weight: 700;
}

.panel, .history-card, .filters {
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.06);
}

.panel {
  margin: 0 auto;
  max-width: 1040px;
  min-height: 470px;
  padding: 30px;
}

.panel h2 {
  font-size: 26px;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.muted {
  color: var(--slate-500);
  line-height: 1.6;
}

.dropzone {
  align-items: center;
  background: linear-gradient(135deg, #fff, var(--amber-50));
  border: 2px dashed var(--stone-300);
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  min-height: 220px;
  padding: 38px;
  text-align: center;
  transition: 160ms ease;
}

.dropzone:hover, .dropzone.is-dragging {
  border-color: var(--amber-500);
  transform: translateY(-1px);
}

.upload-icon {
  align-items: center;
  background: var(--slate-950);
  border-radius: 20px;
  color: white;
  display: inline-flex;
  font-size: 34px;
  height: 72px;
  justify-content: center;
  width: 72px;
}

.file-card, .notice, .summary-grid, .mapping-grid, .confirm-grid {
  display: grid;
  gap: 16px;
}

.file-card {
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 20px;
  padding: 18px;
}

.data-label {
  color: var(--slate-500);
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.data-value {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.field-row {
  align-items: center;
  border-bottom: 1px solid var(--stone-100);
  display: grid;
  gap: 16px;
  grid-template-columns: 1.3fr 1fr 120px;
  padding: 12px 0;
}

.field-row select, .filters select, .filters input, .encoding-select {
  background: white;
  border: 1px solid var(--stone-300);
  border-radius: 10px;
  min-height: 40px;
  padding: 0 12px;
  width: 100%;
}

.confidence, .status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: center;
  padding: 5px 10px;
  white-space: nowrap;
}

.confidence.high, .status-pass, .status-success {
  background: var(--emerald-50);
  color: var(--emerald-600);
}

.confidence.medium, .status-warning, .status-partial {
  background: var(--amber-50);
  color: var(--amber-700);
}

.confidence.low, .status-error, .status-failed {
  background: var(--rose-50);
  color: var(--rose-600);
}

.summary-grid {
  grid-template-columns: repeat(4, 1fr);
  margin: 20px 0;
}

.summary-card {
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  padding: 18px;
}

.summary-card strong {
  display: block;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

.table-wrap {
  border: 1px solid var(--stone-200);
  border-radius: 14px;
  max-width: 100%;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 920px;
  width: 100%;
}

th, td {
  border-bottom: 1px solid var(--stone-100);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--stone-100);
  color: var(--stone-600);
  font-size: 12px;
  letter-spacing: 0.04em;
  position: relative;
  text-transform: uppercase;
}

.resize-handle {
  bottom: 0;
  cursor: col-resize;
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
}

.resize-handle::after {
  background: var(--stone-300);
  bottom: 8px;
  content: "";
  position: absolute;
  right: 2px;
  top: 8px;
  width: 2px;
}

.resize-handle:hover::after {
  background: var(--amber-500);
}

td.numeric, th.numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.row-errors {
  color: var(--slate-500);
  font-size: 12px;
  line-height: 1.5;
  max-width: 240px;
}

.confirm-grid {
  grid-template-columns: 1.2fr 0.8fr;
  margin-top: 22px;
}

.notice {
  border-radius: 14px;
  padding: 18px;
}

.notice.warn {
  background: var(--amber-50);
  border: 1px solid #fde68a;
}

.notice.error {
  background: var(--rose-50);
  border: 1px solid #fecdd3;
}

.notice.info {
  background: var(--blue-50);
  border: 1px solid #bfdbfe;
}

.progress-shell {
  background: var(--stone-200);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  width: 100%;
}

.progress-bar {
  background: linear-gradient(90deg, #fbbf24, var(--amber-500));
  height: 100%;
  transition: width 160ms ease;
}

.pager {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 18px;
}

.pager button {
  background: white;
  border: 1px solid var(--stone-300);
  border-radius: 9px;
  cursor: pointer;
  min-height: 34px;
  min-width: 34px;
}

.pager button.is-active {
  background: var(--slate-950);
  color: white;
}

.actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 20px auto 0;
  max-width: 1040px;
}

.action-group {
  display: flex;
  gap: 12px;
}

.button {
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
  min-height: 42px;
  padding: 0 18px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--slate-950);
  color: white;
}

.secondary {
  background: white;
  border: 1px solid var(--stone-300);
  color: var(--slate-700);
}

.ghost {
  background: transparent;
  color: var(--slate-500);
}

.history-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
}

.filters {
  align-items: end;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(5, 1fr);
  margin: 0 auto 18px;
  max-width: 1180px;
  padding: 18px;
}

.filters label {
  color: var(--slate-500);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

.history-card {
  margin: 0 auto;
  max-width: 1180px;
  overflow: hidden;
}

.history-row {
  border-bottom: 1px solid var(--stone-100);
}

.history-summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 14px;
  grid-template-columns: 120px 1.2fr 120px 170px 110px 90px 90px 100px;
  padding: 16px 18px;
}

.history-detail {
  background: var(--stone-50);
  border-top: 1px solid var(--stone-100);
  display: none;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
  overflow-x: auto;
  padding: 18px;
}

.history-row.is-open .history-detail {
  display: grid;
}

.kv {
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: 12px;
  padding: 14px;
}

.empty {
  padding: 54px;
  text-align: center;
}

.toast {
  background: var(--slate-950);
  border-radius: 999px;
  bottom: 26px;
  color: white;
  left: 50%;
  opacity: 0;
  padding: 12px 18px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 18px);
  transition: 180ms ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  .topbar, .history-head, .actions {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    height: auto;
    padding: 18px 20px;
  }

  main {
    padding: 22px 16px 44px;
  }

  .tabs, .stepper, .summary-grid, .file-card, .confirm-grid, .filters, .history-detail {
    grid-template-columns: 1fr;
  }

  .tabs, .stepper {
    display: grid;
  }

  .tab {
    height: 42px;
    text-align: left;
  }

  .panel {
    padding: 20px;
  }

  .field-row, .history-summary {
    grid-template-columns: 1fr;
  }

  .history-detail .table-wrap {
    max-width: calc(100vw - 72px);
  }

  .history-detail table {
    min-width: 560px;
  }
}
