:root {
  --navy: #102a43;
  --navy-2: #183b56;
  --blue: #2368d8;
  --blue-soft: #eaf2ff;
  --green: #14804a;
  --green-soft: #e8f6ee;
  --amber: #a15c00;
  --amber-soft: #fff5dc;
  --red: #b42318;
  --red-soft: #fff0ee;
  --ink: #172b3a;
  --muted: #617486;
  --line: #dbe4ec;
  --surface: #ffffff;
  --page: #f4f7fa;
  --shadow: 0 12px 32px rgba(16, 42, 67, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% -10%, #e4efff 0, transparent 36rem), var(--page); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar { height: 68px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--navy); text-decoration: none; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.brand strong { color: var(--blue); }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, var(--blue), #194c9d); border-radius: 9px; box-shadow: 0 5px 12px rgba(35,104,216,.24); }
.brand-mark svg, .file-icon svg, button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.network-badge { display: flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid #cde6d7; border-radius: 99px; background: var(--green-soft); color: #0f6b3c; font-size: 12px; font-weight: 650; }
.network-badge span { width: 7px; height: 7px; background: #1b9a59; border-radius: 50%; box-shadow: 0 0 0 4px rgba(27,154,89,.12); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 62px 0 70px; }
.hero { max-width: 760px; margin: 0 auto 38px; text-align: center; }
.eyebrow, .section-kicker { margin: 0 0 8px; color: var(--blue); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
h1 { margin: 0; color: var(--navy); font-size: clamp(35px, 5vw, 54px); line-height: 1.06; letter-spacing: -.045em; }
.hero-copy { max-width: 680px; margin: 18px auto 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.stepper { max-width: 850px; margin: 0 auto 28px; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.stepper::before { content: ""; position: absolute; top: 19px; left: 12.5%; right: 12.5%; border-top: 1px solid #cbd8e4; z-index: 0; }
.step { position: relative; z-index: 1; display: flex; justify-content: center; gap: 10px; color: #8a9aaa; }
.step > span { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid #cbd8e4; background: var(--page); border-radius: 50%; font-weight: 750; }
.step div { padding-top: 1px; }
.step strong, .step small { display: block; }
.step strong { color: #687b8d; font-size: 13px; }
.step small { margin-top: 2px; font-size: 11px; }
.step.active > span, .step.complete > span { border-color: var(--blue); background: var(--blue); color: white; box-shadow: 0 0 0 5px var(--blue-soft); }
.step.active strong, .step.complete strong { color: var(--navy); }
.step.complete > span::after { content: "✓"; }
.step.complete > span { font-size: 0; background: var(--green); border-color: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
#upload-panel, #progress-panel, #error-panel { max-width: 960px; margin: 0 auto; }
#upload-panel { padding: 30px; }
.panel-heading, .results-heading, .card-heading, .fields-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
h2, h3 { color: var(--navy); letter-spacing: -.025em; }
h2 { margin: 0; font-size: 24px; }
h3 { margin: 0; font-size: 18px; }
.privacy-note { color: var(--green); background: var(--green-soft); border-radius: 8px; padding: 8px 11px; font-size: 12px; font-weight: 650; }
.upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr); align-items: center; gap: 10px; margin-top: 26px; }
.dropzone { min-height: 190px; padding: 25px 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; text-align: center; border: 1.5px dashed #b8c8d8; border-radius: 14px; background: #fbfdff; transition: .18s ease; cursor: pointer; }
.dropzone:hover, .dropzone.dragging { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-1px); }
.dropzone.selected { border-style: solid; border-color: #8cc7a6; background: #f8fdf9; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; }
.file-icon svg { width: 26px; }
.blank-icon { color: var(--blue); background: var(--blue-soft); }
.filled-icon { color: var(--green); background: var(--green-soft); }
.drop-copy strong, .drop-copy small { display: block; }
.drop-copy strong { color: var(--navy); font-size: 15px; }
.drop-copy small { margin-top: 5px; color: var(--muted); font-size: 12px; }
.file-state { max-width: 90%; padding: 6px 10px; color: var(--blue); background: #eef4ff; border-radius: 7px; font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected .file-state { color: var(--green); background: var(--green-soft); }
.pair-arrow { text-align: center; color: #93a4b5; font-size: 22px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; }
.form-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.primary-button, .secondary-button { border-radius: 10px; font-weight: 700; transition: .16s ease; }
.primary-button { min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; gap: 8px; border: 0; color: white; background: var(--blue); box-shadow: 0 7px 15px rgba(35,104,216,.22); }
.primary-button:hover:not(:disabled) { background: #175bc4; transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; background: #9fb2c5; box-shadow: none; }
.primary-button svg { width: 17px; }
.secondary-button { padding: 10px 14px; color: var(--navy); background: white; border: 1px solid #bdcbd8; }
.secondary-button:hover { border-color: var(--blue); color: var(--blue); }

#progress-panel { padding: 42px; }
.processing-layout { display: grid; grid-template-columns: 160px 1fr; gap: 38px; align-items: center; }
.processing-visual { width: 150px; height: 180px; position: relative; display: grid; place-items: center; overflow: hidden; border: 1px solid #cdd9e5; border-radius: 12px; color: var(--blue); background: repeating-linear-gradient(#fff 0 18px, #e8eef4 19px 20px); box-shadow: 0 10px 25px rgba(16,42,67,.1); }
.processing-visual::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 20%, rgba(35,104,216,.07), transparent 80%); }
.processing-visual span { font-weight: 850; font-size: 28px; }
.scan-line { position: absolute; z-index: 2; left: 0; right: 0; height: 2px; background: var(--blue); box-shadow: 0 0 14px var(--blue); animation: scan 2.2s ease-in-out infinite; }
@keyframes scan { 0%,100% { top: 12%; } 50% { top: 88%; } }
.processing-copy h2 { margin-bottom: 8px; }
.processing-copy > p:not(.section-kicker) { color: var(--muted); }
.progress-track { height: 9px; margin-top: 24px; overflow: hidden; border-radius: 99px; background: #e7edf3; }
#progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, var(--blue), #52a3ff); border-radius: inherit; transition: width .4s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 11px; }

.error-panel { padding: 22px; display: flex; align-items: center; justify-content: space-between; border-color: #f1b8b1; background: var(--red-soft); box-shadow: none; }
.error-panel strong { color: var(--red); }
.error-panel p { margin: 4px 0 0; color: #7a3028; }

#results-panel { display: grid; gap: 20px; }
.results-heading { margin-top: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric { padding: 21px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 7px 20px rgba(16,42,67,.055); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin: 8px 0 3px; color: var(--navy); font-size: 31px; letter-spacing: -.04em; }
.metric small { font-size: 11px; }
.exception-metric.has-exceptions { border-color: #efc36b; background: var(--amber-soft); }
.exception-metric.has-exceptions strong { color: var(--amber); }
.result-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .7fr); gap: 20px; }
.preview-card, .summary-card, .fields-card { padding: 22px; }
.legend { display: flex; gap: 12px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; }
.legend .green { background: #159447; }
.legend .blue { background: #0066ff; }
.preview-frame { min-height: 380px; max-height: 680px; margin-top: 16px; display: grid; place-items: center; overflow: auto; background: #edf1f5; border: 1px solid #d6e0e9; border-radius: 10px; }
.preview-frame img { max-width: 100%; display: block; background: white; }
.summary-card dl { margin: 20px 0 0; }
.summary-card dl div { padding: 13px 0; border-bottom: 1px solid #e5ebf1; }
.summary-card dl div:last-child { border-bottom: 0; }
.summary-card dt { color: var(--muted); font-size: 11px; }
.summary-card dd { margin: 5px 0 0; color: var(--navy); font-size: 13px; font-weight: 750; }
.filter-group { display: flex; gap: 5px; padding: 4px; background: #edf2f6; border-radius: 9px; }
.filter { padding: 7px 10px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.filter.active { color: var(--blue); background: white; box-shadow: 0 2px 6px rgba(16,42,67,.09); }
.table-wrap { margin-top: 18px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 12px; text-align: left; color: #718397; background: #f5f8fa; border-bottom: 1px solid var(--line); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
td { padding: 12px; border-bottom: 1px solid #e8edf2; vertical-align: top; }
td:first-child { min-width: 210px; color: var(--navy); font-weight: 700; white-space: pre-line; }
td:nth-child(3) { min-width: 180px; }
.status-pill { display: inline-block; padding: 4px 7px; border-radius: 99px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status-good { color: #0c6a3b; background: var(--green-soft); }
.status-review { color: #8a4d00; background: var(--amber-soft); }
.status-empty { color: #315d8a; background: var(--blue-soft); }
.status-muted { color: #667482; background: #edf1f4; }
.empty-filter { padding: 28px; text-align: center; color: var(--muted); }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 34px; display: flex; justify-content: space-between; color: #8191a0; border-top: 1px solid var(--line); font-size: 11px; }

@media (max-width: 800px) {
  main { width: min(100% - 24px, 680px); padding-top: 42px; }
  .network-badge { display: none; }
  .step { display: block; text-align: center; }
  .step > span { margin: auto; }
  .step div { display: none; }
  .upload-grid, .result-grid { grid-template-columns: 1fr; }
  .pair-arrow { transform: rotate(90deg); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .processing-layout { grid-template-columns: 1fr; text-align: center; }
  .processing-visual { margin: auto; }
  .panel-heading, .results-heading, .fields-toolbar { align-items: flex-start; flex-direction: column; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .primary-button { justify-content: center; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 15px; }
  h1 { font-size: 37px; }
  #upload-panel, #progress-panel { padding: 20px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { padding: 15px; }
  .filter-group { width: 100%; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
