/* Imetco West Freight Estimator — light theme, validated palette tokens */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #eb6834;          /* lane / selection */
  --accent-ink: #b44718;
  --steel: #1f3a52;           /* brand header */
  --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec;  /* sequential ramp (validated) */
  --q4: #3987e5; --q5: #256abf; --q6: #184f95;
  --out-region: #efeeea;
  --shadow: 0 1px 3px rgba(11, 11, 11, 0.08), 0 4px 14px rgba(11, 11, 11, 0.06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- header */
header {
  background: var(--steel);
  color: #fff;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-size: 17px; letter-spacing: 0.06em; }
.brand span { font-size: 12px; color: #c9d4e0; }
.origin-chip {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.origin-chip b { color: #ffd9c2; }

.data-pill {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.data-pill.baseline {
  background: #fdf0dc;
  border-color: #e8c690;
  color: #7a4a00;
}
.data-pill.validated {
  background: #e2f3e2;
  border-color: #9fd49f;
  color: #0a5c0a;
}

.tool-sep {
  width: 1px;
  align-self: stretch;
  background: var(--grid);
}
.pill .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 0.5px;
}

/* --------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--grid);
  flex-wrap: wrap;
}
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--baseline);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.pill:hover { border-color: var(--ink-2); }
.pill.active {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
  font-weight: 600;
}
.field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field select {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--baseline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.search-wrap { position: relative; margin-left: auto; min-width: 260px; flex: 0 1 320px; }
.search-wrap input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--baseline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.search-wrap input:focus { outline: 2px solid var(--q4); outline-offset: 1px; }
.search-wrap .icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 1200;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.search-results.open { display: block; }
.search-results button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--ink);
}
.search-results button:hover, .search-results button.hl { background: #eef3fb; }
.search-results .st { color: var(--muted); font-size: 12px; }
.search-results .none { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* ----------------------------------------------------------------- layout */
main { flex: 1; display: flex; min-height: 0; }
#map {
  flex: 1;
  background: var(--page);
  min-height: 0;
  outline: none;
}
aside {
  width: 400px;
  max-width: 44vw;
  border-left: 1px solid var(--grid);
  background: var(--surface);
  overflow-y: auto;
  padding: 16px;
}

/* Leaflet chrome overrides */
.leaflet-container { font: inherit; }
.leaflet-tooltip {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12.5px;
  padding: 6px 9px;
}
.leaflet-tooltip b { font-size: 13px; }
.leaflet-tooltip .sub { color: var(--ink-2); }
.leaflet-bar a { color: var(--ink-2); }
.map-btn {
  background: var(--surface);
  border: 1px solid var(--baseline);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  display: none;
}
.map-btn:hover { color: var(--ink); border-color: var(--ink-2); }

.legend {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.2;
}
.legend .title { font-weight: 600; color: var(--ink); font-size: 11.5px; margin-bottom: 5px; }
.legend .ramp { display: flex; }
.legend .ramp i { width: 34px; height: 10px; display: block; }
.legend .labels { display: flex; justify-content: space-between; margin-top: 3px; color: var(--muted); }
.origin-icon {
  width: 14px; height: 14px;
  background: var(--accent);
  border: 2.5px solid #fff;
  outline: 1px solid var(--accent-ink);
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------ panel */
.panel h2 { margin: 0 0 2px; font-size: 19px; }
.panel .sub { color: var(--ink-2); font-size: 13px; margin-bottom: 12px; }
.hint {
  border: 1px dashed var(--baseline);
  border-radius: 12px;
  padding: 16px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.55;
  background: var(--page);
}
.hint b { color: var(--ink); }
.hint ol { margin: 8px 0 0; padding-left: 20px; }
.hint li { margin-bottom: 5px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.chip {
  font-size: 12px;
  background: var(--page);
  border: 1px solid var(--grid);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 4px 10px;
}
.chip b { color: var(--ink); }
.chip.warn {
  background: #fdf0dc;
  border-color: #e8c690;
  color: #7a4a00;
  font-weight: 600;
}

table.est { width: 100%; border-collapse: collapse; font-size: 13px; }
table.est th {
  text-align: right;
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--baseline);
}
table.est th:first-child { text-align: left; }
table.est td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.est td:first-child { text-align: left; white-space: normal; }
table.est tr.sel td { background: #fdf1ea; }
table.est tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.est .eq { font-weight: 600; }
table.est .exp { font-weight: 700; }
table.est .basis { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
table.est tr.clickable { cursor: pointer; }
table.est tr.clickable:hover td { background: #eef3fb; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  margin-top: 14px;
}
.btn:hover { background: var(--accent-ink); }
.btn.secondary {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--baseline);
  font-weight: 500;
}
.btn.secondary:hover { color: var(--ink); border-color: var(--ink-2); }
.note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 12px; }
.footnote {
  padding: 8px 18px;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px solid var(--grid);
  background: var(--surface);
}
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 2000;
}
.toast.show { opacity: 1; }
.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--grid); border-top-color: var(--q5);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  main { flex-direction: column; }
  #map { min-height: 52vh; }
  aside { width: 100%; max-width: none; border-left: 0; border-top: 1px solid var(--grid); }
  .search-wrap { flex-basis: 100%; }
}
