:root {
  --ink: #17342d;
  --forest: #214d3f;
  --cream: #f6f2e9;
  --paper: #fffdf8;
  --orange: #df6b3b;
  --line: #d8d6cb;
  --muted: #6d7772;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: "Segoe UI", Arial, sans-serif;
}

header {
  min-height: 96px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: white;
  background: var(--forest);
}
header h1 { margin: 0; font: 500 34px/1.1 Georgia, serif; }
header p { margin: 0; }
.eyebrow {
  margin-bottom: 5px;
  color: #f5c6aa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.subtitle { margin-top: 7px; color: #d5e1d8; font-size: 13px; }
header nav { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
header a {
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 999px;
  color: white;
  text-decoration: none;
  font-size: 13px;
}
header a.active { color: var(--forest); background: white; }

main {
  height: calc(100% - 96px);
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
}
.panel {
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.panel section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.panel section:first-child { padding-top: 0; }
.panel section:last-child { border-bottom: 0; }
.panel h2 { margin: 0 0 13px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.summary div { padding: 14px; background: var(--cream); }
.summary strong { display: block; font: 500 22px Georgia, serif; }
.summary span { color: var(--muted); font-size: 11px; }
.controls label { display: block; margin: 11px 0; font-size: 14px; }
.controls input { accent-color: var(--orange); }
.controls select {
  width: 100%;
  margin: 0 0 20px;
  padding: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
}
.controls button {
  width: 100%;
  margin-top: 9px;
  padding: 10px;
  border: 0;
  color: white;
  background: var(--forest);
  cursor: pointer;
}
.legend p, .source p { margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 7px; border-radius: 50%; }
.dot.high { background: #2b8a60; }
.dot.medium { background: #e4a83a; }
.dot.low { background: #d34f3f; }
.section-title { display: flex; justify-content: space-between; align-items: center; }
.link-button { border: 0; color: var(--orange); background: transparent; cursor: pointer; font-size: 12px; }
.segment-list { display: grid; gap: 4px; }
.segment-button {
  width: 100%;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 0;
  text-align: left;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}
.segment-button:hover { background: var(--cream); }
.segment-button.active { color: white; background: var(--forest); }
.segment-order {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 10px;
}
.segment-km { color: var(--muted); white-space: nowrap; }
.segment-button.active .segment-km { color: #d5e1d8; }

.map-shell { position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #dbe4d6; }
.map-status {
  position: absolute;
  z-index: 500;
  right: 18px;
  bottom: 24px;
  max-width: 360px;
  padding: 10px 14px;
  color: white;
  background: rgba(23, 52, 45, .9);
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  font-size: 12px;
}
.stop-marker {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,.32);
  font: 700 9px Arial, sans-serif;
}
.stop-marker.high { background: #2b8a60; }
.stop-marker.medium { background: #e4a83a; }
.stop-marker.low { background: #d34f3f; }
.stop-marker.start { outline: 3px solid #17342d; outline-offset: 2px; }
.stop-marker.finish { outline: 3px solid #df6b3b; outline-offset: 2px; }
.endpoint-tooltip {
  padding: 3px 6px;
  border: 0;
  color: white;
  background: rgba(23,52,45,.9);
  box-shadow: none;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.endpoint-tooltip::before { display: none; }
.popup-role { color: var(--orange); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.leaflet-popup-content { line-height: 1.45; }
.leaflet-popup-content strong { color: var(--forest); }
.popup-meta { color: var(--muted); font-size: 11px; }

@media (max-width: 760px) {
  header { min-height: 84px; padding: 14px 18px; align-items: flex-start; flex-direction: column; }
  header nav { justify-content: flex-start; }
  header h1 { font-size: 26px; }
  .subtitle { display: none; }
  main { height: calc(100% - 84px); grid-template-columns: 1fr; grid-template-rows: 42% 58%; }
  .panel { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .map-shell { order: 1; }
}
