:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f2f5f9;
  --ink: #152033;
  --muted: #667085;
  --line: #d7dde7;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e8f0ff;
  --warn: #b42318;
  --shadow: 0 18px 42px rgba(21, 32, 51, 0.08);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 0 0 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-strip button {
  min-width: 104px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.status-strip button:hover {
  border-color: #b9c4d4;
  box-shadow: 0 8px 18px rgba(21, 32, 51, 0.07);
}

.status-strip button:focus {
  box-shadow: var(--focus);
  outline: none;
}

.status-strip strong {
  display: block;
  color: var(--ink);
  font-size: 1.05rem;
}

.status-strip span {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(312px, 370px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.import-panel,
.search-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.import-panel {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.search-panel {
  min-height: 620px;
  padding: 18px;
}

.panel-heading,
.mapping-head,
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button,
.text-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
}

.icon-button.danger {
  color: var(--warn);
}

.text-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-strong);
  font-weight: 700;
}

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

.primary-button {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.16);
}

.drop-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 132px;
  margin: 12px 0 16px;
  padding: 18px;
  border: 1px dashed #9aa7ba;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-title {
  font-weight: 800;
  color: var(--ink);
}

.drop-copy,
.saved-panel p,
#resultSummary {
  color: var(--muted);
  line-height: 1.45;
}

.field-row {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field-row label {
  color: #344054;
  font-size: 0.8rem;
  font-weight: 800;
}

.field-row input,
.field-row select,
.mapping-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.field-row input:focus,
.field-row select:focus,
.mapping-grid select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus);
  outline: none;
}

.mapping-area {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 18px 0;
  padding: 16px 0;
}

.hidden {
  display: none !important;
}

.mapping-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.map-item {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 8px;
  align-items: center;
}

.map-source {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-list {
  display: grid;
  gap: 8px;
}

.source-pill {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.84rem;
}

.source-pill strong {
  color: var(--ink);
}

.search-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(160px, 0.9fr) minmax(190px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.search-form .field-row {
  margin-bottom: 0;
}

.radius-control {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
}

input[type="range"] {
  accent-color: var(--accent);
}

output {
  color: var(--accent-strong);
  font-weight: 800;
  text-align: right;
}

.search-button {
  min-width: 132px;
}

.results-toolbar {
  margin-top: 18px;
  align-items: flex-start;
}

.search-progress {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.progress-head strong {
  color: var(--accent-strong);
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #edf2f7;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.message {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #fedf89;
  border-radius: 8px;
  background: #fffbeb;
  color: #7a4b00;
}

.results-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.overview-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

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

.overview-head h3 {
  margin: 0;
}

.trade-list {
  display: grid;
  gap: 8px;
}

.trade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.trade-row:hover {
  border-color: #b9c4d4;
  box-shadow: 0 8px 18px rgba(21, 32, 51, 0.06);
}

.trade-row.is-archived {
  background: #f3f5f8;
  opacity: 0.86;
}

.trade-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.trade-main:focus,
.trade-archive-button:focus {
  box-shadow: var(--focus);
  outline: none;
}

.trade-main span {
  min-width: 0;
}

.trade-main strong,
.trade-main small {
  display: block;
}

.trade-main small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.trade-main b {
  min-width: 46px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
}

.trade-archive-button {
  min-height: 36px;
  white-space: nowrap;
}

.trade-group-button {
  min-height: 36px;
}

.group-control {
  display: grid;
  gap: 4px;
  min-width: 170px;
}

.group-control span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.group-control input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.group-control input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus);
  outline: none;
}

.overview-filter {
  margin-bottom: 12px;
}

.archive-list {
  margin-top: 12px;
}

.archive-list summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.archive-list .trade-list {
  margin-top: 10px;
}

.result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(21, 32, 51, 0.04);
}

.result-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.company {
  margin: 4px 0 0;
  color: var(--muted);
}

.meta,
.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta {
  margin-top: 10px;
}

.badge {
  padding: 6px 8px;
  border: 1px solid #dce3ee;
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 0.78rem;
  font-weight: 700;
}

.result-distance {
  align-self: start;
  max-width: 160px;
  min-width: 96px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
  text-align: center;
  overflow-wrap: anywhere;
}

.overview-record .result-distance {
  background: #f8fafc;
  color: #344054;
  font-size: 0.82rem;
}

.contact-row {
  grid-column: 1 / -1;
}

.contact-row a,
.contact-row span {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.notes {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

  .import-panel {
    position: static;
  }

  .search-form {
    grid-template-columns: 1fr 1fr;
  }

  .search-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .results-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    justify-content: stretch;
  }

  .status-strip button {
    flex: 1 1 92px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .result-card {
    grid-template-columns: 1fr;
  }

  .result-distance {
    justify-self: start;
  }

  .trade-row {
    align-items: stretch;
    flex-direction: column;
  }

  .group-control {
    min-width: 0;
  }
}
