:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --panel-green: #ecfdf5;
  --line: #d9e2ec;
  --line-strong: #b8c4d2;
  --text: #10201a;
  --muted: #64748b;
  --muted-strong: #405569;
  --accent: #10b981;
  --accent-strong: #065f46;
  --accent-soft: #d1fae5;
  --accent-border: #8be3bd;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --purple: #a855f7;
  --purple-soft: #f3e8ff;
  --amber: #f59e0b;
  --amber-strong: #8a4a08;
  --amber-border: #f7cf75;
  --amber-soft: #fef3c7;
  --rose: #ef4444;
  --rose-soft: #fee2e2;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.13);
  --soft-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 32rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.72;
}

.search-form[data-mode="area"] #maxDetour:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: 398px minmax(0, 1fr);
}

.app-header {
  grid-column: 1 / -1;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 650;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(14px);
}

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

.app-brand h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.1;
}

.app-brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.96));
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
  box-shadow: 16px 0 45px rgba(31, 47, 34, 0.08);
  z-index: 2;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 2px 3px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: white;
  box-shadow: 0 13px 28px rgba(16, 185, 129, 0.26);
}

.brand-mark.mini {
  width: 40px;
  height: 40px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand h2,
.results-header h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.15;
}

.brand p,
.results-header p,
.status-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mode-switch button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted-strong);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 850;
}

.mode-switch button.is-active {
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.25);
}

.mode-switch button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.search-form {
  display: grid;
  gap: 12px;
}

.form-group,
.status-panel,
.summary-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--soft-shadow);
}

.form-group {
  display: grid;
  gap: 11px;
  padding: 13px;
}

.group-label,
.status-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.group-label svg,
.status-heading svg {
  width: 16px;
  height: 16px;
}

label {
  display: grid;
  gap: 6px;
}

label > span {
  color: var(--muted-strong);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
  transition: border 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.4;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #8da2b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.17);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted-strong) 50%),
    linear-gradient(135deg, var(--muted-strong) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}

.autocomplete-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.3;
  cursor: pointer;
}

.autocomplete-list li svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--muted);
}

.autocomplete-list li .ac-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-list li.is-active,
.autocomplete-list li:hover {
  background: var(--panel-soft);
}

.autocomplete-list li.is-empty,
.autocomplete-list li.is-loading {
  cursor: default;
  color: var(--muted);
  font-size: 0.82rem;
}

.autocomplete-list li.is-empty:hover,
.autocomplete-list li.is-loading:hover {
  background: transparent;
}

.current-location-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-top: 2px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.current-location-button:hover {
  background: var(--panel-soft);
  border-color: var(--accent);
}

.current-location-button:disabled {
  cursor: progress;
  color: var(--muted);
  border-color: var(--line-strong);
  background: transparent;
}

.current-location-button svg {
  width: 14px;
  height: 14px;
}

.field-error {
  color: var(--rose);
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: none;
}

.field-hint {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.check-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check-line input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.check-line > span {
  text-transform: none;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted-strong);
}

.life-list-import {
  display: grid;
  gap: 9px;
}

.life-list-import > div:first-child {
  display: grid;
  gap: 5px;
}

.life-list-import > div:first-child > span {
  color: var(--muted-strong);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.file-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 9px;
}

.file-button,
.file-actions button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 850;
  box-shadow: 0 7px 18px rgba(31, 47, 34, 0.06);
  transition: border 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.file-button {
  cursor: pointer;
}

.file-button:hover,
.file-actions button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 12px 26px rgba(31, 47, 34, 0.12);
  transform: translateY(-1px);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button svg,
.file-actions svg {
  width: 16px;
  height: 16px;
}

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

.number-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.number-field input {
  border-radius: 8px 0 0 8px;
}

.number-field small {
  min-width: 47px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 850;
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px 44px;
  gap: 9px;
}

.actions button,
.ghost-button,
.icon-button,
#closeDetails,
.modal-actions button,
.saved-trip-actions button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 7px 18px rgba(31, 47, 34, 0.06);
  transition: border 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.actions button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: var(--accent);
  color: white;
  font-weight: 850;
  box-shadow: 0 15px 30px rgba(16, 185, 129, 0.24);
}

.actions button:hover,
.ghost-button:hover,
.icon-button:hover,
.modal-actions button:hover,
.saved-trip-actions button:hover,
#closeDetails:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(31, 47, 34, 0.12);
  transform: translateY(-1px);
}

.actions button.primary:hover {
  background: linear-gradient(135deg, #0fba81, #047857);
}

.ghost-button,
.modal-actions button {
  padding: 0 13px;
  font-size: 0.86rem;
  font-weight: 850;
}

.icon-button {
  width: 44px;
  padding: 0;
}

.setup-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  font-weight: 900;
}

.setup-badge svg,
.ghost-button svg,
.icon-button svg,
.modal-actions svg,
.saved-trip-actions svg {
  width: 17px;
  height: 17px;
}

.setup-checking {
  color: var(--muted-strong);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.saved-trip-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
  gap: 9px;
}

.saved-trip-actions button {
  min-height: 40px;
  font-size: 0.82rem;
  font-weight: 850;
}

.saved-trip-actions button:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.saved-trip-actions button:disabled {
  cursor: not-allowed;
}

.saved-trips-status {
  min-height: 1rem;
}

.setup-needed {
  color: var(--amber-strong);
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
}

.setup-ready {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

.actions svg,
.stop-metrics svg,
.empty-state svg,
#closeDetails svg,
.map-glass svg {
  width: 18px;
  height: 18px;
}

.status-panel {
  padding: 13px;
  background: linear-gradient(135deg, rgba(209, 250, 229, 0.78), rgba(219, 234, 254, 0.7));
}

#progressTitle {
  font-weight: 900;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: white;
  border-color: var(--line);
}

.summary-tile {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  align-content: space-between;
}

.summary-panel span {
  display: block;
  font-weight: 900;
  font-size: 1.28rem;
  line-height: 1;
}

.summary-panel small {
  color: var(--muted-strong);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tile-targets {
  background: var(--rose-soft);
  border-color: #fecaca;
  color: #b91c1c;
}

.tile-lifers {
  background: var(--amber-soft);
  border-color: #fde68a;
  color: #b45309;
}

.tile-notable {
  background: var(--purple-soft);
  border-color: #e9d5ff;
  color: #7e22ce;
}

.tile-hotspots {
  background: var(--accent-soft);
  border-color: #a7f3d0;
  color: var(--accent-strong);
}

.tile-ranked {
  background: var(--blue-soft);
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.tile-route {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.tile-budget {
  background: var(--amber-soft);
  border-color: #fde68a;
  color: #b45309;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(420px, 60vh) minmax(290px, 1fr);
  position: relative;
}

.map-region {
  min-height: 0;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  background: #d6e6ee;
}

#map {
  width: 100%;
  height: 100%;
  background: #dbeafe;
}

.leaflet-container {
  font: inherit;
}

.leaflet-control-zoom a {
  color: var(--accent-strong);
}

.leaflet-interactive:focus,
.leaflet-interactive:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.google-html-marker {
  position: absolute;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%);
}

.google-html-marker:focus-visible .bird-marker {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.map-glass {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 450;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.map-glass span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-strong);
  box-shadow: 0 12px 32px rgba(31, 47, 34, 0.15);
  backdrop-filter: blur(12px);
  font-size: 0.82rem;
  font-weight: 850;
}

.legend-dot,
.legend-line {
  display: inline-block;
  flex: 0 0 auto;
}

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

.legend-dot.target {
  background: var(--rose);
}

.legend-dot.lifer {
  background: var(--amber);
}

.legend-dot.notable {
  background: var(--purple);
}

.legend-dot.hotspot {
  background: var(--accent);
}

.legend-dot.pinned,
.marker-pinned {
  background: var(--amber);
}

.legend-line.route {
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: var(--blue);
}

.results-region {
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98)),
    var(--panel);
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
}

.results-header {
  padding: 17px 22px 13px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
}

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tier {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.tier.high,
.marker-high {
  background: var(--accent);
}

.tier.mid,
.marker-mid {
  background: var(--purple);
}

.tier.lifer,
.marker-lifer {
  background: var(--amber);
}

.tier.low,
.marker-low {
  background: var(--rose);
}

.marker-standard {
  background: var(--blue);
}

.insight-strip {
  padding: 14px 22px 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.insight-panel {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.insight-panel div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.insight-panel svg {
  width: 16px;
  height: 16px;
}

.insight-panel p {
  margin: 8px 0 0;
  color: var(--muted-strong);
  font-size: 0.86rem;
  line-height: 1.35;
}

.route-tradeoff-panel {
  margin: 14px 22px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  overflow: hidden;
}

.route-tradeoff-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.route-tradeoff-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.route-tradeoff-kicker svg {
  width: 16px;
  height: 16px;
}

.route-tradeoff-header h3 {
  margin: 7px 0 0;
  font-size: 1rem;
  line-height: 1.25;
}

.route-tradeoff-header p {
  margin: 5px 0 0;
  color: var(--muted-strong);
  font-size: 0.86rem;
  line-height: 1.35;
}

.route-tradeoff-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.route-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px;
}

.route-choice-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.route-choice-card-birding {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.route-choice-card span,
.route-choice-card small {
  display: block;
}

.route-choice-card span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.route-choice-card b {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text);
  font-size: 1.18rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-choice-card small {
  margin-top: 5px;
  color: var(--muted-strong);
  font-size: 0.78rem;
  line-height: 1.25;
}

.budget-unlocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(154px, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.budget-unlock {
  min-width: 0;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

button.budget-unlock {
  cursor: pointer;
}

button.budget-unlock:hover,
button.budget-unlock:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.budget-unlock.is-current {
  border-color: var(--amber-border);
  background: #fffbeb;
}

.budget-unlock.is-empty {
  background: var(--panel-soft);
  color: var(--muted);
}

.budget-unlock span,
.budget-unlock b,
.budget-unlock small {
  display: block;
}

.budget-unlock span {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.budget-unlock b {
  margin-top: 5px;
  overflow: hidden;
  font-size: 0.86rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-unlock small {
  margin-top: 4px;
  color: var(--muted-strong);
  font-size: 0.76rem;
  line-height: 1.25;
}

.itinerary-builder {
  margin: 14px 22px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.itinerary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.itinerary-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.itinerary-heading svg {
  width: 16px;
  height: 16px;
}

.itinerary-builder > p {
  margin: 8px 0 10px;
  color: var(--muted-strong);
  font-size: 0.86rem;
}

.itinerary-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.itinerary-stats div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 8px 10px;
}

.itinerary-stats small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.itinerary-stats b {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.itinerary-list {
  display: grid;
  gap: 7px;
}

.itinerary-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 12px;
  text-align: center;
  font-size: 0.84rem;
  font-weight: 750;
}

.itinerary-stop {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fffbeb);
  padding: 7px;
}

.itinerary-rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--amber);
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
}

.itinerary-name {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.itinerary-stop-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.itinerary-controls {
  display: flex;
  gap: 4px;
}

.itinerary-controls button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: white;
  color: var(--muted-strong);
}

.itinerary-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.itinerary-controls svg {
  width: 15px;
  height: 15px;
}

.comparison-panel {
  margin: 14px 22px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  overflow: hidden;
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.92));
}

.comparison-header h3 {
  margin: 0;
  font-size: 0.98rem;
}

.comparison-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.comparison-content {
  overflow-x: auto;
}

.comparison-empty {
  min-height: 118px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.comparison-empty svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.comparison-table {
  min-width: 560px;
  display: grid;
  align-items: stretch;
}

.comparison-label,
.comparison-stop,
.comparison-cell {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 11px;
}

.comparison-label {
  color: var(--muted-strong);
  background: var(--panel-soft);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.comparison-sticky {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom-color: var(--line-strong);
}

.comparison-stop {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: start;
  gap: 8px;
  background: white;
}

.comparison-stop b {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.comparison-remove {
  width: 30px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel-soft);
}

.comparison-remove:hover,
.comparison-remove:focus-visible {
  color: var(--rose);
  border-color: var(--rose-soft);
  background: #fff5f5;
}

.comparison-remove:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.comparison-remove svg {
  width: 15px;
  height: 15px;
}

.comparison-cell {
  min-width: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.87rem;
  line-height: 1.35;
}

.comparison-cell b,
.comparison-cell small {
  display: block;
}

.comparison-cell small {
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.comparison-score {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.comparison-score span {
  display: grid;
  gap: 3px;
}

.comparison-score span > i {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(184, 196, 178, 0.34);
}

.comparison-score span > i > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.results-list {
  padding: 16px 22px 26px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  align-content: start;
}

.results-list.empty {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
}

.empty-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--muted);
  gap: 10px;
  text-align: center;
}

.empty-state svg {
  width: 44px;
  height: 44px;
  color: var(--accent);
}

.stop-card {
  border: 1px solid rgba(216, 223, 211, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  overflow: hidden;
  box-shadow: var(--soft-shadow);
  transition: border 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.stop-card:hover,
.stop-card.is-selected {
  border-color: rgba(16, 185, 129, 0.65);
  box-shadow: 0 18px 42px rgba(31, 47, 34, 0.13);
  transform: translateY(-1px);
}

.stop-card.is-selected {
  outline: 3px solid rgba(16, 185, 129, 0.16);
}

.stop-card.is-pinned {
  border-color: var(--amber-border);
}

.stop-main {
  width: 100%;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 13px;
  text-align: left;
}

.rank {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: white;
  font-weight: 900;
}

.stop-copy {
  min-width: 0;
}

.stop-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}

.stop-preview {
  display: block;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
}

.stop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.stop-chip {
  min-height: 23px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.chip-target {
  background: var(--rose-soft);
  color: #b91c1c;
}

.chip-lifer {
  background: var(--amber-soft);
  color: #b45309;
}

.chip-notable {
  background: var(--purple-soft);
  color: #7e22ce;
}

.chip-hotspot {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.score-pill {
  min-width: 58px;
  border-radius: 999px;
  padding: 6px 9px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: white;
  text-align: center;
  font-weight: 900;
  font-size: 0.88rem;
  box-shadow: 0 10px 20px rgba(31, 122, 84, 0.2);
}

.stop-reason {
  display: grid;
  gap: 4px;
  padding: 0 13px 12px 66px;
  margin-top: -3px;
}

.stop-reason span,
.reason-line h4 {
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.stop-reason p,
.reason-line p,
.report .report-stop .report-stop-reason {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.stop-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.stop-metrics span {
  min-width: 0;
  padding: 10px 6px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(180deg, rgba(248, 250, 244, 0.65), rgba(255, 255, 255, 0.92));
  font-size: 0.82rem;
}

.stop-links {
  display: flex;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}

.stop-links a,
.stop-links button {
  flex: 1 1 0;
  border: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 800;
}

.stop-links button {
  color: var(--muted-strong);
}

.stop-links button.is-active {
  color: var(--amber-strong);
  background: var(--amber-soft);
}

.stop-links .compare-toggle.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.stop-links button:disabled {
  cursor: not-allowed;
}

.stop-links a:hover,
.stop-links button:hover:not(:disabled) {
  background: var(--accent-soft);
}

.stop-links svg {
  width: 15px;
  height: 15px;
}

.stop-metrics b {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(460px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(216, 223, 211, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 500;
  padding: 16px;
  backdrop-filter: blur(16px);
}

#closeDetails {
  position: sticky;
  top: 0;
  margin-left: auto;
  width: 38px;
  min-height: 38px;
  z-index: 1;
}

.details-panel h3 {
  margin: 0 44px 4px 0;
  font-size: 1.22rem;
  line-height: 1.2;
}

.detail-subtitle {
  color: var(--muted);
  margin: 0 0 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 12px 0;
}

.detail-grid div,
.score-line,
.reason-line,
.species-list,
.warning {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.92);
}

.detail-grid div {
  padding: 11px;
}

.detail-grid b {
  display: block;
  font-size: 1.08rem;
}

.detail-grid small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-line {
  padding: 11px;
  margin: 10px 0;
}

.reason-line {
  padding: 11px;
  margin: 10px 0;
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.score-line h4,
.reason-line h4,
.species-list h4 {
  margin: 0 0 9px;
}

.score-bars,
.impact-list {
  display: grid;
  gap: 8px;
}

.impact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.86rem;
  font-weight: 700;
}

.impact-row b {
  color: var(--text);
}

.score-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 750;
}

.score-row b {
  text-align: right;
  color: var(--text);
}

.score-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(184, 196, 178, 0.34);
}

.score-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.species-list {
  padding: 11px;
  margin-top: 10px;
}

.species-list ul {
  margin: 0;
  padding-left: 18px;
}

.species-list li {
  margin: 4px 0;
}

.species-list small {
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.detail-actions a,
.detail-actions button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--accent-strong);
  background: white;
  text-decoration: none;
  padding: 9px 11px;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(31, 47, 34, 0.07);
}

.detail-actions button {
  cursor: pointer;
}

.detail-actions .detail-pin {
  color: var(--amber-strong);
  background: var(--amber-soft);
  border-color: var(--amber-border);
}

.warning {
  padding: 11px;
  color: #70450f;
  background: #fff3df;
  border-color: #efd09d;
}

.warning-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.warning-heading svg {
  width: 16px;
  height: 16px;
}

#warningPanel p {
  margin: 6px 0 0;
  color: #70450f;
  font-size: 0.86rem;
}

.bird-marker {
  width: 32px;
  height: 32px;
  border: 3px solid white;
  border-radius: 999px;
  box-shadow: 0 4px 13px rgba(0, 0, 0, 0.32);
  position: relative;
  display: grid;
  place-items: center;
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
}

.bird-marker::after {
  display: none;
}

.marker-selected {
  outline: 4px solid rgba(59, 130, 246, 0.28);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  padding: 22px;
  background: rgba(15, 23, 42, 0.38);
  display: grid;
  place-items: center;
}

.quick-start-modal {
  width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  padding: 22px;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 14px;
  right: 14px;
}

.modal-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.quick-start-modal h2 {
  margin: 14px 48px 16px 0;
  font-size: 1.5rem;
  line-height: 1.15;
}

.quick-steps {
  display: grid;
  gap: 10px;
}

.quick-steps div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 3px 10px;
  background: var(--panel-soft);
}

.quick-steps b {
  grid-row: span 2;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
}

.quick-steps span {
  font-weight: 900;
}

.quick-steps p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.88rem;
  line-height: 1.35;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.modal-actions .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

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

  .app-header,
  .sidebar,
  .workspace {
    grid-column: 1;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 38px rgba(31, 47, 34, 0.08);
  }

  .workspace {
    grid-template-rows: 420px minmax(360px, auto);
  }

  .insight-strip {
    grid-template-columns: 1fr;
  }

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

  .route-tradeoff-actions {
    justify-content: flex-start;
  }

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

}

@media (max-width: 700px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .sidebar {
    padding: 14px;
  }

  .brand h2,
  .app-brand h1 {
    font-size: 1.08rem;
  }

  .control-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .actions {
    grid-template-columns: 1fr repeat(3, 42px);
  }

  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend {
    flex-wrap: wrap;
  }

  .results-list {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .route-tradeoff-panel,
  .itinerary-builder {
    margin: 14px 14px 0;
  }

  .route-tradeoff-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .budget-unlocks {
    grid-template-columns: 1fr;
  }

  .itinerary-stats {
    grid-template-columns: 1fr;
  }

  .itinerary-stop {
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: stretch;
  }

  .itinerary-stop-meta {
    grid-column: 2;
    white-space: normal;
  }

  .itinerary-controls {
    grid-column: 1 / -1;
  }

  .itinerary-controls button {
    flex: 1 1 0;
  }

  .stop-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .map-glass {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .score-row {
    grid-template-columns: 88px minmax(0, 1fr) 34px;
  }

  .quick-start-modal {
    padding: 18px;
  }
}

.report {
  display: none;
}

.report h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}

.report .report-sub {
  color: var(--muted);
  margin: 0 0 18px;
}

.report h2 {
  font-size: 1.05rem;
  margin: 22px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-strong);
}

.report .report-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 22px 0 8px;
  border-bottom: 1px solid var(--line-strong);
}

.report .report-section-heading h2 {
  margin: 0;
  border-bottom: 0;
}

.report .report-section-heading a {
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 800;
}

.report .report-params,
.report .report-route,
.report .report-stop-route {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 18px;
  margin: 0;
}

.report .report-stop-route {
  grid-template-columns: minmax(120px, 0.6fr) repeat(2, minmax(0, 1fr));
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.report .report-params div,
.report .report-route div,
.report .report-stop-route div {
  font-size: 0.9rem;
}

.report .report-params dt,
.report .report-route dt,
.report .report-stop-route dt {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 800;
}

.report .report-params dd,
.report .report-route dd,
.report .report-stop-route dd {
  margin: 1px 0 0;
  font-weight: 700;
}

.report .report-stop-route a {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.report .report-map-card {
  break-inside: avoid;
}

.report .report-map {
  width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.report .report-map-bg {
  fill: #eef6f1;
}

.report .report-map-radius {
  fill: rgba(59, 130, 246, 0.11);
  stroke: #3b82f6;
  stroke-dasharray: 7 6;
  stroke-width: 2;
}

.report .report-map-route {
  fill: none;
  stroke: #2563eb;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.report .report-map-stop circle {
  fill: #065f46;
  stroke: white;
  stroke-width: 3;
}

.report .report-map-endpoint rect {
  fill: #10201a;
  stroke: white;
  stroke-width: 3;
}

.report .report-map-stop text,
.report .report-map-endpoint text {
  fill: white;
  font-size: 11px;
  font-weight: 900;
  text-anchor: middle;
}

.report .report-note {
  color: var(--muted-strong);
  font-size: 0.88rem;
  margin: 6px 0 0;
}

.report .report-stop-order,
.report .report-target-list,
.report .report-fallback-list {
  margin: 6px 0 0;
  padding-left: 22px;
  font-size: 0.9rem;
}

.report .report-stop-order li,
.report .report-target-list li,
.report .report-fallback-list li {
  margin: 5px 0;
}

.report .report-stop-order span,
.report .report-target-list span {
  display: block;
  color: var(--muted-strong);
}

.report .report-stop-order a {
  color: var(--accent-strong);
  font-weight: 800;
}

.report .report-stop {
  break-inside: avoid;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
}

.report .report-stop h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.report .report-stop .report-stop-meta {
  color: var(--muted-strong);
  font-size: 0.85rem;
  margin: 0 0 6px;
}

.report .report-stop ul {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 0.85rem;
  columns: 2;
}

.report .report-stop h4 {
  margin: 8px 0 2px;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 700px) {
  .report .report-params,
  .report .report-route,
  .report .report-stop-route {
    grid-template-columns: 1fr;
  }

  .report .report-section-heading {
    display: block;
  }

  .report .report-stop ul {
    columns: 1;
  }
}

@media print {
  body {
    background: white;
  }

  .app-shell {
    display: none !important;
  }

  .report {
    display: block;
    padding: 0;
    color: black;
  }

  .report-stop {
    box-shadow: none;
  }
}
