:root {
  color-scheme: light;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #b45309;
  --surface: #f4f7f6;
  --text: #17211f;
  --white: #ffffff;
  --muted: #5f6f6b;
  --muted-light: #87938f;
  --border: #d9e1df;
  --border-strong: #b9c7c3;
  --control: #eef3f1;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(18, 33, 29, 0.16);
  --topbar-height: 64px;
  --nav-label-line-height: 20px;
  --icon-stroke: 2.25;
  --sidebar-width: 390px;
  --radius: 6px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  font: 14px/1.5 var(--font);
}
.lucide { stroke-width: var(--icon-stroke); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-strong); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.mobile-only { display: none !important; }
.muted { color: var(--muted); }

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: calc(var(--sidebar-width) - 18px);
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 5px;
  background: var(--brand-strong);
  color: #fff;
}
.brand-mark svg { width: 17px; height: 17px; stroke-width: var(--icon-stroke); }
.search-wrap {
  position: relative;
  width: min(520px, 45vw);
}
.search-wrap > svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
  stroke-width: var(--icon-stroke);
  transform: translateY(-50%);
}
.search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 42px 0 39px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
}
.search-wrap input:focus,
.control select:focus,
.control input:focus,
.input-action input:focus,
.note-input:focus {
  border-color: var(--brand);
  outline: 3px solid color-mix(in srgb, var(--brand) 15%, transparent);
}
.search-wrap kbd {
  position: absolute;
  top: 9px;
  right: 9px;
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--control);
  font: 11px/17px var(--font);
  text-align: center;
}
.topbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
/* Keep nav labels on one line box; center icons independently of the baseline. */
.topbar-actions .button {
  line-height: var(--nav-label-line-height);
  white-space: nowrap;
}
.topbar-actions .button > span:not(.button-count) { line-height: inherit; }
.button, .icon-btn, .text-button {
  border: 0;
  cursor: pointer;
}
.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 750;
  text-decoration: none;
}
.button svg {
  flex: none;
  width: 16px;
  height: 16px;
  stroke-width: var(--icon-stroke);
}
.button.primary { background: var(--brand-strong); color: #fff; }
.button.primary:hover { background: var(--brand); }
.button.secondary {
  border-color: var(--border);
  background: var(--white);
  color: var(--text);
}
.button.secondary:hover { border-color: var(--brand); background: var(--control); }
.button-count {
  min-width: 19px;
  padding: 1px 5px;
  border-radius: 9px;
  background: var(--control);
  color: var(--muted);
  font-size: 11px;
}
.primary .button-count { background: rgba(255,255,255,.17); color: #fff; }
.icon-btn {
  display: inline-grid;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
}
.icon-btn:hover { border-color: var(--brand); background: var(--control); }
.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: var(--icon-stroke);
}
.text-button {
  padding: 2px 0;
  background: transparent;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}
.full-width { width: 100%; }

.workspace {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}
.sidebar {
  z-index: 12;
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--white);
}
.sidebar-head {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  margin-bottom: 5px;
  color: var(--brand-strong);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.sidebar-head h1 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.35;
}
.filter-section {
  padding: 15px 20px 17px;
  border-bottom: 1px solid var(--border);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}
.section-heading h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
}
.section-heading > span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.control { min-width: 0; }
.control.wide { grid-column: 1 / -1; }
.control label, .toggle-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.control select {
  width: 100%;
  height: 34px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--white);
  color: var(--text);
  font-size: 12px;
}
.range-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.range-heading output { color: var(--brand-strong); }
.control input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}
.toggle-control {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  min-height: 33px;
}
.toggle-control .toggle-label { margin: 0; color: var(--text); font-size: 12px; }
.switch {
  position: relative;
  width: 36px;
  height: 20px;
}
.switch input { position: absolute; opacity: 0; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--border-strong);
  cursor: pointer;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .16s ease;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.results-section {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding-top: 15px;
}
.results-section .section-heading { padding: 0 20px; }
.results-list { min-height: 0; overflow-y: auto; }
.result-row {
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.result-row:hover, .result-row.active { background: var(--control); }
.result-row.active { box-shadow: inset 3px 0 0 var(--brand); }
.result-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.result-title strong { font-size: 13px; line-height: 1.35; }
.score {
  display: inline-flex;
  min-width: 35px;
  height: 25px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--score-color, var(--brand));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.result-location {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 11px;
}
.result-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  color: var(--muted);
  font-size: 11px;
}
.result-facts span { white-space: nowrap; }
.empty-state {
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
}

.map-region { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #e8efed; }
.map-modes {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  max-width: calc(100% - 92px);
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.96);
  box-shadow: 0 7px 24px rgba(20,40,35,.12);
}
.map-modes > span {
  display: block;
  margin: 0 0 5px 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.map-mode-segments {
  display: flex;
  max-width: min(560px, calc(100vw - 520px));
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.map-mode-segments button {
  min-height: 30px;
  flex: 0 1 auto;
  padding: 5px 10px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--white);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}
.map-mode-segments button:last-child { border-right: 0; }
.map-mode-segments button:hover { background: var(--control); color: var(--text); }
.map-mode-segments button.active { background: var(--brand-strong); color: #fff; }
.maplibregl-ctrl-top-right { top: 10px; right: 10px; }
.maplibregl-ctrl-group { border-radius: var(--radius) !important; box-shadow: 0 4px 18px rgba(20,40,35,.14) !important; }
.map-message {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 12px;
  transform: translateX(-50%);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-key {
  position: absolute;
  right: 14px;
  bottom: 28px;
  z-index: 3;
  width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.95);
  box-shadow: 0 7px 24px rgba(20,40,35,.12);
}
.map-key strong {
  display: block;
  margin-bottom: 7px;
  font-size: 10px;
  text-transform: uppercase;
}
.legend-ramp {
  height: 8px;
  border-radius: 4px;
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}
.legend-missing {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
}
.legend-missing i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7a8581;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  visibility: hidden;
  background: rgba(15, 28, 25, .42);
  opacity: 0;
  transition: opacity .18s ease, visibility .18s ease;
}
.backdrop.open { visibility: visible; opacity: 1; }
.drawer {
  position: fixed;
  z-index: 50;
  top: calc(var(--topbar-height) + 12px);
  right: 12px;
  bottom: 12px;
  width: min(430px, calc(100vw - 24px));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 24px));
  transition: transform .22s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-close {
  position: sticky;
  top: 12px;
  z-index: 2;
  float: right;
  margin: 12px 12px -48px 0;
}
.drawer-hero { padding: 27px 24px 19px; border-bottom: 1px solid var(--border); }
.drawer-hero h2 {
  max-width: calc(100% - 45px);
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.24;
}
.drawer-location { margin-bottom: 14px; color: var(--muted); font-size: 12px; }
.drawer-score-row { display: flex; align-items: center; gap: 10px; }
.drawer-score-row .score { min-width: 48px; height: 34px; font-size: 14px; }
.drawer-score-row > span:not(.score) { color: var(--muted); font-size: 11px; }
.drawer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}
.drawer-actions .button { min-width: 0; padding-inline: 8px; }
.detail-section { padding: 18px 24px; border-bottom: 1px solid var(--border); }
.detail-section h3 {
  margin-bottom: 11px;
  font-size: 11px;
  text-transform: uppercase;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.detail-item dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.detail-item dd { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.field-source {
  display: inline-flex;
  margin-left: 4px;
  color: var(--muted-light);
  vertical-align: middle;
}
.field-source svg { width: 12px; height: 12px; }
.lock-panel {
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--control);
  text-align: center;
}
.lock-panel svg { width: 20px; color: var(--accent); }
.lock-panel p { margin: 7px 0 11px; color: var(--muted); font-size: 12px; }
.note-input {
  width: 100%;
  min-height: 72px;
  padding: 9px 10px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sources-list { margin: 0; padding: 0; list-style: none; }
.sources-list li + li { margin-top: 10px; }
.sources-list a { font-weight: 700; text-decoration: none; }
.sources-list span { display: block; color: var(--muted); font-size: 10px; }
.disclaimer {
  margin: 0;
  padding: 16px 24px 22px;
  color: var(--muted);
  font-size: 10px;
}

.modal-backdrop { z-index: 60; }
.modal {
  position: fixed;
  z-index: 61;
  top: 50%;
  left: 50%;
  display: none;
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}
.modal.open { display: block; }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 20px; }
.upgrade-modal { padding: 28px; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.upgrade-modal h2 { margin-bottom: 9px; font-size: 25px; }
.upgrade-price { display: flex; align-items: baseline; gap: 7px; margin-bottom: 13px; }
.upgrade-price strong { font-size: 27px; }
.upgrade-price span { color: var(--muted); font-size: 12px; }
.feature-list { margin: 18px 0 21px; padding: 0; list-style: none; }
.feature-list li { position: relative; padding: 6px 0 6px 25px; }
.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 2px;
  color: var(--brand);
  font-weight: 900;
}
.license-entry { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--border); }
.license-entry label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 750; }
.input-action { display: flex; gap: 7px; }
.input-action input {
  min-width: 0;
  flex: 1;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
#license-message { min-height: 18px; margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.compare-modal { width: min(1060px, calc(100vw - 28px)); }
.compare-content { overflow-x: auto; padding: 0 22px 20px; }
.compare-toolbar { display: flex; justify-content: flex-end; padding: 13px 0; }
.compare-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 12px; }
.compare-table th, .compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare-table thead th { position: sticky; top: 0; background: var(--white); }
.compare-table th:first-child { width: 150px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.compare-name { display: block; max-width: 190px; font-size: 13px; }
.toast {
  position: fixed;
  z-index: 90;
  bottom: 20px;
  left: 50%;
  visibility: hidden;
  padding: 9px 13px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: .18s ease;
}
.toast.open { visibility: visible; opacity: 1; transform: translate(-50%, 0); }

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--control);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(23 33 31 / 9%), transparent);
  transform: translateX(-100%);
  animation: skeleton-shimmer 1.25s ease-in-out infinite;
}
@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-line.sm { height: 9px; }
.sk-line.lg { height: 22px; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.drawer-skeleton-hero { padding: 30px 24px 20px; border-bottom: 1px solid var(--border); }
.drawer-skeleton-section { padding: 20px 24px; }
.sk-score { width: 100%; height: 34px; margin-top: 18px; }
.sk-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 17px; }
.sk-actions .skeleton { height: 38px; }
.sk-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin-top: 14px; }
.sk-detail-grid .skeleton { height: 38px; }

@media (max-width: 900px) {
  .mobile-only { display: inline-grid !important; }
  .topbar { gap: 9px; padding: 0 10px; }
  .brand { min-width: 30px; }
  .brand > span:last-child { display: none; }
  .search-wrap { width: auto; min-width: 0; flex: 1; }
  .topbar-actions .button span:not(.button-count) { display: none; }
  .topbar-actions .button { width: 38px; padding: 0; }
  #saved-button .button-count { display: none; }
  .workspace { display: block; }
  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(390px, calc(100vw - 34px));
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; }
  .map-region { position: absolute; inset: 0; }
  .map-modes { top: 10px; left: 10px; max-width: calc(100% - 75px); }
  .map-mode-segments { max-width: calc(100vw - 105px); }
  .map-key { bottom: 80px; }
  .map-results-button {
    position: absolute;
    z-index: 4;
    bottom: 58px;
    left: 50%;
    display: inline-flex !important;
    min-height: 40px;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 0;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    box-shadow: var(--shadow);
    font-weight: 750;
    transform: translateX(-50%);
  }
  .map-results-button svg { width: 17px; }
}

@media (max-width: 560px) {
  .search-wrap kbd { display: none; }
  .search-wrap input { padding-right: 10px; }
  #upgrade-button { display: none; }
  .drawer {
    top: calc(var(--topbar-height) + 7px);
    right: 7px;
    bottom: 7px;
    width: calc(100vw - 14px);
  }
  .drawer-hero, .detail-section { padding-right: 18px; padding-left: 18px; }
  .detail-grid { grid-template-columns: 1fr; }
  .map-key { display: none; }
  .upgrade-modal { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .skeleton::after { animation: none; }
}
