/**
 * Map page styles  -  left sidebar + map + bottom detail drawer.
 */

/* ── Shell layout ───────────────────────────────────────────────── */
.map-page-main {
  padding: 0;
  height: calc(100vh - 24px);
  min-height: 520px;
}

body.map-page {
  overflow: hidden;
}

#map-container.map-shell,
.map-shell#map-container {
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 560px;
  overflow: hidden;
  --map-inspector-height: min(42vh, 400px);
  --map-inspector-width: 420px;
  --map-sidebar-width: 300px;
  --map-inspector-width: 420px;
  --map-sidebar-width: 300px;
  --fg-font: 'Montserrat', system-ui, -apple-system, sans-serif;
  --fg-text-2xs: 10px;
  --fg-text-xs: 11px;
  --fg-text-sm: 12px;
  --fg-text-base: 13px;
  --fg-text-lg: 14px;
  --fg-ink: #121418;
  --fg-body: #1c1917;
  --fg-muted: #78716c;
  --fg-subtle: #a8a29e;
  --fg-line: 1.45;
  --fg-link: var(--fg-accent, #56b8cf);
  --fg-border: #eceae6;
  --fg-surface: #fafaf9;
}

.map-container--editor.map-shell {
  height: 100%;
  min-height: 560px;
}

#panel-map.editorial-panel.active {
  display: flex;
  flex-direction: column;
  min-height: min(78vh, calc(100vh - 200px));
}

#panel-map.editorial-panel.active .map-container--editor.map-shell {
  flex: 1;
  min-height: 560px;
}

.map-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.map-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

#map,
#map-editor-map {
  width: 100%;
  height: 100%;
}

/* ── Left sidebar (controls + facility list) ────────────────────── */
.map-sidebar {
  width: var(--map-sidebar-width, 300px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(11, 26, 51, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: #e8eef7;
  z-index: 11;
  font-family: var(--fg-font);
  font-size: var(--fg-text-sm);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
}

.map-atlas-stats {
  display: none !important;
}

.map-sidebar-header {
  padding: 8px 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.map-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #f8fafc;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.map-sidebar-logo img {
  border-radius: 5px;
  width: 24px;
  height: 24px;
}

.map-sidebar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 6px 0 4px;
}

.map-sidebar-nav a {
  padding: 3px 7px;
  border-radius: 5px;
  font-family: inherit;
  font-size: var(--fg-text-2xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  color: #94a3b8;
  transition: color 0.15s, background 0.15s;
}

.map-sidebar-nav a:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}

.map-sidebar-nav a.nav-active {
  color: #f8fafc;
  background: rgba(245, 158, 11, 0.18);
}

.map-sidebar-kicker {
  margin: 0 0 2px;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.map-sidebar-title-main {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
  line-height: 1.2;
}

.map-sidebar-body {
  overflow-y: auto;
  padding: 6px 10px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.map-sidebar-section + .map-sidebar-section,
.map-sidebar-collapsible + .map-sidebar-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.map-org-scroller {
  margin: 5px 0 8px;
  max-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.map-org-scroller::-webkit-scrollbar {
  width: 5px;
}

.map-org-scroller::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 4px;
}

.map-org-list {
  list-style: none;
  margin: 0;
  padding: 2px 0;
}

.map-org-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.map-org-item:last-child {
  border-bottom: none;
}

.map-org-head {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease;
}

.map-org-head:hover {
  background: rgba(255, 255, 255, 0.06);
}

.map-org-item.is-active > .map-org-head {
  background: rgba(245, 158, 11, 0.14);
}

.map-org-name {
  display: block;
  font-size: var(--fg-text-sm);
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-org-empty {
  padding: 7px 10px;
  font-size: var(--fg-text-xs);
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-sidebar-title {
  margin: 0 0 5px;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #cbd5e1;
}

.legend-basemap-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.legend-item-compact {
  padding: 2px 0;
  font-size: 12px;
  gap: 6px;
}

.legend-radio input[type="radio"] {
  accent-color: #f59e0b;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  line-height: 1.3;
}

.legend-item input[type="checkbox"] {
  accent-color: #44cc44;
}

.facility-layer {
  margin-top: 0;
}

.facility-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  border: 1.5px solid #fff;
  flex-shrink: 0;
}

.facility-dot-linked {
  background: #f59e0b;
}

.legend-hint {
  margin: 16px 0 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  color: #64748b;
  line-height: 1.45;
}

.legend-hint code {
  font-size: 10px;
  color: #94a3b8;
}

/* Mobile: collapsible sidebar */
.map-sidebar-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.map-sidebar-toggle {
  display: none;
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 12;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(20, 20, 40, 0.92);
  color: #e2e8f0;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
}

.map-sidebar-toggle:hover {
  border-color: rgba(245, 158, 11, 0.6);
  color: #fbbf24;
}

/* ── Bottom detail drawer (map shrinks above, not covered) ─────── */
.map-inspector {
  flex: 0 0 0;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  background: var(--fg-surface);
  border-top: 0 solid var(--fg-border);
  box-shadow: none;
  z-index: 12;
  display: flex;
  flex-direction: column;
  font-family: var(--fg-font);
  font-size: var(--fg-text-sm);
  line-height: var(--fg-line);
  color: var(--fg-body);
  -webkit-font-smoothing: antialiased;
  transition: flex-basis 0.28s ease, max-height 0.28s ease, border-width 0.28s ease, box-shadow 0.28s ease;
}

.map-shell.map-inspector-open .map-inspector.is-open {
  flex: 0 0 var(--map-inspector-height);
  max-height: var(--map-inspector-height);
  border-top-width: 1px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.map-shell.map-inspector-resizing .map-inspector {
  transition: none;
}

.map-inspector-resize {
  flex-shrink: 0;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  background: #fff;
  border-bottom: 1px solid var(--fg-border);
}

.map-inspector-resize:focus-visible {
  outline: 2px solid var(--fg-accent, #56b8cf);
  outline-offset: -2px;
}

.map-inspector-resize-grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #d6d3d1;
  pointer-events: none;
}

.map-inspector-resize:hover .map-inspector-resize-grip,
.map-inspector-resize:focus-visible .map-inspector-resize-grip {
  background: #78716c;
}

body.map-inspector-dragging {
  cursor: ns-resize !important;
  user-select: none;
}

.map-inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px 7px;
  border-bottom: 1px solid var(--fg-border);
  flex-shrink: 0;
  background: #fff;
}

.map-inspector-heading {
  min-width: 0;
}

.map-inspector-kicker {
  margin: 0 0 2px;
  font-size: var(--fg-text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-inspector-header h2 {
  margin: 0;
  font-size: var(--fg-text-lg);
  font-weight: 700;
  color: var(--fg-ink);
  line-height: 1.25;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.map-inspector-close {
  border: none;
  background: #f5f5f4;
  color: #57534e;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.map-inspector-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 14px 12px;
  flex: 1;
  display: block;
  min-height: 0;
  font-size: var(--fg-text-sm);
}

.map-inspector-body .inspector-edit-form,
.map-inspector-body .inspector-edit-readonly,
.map-inspector-body .inspector-loading,
.map-inspector-body .inspector-error,
.map-inspector-body > p {
  max-width: none;
}

.inspector-section {
  margin-bottom: 0;
  min-width: 0;
}

.inspector-section h3,
.inspector-edit-section-title {
  margin: 0 0 8px;
  font-size: var(--fg-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 700;
}

.inspector-lead {
  margin: 0 0 6px;
  font-size: var(--fg-text-base);
  font-weight: 600;
  color: var(--fg-body);
}

.inspector-website {
  color: var(--fg-link);
  font-size: var(--fg-text-sm);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}

.inspector-website:hover {
  text-decoration: underline;
}

.inspector-actions {
  margin: 8px 0 0;
  font-size: var(--fg-text-sm);
}

.inspector-actions a {
  color: var(--fg-link);
  text-decoration: none;
  font-weight: 600;
}

.inspector-dl {
  display: grid;
  gap: 2px;
  margin: 0;
}

.inspector-dl div {
  display: grid;
  grid-template-columns: minmax(88px, 34%) 1fr;
  gap: 8px;
  font-size: var(--fg-text-sm);
  line-height: var(--fg-line);
  padding: 3px 0;
}

.inspector-dl dt {
  margin: 0;
  color: var(--fg-muted);
  font-weight: 600;
  font-size: var(--fg-text-xs);
}

.inspector-dl dd {
  margin: 0;
  color: var(--fg-body);
  font-weight: 500;
  white-space: pre-wrap;
}

.portal-value-list {
  margin: 0;
  padding-left: 1.15em;
  list-style: disc;
}

.portal-value-list li {
  margin: 0 0 4px;
  padding: 0;
  line-height: var(--fg-line);
}

.portal-value-list li:last-child {
  margin-bottom: 0;
}

.inspector-dl dd .portal-value-list {
  white-space: normal;
}

.inspector-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.inspector-row {
  padding: 7px 0;
  border-bottom: 1px solid #f0efec;
}

.inspector-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.inspector-row-title {
  font-size: var(--fg-text-sm);
  font-weight: 600;
  color: var(--fg-body);
  line-height: var(--fg-line);
}

.inspector-row-link {
  display: block;
  color: var(--fg-link);
  font-weight: 600;
  font-size: var(--fg-text-sm);
  text-decoration: none;
  line-height: var(--fg-line);
}

.inspector-row-link:hover {
  text-decoration: underline;
}

.inspector-row-meta {
  display: block;
  font-size: var(--fg-text-xs);
  color: var(--fg-muted);
  font-weight: 500;
  margin-top: 2px;
}

.inspector-muted {
  color: var(--fg-subtle);
  font-size: var(--fg-text-sm);
  font-weight: 500;
  margin: 0;
  padding: 2px 0 6px;
}

.inspector-loading,
.inspector-error {
  font-size: var(--fg-text-sm);
  color: var(--fg-muted);
}

.inspector-error {
  color: #b91c1c;
}

.inspector-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inspector-chip {
  border: 1px solid #e7e5e4;
  background: #fafaf9;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  color: #1c1917;
}

.inspector-chip:hover {
  border-color: var(--fg-accent, #56b8cf);
  color: var(--fg-accent, #56b8cf);
}

@media (max-width: 900px) {
  .map-page-main {
    height: 100dvh;
    height: 100vh;
    min-height: 0;
  }

  #map-container.map-shell,
  .map-shell#map-container {
    height: 100%;
    min-height: 0;
    --map-inspector-height: min(52dvh, 440px);
  }

  .map-page .site-footer.map-page-footer {
    display: none;
  }

  .map-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    z-index: 11;
  }

  .map-shell.map-sidebar-open .map-sidebar {
    transform: translateX(0);
  }

  .map-shell.map-sidebar-open .map-sidebar-backdrop {
    display: block;
  }

  .map-sidebar-toggle {
    display: inline-flex;
  }

  .map-shell.map-sidebar-open .map-sidebar-toggle {
    left: min(312px, calc(88vw + 12px));
  }

  .map-shell.map-inspector-open .map-inspector.is-open {
    max-height: min(88dvh, var(--map-inspector-height));
  }

  .map-filter-chip {
    min-height: 32px;
    padding: 4px 8px;
  }

  .map-org-head {
    min-height: 40px;
    padding: 8px 10px;
  }

  .map-fit-canada-btn {
    min-height: 40px;
  }
}

@media (max-width: 720px) {
  .map-shell {
    --map-inspector-height: min(58dvh, 480px);
  }

  .map-inspector-body {
    padding: 10px 14px 16px;
  }

  .map-inspector-header h2 {
    -webkit-line-clamp: 2;
    font-size: 15px;
  }

  .inspector-dl div {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 6px 0;
  }

  .map-summary-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .map-add-form {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 72dvh;
    overflow-y: auto;
  }

  .maplibregl-popup-content {
    min-width: 0 !important;
    max-width: min(92vw, 320px);
  }
}

/* ── Facility popups ────────────────────────────────────────────── */
.facility-popup {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  color: #222;
  line-height: 1.5;
}

.facility-popup h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
}

.facility-popup p {
  margin: 4px 0;
}

.facility-popup .source-note {
  font-size: 11px;
  color: #888;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #eee;
}

.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-existing { background: #e8f5e9; color: #2e7d32; }
.status-proposed { background: #fff8e1; color: #f57f17; }
.status-under_construction { background: #fff3e0; color: #e65100; }
.status-closed { background: #fbe9e7; color: #c62828; }

/* ── Map page chrome ─────────────────────────────────────────────── */
.map-page .site-footer.map-page-footer {
  padding: 0.2rem 0.75rem;
  font-size: 0.68rem;
  background: rgba(20, 20, 40, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── MapLibre overrides ─────────────────────────────────────────── */
.maplibregl-popup-content {
  border-radius: 8px !important;
  padding: 12px 16px !important;
  min-width: 240px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
}

/* Hover tooltips are pointer-events none so clicks reach map pins */
.map-layer-subhead {
  margin-top: 0.35rem;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.map-regulatory-panel {
  max-height: 420px;
  overflow-y: auto;
}

.map-regulatory-layers {
  margin-top: 0.35rem;
}

.reg-layer-row[hidden] {
  display: none !important;
}

.reg-layer-hint {
  margin-top: 0.5rem;
  font-size: 10px;
  line-height: 1.35;
}

.reg-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0.25rem;
}

.reg-quick-btn {
  font-size: 10px;
  padding: 0.25rem 0.5rem;
}

.map-infra-tooltip.maplibregl-popup,
.map-infra-tooltip .maplibregl-popup-content,
.map-infra-tooltip .maplibregl-popup-tip,
.map-infra-popup .maplibregl-popup-content {
  pointer-events: none;
}

.map-infra-popup .maplibregl-popup-content {
  pointer-events: auto;
}

.map-infra-tooltip .maplibregl-popup-content,
.map-infra-popup .maplibregl-popup-content {
  min-width: 0;
  padding: 10px 12px !important;
  font-family: var(--fg-font);
  font-size: 12px;
  line-height: 1.4;
  background: rgba(11, 26, 51, 0.96) !important;
  color: #f8fafc;
  border: 1px solid rgba(212, 154, 0, 0.4);
}

.map-infra-popup strong,
.map-infra-tooltip strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.map-infra-kicker {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--fg-data-compost, #b8925a);
  margin-bottom: 4px;
}

.map-infra-row {
  display: block;
  color: #c5d4e8;
  font-size: 11px;
}

.map-infra-muted {
  color: #8fa3bf !important;
}

.map-infra-source {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: #64748b;
}

.map-infra-link {
  display: block;
  margin-top: 6px;
  color: #7eb8ff !important;
  font-size: 11px;
  font-weight: 600;
}

.map-pin-tooltip.maplibregl-popup,
.map-pin-tooltip .maplibregl-popup-content,
.map-pin-tooltip .maplibregl-popup-tip {
  pointer-events: none;
}

.map-pin-tooltip .maplibregl-popup-content {
  min-width: 0;
  padding: 8px 12px !important;
  font-family: var(--fg-font);
  font-size: 12px;
  line-height: 1.35;
  background: rgba(11, 26, 51, 0.94) !important;
  color: #f8fafc;
  border: 1px solid rgba(212, 154, 0, 0.35);
}

.map-pin-tooltip strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.map-pin-tooltip-op,
.map-pin-tooltip-meta {
  display: block;
  color: #8fa3bf;
  font-size: 11px;
  font-weight: 600;
}

.maplibregl-ctrl-attrib {
  font-size: 10px !important;
  background: rgba(20, 20, 40, 0.8) !important;
  color: #888 !important;
}

.maplibregl-ctrl-attrib a {
  color: #aaa !important;
}

/* ── Editorial map editor (inspector form) ──────────────────────── */
.inspector-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspector-edit-hint {
  margin: 0 0 4px;
  font-size: 12px;
  color: #57534e;
  line-height: 1.45;
}

.inspector-edit-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #78716c;
}

.inspector-edit-label input {
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  padding: 8px 10px;
  border: 1px solid #e7e5e4;
  border-radius: 6px;
  color: #1c1917;
}

.inspector-edit-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.inspector-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.inspector-btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}

.inspector-btn-primary {
  background: var(--fg-accent, #56b8cf);
  color: #fff;
}

.inspector-btn-ghost {
  background: #fff;
  color: #57534e;
  border-color: #e7e5e4;
}

.inspector-btn-delete {
  color: #b91c1c;
  border-color: #fecaca;
}

.inspector-btn-delete:hover:not(:disabled) {
  background: #fef2f2;
}

.inspector-btn-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inspector-edit-meta {
  margin: 0;
  font-size: 11px;
  color: #a8a29e;
}

.inspector-edit-section-title {
  margin: 20px 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #78716c;
}

.map-inspector-editor-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 0 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--fg-border);
}

.map-inspector-editor-bar .inspector-btn.is-active {
  background: #07080a;
  color: #fff;
  border-color: #07080a;
}

.map-portal-view-mount,
.map-portal-edit-mount {
  min-height: 0;
}

.map-sidebar-editor-tools {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--fg-border);
}

.fg-grid-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid rgba(6, 95, 212, 0.35);
  background: rgba(6, 95, 212, 0.1);
  color: var(--fg-accent, #56b8cf);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

.fg-grid-link-btn:hover {
  background: rgba(6, 95, 212, 0.16);
}

.map-sidebar-editor-status {
  margin: 8px 0 0;
  font-size: var(--fg-text-xs);
  color: var(--fg-muted);
  line-height: 1.45;
}

.map-sidebar-add-btn {
  width: 100%;
  margin-top: 8px;
}

.inspector-site-fields {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0efec;
}

.inspector-site-fields > summary {
  cursor: pointer;
  list-style: none;
}

.inspector-site-fields > summary::-webkit-details-marker {
  display: none;
}

.portal-editor-shell {
  margin-top: 4px;
}

.portal-editor-preview {
  margin-bottom: 12px;
}

.portal-editor-edit {
  border: 1px solid #e7e5e4;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafaf9;
}

.portal-editor-edit > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #57534e;
}

.portal-editor-hint {
  margin: 10px 0 8px;
  font-size: 11px;
  color: #78716c;
  line-height: 1.45;
}

.portal-editor-json {
  width: 100%;
  min-height: 180px;
  box-sizing: border-box;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.45;
  padding: 10px;
  border: 1px solid #d6d3d1;
  border-radius: 6px;
  resize: vertical;
  color: #1c1917;
  background: #fff;
}

.portal-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.portal-editor-status {
  margin: 8px 0 0;
  font-size: 11px;
  color: #059669;
}

.portal-editor-status-error {
  color: #b91c1c;
}

.inspector-export-meta {
  margin: 0;
  font-size: 11px;
  color: #059669;
}

.inspector-export-meta-error {
  color: #b91c1c;
}

.inspector-edit-readonly {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid #f0efec;
}

.fg-session-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 10px 16px;
  background: #b91c1c;
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.fg-preview-login {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(6px);
}

.fg-preview-login-card {
  width: min(420px, 100%);
  padding: 32px 28px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.fg-preview-login-card img {
  margin: 0 auto 12px;
}

.fg-preview-login-kicker {
  margin: 0 0 4px;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #78716c;
}

.fg-preview-login-card h2 {
  margin: 0 0 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #1c1917;
}

.fg-preview-login-copy {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: #57534e;
}

.fg-preview-login-label {
  display: block;
  margin-bottom: 6px;
  text-align: left;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #44403c;
}

.fg-preview-login-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #d6d3d1;
  border-radius: 8px;
  font-size: 15px;
}

.fg-preview-login-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: #b91c1c;
}

.fg-preview-login-btn {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  background: #1c1917;
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

body.map-page.qt-app .fg-preview-login-skip {
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--qt-midlight, #555);
  color: var(--qt-text-muted, #aaa);
}

.fg-preview-login-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
}

/* ── Phase 4: filters + sidebar list + portal detail ─────────────── */
.map-summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
}

.map-summary-stats div {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}

.map-summary-stats dt {
  margin: 0 0 2px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.map-summary-stats dd {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.1;
}

.map-summary-provinces {
  margin: 8px 0 0;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

.map-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 2px;
}

.map-filter-chips-wrap {
  gap: 3px;
}

.map-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.map-filter-chip input {
  accent-color: #f59e0b;
}

.map-list-count {
  font-weight: 600;
  color: #94a3b8;
}

.map-facility-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
  max-height: none;
}

.map-facility-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.map-facility-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(245, 158, 11, 0.35);
}

.map-facility-item.is-active {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.55);
}

.map-facility-item-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.map-facility-item-text {
  min-width: 0;
}

.map-facility-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.3;
}

.map-facility-meta {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-facility-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-left: 18px;
}

.map-facility-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.map-facility-tag-muted {
  color: #64748b;
  background: transparent;
  padding-left: 0;
}

.map-facility-empty {
  padding: 12px 8px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.map-sidebar-collapsible {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.map-sidebar-collapsible-filters {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.map-sidebar-collapsible summary {
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #cbd5e1;
  list-style: none;
  margin-bottom: 4px;
  padding: 2px 0;
}

.map-sidebar-collapsible summary::-webkit-details-marker {
  display: none;
}

.map-sidebar-collapsible[open] summary {
  margin-bottom: 6px;
}

.map-sidebar-collapsible-body {
  padding-bottom: 2px;
}

.map-search-label {
  display: block;
  margin: 0 0 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.map-search-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.25);
  color: #f1f5f9;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
}

.map-filter-group-label {
  margin: 5px 0 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.map-filter-sublabel {
  margin: 4px 0 2px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.map-fit-canada-btn {
  display: block;
  width: 100%;
  margin: 8px 0 4px;
  padding: 6px 10px;
  font-family: var(--fg-font);
  font-size: var(--fg-text-sm);
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  cursor: pointer;
}

.map-fit-canada-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.map-filter-group-label-tight {
  margin-top: 6px;
}

.facility-dot-rng { background: #3b82f6; }
.facility-dot-compost { background: #22c55e; }
.facility-dot-lfg { background: #64748b; }
.facility-dot-mixed { background: #f59e0b; }
.facility-dot-both-mixed { background: #7c3aed; }
.facility-dot-transfer { background: #d9a441; }
.facility-dot-landfill { background: #7d6b57; }
.facility-dot-unpublished {
  background: #8a9099;
  border: 1.5px solid #f59e0b;
  box-sizing: border-box;
}

.portal-process-lines {
  display: grid;
  gap: 0.65rem;
}

.portal-process-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.portal-header { margin-bottom: 0; }
.portal-kicker {
  margin: 0 0 6px;
  font-size: var(--fg-text-xs);
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.portal-chips-row {
  padding: 6px 0 4px;
}
.portal-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
.portal-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fg-text-2xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
}
.portal-chip-rng { background: #dbeafe; color: #1d4ed8; }
.portal-chip-compost { background: #dcfce7; color: #15803d; }
.portal-chip-mixed { background: #fef3c7; color: #b45309; }
.portal-chip-status { background: #e2e8f0; color: #334155; }
.portal-chip-province { background: #f1f5f9; color: #475569; }
.portal-chip-draft { background: #fee2e2; color: #b91c1c; }
.portal-lead { margin: 0; font-size: var(--fg-text-sm); line-height: var(--fg-line); color: #334155; }

.portal-subsection {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0efec;
}

.portal-subsection:first-child,
.portal-tab-panel > .portal-subsection:first-child,
.portal-tab-panel > .inspector-dl:first-child,
.portal-tab-panel > .inspector-list:first-child,
.portal-tab-panel > .inspector-muted:first-child,
.portal-tab-panel > .portal-narrative:first-child,
.portal-tab-panel > p:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.portal-section-label,
.portal-subsection-label {
  margin: 0 0 6px;
  font-size: var(--fg-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-family: var(--fg-font);
}

.portal-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid #e2e8f0;
}
.portal-tab {
  padding: 7px 11px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: transparent;
  color: #64748b;
  font-family: var(--fg-font);
  font-size: var(--fg-text-xs);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1.2;
}
.portal-tab:hover {
  color: var(--fg-ink);
}
.portal-tab.is-active {
  background: transparent;
  color: var(--fg-ink);
  border-bottom-color: var(--fg-ink);
  font-weight: 700;
}
.portal-tab-panel {
  display: none;
  padding-top: 10px;
}
.portal-tab-panel.is-active { display: block; }
.portal-narrative {
  margin: 0 0 8px;
  font-size: var(--fg-text-sm);
  line-height: var(--fg-line);
  color: #334155;
  font-weight: 500;
}

.portal-narrative .portal-value-list {
  margin: 0;
}
.portal-actions {
  margin: 8px 0 0;
}
.portal-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 10px;
}
.portal-action-link {
  font-size: var(--fg-text-xs);
  font-weight: 600;
  color: var(--fg-blue, var(--fg-accent, #56b8cf));
  text-decoration: none;
}
.portal-action-link:hover {
  text-decoration: underline;
}
.portal-table-wrap { overflow-x: auto; margin: 0 0 8px; }
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fg-text-xs);
}
.portal-table th,
.portal-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}
.portal-table th {
  font-size: var(--fg-text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-weight: 700;
}
.portal-table td {
  color: var(--fg-body);
  font-weight: 500;
}
.portal-sisters {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--fg-border);
}
.portal-sisters h4 {
  margin: 0 0 6px;
  font-size: var(--fg-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.portal-tabs-scroll { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; white-space: nowrap; scrollbar-width: thin; }
.portal-tabs-scroll .portal-tab { flex: 0 0 auto; }

.map-inspector-body .portal-kicker { display: none; }

.map-inspector-body .portal-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--fg-surface);
  margin: 0 -14px;
  padding: 0 14px;
  box-shadow: 0 6px 8px -6px rgba(15, 23, 42, 0.12);
}

/* ── Editor page: content gates + add facility ─────────────────── */
.map-gates-hint {
  margin: 0 0 8px;
  font-size: var(--fg-text-xs);
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.45;
}

.map-content-gates {
  flex-direction: column;
  align-items: stretch;
}

.map-gate-chip.map-filter-chip {
  justify-content: flex-start;
}

.map-sidebar-editor-tools {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.map-sidebar-editor-tools .map-filter-group-label {
  color: rgba(255, 255, 255, 0.72);
}

.map-sidebar-editor-status {
  color: rgba(255, 255, 255, 0.5);
}

.map-sidebar .btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-family: var(--fg-font);
  font-weight: 600;
}

.map-sidebar .btn-blue {
  background: var(--fg-accent, #56b8cf);
  color: #fff;
}

.map-sidebar .btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.map-sidebar .btn-toggle.active {
  background: var(--fg-data-compost, #b8925a);
  color: #fff;
  border-color: var(--fg-data-compost, #b8925a);
}

.map-add-form {
  position: absolute;
  top: 70px;
  left: 16px;
  z-index: 15;
  background: #fff;
  border: 1px solid #e5e9f0;
  border-radius: 10px;
  padding: 16px;
  width: 280px;
  box-shadow: 0 6px 24px rgba(11, 26, 51, 0.15);
  display: none;
}

.map-add-form.show {
  display: block;
}

.map-add-form-title {
  display: block;
  font-size: 13px;
  color: #07080a;
  margin-bottom: 4px;
}

.map-add-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-top: 8px;
}

.map-add-form input,
.map-add-form select {
  width: 100%;
  padding: 8px 10px;
  margin-top: 3px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: var(--fg-font);
  font-size: 13px;
  box-sizing: border-box;
}

.map-add-form .form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.map-inspector-editor-bar {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.map-inspector-gate-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-right: auto;
}

.map-gate-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-gate-badge-draft {
  background: #fef3c7;
  color: #92400e;
}

.map-gate-badge-ready {
  background: #dcfce7;
  color: #166534;
}

.map-gate-badge-new {
  background: #dbeafe;
  color: #1e40af;
}

/* ── Inline portal editor forms ─────────────────────────────────── */
.portal-inline-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-form-section {
  border: 1px solid #eceae6;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.portal-form-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.portal-form-section-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #78716c;
}

.portal-form-section-head .portal-form-section-title {
  margin-bottom: 0;
}

.portal-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
}

.portal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.portal-field-block {
  grid-column: 1 / -1;
}

.portal-field-label {
  font-size: 11px;
  font-weight: 600;
  color: #57534e;
}

.portal-field-input,
.portal-field-textarea,
.portal-list-cell input,
.portal-list-cell textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid #d6d3d1;
  border-radius: 6px;
  font-family: var(--fg-font);
  font-size: 12px;
  color: #1c1917;
  background: #fafaf9;
}

.portal-field-textarea,
.portal-list-cell textarea {
  resize: vertical;
  min-height: 56px;
}

.portal-form-empty {
  margin: 0;
  font-size: 11px;
  color: #a8a29e;
}

.portal-list-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-list-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px dashed #e7e5e4;
  border-radius: 8px;
  background: #fafaf9;
}

.portal-list-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.portal-list-cell span {
  font-size: 10px;
  font-weight: 600;
  color: #78716c;
}

.portal-list-cell-wide {
  grid-column: span 2;
}

.portal-list-remove {
  width: 28px;
  height: 28px;
  border: 1px solid #e7e5e4;
  border-radius: 6px;
  background: #fff;
  color: #78716c;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.portal-editor-advanced {
  margin-top: 12px;
  border-top: 1px solid #eceae6;
  padding-top: 10px;
}

.portal-editor-advanced > summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: #78716c;
  list-style: none;
}

.portal-editor-advanced > summary::-webkit-details-marker {
  display: none;
}

.portal-editor-panel .portal-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.portal-editor-status {
  margin: 6px 0 0;
  font-size: 11px;
  color: #166534;
}

.portal-editor-status-error {
  color: #b91c1c;
}

.portal-editor-status-dirty {
  color: #92400e;
}

.portal-editor-status-saving {
  color: #57534e;
}

.inspector-edit-save-status {
  margin: 0;
  font-size: 11px;
  color: #166534;
  flex: 1;
}

.portal-site-record {
  margin-bottom: 12px;
}

.portal-site-publish-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 12px 0 4px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.portal-site-publish-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.portal-site-publish-state {
  font-size: 12px;
  color: #334155;
}

.portal-site-record-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 10px;
}

.portal-site-record-meta {
  margin: 0;
  font-size: 11px;
  color: #78716c;
}

.portal-site-location-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eceae6;
}

.portal-site-location-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.portal-site-location-hint {
  font-size: 11px;
  color: #78716c;
  line-height: 1.4;
}

.portal-site-location-actions .inspector-btn.is-active {
  box-shadow: inset 0 0 0 2px rgba(212, 154, 0, 0.45);
}

.portal-site-location-actions .inspector-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.portal-field-input-readonly {
  background: #f5f4f1;
  color: #57534e;
  cursor: default;
}

.portal-form-hint {
  margin: 0 0 10px;
  font-size: 11px;
  color: #78716c;
  line-height: 1.45;
}

.portal-editor-content {
  border-top: 1px solid #eceae6;
  padding-top: 10px;
}

.portal-editor-panels .portal-editor-panel {
  padding-top: 8px;
}
/* === Modern layout pass (Phase A + B) === */
.map-sidebar-kicker {
  color: #8fa3bf;
}

.map-sidebar-title-main {
  font-size: 15px;
}

.map-summary-stats div {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(212, 154, 0, 0.18);
  border-radius: 10px;
  padding: 10px 8px;
}

.map-summary-stats dt {
  font-size: 10px;
  color: #8fa3bf;
}

.map-summary-stats dd {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
}

.map-filter-chip.map-filter-pill {
  position: relative;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.map-filter-chip.map-filter-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.map-filter-chip.map-filter-pill:has(input:checked) {
  background: rgba(212, 154, 0, 0.2);
  border-color: rgba(212, 154, 0, 0.55);
  color: #fde68a;
  box-shadow: 0 0 0 1px rgba(212, 154, 0, 0.15);
}

.map-filter-chip.map-filter-pill:active {
  transform: scale(0.98);
}

.map-filter-chip.map-filter-pill.map-filter-pill--wide {
  display: inline-flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  text-transform: none;
  letter-spacing: 0.02em;
}

.map-filter-dock {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  width: min(420px, calc(100% - 24px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(11, 26, 51, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(212, 154, 0, 0.28);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}

.map-filter-dock--quick {
  width: auto;
  max-width: min(520px, calc(100% - 24px));
  padding: 8px 12px;
}

.map-sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
  flex-shrink: 0;
}

.map-sidebar-search-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg-data-compost, #b8925a);
  font-size: 16px;
  font-weight: 700;
}

.map-search-input-sidebar {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: #f8fafc;
  font-family: var(--fg-font);
  font-size: 13px;
  font-weight: 600;
}

.map-search-input-sidebar::placeholder {
  color: #8fa3bf;
}

.map-search-input-sidebar:focus {
  outline: none;
  border-color: rgba(6, 95, 212, 0.65);
  box-shadow: 0 0 0 3px rgba(6, 95, 212, 0.2);
}

.map-result-count-sidebar {
  margin: 0;
  padding: 0 10px 6px;
  font-size: 11px;
  color: #8fa3bf;
}

.map-filter-dock-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.map-filter-dock-search-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg-data-compost, #b8925a);
  font-size: 16px;
  font-weight: 700;
}

.map-search-input-dock {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: #f8fafc;
  font-family: var(--fg-font);
  font-size: 13px;
  font-weight: 600;
}

.map-search-input-dock::placeholder {
  color: #8fa3bf;
}

.map-search-input-dock:focus {
  outline: none;
  border-color: rgba(6, 95, 212, 0.65);
  box-shadow: 0 0 0 3px rgba(6, 95, 212, 0.2);
}

.map-filter-dock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map-filter-dock-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fa3bf;
}

.map-filter-chips-dock {
  flex: 1;
  min-width: 0;
}

.map-filter-dock .map-result-count {
  margin: 8px 0 0;
  font-size: 11px;
  color: #8fa3bf;
}

.map-sidebar-browse {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  margin: 4px -10px 0;
  padding: 0;
  width: calc(100% + 20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.map-sidebar-browse.map-sidebar-section {
  margin-top: 8px;
  padding-top: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.map-sidebar-browse-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  padding: 0 10px;
}

.map-org-scroller-tall {
  max-height: none;
  flex: 1;
  min-height: 120px;
  width: 100%;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  background: rgba(0, 0, 0, 0.22);
}

.map-sidebar-browse .map-org-list {
  padding: 0;
}

.map-sidebar-browse .map-org-card {
  padding-left: 10px;
  padding-right: 10px;
}

.map-sidebar-browse .map-org-empty-actions {
  margin: 10px 10px 8px;
}

.map-org-card {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}

.map-org-card:hover,
.map-org-item.is-hover .map-org-card {
  background: rgba(255, 255, 255, 0.06);
}

.map-org-item.is-active .map-org-card {
  background: rgba(212, 154, 0, 0.14);
  box-shadow: inset 3px 0 0 var(--fg-data-compost, #b8925a);
}

.map-org-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.map-org-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  color: #f8fafc;
}

.map-org-count {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--fg-data-compost, #b8925a);
  white-space: nowrap;
}

.map-org-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.map-org-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #cbd5e1;
}

.map-org-chip-more {
  color: var(--fg-data-compost, #b8925a);
  border-color: rgba(212, 154, 0, 0.35);
}

.map-search-hit {
  background: rgba(212, 154, 0, 0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 1px;
}

.map-org-empty-actions {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  text-align: center;
}

.map-org-empty-msg {
  margin: 0 0 8px;
  font-size: 12px;
  color: #8fa3bf;
}

.map-clear-filters-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(212, 154, 0, 0.45);
  background: rgba(212, 154, 0, 0.16);
  color: #fde68a;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.map-clear-filters-btn:hover {
  background: rgba(212, 154, 0, 0.26);
}

.map-stage .map-inspector {
  position: absolute;
  z-index: 6;
}

.map-inspector-header {
  background: #07080a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.map-inspector-header h2 {
  color: #f8fafc;
}

.map-inspector-kicker {
  color: #8fa3bf;
}

.map-inspector-close {
  color: #cbd5e1;
}

.map-inspector-body {
  background: #fafaf9;
}

@media (min-width: 901px) {
  .map-stage .map-inspector {
    top: 12px;
    right: 12px;
    bottom: 12px;
    left: auto;
    width: var(--map-inspector-width, 420px);
    max-width: min(460px, 44vw);
    flex: none;
    max-height: none;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s ease, opacity 0.22s ease, box-shadow 0.28s ease;
  }

  .map-shell.map-inspector-open .map-stage .map-inspector.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    flex: none;
    max-height: none;
    border-top-width: 0;
  }

  .map-stage .map-inspector-resize {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    height: auto;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    cursor: ew-resize;
  }

  .map-stage .map-inspector-resize-grip {
    width: 4px;
    height: 40px;
  }

  body.map-inspector-dragging {
    cursor: ew-resize !important;
  }

  .map-canvas-legend {
    bottom: 16px;
    left: 16px;
  }

  .map-shell.map-inspector-open .map-canvas-legend {
    right: calc(var(--map-inspector-width, 420px) + 28px);
    left: auto;
  }
}

@media (max-width: 900px) {
  .map-filter-dock {
    top: 56px;
    left: 8px;
    width: calc(100% - 16px);
    padding: 10px 12px;
  }

  .map-filter-chip.map-filter-pill {
    min-height: 36px;
    padding: 8px 12px;
  }

  .map-stage .map-inspector {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 0;
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    opacity: 1;
    pointer-events: none;
    transition: transform 0.28s ease, max-height 0.28s ease;
  }

  .map-shell.map-inspector-open .map-stage .map-inspector.is-open {
    transform: translateY(0);
    pointer-events: auto;
    max-height: min(70dvh, var(--map-inspector-height));
  }

  .map-sidebar {
    width: min(var(--map-sidebar-width), 88vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-filter-chip.map-filter-pill,
  .map-stage .map-inspector,
  .map-org-card {
    transition: none;
  }
}

/* ── Paywall & sample banners (Obsidian accent) ──────────────────── */
.portal-chip-sample { background: rgba(86, 184, 207, 0.16); color: #56b8cf; }
.portal-chip-locked { background: rgba(86, 184, 207, 0.1); color: #8a9099; }

.portal-paywall-banner {
  background: #0b1220;
  color: #f3f1ec;
  border: 1px solid rgba(86, 184, 207, 0.35);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 10px;
  font-size: var(--fg-text-xs);
  font-weight: 500;
  line-height: var(--fg-line);
}
.portal-paywall-banner a {
  color: #56b8cf;
  font-weight: 700;
  text-decoration: underline;
}

.portal-sample-banner {
  background: rgba(86, 184, 207, 0.12);
  color: #56b8cf;
  border: 1px solid rgba(86, 184, 207, 0.4);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 10px;
  font-size: var(--fg-text-xs);
  font-weight: 600;
  line-height: var(--fg-line);
}

.portal-paywall {
  background: #0b1220;
  border: 1px solid rgba(86, 184, 207, 0.3);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 4px 0;
}
.portal-paywall-title {
  margin: 0 0 6px;
  font-size: var(--fg-text-lg);
  font-weight: 700;
  color: #f3f1ec;
}
.portal-paywall .inspector-muted {
  color: #9aa3ad;
}
.portal-paywall-cta {
  display: inline-block;
  margin-top: 10px;
  background: #56b8cf !important;
  border-color: #56b8cf !important;
  color: #07080a !important;
}
.portal-paywall-cta:hover {
  background: #6fc7db !important;
  border-color: #6fc7db !important;
}
.portal-paywall-note {
  margin-top: 8px !important;
  padding: 0 !important;
  font-size: var(--fg-text-2xs) !important;
  color: #7a828c !important;
}

.fg-jurisdiction-filters {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.fg-jurisdiction-heading {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a9199;
  margin-bottom: 0.35rem;
}
.fg-jurisdiction-group .fg-province-grid {
  margin-bottom: 0.15rem;
}
