:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #17242c;
  background: #edf2f3;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

.topbar {
  z-index: 2;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1.25rem;
  color: #f5fbfa;
  background: #12313a;
  box-shadow: 0 2px 10px #0c202733;
}

.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: .01em; }
.topbar p { margin: .25rem 0 0; color: #c6dbd8; font-size: .83rem; }
.header-actions { display: flex; align-items: center; gap: .8rem; }
.header-actions a, .sidebar a { color: #bfe6dc; }
.header-actions button {
  border: 1px solid #8fbbb4;
  border-radius: 5px;
  padding: .45rem .7rem;
  color: white;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.workspace { min-height: 0; flex: 1; display: flex; }
.sidebar.sidebar-hidden { display: none; }
.sidebar {
  z-index: 1;
  width: 330px;
  flex: 0 0 330px;
  overflow: auto;
  padding: .9rem 1rem 1rem;
  background: #17333a;
  color: #eef5f4;
  box-shadow: 2px 0 9px #0c202722;
}

.sidebar h2 {
  margin: 0 0 .65rem;
  color: #d7ece7;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.panel-section { padding: .5rem 0 .85rem; border-bottom: 1px solid #ffffff21; }
.layer-group { padding: .75rem 0 .45rem; border-bottom: 1px solid #ffffff21; }
.layer-group h2 { display: inline; margin: 0; }
.layer-group summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .1rem 0 .35rem;
  cursor: pointer;
  list-style: none;
}
.layer-group summary::-webkit-details-marker { display: none; }
.layer-group summary::before { content: "▸"; color: #9fc4bd; font-size: .75rem; }
.layer-group[open] summary::before { content: "▾"; }
.group-count {
  margin-left: auto;
  border-radius: 8px;
  padding: 0 .4rem;
  color: #bdd0cd;
  background: #ffffff14;
  font-size: .68rem;
}
.layer-toggle {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: .5rem;
  color: #f0f6f4;
  font-size: .82rem;
  cursor: pointer;
}
.layer-toggle input { accent-color: #56b59b; }
.swatch { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 2px; }
.cost-swatch { background: linear-gradient(135deg, #2d8e5b, #f4cc4f, #be3434); }
.gradient-legend { height: 9px; margin: .5rem 0 .25rem; border-radius: 6px; background: linear-gradient(90deg, #2d8e5b, #f4cc4f, #be3434); }
.legend-labels { display: flex; justify-content: space-between; color: #d6e4e1; font-size: .72rem; }
.muted, .sidebar-footer { color: #bdd0cd; font-size: .73rem; line-height: 1.45; }
.muted { margin: .5rem 0 0; }
.sidebar-footer { padding-top: .7rem; }
.sidebar-footer p { margin: .35rem 0; }
.sidebar-footer a { color: #bfe6dc; }
.status {
  margin-bottom: .6rem;
  border-left: 3px solid #69c5aa;
  padding: .65rem .7rem;
  color: #e7f3ef;
  background: #24464d;
  font-size: .78rem;
  line-height: 1.4;
}
.status.warning { border-color: #edc969; }
.status.error { border-color: #ed8176; }

.score-badge {
  margin-left: auto;
  min-width: 1.6rem;
  border-radius: 3px;
  padding: .05rem .3rem;
  color: #d6e4e1;
  background: #ffffff1a;
  font-size: .68rem;
  text-align: center;
}

.hotspot-legend { display: flex; gap: 1rem; margin: .35rem 0 .2rem; color: #d6e4e1; font-size: .74rem; }
.hotspot-legend > span { display: flex; align-items: center; gap: .35rem; }
.dot { display: inline-block; border-radius: 50%; }
.source-dot { width: 10px; height: 10px; border: 2px solid #17333a; background: #e28b24; box-shadow: 0 0 0 1px #e28b24; }
.storage-dot { width: 13px; height: 13px; border: 2px solid #ffffff; background: #2878a8; }

.subheading { margin-top: .9rem !important; }
.route-filter-label { display: block; margin-bottom: .2rem; color: #bdd0cd; font-size: .72rem; }
#route-filter {
  width: 100%;
  border: 1px solid #ffffff33;
  border-radius: 4px;
  padding: .3rem .4rem;
  color: #eef5f4;
  background: #24464d;
  font: inherit;
  font-size: .8rem;
}
.route-list { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; }
.route-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .1rem .5rem;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: .4rem .5rem;
  color: #eef5f4;
  background: #ffffff0d;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.route-row:hover, .route-row:focus-visible { background: #ffffff1f; outline: none; }
.route-row.selected { border-color: #ffd23f; background: #ffd23f1f; }
.route-title { grid-column: 1; font-size: .78rem; line-height: 1.3; }
.route-meta { grid-column: 1; color: #bdd0cd; font-size: .7rem; }
.route-badges { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: .2rem; align-items: flex-end; }
.badge { border-radius: 3px; padding: .02rem .3rem; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge.best { color: #12313a; background: #69c5aa; }
.badge.mst { color: #ffffff; background: #4b47a8; }

.map-wrap { position: relative; min-width: 0; flex: 1; }
#map { position: absolute; inset: 0; }
.map-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #e6eeed;
  color: #3b5559;
  font-size: .95rem;
  pointer-events: none;
}
.map-loading.hidden { display: none; }
.map-note {
  position: absolute;
  right: 10px;
  bottom: 28px;
  max-width: 260px;
  border-radius: 3px;
  padding: .35rem .5rem;
  color: #273b3e;
  background: #ffffffdf;
  font-size: .68rem;
  pointer-events: none;
}
.maplibregl-popup-content { max-width: 320px; font-size: .8rem; line-height: 1.4; }
.popup-title { margin: 0 0 .35rem; font-size: .95rem; }
.popup-table { border-collapse: collapse; }
.popup-table td { padding: .12rem .35rem .12rem 0; vertical-align: top; }
.popup-table td:first-child { color: #52686c; }
.popup-note { margin: .4rem 0 0; color: #52686c; font-size: .72rem; }

@media (max-width: 760px) {
  .topbar { min-height: 62px; padding: .55rem .8rem; }
  .topbar h1 { font-size: 1rem; }
  .topbar p { font-size: .72rem; }
  .sidebar { width: min(82vw, 330px); flex-basis: min(82vw, 330px); }
  .map-note { bottom: 24px; max-width: 180px; }
}

@media (max-width: 430px) {
  .header-actions a { display: none; }
}
