:root {
  --navy: #08284a;
  --wine: #9b003f;
  --teal: #0f766e;
  --blue: #2563a8;
  --green: #2f855a;
  --amber: #c97918;
  --red: #bf3b36;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee4;
  --panel: #ffffff;
  --bg: #f4f7f9;
  --shadow: 0 14px 34px rgba(8, 40, 74, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 18px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.brand p,
.eyebrow {
  margin: 0 0 4px;
  color: var(--wine);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand h1,
.summary-panel h2,
.control-section h2,
.legend-panel h2 {
  margin: 0;
  color: var(--navy);
}

.brand h1 {
  font-size: 24px;
  line-height: 1.15;
}

.source-pill {
  max-width: 420px;
  border: 1px solid #cbd5df;
  border-radius: 999px;
  background: #f8fafc;
  padding: 8px 12px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.app-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 126px);
  padding: 14px;
}

.control-panel {
  display: flex;
  max-height: calc(100vh - 154px);
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.control-section,
.legend-panel,
.summary-panel,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-section,
.legend-panel {
  padding: 14px;
}

.control-section {
  display: grid;
  gap: 10px;
}

.control-section h2,
.legend-panel h2 {
  font-size: 15px;
}

label {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.field-label i {
  color: var(--wine);
}

input,
select,
.mode-button,
#search-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

select {
  width: 100%;
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  outline: none;
}

.search-box {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
}

.search-box > i {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  padding: 0 12px 0 36px;
}

#search-button,
.mode-button {
  cursor: pointer;
}

#search-button {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.check-row {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.mode-button {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  padding: 0 12px;
  color: var(--navy);
  font-weight: 800;
}

.mode-button:hover {
  border-color: var(--teal);
  background: #f0fdfa;
}

.primary-action {
  justify-content: center;
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.primary-action:hover {
  border-color: var(--navy);
  background: #103d6d;
}

.route-results {
  display: grid;
  gap: 8px;
}

.route-card {
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.route-card h3 {
  margin: 0 0 6px;
  color: var(--navy);
  font-size: 14px;
}

.route-card p {
  margin: 4px 0;
  color: #475467;
  font-size: 12px;
  line-height: 1.45;
}

.route-card a,
.panel-action {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  justify-content: center;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 10px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.panel-action {
  width: 100%;
  margin-top: 10px;
  cursor: pointer;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.legend-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #475467;
  font-size: 12px;
}

.legend-color {
  width: 24px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 3px;
}

.map-workspace {
  display: grid;
  min-width: 0;
  grid-template-rows: auto minmax(520px, 1fr);
  gap: 12px;
}

.summary-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.summary-panel h2 {
  font-size: 21px;
  line-height: 1.2;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 7px;
  color: var(--navy);
  font-size: 20px;
  line-height: 1.1;
}

.map {
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe8ee;
  box-shadow: var(--shadow);
}

.info-panel {
  position: fixed;
  top: 0;
  right: -440px;
  z-index: 1000;
  width: min(420px, 96vw);
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  transition: right 180ms ease;
}

.info-panel.active {
  right: 0;
}

.close-panel {
  position: sticky;
  top: 0;
  float: right;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--navy);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

#panel-content h2,
#panel-content h3 {
  margin: 0 46px 12px 0;
  color: var(--navy);
}

#panel-content p {
  color: #475467;
  font-size: 14px;
  line-height: 1.55;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 10px;
  border-bottom: 1px solid #edf1f4;
  padding-bottom: 7px;
  font-size: 13px;
}

.detail-list strong {
  color: #344054;
}

.detail-note {
  border-left: 3px solid var(--teal);
  background: #f0fdfa;
  padding: 8px 10px;
  color: #344054;
  font-size: 12px;
  line-height: 1.45;
}

.popup-title {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 15px;
}

.popup-line {
  margin: 4px 0;
  color: #475467;
  font-size: 12px;
}

footer {
  border-top: 1px solid var(--line);
  background: #ffffff;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}

footer p {
  margin: 0;
}

@media (max-width: 1120px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
  }

  .summary-panel,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-pill {
    max-width: 100%;
  }

  .app-layout {
    padding: 10px;
  }

  .summary-panel,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .map {
    min-height: 500px;
  }
}
