:root {
  --gmr-blue: #003b71;
  --gmr-red: #c41928;
  --gmr-yellow: #ffce38;
  --ink: #172c41;
  --muted: #52677b;
  --line: #dce5ed;
  --surface: #fff;
  --tint: #f0f5fa;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; background: var(--surface); font: 14px/1.45 "Segoe UI", Arial, sans-serif; color: var(--ink); }
button, input { font: inherit; }
button, summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gmr-blue); outline-offset: 2px; }
[hidden] { display: none !important; }

.masthead {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.project-heading { min-width: 0; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; }
.masthead h1 { margin: 0; color: var(--gmr-blue); font-size: clamp(17px, 2vw, 23px); line-height: 1.15; letter-spacing: -.02em; }
.property-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--gmr-blue);
  border-radius: 7px;
  background: var(--gmr-blue);
  color: #fff;
  font-weight: 650;
}
.property-toggle:hover { background: #002c55; }
.property-toggle[aria-expanded="true"] { background: var(--tint); border-color: var(--line); color: var(--gmr-blue); }

.workspace { position: relative; display: flex; flex: 1; min-height: 0; }
.sidebar { flex: 0 0 228px; min-width: 0; padding: 19px 13px; overflow: auto; background: var(--surface); border-right: 1px solid var(--line); }
.road-walkthrough { margin-bottom: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint); }
.walkthrough-header { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.road-walkthrough h2 { margin: 0; color: var(--gmr-blue); font-size: 11px; white-space: nowrap; }
.road-walkthrough .property-toggle { padding: 4px 6px; font-size: 11px; }
#walkthrough-status:empty { display: none; }
.walkthrough-parcel { margin: 5px 0; font-weight: 700; }
.walkthrough-areas { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; font-size: 11px; }
.walkthrough-areas dt::before { content: ""; display: block; width: 15px; margin-bottom: 4px; }
.walkthrough-full::before { border-top: 2px dashed #007a96; }
.walkthrough-corridor::before { border-top: 3px solid #d33360; }
.walkthrough-areas dd { margin: 2px 0 0; color: var(--gmr-blue); font-size: 13px; font-weight: 700; }
.walkthrough-nav { display: flex; gap: 6px; }
.walkthrough-nav button { flex: 1; padding: 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--gmr-blue); font-size: 12px; }
.walkthrough-nav button:disabled { opacity: .5; cursor: default; }
#walkthrough-end { margin-top: 5px; padding-inline: 0; }
.sidebar-heading { padding: 0 7px 13px; }
.sidebar-heading h2 { margin: 0; color: var(--gmr-blue); font-size: 16px; }
.sidebar-heading p, .hint { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.categories { display: grid; gap: 3px; }
.categories details { min-width: 0; border: 1px solid transparent; border-radius: 8px; }
.categories details[open] { border-color: var(--line); }
.categories summary {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--ink);
  list-style: none;
  font-size: 13px;
  font-weight: 650;
}
.categories summary::-webkit-details-marker { display: none; }
.categories summary::before { content: ""; width: 10px; height: 10px; border: 1px solid #7799b8; border-radius: 3px; background: var(--tint); }
.categories summary::after { content: ""; width: 6px; height: 6px; border: solid #526f89; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.categories summary:hover, .categories details[open] summary { color: var(--gmr-blue); background: var(--tint); }
.categories details[open] summary { border-radius: 7px 7px 0 0; }
.categories details[open] summary::before { border-color: #a77900; background: var(--gmr-yellow); }
.categories details[open] summary::after { transform: rotate(225deg); }
.category-layers { padding: 5px 8px 7px; border-top: 1px solid var(--line); }
input[type="checkbox"] { accent-color: var(--gmr-blue); }
.layer-row { display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 3px 2px; font-size: 12px; }
.layer-row input { flex: none; margin: 0 2px; }
.layer-select-all { margin-bottom: 3px; border-bottom: 1px solid var(--line); color: var(--gmr-blue); font-weight: 650; }
.layer-swatch { width: 12px; height: 10px; flex: 0 0 12px; border: 1px solid var(--swatch); background: color-mix(in srgb, var(--swatch) 35%, white); }
.layer-symbol { width: 16px; height: 16px; flex: 0 0 16px; object-fit: contain; }
.layer-error, .dataset { color: var(--gmr-red); font-size: .75rem; }
.layer-error { margin-left: auto; }
.dataset { padding: 0 7px; }

.map-shell { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; }
#map { width: 100%; height: 100%; background: #e5eee7; }
#map .leaflet-control-zoom, #map .leaflet-draw-toolbar { border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 2px 8px #172c4120; }
.parcel-legend {
  display: grid;
  gap: 4px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #161d24;
  box-shadow: 0 2px 8px #172c4120;
  font-size: 12px;
}
#map .parcel-legend { margin-bottom: 56px; }
.parcel-legend-total { display: flex; justify-content: space-between; gap: 12px; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.parcel-legend-total strong { color: var(--gmr-blue); white-space: nowrap; }
.parcel-legend-row { display: grid; grid-template-columns: 15px minmax(0, 1fr) 26px 26px; align-items: center; gap: 6px; }
.parcel-legend[hidden], .parcel-legend-total[hidden], .gmr-hidden .gmr-owner-outline { display: none; }
.legend-icon { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--gmr-blue); }
.legend-icon:hover { background: var(--tint); border-color: var(--line); }
.legend-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.legend-icon[aria-pressed="true"] .eye-slash { display: none; }
.legend-icon[aria-pressed="false"] { color: var(--muted); }
.legend-info-button span {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--parcel-color);
  border-radius: 50%;
  color: color-mix(in srgb, var(--parcel-color) 62%, #172c41);
  font: 700 12px/1 Georgia, serif;
}
.layer-info { width: min(400px, calc(100% - 30px)); padding: 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); }
.layer-info::backdrop { background: #132b4560; }
.layer-info-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.layer-info-header h2 { margin: 0; color: var(--gmr-blue); font-size: 18px; }
.layer-info > p { font-size: 13px; }
.layer-info-stats { display: flex; gap: 26px; padding: 10px 0; border-block: 1px solid var(--line); }
.layer-info-stats dt { font-size: 12px; color: var(--muted); }
.layer-info-stats dd { margin: 3px 0 0; font-weight: 700; }
#layer-info-status:empty { display: none; }
.layer-info-candidates { margin-top: 14px; }
.layer-info-candidates summary { cursor: pointer; color: var(--gmr-blue); font-size: 13px; }
.layer-info-candidates ul { max-height: 210px; overflow: auto; list-style: none; margin: 7px 0 0; padding: 0; }
.layer-info-candidates li { display: grid; gap: 3px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.layer-info-candidates button { justify-self: start; padding: 0; margin: 0; border: 0; background: transparent; text-align: left; }
.layer-info-candidates small { color: var(--muted); }
.shortlist-estimate { display: grid; gap: 1px; font-size: 12px; color: var(--muted); }
.shortlist-estimate strong { color: var(--ink); font-weight: 600; }
.shortlist-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shortlist-row .shortlist-pin { flex: none; min-width: 44px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--gmr-blue); font-size: 11px; text-align: center; }
.shortlist-pin[aria-pressed="true"] { background: var(--tint); border-color: var(--gmr-blue); }
.shortlist-pin:disabled { opacity: .55; cursor: default; }
.shortlist-total { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--tint); }
.shortlist-total h3 { margin: 0; color: var(--gmr-blue); font-size: 13px; }
.shortlist-total dl { margin: 6px 0 0; font-size: 12px; }
.shortlist-total dl div { display: flex; justify-content: space-between; gap: 8px; }
.shortlist-total dl div:last-child { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); font-weight: 700; color: var(--gmr-blue); }
.shortlist-total dd { margin: 0; white-space: nowrap; }
.shortlist-comparison { overflow-x: auto; margin: 8px 0; }
.shortlist-comparison table { width: 100%; border-collapse: collapse; font-size: 11px; }
.shortlist-comparison caption { padding-bottom: 4px; color: var(--gmr-blue); font-weight: 700; text-align: left; }
.shortlist-comparison th, .shortlist-comparison td { padding: 4px 5px; border: 1px solid var(--line); text-align: left; white-space: nowrap; }
.shortlist-comparison th { background: var(--tint); white-space: normal; }
.parcel-legend-swatch {
  width: 15px;
  height: 11px;
  border: 1px solid var(--parcel-color);
  background: color-mix(in srgb, var(--parcel-color) var(--parcel-strength), white);
}
.map-coordinates {
  position: absolute;
  z-index: 750;
  bottom: 24px;
  left: 12px;
  background: var(--surface);
  color: var(--gmr-blue);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 2px 8px #172c4114;
  padding: 4px 8px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  pointer-events: none;
}

.property-drawer { flex: 0 0 clamp(290px, 26vw, 352px); min-width: 0; overflow: auto; overscroll-behavior: contain; background: var(--surface); border-left: 1px solid var(--line); }
.drawer-heading { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 17px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-heading h2 { margin: 0; color: var(--gmr-blue); font-size: 18px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: var(--tint); color: var(--gmr-blue); }
.icon-button:hover { background: #e2edf6; }
.property-drawer .panel { padding: 16px 17px; }
.property-drawer .panel + .panel { border-top: 1px solid var(--line); }
.property-drawer h3 { margin: 0 0 8px; color: var(--gmr-blue); font-size: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.text-button { color: var(--gmr-blue); border: 0; background: none; font-size: 12px; }
.text-button:disabled { color: var(--muted); cursor: default; }
.panel > label { display: block; color: var(--muted); font-size: 12px; margin: 4px 0 5px; }
input[type="search"], #owner-picker { width: 100%; padding: 8px 10px; min-height: 37px; color: inherit; font-size: 13px; border: 1px solid #bdcddc; border-radius: 6px; background: var(--surface); }
#owner-picker { position: relative; margin-top: 7px; padding-right: 34px; text-align: left; overflow-wrap: anywhere; }
#owner-picker::after { content: ""; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px; border: solid var(--gmr-blue); border-width: 0 2px 2px 0; transform: translateY(-70%) rotate(45deg); }
#owner-picker[aria-expanded="true"]::after { transform: translateY(-25%) rotate(225deg); }
#owner-picker:disabled { color: var(--muted); cursor: default; }
#owner-options { margin: 4px 0 0; padding: 3px; list-style: none; max-height: 7rem; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 6px; }
#owner-options button { display: block; width: 100%; border: 0; border-radius: 4px; padding: 6px 8px; background: var(--surface); color: inherit; text-align: left; overflow-wrap: anywhere; font-size: 12px; }
#owner-options button:hover, #owner-options button:focus-visible, #owner-options button[aria-current="true"] { background: var(--tint); }
#owner-options button:focus-visible { outline-offset: -2px; }
.selection { display: flex; align-items: baseline; gap: 8px; padding: 9px 10px; background: #fff7db; border-radius: 7px; margin-top: 13px; font-size: 13px; overflow-wrap: anywhere; }
.selection-dot { flex: 0 0 8px; height: 8px; border-radius: 50%; background: #ffb51f; }
.selection small, .distance, .area-comparison small, .area-totals small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.area-summary { margin-top: 16px; font-size: 12px; }
.area-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0 0 12px; }
.area-totals > div { min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
.area-totals dt { color: var(--muted); font-size: 11px; }
.area-totals dd { margin: 3px 0 0; color: var(--gmr-blue); font-weight: 700; }
.area-comparison { display: flex; align-items: center; gap: 9px; }
.area-donut { flex: 0 0 32px; height: 32px; border-radius: 50%; background: radial-gradient(circle, #fff 46%, transparent 49%), conic-gradient(var(--gmr-yellow) var(--owner-share, 0%), var(--gmr-blue) 0%); }
.property-drawer table { width: 100%; border-collapse: collapse; margin-top: 9px; font-size: 12px; }
.property-drawer th, .property-drawer td { border-bottom: 1px solid var(--line); padding: 7px 4px; text-align: left; }
.property-drawer thead th { background: var(--tint); color: var(--gmr-blue); font-size: 11px; }
.property-drawer th:last-child, .property-drawer td:last-child { text-align: right; white-space: nowrap; }
#nearby-list button { border: 0; background: transparent; padding: 0; text-align: left; color: var(--gmr-blue); text-decoration: underline; overflow-wrap: anywhere; }
#nearby-list button[aria-pressed="true"] { color: var(--gmr-red); font-weight: bold; }

.leaflet-tooltip.boundary-label { font-weight: bold; padding: 1px 3px; color: #942a21; background: #fff9; box-shadow: none; border: 0; }
.popup-title { display: block; margin-bottom: 4px; }
.popup-fields { margin: 0; max-height: 175px; overflow: auto; }
.popup-fields div { display: flex; gap: 6px; }
.popup-fields dt { font-weight: bold; }
.popup-fields dd { margin: 0; overflow-wrap: anywhere; }
.popup-owner { margin-top: 8px; color: var(--gmr-blue); }

@media (max-width: 860px) {
  .property-drawer { position: absolute; z-index: 800; bottom: 10px; right: 10px; width: min(340px, calc(100% - 20px)); max-height: 54%; border: 1px solid var(--line); border-top: 3px solid var(--gmr-blue); border-radius: 10px; box-shadow: 0 8px 30px #172c4130; }
}

@media (max-width: 600px) {
  .masthead { padding: 9px 11px; gap: 8px; }
  .property-toggle { gap: 5px; padding: 7px; font-size: 12px; }
  .property-toggle svg { width: 14px; height: 14px; }
}
.leaflet-tooltip.boundary-label.gmr-survey-label { color: #fff; background: transparent; font-size: 12px; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 5px #000; }
.leaflet-tooltip.boundary-label::before { display: none; }
.leaflet-tooltip.boundary-label.highway-label { z-index: 1000; }
.leaflet-tooltip.boundary-label.highway-label { background: transparent; border: 0; padding: 0; box-shadow: none; }
.highway-label span { display: inline-block; white-space: nowrap; color: #fff; background: #7a5a00; border: 1px solid #fff; border-radius: 3px; padding: 2px 8px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- Mobile / touch ---------- */
html { -webkit-text-size-adjust: 100%; }
body { height: 100dvh; overflow: hidden; }
.masthead-actions { display: flex; flex: none; gap: 10px; align-items: center; }
.layers-toggle { display: none; }
.leaflet-popup-content { max-width: 72vw; }
.layer-info { max-height: calc(100dvh - 30px); overflow: auto; }

@media (max-width: 860px) {
  .layers-toggle { display: inline-flex; }
  .sidebar {
    position: absolute; z-index: 900; top: 0; bottom: 0; left: 0;
    flex: none; width: min(300px, 86vw);
    visibility: hidden; transform: translateX(-102%);
    transition: transform .22s ease, visibility 0s linear .22s;
    box-shadow: 4px 0 24px #0007;
  }
  body.layers-open .sidebar { visibility: visible; transform: none; transition-delay: 0s; }
  #map .parcel-legend { max-width: min(300px, calc(100vw - 80px)); }
}

@media (max-width: 600px) {
  .masthead { padding-top: max(9px, env(safe-area-inset-top)); padding-inline: 11px; }
  .masthead-actions { gap: 6px; }
  .btn-label { display: none; }
  .property-toggle { justify-content: center; min-width: 40px; min-height: 40px; padding: 0 10px; }
  .property-toggle svg { width: 18px; height: 18px; }
  .masthead h1 { font-size: 16px; }
  .eyebrow { font-size: .58rem; }

  .property-drawer {
    left: 0; right: 0; bottom: 0; width: 100%; max-height: 62%;
    border-radius: 14px 14px 0 0; border-inline: 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.drawer-open .parcel-legend, body.drawer-open .map-coordinates { display: none; }

  .map-coordinates { bottom: 20px; left: 8px; font-size: 10px; }
  #map .parcel-legend { margin-bottom: 40px; margin-left: 8px; padding: 6px 8px; font-size: 11px; }
  .parcel-legend-row { grid-template-columns: 15px minmax(0, 1fr) 32px 32px; gap: 4px; }
  .legend-icon { width: 32px; height: 32px; }

  .layer-row { min-height: 40px; font-size: 13px; }
  .categories summary { padding: 12px 10px; }
  input[type="search"], #owner-picker, #owner-options button { font-size: 16px; }
  #owner-options { max-height: 10rem; }
  .layer-info { width: calc(100% - 20px); padding: 14px; }
  .layer-info-stats { gap: 16px; flex-wrap: wrap; }
  .highway-label span { font-size: 11px; padding: 1px 5px; }
  .leaflet-tooltip.boundary-label.gmr-survey-label { font-size: 11px; }
}