* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: #e7edf4;
  background: #0e151b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button,
input,
select {
  font: inherit;
}

#landmax-app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.camera-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 18px;
  background: #0e1521;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: #d7e2ef;
  font-size: 14px;
  white-space: nowrap;
  overflow-x: auto;
}
.camera-bar .range-control {
  display: grid;
  grid-template-columns: auto minmax(112px, 200px);
  align-items: center;
  gap: 8px;
}
.camera-bar .range-control output {
  display: inline-block;
  min-width: 38px;
  color: #bfeaff;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.camera-bar .range-control input[type="range"] {
  width: 100%;
  accent-color: #7dd3fc;
}
.camera-bar .heading-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.camera-bar .heading-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.camera-bar .compass-button {
  min-width: 30px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid rgba(191,234,255,0.28);
  border-radius: 14px;
  color: #bfeaff;
  background: rgba(14,116,144,0.16);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.camera-bar .compass-button:hover { background: rgba(14,116,144,0.28); }
.camera-bar .compass-button.is-active {
  border-color: rgba(191,234,255,0.72);
  color: #fff;
  background: rgba(14,116,144,0.42);
}

.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 9px 18px;
  background: #111922;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}

.header-tail {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewport-tail {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: #aab7c5;
  font-size: 14px;
  visibility: hidden;
}

.viewport-tail.visible {
  visibility: visible;
}

.viewport-tail-arrow {
  color: #6f7e8d;
}

.viewport-tail-label {
  color: #e7edf4;
}

.viewport-tail-save {
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  color: #0d1820;
  background: #9fdcbe;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.viewport-tail-save:disabled {
  color: #4a5969;
  background: rgba(159, 220, 190, 0.32);
  cursor: not-allowed;
}

.center-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  pointer-events: none;
  z-index: 4;
}

.center-crosshair::before,
.center-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(13, 24, 32, 0.7);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.55);
}

.center-crosshair::before {
  top: 0; bottom: 0; left: 50%;
  width: 1px; margin-left: -0.5px;
}

.center-crosshair::after {
  left: 0; right: 0; top: 50%;
  height: 1px; margin-top: -0.5px;
}

.brand {
  color: #f5f7fa;
  font-size: 18px;
  font-weight: 760;
  text-decoration: none;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: #aab7c5;
  font-size: 15px;
  white-space: nowrap;
}

.breadcrumbs a {
  color: #8dd8ff;
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: #c8edff;
}

.breadcrumbs span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-status {
  padding: 5px 10px;
  border: 1px solid rgba(142, 213, 255, 0.28);
  border-radius: 8px;
  color: #c8edff;
  background: rgba(18, 105, 145, 0.20);
  font-size: 14px;
  white-space: nowrap;
}

.route-status.error {
  border-color: rgba(252, 165, 165, 0.36);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.30);
}

.app-layout {
  display: flex;
  min-height: 0;
  --details-width: 420px;
}

.map-pane {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

#app-map {
  width: 100%;
  height: 100%;
}

.layout-splitter {
  flex: 0 0 9px;
  width: 9px;
  cursor: col-resize;
  background: #101820;
  border-left: 1px solid rgba(255,255,255,0.08);
  border-right: 1px solid rgba(255,255,255,0.08);
}

.layout-splitter:hover,
.layout-splitter.dragging {
  background: #1d2b35;
}

.details-panel {
  display: flex;
  flex: 0 0 var(--details-width);
  flex-direction: column;
  min-width: 340px;
  max-width: min(680px, 52vw);
  min-height: 0;
  color: #e9eef4;
  background: #151d25;
  border-left: 1px solid rgba(255,255,255,0.09);
  overflow: auto;
}

.details-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.route-kicker {
  margin: 0 0 5px;
  color: #9fb0bf;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
}

.details-header h1 {
  margin: 0;
  overflow-wrap: anywhere;
  color: #f8fafc;
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

.route-content {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.section {
  display: grid;
  gap: 10px;
}

/* Parcel-detail card — appears as the top-most section of #route-content
   when the user clicks an Esri parcel on a leaf that declares a
   `query_on_parcel_click` dataset (Edmonton's per-account assessments).
   See parcel-detail.js. */
.section.parcel-detail {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.10) 0%, rgba(99, 102, 241, 0.10) 100%);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 12px;
  padding: 14px 16px;
  gap: 8px;
}
.parcel-detail-kicker {
  font-size: 11px;
  color: #67e8f9;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.parcel-detail-title {
  margin: 0;
  font-size: 18px;
  color: #f1f5f9;
  font-weight: 600;
  line-height: 1.25;
}
.parcel-detail-subhead {
  font-size: 12px;
  color: #94a3b8;
}
.parcel-detail-value {
  font-size: 24px;
  font-weight: 700;
  color: #67e8f9;
  margin: 4px 0 2px;
}
.parcel-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}
.parcel-detail-table th {
  text-align: left;
  color: #94a3b8;
  font-weight: 500;
  padding: 4px 8px 4px 0;
  white-space: nowrap;
  width: 38%;
}
.parcel-detail-table td {
  color: #e2e8f0;
  padding: 4px 0;
  word-break: break-word;
}

/* Multi-unit summary (count line under the assessed-value display).
   Shows "32 units · 18 parking / storage" for condo towers. */
.parcel-detail-summary {
  font-size: 12px;
  color: #94a3b8;
  margin-top: -4px;
  margin-bottom: 4px;
}

/* Per-unit table — one row per suite or parking stall. Compact 4-column
   grid: suite | civic # | garage | assessed value. */
.parcel-detail-units {
  margin-top: 8px;
  display: grid;
  gap: 1px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.4);
  max-height: 380px;
  overflow-y: auto;
}
.parcel-detail-units-header,
.parcel-detail-unit-row {
  display: grid;
  grid-template-columns: 1fr 2fr 0.5fr 1.4fr;
  gap: 6px;
  padding: 5px 8px;
  font-size: 11.5px;
  background: rgba(15, 23, 42, 0.6);
}
.parcel-detail-units-header {
  background: rgba(34, 211, 238, 0.18);
  color: #67e8f9;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
}
.parcel-detail-unit-row {
  color: #e2e8f0;
}
.parcel-detail-unit-row.aux {
  color: #94a3b8;
  font-style: italic;
}
.parcel-detail-unit-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parcel-detail-unit-row span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.section h2 {
  margin: 0;
  color: #b9c7d6;
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section p {
  margin: 0;
  color: #d7e0e9;
  font-size: 15px;
  line-height: 1.45;
}

.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.fact {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 8px;
  background: rgba(255,255,255,0.035);
}

.fact span {
  display: block;
  color: #9fb0bf;
  font-size: 13px;
}

.fact strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: #f3f6f8;
  font-size: 16px;
}

.dataset-list,
.link-list,
.attribution-list {
  display: grid;
  gap: 8px;
}

.dataset-row,
.link-row,
.attribution-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.075);
  color: inherit;
  text-decoration: none;
}

.dataset-row:last-child,
.link-row:last-child,
.attribution-row:last-child {
  border-bottom: none;
}

.row-title {
  overflow-wrap: anywhere;
  color: #f3f6f8;
  font-size: 15px;
  font-weight: 680;
}

.row-meta {
  margin-top: 3px;
  color: #9fb0bf;
  font-size: 14px;
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  color: #0d1820;
  background: #9fdcbe;
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.pill.muted {
  color: #d8e2eb;
  background: rgba(255,255,255,0.12);
}

.maplibregl-popup.landmax-popup .maplibregl-popup-content {
  padding: 12px 14px;
  border-radius: 10px;
  color: #0d1820;
  background: #f5f7fa;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,0.32);
}

.maplibregl-popup.landmax-popup .popup-kicker {
  margin-bottom: 6px;
  color: #4a5969;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.maplibregl-popup.landmax-popup .popup-headline {
  font-size: 15px;
  font-weight: 700;
  color: #0d1820;
  line-height: 1.25;
  margin-bottom: 2px;
}

.maplibregl-popup.landmax-popup .popup-subhead {
  font-size: 11px;
  color: #6b7785;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.maplibregl-popup.landmax-popup .popup-crumbs {
  font-size: 11px;
  color: #4a5969;
  margin-bottom: 8px;
}

.maplibregl-popup.landmax-popup .popup-crumbs .popup-sep {
  margin: 0 4px;
  border: 0;
  color: #94a3b8;
}

.maplibregl-popup.landmax-popup .popup-table {
  width: 100%;
  border-collapse: collapse;
}

.maplibregl-popup.landmax-popup .popup-table th,
.maplibregl-popup.landmax-popup .popup-table td {
  padding: 3px 0;
  border-bottom: 1px solid rgba(13,24,32,0.08);
  text-align: left;
  vertical-align: top;
}

.maplibregl-popup.landmax-popup .popup-table th {
  width: 40%;
  padding-right: 10px;
  color: #4a5969;
  font-weight: 580;
}

.maplibregl-popup.landmax-popup .popup-table td {
  color: #0d1820;
  font-weight: 600;
  word-break: break-word;
}

.maplibregl-popup.landmax-popup .popup-empty {
  color: #4a5969;
  font-size: 12px;
  font-style: italic;
}

.maplibregl-popup.landmax-popup .popup-sep {
  margin: 10px 0;
  border: 0;
  border-top: 1px solid rgba(13,24,32,0.16);
}

.maplibregl-popup.landmax-popup .popup-kicker {
  margin-top: 0;
}

.maplibregl-popup.landmax-popup .popup-sep + .popup-kicker {
  margin-top: 0;
}

.leaf-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255,255,255,0.10);
}

.leaf-counts .pill {
  font-weight: 600;
}

.empty {
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #aab7c5;
  background: rgba(255,255,255,0.035);
  font-size: 15px;
  line-height: 1.45;
}

.fade-in {
  animation: fade-in 180ms ease-out;
}

@keyframes fade-in {
  from { opacity: 0.72; }
  to { opacity: 1; }
}

@media (max-width: 860px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .breadcrumbs {
    grid-column: 1 / -1;
    order: 3;
  }

  .app-layout {
    flex-direction: column;
  }

  .layout-splitter {
    display: none;
  }

  .map-pane {
    min-height: 48vh;
  }

  .details-panel {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-width: 0;
    border-top: 1px solid rgba(255,255,255,0.09);
    border-left: none;
  }

  .facts {
    grid-template-columns: 1fr;
  }
}
