:root {
  --bg: #0c1116;
  --panel: rgba(17, 24, 33, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #b7c0cc;
  --accent-yellow: #f8f4b4;
  --accent-orange: #f4a261;
  --accent-red: #e63946;
  --accent-purple: #5a189a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

#map {
  height: 100%;
  width: 100%;
  filter: saturate(0.95);
}

.hidden {
  display: none !important;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: rgba(7, 10, 14, 0.68);
  color: var(--text);
  backdrop-filter: blur(2px);
}

.status-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 650;
  background: rgba(20, 31, 43, 0.95);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
}

.status-banner.error {
  background: rgba(92, 24, 32, 0.95);
  border-color: rgba(230, 57, 70, 0.55);
}

#right-rail {
  position: absolute;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: 440px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 600;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

#right-rail .rank-panel {
  display: none;
}

#right-rail .detail-panel {
  display: none;
}

#right-rail .detail-panel.visible {
  display: block;
}

.panel {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 24px;
  color: var(--text);
  animation: fadeIn 0.6s ease-out;
  pointer-events: auto;
}

#left-panel {
  position: absolute;
  top: 24px;
  left: 24px;
  width: 340px;
  max-height: calc(100vh - 84px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.title-block h1 {
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 10px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.2px;
}

/* Mobile-only disclosure toggles — hidden on desktop; revealed inside the ≤720px media query */
.info-toggle,
.route-options-toggle {
  display: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border 0.2s ease, transform 0.2s ease;
}

.info-toggle:hover,
.route-options-toggle:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.context-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.context-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0;
}

.context-row strong {
  color: var(--text);
}

.ops-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(32, 47, 59, 0.78);
  border: 1px solid rgba(141, 202, 208, 0.22);
}

.ops-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ops-mode {
  margin-top: 5px;
  font-size: 16px;
  font-weight: 700;
}

.ops-focus {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.toggles {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.slider {
  position: relative;
  width: 42px;
  height: 22px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.toggle input:checked + .slider {
  background: rgba(248, 244, 180, 0.5);
}

.toggle input:checked + .slider::after {
  transform: translateX(20px);
}

.toggle input:focus-visible + .slider {
  outline: 2px solid rgba(248, 244, 180, 0.9);
  outline-offset: 2px;
}

.toggle-label {
  color: var(--text);
  font-weight: 500;
}

.legend {
  margin-top: auto;
  padding-top: 18px;
}

.legend-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.legend-bar {
  margin-top: 10px;
  height: 120px;
  width: 12px;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    var(--accent-purple) 0%,
    var(--accent-red) 35%,
    var(--accent-orange) 65%,
    var(--accent-yellow) 100%
  );
}

.legend-labels {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.legend-call-group {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.legend-call {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot--open {
  background: rgba(244, 162, 97, 0.7);
  border: 1px solid rgba(248, 244, 180, 0.65);
  box-shadow: 0 0 8px rgba(244, 162, 97, 0.45);
}

.legend-dot--closed {
  background: rgba(100, 116, 139, 0.78);
  border: 1px solid rgba(203, 213, 225, 0.68);
  box-shadow: 0 0 8px rgba(148, 163, 184, 0.3);
}

.detail-panel {
  width: 100%;
  flex: 0 0 auto;
  max-height: 46vh;
  min-height: 0;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.detail-panel {
  padding: 18px;
}

.detail-panel.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-zip {
  font-size: 28px;
  font-weight: 700;
}

.detail-name {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}

.detail-name.is-empty {
  display: none;
}


.score-badge {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--accent-purple);
  color: #fff;
  text-align: center;
  transition: background 0.3s ease;
}

.score-value {
  font-size: 26px;
  font-weight: 700;
}

.score-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-strip {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.score-strip-title {
  font-size: 12px;
  color: var(--muted);
}

.score-strip-value {
  font-size: 18px;
  font-weight: 600;
  margin: 6px 0 10px;
}

.score-strip-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.score-strip-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent-purple);
  transition: width 0.7s ease;
}

.factors {
  margin-top: 20px;
}

.factors-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 12px;
}

.factor {
  margin-bottom: 12px;
}

.factor-label {
  font-size: 13px;
  margin-bottom: 6px;
}

.factor-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.factor-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent-orange);
  transition: width 0.7s ease;
}

.ai-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(90, 24, 154, 0.16);
  border: 1px solid rgba(90, 24, 154, 0.35);
}

.ai-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.ai-box p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.rank-panel {
  width: 100%;
  max-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 0 0 auto;
  min-height: 0;
}

.route-panel {
  width: 100%;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border-color: rgba(141, 202, 208, 0.24);
}

#right-rail.zip-detail-mode .route-panel {
  display: none;
}

#right-rail.zip-detail-mode .detail-panel.visible {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  max-height: none;
  overflow-y: auto;
}

.route-collapsed-tab {
  display: none;
  width: 100%;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: rgba(248, 244, 180, 0.28);
  text-align: left;
  cursor: pointer;
}

#right-rail.zip-detail-mode .route-collapsed-tab {
  display: flex;
  padding: 16px 18px;
}

.route-collapsed-tab span {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.route-collapsed-tab strong {
  color: var(--accent-yellow);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.route-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.route-title {
  font-size: 18px;
  font-weight: 600;
}

.route-subtitle {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.route-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 120px;
  max-height: 360px;
}

.route-summary {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.16);
  color: #d8fbff;
  font-size: 12px;
  line-height: 1.4;
}

.route-start-section {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.route-field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.route-start-optional {
  font-weight: 400;
  opacity: 0.55;
  text-transform: none;
  letter-spacing: 0;
}

.route-start-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
}

.route-start-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
  transition: border 0.2s ease;
}

.route-start-input::placeholder {
  color: rgba(183, 192, 204, 0.5);
}

.route-start-input:focus {
  border-color: rgba(34, 211, 238, 0.45);
}

.route-start-search {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  white-space: nowrap;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.route-start-search:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.route-start-search:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.route-start-gps {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.route-start-gps:hover {
  border-color: rgba(34, 211, 238, 0.45);
  color: #22d3ee;
  transform: translateY(-1px);
}

.route-start-gps.is-loading {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.route-start-suggestions {
  list-style: none;
  margin: 0;
  padding: 4px;
  background: rgba(17, 24, 33, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  max-height: 220px;
  overflow-y: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.route-start-suggestion {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  display: grid;
  gap: 2px;
}

.route-start-suggestion:hover,
.route-start-suggestion.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.route-start-suggestion-primary {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-start-suggestion-secondary {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.route-start-status {
  font-size: 11px;
  color: var(--muted);
  min-height: 16px;
  transition: color 0.2s ease;
}

.route-start-status.is-resolved {
  color: #22d3ee;
}

.route-start-status.is-error {
  color: var(--accent-red);
}

.route-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.route-field,
.route-check {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.route-field-wide {
  grid-column: 1 / -1;
}

.route-field select,
.route-stops-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 9px;
  font: inherit;
}

.route-stops-input::-webkit-inner-spin-button,
.route-stops-input::-webkit-outer-spin-button {
  opacity: 0.4;
  cursor: pointer;
}

.route-stops-input:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.45);
}

.route-check {
  grid-template-columns: 16px 1fr;
  align-items: center;
  min-height: 28px;
}

.route-check input {
  accent-color: #22d3ee;
}

.route-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
}

.route-calculate {
  width: auto;
  min-height: 40px;
  border: 1px solid rgba(248, 244, 180, 0.5);
  border-radius: 8px;
  background: rgba(248, 244, 180, 0.16);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.route-calculate:hover {
  border-color: rgba(248, 244, 180, 0.8);
  background: rgba(248, 244, 180, 0.23);
  transform: translateY(-1px);
}

.route-calculate:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.route-clear {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  white-space: nowrap;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.route-clear:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.route-clear:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.route-item {
  display: grid;
  grid-template-columns: 24px 1fr 36px;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 10px;
  text-align: left;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.route-item:hover {
  border-color: rgba(141, 202, 208, 0.35);
  transform: translateY(-1px);
}

.route-item.active {
  border-color: rgba(248, 244, 180, 0.85);
  box-shadow: inset 0 0 0 1px rgba(248, 244, 180, 0.25);
}

.route-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(141, 202, 208, 0.18);
  color: #d8fbff;
  font-size: 11px;
  font-weight: 700;
}

.route-main {
  min-width: 0;
}

.route-address {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.route-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.route-tags,
.route-popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.route-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #f4f7fb;
  background: rgba(255, 255, 255, 0.1);
}

.route-tag--new {
  background: rgba(37, 99, 235, 0.5);
}

.route-tag--known {
  background: rgba(71, 85, 105, 0.75);
}

.route-tag--repeat,
.route-tag--open {
  background: rgba(230, 57, 70, 0.58);
}

.route-tag--single {
  background: rgba(20, 184, 166, 0.42);
}

.route-tag--resource {
  background: rgba(5, 150, 105, 0.68);
}

.route-tag--subway {
  background: rgba(8, 145, 178, 0.7);
}

.route-priority {
  justify-self: end;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 244, 180, 0.9);
  color: #231a07;
  font-size: 12px;
  font-weight: 800;
}

.route-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.route-stop-detail {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

.route-stop-detail-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.stop-detail-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.stop-detail-kicker {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.stop-detail-title {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.stop-detail-score {
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 244, 180, 0.9);
  color: #231a07;
  font-weight: 800;
  font-size: 13px;
}

.stop-detail-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.stop-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.stop-detail-row strong {
  color: var(--text);
  text-align: right;
}

.tag-definitions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tag-definition {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.rank-panel.expanded {
  flex: 1 1 auto;
  max-height: none;
}

.rank-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.rank-title {
  font-size: 14px;
  font-weight: 600;
}

.rank-subtitle {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.rank-toggle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.rank-toggle:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.rank-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

.rank-item {
  display: grid;
  grid-template-columns: 24px 1fr 64px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.rank-item:hover {
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.rank-item.active {
  border-color: rgba(248, 244, 180, 0.6);
}

.rank-number {
  font-size: 12px;
  color: var(--muted);
}

.rank-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rank-zip {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.rank-borough {
  font-size: 11px;
  color: var(--muted);
}

.rank-score {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.rank-score span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.rank-score span.rank-score-badge--low {
  background: #f8f4b4;
  color: #231a07;
}

.rank-score span.rank-score-badge--elevated {
  background: #f4a261;
  color: #fff;
}

.rank-score span.rank-score-badge--high {
  background: #e63946;
  color: #fff;
}

.rank-score span.rank-score-badge--critical {
  background: #5a189a;
  color: #fff;
}

#footer {
  position: absolute;
  left: 24px;
  bottom: 18px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  z-index: 600;
}

.leaflet-container {
  background: #0b1217;
}

.zip-shape {
  transition: fill 0.2s ease, stroke 0.2s ease, fill-opacity 0.2s ease;
}

.leaflet-tooltip.zip-tooltip {
  background: rgba(15, 20, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.call-point {
  filter: drop-shadow(0 0 6px rgba(244, 162, 97, 0.35));
  cursor: pointer;
  transition: opacity 0.2s ease, fill-opacity 0.2s ease;
}

.call-point:hover {
  filter: drop-shadow(0 0 10px rgba(248, 244, 180, 0.6));
}

.leaflet-popup.call-popup .leaflet-popup-content-wrapper {
  background: rgba(15, 20, 26, 0.95);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.leaflet-popup.call-popup .leaflet-popup-tip {
  background: rgba(15, 20, 26, 0.95);
}

.route-stop-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(248, 244, 180, 0.92);
  border: 2px solid rgba(35, 26, 7, 0.85);
  color: #231a07;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}


.route-stop-marker.active {
  background: #e63946;
  border-color: #f8f4b4;
  color: #fff;
}

.route-stop-marker span {
  font-size: 12px;
  font-weight: 800;
}

.call-popup-content {
  display: grid;
  gap: 4px;
  min-width: 220px;
  max-width: 310px;
}

.call-popup-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.call-popup-row {
  display: grid;
  gap: 2px;
}

.call-popup-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.call-popup-value {
  font-size: 12px;
  color: var(--text);
}

.route-popup-definitions {
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  #left-panel {
    width: 300px;
    left: 16px;
    top: 16px;
  }

  #right-rail {
    right: 16px;
    top: 16px;
    bottom: 16px;
    width: 360px;
  }

  .rank-panel {
    max-height: 240px;
  }

  #footer {
    left: 16px;
  }
}

@media (max-width: 720px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  #app {
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .loading-overlay {
    position: fixed;
    z-index: 900;
  }

  .status-banner {
    order: 2;
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    transform: none;
    margin: 0 12px;
    border-radius: 12px;
    text-align: center;
    z-index: 950;
  }

  .panel {
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  }

  #left-panel {
    order: 1;
    position: relative;
    width: auto;
    top: auto;
    left: auto;
    margin: 0 12px;
  }

  .title-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .title-block h1 {
    font-size: 18px;
    margin-bottom: 0;
  }

  .subtitle {
    display: none;
  }

  .info-toggle,
  .route-options-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }

  #left-panel.info-collapsed .left-panel-body {
    display: none;
  }

  .route-options-toggle {
    margin-top: 14px;
  }

  .route-settings.collapsed {
    display: none;
  }

  .context-box {
    margin-top: 12px;
    padding: 12px;
  }

  .ops-box {
    margin-top: 12px;
    padding: 12px;
  }

  .context-row {
    margin: 4px 0;
    font-size: 12px;
  }

  .toggles {
    margin-top: 14px;
    gap: 10px;
  }

  .toggle {
    align-items: flex-start;
    gap: 10px;
  }

  .toggle-label {
    font-size: 13px;
    line-height: 1.3;
  }

  .legend {
    margin-top: 14px;
  }

  .legend-bar {
    height: 8px;
    width: 100%;
    background: linear-gradient(
      90deg,
      var(--accent-yellow) 0%,
      var(--accent-orange) 35%,
      var(--accent-red) 65%,
      var(--accent-purple) 100%
    );
  }

  .legend-labels {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    font-size: 10px;
  }

  .legend-call-group {
    margin-top: 10px;
    gap: 6px;
  }

  .legend-call {
    font-size: 11px;
  }

  #map {
    order: 3;
    width: calc(100% - 24px);
    height: min(56vh, 420px);
    min-height: 270px;
    margin: 0 12px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  #right-rail {
    order: 4;
    position: relative;
    width: auto;
    margin: 0 12px;
    top: auto;
    right: auto;
    bottom: auto;
    gap: 12px;
  }

  .detail-panel {
    max-height: none;
    overflow: visible;
  }

  .detail-header {
    align-items: flex-start;
    gap: 12px;
  }

  .detail-zip {
    font-size: 24px;
  }

  .score-badge {
    width: 74px;
    height: 74px;
  }

  .score-value {
    font-size: 22px;
  }

  .score-strip {
    margin-top: 14px;
    padding: 12px;
  }

  .factors {
    margin-top: 16px;
  }

  .factor-label {
    font-size: 12px;
  }

  .ai-box {
    margin-top: 14px;
    padding: 12px;
  }

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

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

  .rank-subtitle,
  .route-subtitle {
    display: none;
  }

  .rank-toggle,
  .route-toggle {
    font-size: 12px;
    padding: 9px 14px;
  }

  .rank-list {
    gap: 8px;
    padding-right: 0;
    max-height: none;
  }

  .route-list {
    gap: 8px;
    padding-right: 0;
    max-height: none;
  }

  .route-settings {
    grid-template-columns: 1fr;
  }

  .route-item {
    grid-template-columns: 24px 1fr 36px;
    gap: 8px;
    padding: 10px;
  }

  .rank-item {
    grid-template-columns: 24px 1fr 56px;
    gap: 8px;
    padding: 10px;
  }

  .rank-zip {
    font-size: 13px;
  }

  .rank-borough {
    font-size: 10px;
  }

  .rank-score span {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .route-start-input,
  .route-start-search,
  .route-start-gps,
  #route-focus-borough,
  #route-max-stops,
  #route-borough-penalty,
  .route-calculate,
  .route-clear {
    min-height: 44px;
  }

  #footer {
    order: 5;
    position: relative;
    left: auto;
    bottom: auto;
    margin: 0 12px;
    font-size: 10px;
  }
}

@media (max-width: 440px) {
  .panel {
    padding: 14px;
  }

  .title-block h1 {
    font-size: 17px;
  }

  .rank-list {
    max-height: none;
  }

  .route-list {
    max-height: none;
  }
}

/* ------------------------------------------------------------------ */
/* Predicted mode                                                      */
/* ------------------------------------------------------------------ */

.predicted-controls {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.predicted-controls.hidden { display: none; }

.horizon-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.horizon-row .route-select,
.horizon-row select {
  flex: 1;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
}

.scrub-btn {
  width: 26px;
  height: 26px;
  font-size: 15px;
  line-height: 1;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  cursor: pointer;
}

.scrub-btn:hover { border-color: rgba(248, 244, 180, 0.5); color: #f8f4b4; }

.block-window {
  flex: 1;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
}

.volume-badge {
  padding: 6px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.55);
  border-left: 2px solid rgba(148, 163, 184, 0.5);
  border-radius: 4px;
}

.volume-badge.is-low  { border-left-color: #60a5fa; }
.volume-badge.is-high { border-left-color: #f4a261; }

.model-note {
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.45;
  color: #94a3b8;
}

/* Driver bars replace the fixed factor bars in predicted mode. */

.driver-list { display: flex; flex-direction: column; gap: 7px; }

.driver-header {
  font-size: 11.5px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 2px;
}

.driver-empty { font-size: 11px; color: #94a3b8; }

.driver-row {
  display: grid;
  grid-template-columns: 1fr 58px 40px;
  align-items: center;
  gap: 7px;
}

.driver-label { font-size: 10.5px; color: #cbd5e1; }

.driver-bar {
  height: 5px;
  background: rgba(148, 163, 184, 0.16);
  border-radius: 3px;
  overflow: hidden;
}

.driver-fill { height: 100%; border-radius: 3px; transition: width 320ms ease; }
.driver-row.is-positive .driver-fill { background: #f4a261; }
.driver-row.is-negative .driver-fill { background: #60a5fa; }

.driver-amount {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #94a3b8;
}

/* Model scorecard */

.scorecard { margin-top: 10px; border-top: 1px solid rgba(148, 163, 184, 0.14); padding-top: 8px; }

.scorecard-toggle {
  width: 100%;
  padding: 5px 0;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  color: #94a3b8;
  background: none;
  border: 0;
  cursor: pointer;
}

.scorecard-toggle:hover { color: #f8f4b4; }
.scorecard-body.hidden { display: none; }

.scorecard-intro,
.scorecard-caveat {
  font-size: 10.5px;
  line-height: 1.5;
  color: #94a3b8;
  margin: 4px 0 8px;
}

.scorecard-subtitle {
  font-size: 10.5px;
  font-weight: 600;
  color: #cbd5e1;
  margin: 10px 0 5px;
}

.scorecard-rows { display: flex; flex-direction: column; gap: 5px; }

.scorecard-row {
  display: grid;
  grid-template-columns: 1fr 60px 38px;
  align-items: center;
  gap: 7px;
}

.scorecard-label { font-size: 10.5px; color: #cbd5e1; }

.scorecard-track {
  height: 5px;
  background: rgba(148, 163, 184, 0.16);
  border-radius: 3px;
  overflow: hidden;
}

.scorecard-fill { height: 100%; background: rgba(148, 163, 184, 0.65); border-radius: 3px; }
.scorecard-row.is-model .scorecard-fill { background: #f8f4b4; }
.scorecard-row.is-model .scorecard-label { color: #f8f4b4; font-weight: 600; }

.scorecard-value {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #94a3b8;
}

/* The open/closed dot key describes observed 311 records only. */
body:not(.mode-observed) .call-status-key { display: none; }

/* Open/new-location prioritisation only exists for observed 311 records --
   predicted stops carry no open/closed status. */
body:not(.mode-observed) .observed-only { display: none; }

/* ------------------------------------------------------------------ */
/* Observed (v1) corner toggle                                         */
/* Deliberately small and out of the way: v1 shows 20-44h-old data and  */
/* exists for comparison, not for daily use.                           */
/* ------------------------------------------------------------------ */

.mode-v1-toggle {
  flex-shrink: 0;
  padding: 5px 11px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.mode-v1-toggle:hover {
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.5);
}

.mode-v1-toggle.is-active {
  color: #f8f4b4;
  border-color: rgba(248, 244, 180, 0.55);
  background: rgba(248, 244, 180, 0.12);
}

/* ------------------------------------------------------------------ */
/* Predicted hotspot popup                                             */
/* ------------------------------------------------------------------ */

.predicted-popup { min-width: 246px; max-width: 288px; }

.predicted-popup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.predicted-popup-sub {
  margin-top: 2px;
  font-size: 10.5px;
  color: #94a3b8;
}

.predicted-popup-score {
  flex-shrink: 0;
  min-width: 32px;
  padding: 4px 7px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
  border-radius: 6px;
}

.predicted-popup-mix {
  margin-bottom: 7px;
  padding-bottom: 6px;
  font-size: 10px;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.predicted-popup-why {
  margin: 9px 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e2e8f0;
}

.predicted-popup-driver {
  display: grid;
  grid-template-columns: 1fr 46px 38px;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.predicted-popup-driver-label { font-size: 10px; color: #cbd5e1; }

.predicted-popup-driver-bar {
  display: block;
  height: 4px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 2px;
  overflow: hidden;
}

.predicted-popup-driver-bar > span { display: block; height: 100%; border-radius: 2px; }
.predicted-popup-driver.is-positive .predicted-popup-driver-bar > span { background: #f4a261; }
.predicted-popup-driver.is-negative .predicted-popup-driver-bar > span { background: #60a5fa; }

.predicted-popup-driver-amount {
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #94a3b8;
}

.predicted-popup-note {
  margin-top: 8px;
  padding-top: 7px;
  font-size: 9.5px;
  line-height: 1.45;
  color: #94a3b8;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.footer-stamps { display: flex; flex-direction: column; gap: 4px; }

/* ------------------------------------------------------------------ */
/* Collapsed route panel (predicted-mode default)                      */
/* Routing leads in the observed view but is secondary in the forecast, */
/* where the map and horizon controls carry the message.               */
/* ------------------------------------------------------------------ */

#right-rail.route-collapsed .route-panel {
  display: none;
}

#right-rail.route-collapsed .route-collapsed-tab {
  display: flex;
  padding: 16px 18px;
}

.route-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.route-hide {
  opacity: 0.72;
}

.route-hide:hover {
  opacity: 1;
}

/* A stratum where the model trails the baseline -- shown, not hidden. */
.scorecard-row.is-behind .scorecard-fill { background: rgba(148, 163, 184, 0.4); }
.scorecard-row.is-behind .scorecard-value { color: #f4a261; }

/* Darkens the OpenStreetMap raster basemap to match the app's palette. Only
   applied when no CARTO API key is configured -- CARTO's dark_all needs no
   filtering. Kept off the Leaflet overlay panes so the choropleth, markers and
   route lines keep their true colours. */
.basemap-dark .leaflet-tile {
  filter: invert(1) hue-rotate(180deg) brightness(0.62) contrast(0.68) saturate(0.25);
}

.predicted-popup-mix-caption {
  margin-bottom: 3px;
  font-size: 9.5px;
  line-height: 1.35;
  color: #94a3b8;
}

/* Borough filter: multi-select as chips rather than a <select multiple>, which
   needs cmd-click on desktop and is unusable on mobile. */
.route-field--stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: 1 / -1;
}

.route-field-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #94a3b8;
}

.borough-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.borough-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.borough-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.borough-chip:hover { color: #e2e8f0; border-color: rgba(148, 163, 184, 0.45); }

.borough-chip:has(input:checked) {
  color: #f8f4b4;
  background: rgba(248, 244, 180, 0.14);
  border-color: rgba(248, 244, 180, 0.5);
}

.borough-chip:has(input:focus-visible) { outline: 2px solid rgba(248, 244, 180, 0.6); outline-offset: 1px; }

/* Explicit close for the ZIP summary. Previously the only ways out were the
   route tab or clicking empty map, neither of which reads as "close". */
.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.panel-close:hover {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(148, 163, 184, 0.5);
}

.detail-panel { position: relative; }
/* Keep the close button clear of the score badge. */
.detail-panel .detail-header { padding-right: 30px; }
