/* spectrum-platform-next/styles/views-map.css
   ──────────────────────────────────────────────────────────────────────────
   Map view — ported from spectrum-platform-pages/styles.css map section,
   re-skinned onto the next design tokens. Covers Leaflet pin markers, zone
   point pins, zone shapes (rect + polygon with edit handles), the floor-plan
   zoom/pan wrap + controls, measurement overlays, and the plan picker.
   ────────────────────────────────────────────────────────────────────────── */

/* Leaflet base container sits on the dark canvas. */
#map-leaflet-container { background: var(--bg-0); }
.map-leaflet-host { width: 100%; height: 100%; }
/* Attribution chip on every Leaflet map. leaflet.css paints #0078a8 links on
   80% white (3.1:1) and loads after this file, so these selectors outrank
   `.leaflet-container .leaflet-control-attribution` and `.leaflet-container a`.
   92% --bg-1 keeps --accent-text above 4.5:1 even over a white tile. */
.leaflet-container .leaflet-bottom .leaflet-control-attribution {
  background: color-mix(in srgb, var(--bg-1) 92%, transparent);
  color: var(--text-2);
}
.leaflet-container .leaflet-bottom .leaflet-control-attribution a { color: var(--accent-text); }

/* Dark basemap treatment (js/map-tiles.js `dark: true`). OSM raster tiles are
   light-only; CARTO's keyless dark basemap died 2026-09 (tiles watermarked
   "API KEY REQUIRED"), so the geographic map keeps its dark look via the
   established invert + hue-rotate filter on the BASE tile layer container
   only. Leaflet applies this class to the tile layer's own div (`className`
   option) — markers, zones, and popups live in other panes and keep their
   true colors. hue-rotate(180deg) restores hues after invert so water stays
   blue-ish; brightness/saturate tuned to sit close to the old CARTO dark_all. */
.map-tiles-dark {
  filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.35);
}
/* Contain the map area's internal stacking (Leaflet panes run z 200–700, the
   placement banner z 600, fp zoom controls z 100…) so none of it can paint
   over the sticky event header / global nav (z 100) when the page scrolls.
   (#map-leaflet-container already self-isolates via its z-index:1 below.) */
#map-canvas { isolation: isolate; }

/* While placing a pin, drawing a shape, measuring or georeferencing
   (body.map-placing / .map-drawing / .map-measuring) the click must reach the
   plan image — and, since 2026-09-18, the MAP: zone shapes, their
   labels/handles and every pin stop intercepting it.
   (Owner: a zone pin could not be dropped over an existing area — the shape
   swallowed the click. Then: a trace could not be placed inside a zone on the
   geographic map — the source PINS over it swallowed that one.)
   `.pin-marker` / `.trace-pin` are the geographic (Leaflet divIcon) pins —
   `.pin-marker` is the inner column of EVERY one of them (analyzer, Pi, zone and,
   since 2026-09-18, trace), and `.trace-pin` is the trace pin's icon ROOT.
   drawGeoOverlays already builds them with `interactive:false` while a mode is
   armed, which is what frees Leaflet's own dispatch; this rule is what stops
   the pin's INNER divs (which Leaflet's own stylesheet never sees) from
   keeping the divIcon a hit target anyway. */
.map-placing .zone-shape, .map-placing .zone-shape-poly, .map-placing .zone-shape-poly polygon,
.map-placing .zone-shape-poly-label-html, .map-placing .zone-shape-handle, .map-placing .zone-shape-vertex, .map-placing .fp-pin,
.map-placing .pin-marker, .map-placing .trace-pin,
.map-drawing .zone-shape, .map-drawing .zone-shape-poly, .map-drawing .zone-shape-poly polygon,
.map-drawing .zone-shape-poly-label-html, .map-drawing .zone-shape-handle, .map-drawing .zone-shape-vertex, .map-drawing .fp-pin,
.map-drawing .pin-marker, .map-drawing .trace-pin,
.map-measuring .zone-shape, .map-measuring .zone-shape-poly, .map-measuring .zone-shape-poly polygon,
.map-measuring .zone-shape-poly-label-html, .map-measuring .zone-shape-handle, .map-measuring .zone-shape-vertex, .map-measuring .fp-pin,
.map-measuring .pin-marker, .map-measuring .trace-pin {
  pointer-events: none !important;
}
/* …including the glyph, which is the pin's ONE permanent hit target (see the
   pin block below). Its own `pointer-events: auto` sits on the glyph element
   itself, so an `!important` on the parent `.pin-marker` cannot reach it — a
   declaration on the element always beats an inherited one. Without this the
   30px dot would still eat the crosshair click while a mode is armed. */
.map-placing .pin-marker .pin-glyph,
.map-drawing .pin-marker .pin-glyph,
.map-measuring .pin-marker .pin-glyph {
  pointer-events: none !important;
}

/* Crosshair cursors for the active interaction modes. */
.map-placing #map-leaflet-container,
.map-placing .leaflet-container { cursor: crosshair !important; }
.map-drawing #floor-plan-img,
.map-drawing .leaflet-container { cursor: crosshair !important; }
.map-measuring #floor-plan-img,
.map-measuring .leaflet-container { cursor: crosshair !important; }

/* ── Analyzer / Pi / trace / zone pin markers (Leaflet divIcons) ──────────── */
/* A pin is a 30px GLYPH with a wide caption under it, and only the glyph is a
   control. The whole stack is therefore click-transparent and the glyph opts
   back in — one element wide instead of the label's ~140px.
   Three elements own the caption's box and every one of them had to be taken
   out, or the click simply landed on the next one up:
     · `.pin-label` / `.pin-kind` / `.pin-badge`   (the captions themselves)
     · `.pin-marker`                 (the divIcon's inner flex column)
     · the Leaflet icon ROOT         (`.analyzer-pin` / `.zone-pin` /
                                      `.trace-pin`, below)
   `iconSize: null` (sourceIcon / zoneIcon) leaves the root shrink-to-fit
   around the label, and leaflet.css re-arms it with
   `.leaflet-marker-icon.leaflet-interactive { pointer-events: auto }` — so
   neutralising the captions alone moved the hit target one level up and
   reclaimed nothing (measured: elementFromPoint at the label's centre returned
   DIV.pin-marker, then DIV…analyzer-pin, before the root rule went in).
   Dragging is unaffected: L.Marker's Draggable binds to the icon ROOT, and a
   mousedown on the glyph still bubbles to it through the none'd ancestors. */
.pin-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
/* The Leaflet icon root. Scoped through `.leaflet-pane` for specificity (0,3,0)
   — views-map.css is linked BEFORE leaflet.css (engine/vendor-scripts.js
   appends leaflet.css at the end of <head>), so a plain
   `.leaflet-marker-icon.analyzer-pin` (0,2,0) would tie with, and lose to,
   leaflet's own `.leaflet-marker-icon.leaflet-interactive`. */
.leaflet-pane .leaflet-marker-icon.analyzer-pin,
.leaflet-pane .leaflet-marker-icon.zone-pin,
.leaflet-pane .leaflet-marker-icon.trace-pin {
  pointer-events: none;
}
.pin-marker .pin-glyph {
  pointer-events: auto;     /* the pin's one hit target: drag handle + tooltip */
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--text-muted);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.pin-marker.analyzer.online  .pin-glyph,
.pin-marker.pi.online        .pin-glyph { background: var(--ok); }
.pin-marker.analyzer.stale   .pin-glyph,
.pin-marker.pi.stale         .pin-glyph { background: var(--warn); border-color: #fff; }
.pin-marker.analyzer.offline .pin-glyph,
.pin-marker.pi.offline       .pin-glyph { background: var(--danger-strong); }
.pin-marker.zone             .pin-glyph { background: var(--zone-color, #a855f7); }
/* A TRACE pin is one antenna of an analyzer, and it must be tellable from the
   analyzer at a glance — so its glyph carries the KIND (the same --pin accent the
   sidebar's trace rows use), not the status colours the analyzer/Pi glyphs use. A
   trace has no last_seen of its own anyway: the status it shows is its analyzer's,
   and it is on the row's pill and the pin's tooltip. */
.pin-marker.trace            .pin-glyph { background: var(--pin); }
/* The name, the kind flag and the provenance badge are CAPTIONS, not controls.
   Redundant now that `.pin-marker` and the icon root are both none (a child
   inherits it), and kept deliberately: it is the declaration that says WHY these
   three are not controls, and it is what keeps them captions if the stack above
   them is ever re-armed. `.pin-label` is a wide text box under a 30px dot, so while the
   stack took pointer events a pin covered far more of the map than it looked
   like — measured on prod event 26, where document.elementFromPoint returned
   DIV.pin-label (or DIV.pin-marker) at all twelve points sampled inside a zone
   area, never the polygon and never the map, so a click meant for the zone had
   nowhere to land. This holds whether or not a mode is armed; the block at the
   top of this file is the while-armed half. */
.pin-marker .pin-label,
.pin-marker .pin-kind,
.pin-marker .pin-badge { pointer-events: none; }
.pin-marker .pin-label {
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  background: rgba(10, 14, 22, .92);
  color: #fff;
  border-radius: var(--r-sm);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The KIND flag ("Trace") — a small chip under the name saying what the pin is.
   Separate from `.pin-badge`, which means placement provenance ("Manual" /
   "GPS ±6.4 m"); one caption cannot honestly carry both. */
.pin-marker .pin-kind {
  padding: 0 5px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: var(--pin);
  background: rgba(10, 14, 22, .92);
  border: 1px solid var(--pin);
  border-radius: var(--r-pill);
  white-space: nowrap;
}

/* ── Floor-plan zoom + pan ─────────────────────────────────────────────────── */
.fp-zoom-wrap {
  position: absolute;
  inset: 0;
  transform-origin: center;
  will-change: transform;
  touch-action: none;     /* let our pointer handlers own pan/zoom on touch */
}
.fp-zoom-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(10, 14, 22, .85);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.fp-zoom-controls button {
  background: transparent;
  border: none;
  color: var(--text-2);
  width: 28px;
  height: 28px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-weight: 600;
}
.fp-zoom-controls button:hover { background: rgba(255, 255, 255, .08); color: var(--text-1); }
#floor-plan-img { touch-action: none; user-select: none; -webkit-user-drag: none; }

.fp-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .55);
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  transform-origin: center;
  z-index: 8;
  cursor: pointer;
}
.fp-pin-label {
  position: absolute;
  margin-top: 2px;
  transform: translate(-50%, 6px) scale(var(--inv-zoom, 1));
  transform-origin: top center;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(10, 14, 22, .9);
  color: #fff;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 8;
}
.fp-pin.trace-fp-pin { width: 10px; height: 10px; }

/* ── Zone shapes: rect ───────────────────────────────────────────────────────
   Drawn in the zone's colour (--zone-color, set per shape from js zoneColor())
   — the SAME colour as the zone card's swatch and the zone's pins. */
.zone-shape {
  position: absolute;
  border: 2px solid var(--zone-color, #a855f7);
  background: color-mix(in srgb, var(--zone-color, #a855f7) 16%, transparent);
  box-sizing: border-box;
  border-radius: 2px;
}
.zone-shape-label {
  position: absolute;
  top: 2px;
  left: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
  background: rgba(10, 14, 22, .65);
  padding: 1px var(--s1);
  border-radius: 3px;
  white-space: nowrap;
  transform-origin: top left;
  transform: scale(var(--inv-zoom, 1));
}
.zone-shape-preview {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(59, 130, 246, .20);
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 2px;
}
.zone-shape-rect { pointer-events: auto; cursor: pointer; }
.zone-shape-rect.zone-shape-selected {
  border-color: var(--warn);
  background: rgba(251, 191, 36, .18);
  cursor: move;
  z-index: 5;
}
.zone-shape-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--warn);
  border: 1px solid #110;
  border-radius: 2px;
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  pointer-events: auto;
  z-index: 6;
  touch-action: none;
}
.zone-shape-handle-nw { cursor: nwse-resize; }
.zone-shape-handle-ne { cursor: nesw-resize; }
.zone-shape-handle-sw { cursor: nesw-resize; }
.zone-shape-handle-se { cursor: nwse-resize; }

/* ── Zone shapes: polygon (SVG) ────────────────────────────────────────────── */
/* No browser focus ring on the overlay SVGs. Chrome focuses an inline <svg>
   root on a click and paints its focus ring (the SVG's bounding box) as soon
   as a key press — Esc leaving draw mode — makes :focus-visible match:
   measured live 2026-09-18 (ev30) as a blue rectangle around a zone polygon
   that outlived "Draw on map". These overlays are not keyboard controls
   (nothing inside them takes focus); the ring stays on the real controls
   (base.css :focus-visible → --ring). */
.zone-shape-poly:focus, .zone-shape-poly:focus-visible,
.zone-shape-poly-preview:focus, .zone-shape-poly-preview:focus-visible,
.measure-svg:focus, .measure-svg:focus-visible,
.leaflet-container svg:focus, .leaflet-container svg:focus-visible,
.leaflet-interactive:focus, .leaflet-interactive:focus-visible { outline: none; }
.zone-shape-poly polygon {
  fill: color-mix(in srgb, var(--zone-color, #a855f7) 18%, transparent);
  stroke: var(--zone-color, #a855f7);
  stroke-width: 2;
  pointer-events: auto;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}
.zone-shape-poly.zone-shape-selected polygon {
  fill: rgba(251, 191, 36, .20);
  stroke: var(--warn);
  cursor: move;
}
.zone-geo-shape { cursor: pointer; }
.zone-geo-shape-selected { cursor: default; }
.zone-geo-shape-pending { opacity: .55; }
.zone-geo-vertex-icon { background: none; border: 0; }
.zone-geo-vertex {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--warn);
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, .6);
  cursor: grab;
}
.zone-geo-popup .leaflet-popup-content { margin: 10px var(--s3); }
.zone-shape-poly-label-html {
  position: absolute;
  background: rgba(10, 14, 22, .75);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--zone-color, #a855f7) 40%, transparent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .30);
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  transform-origin: center;
  pointer-events: none;
}
.zone-shape-vertex {
  fill: var(--warn);
  stroke: #110;
  stroke-width: 1;
  pointer-events: auto;
  cursor: grab;
  vector-effect: non-scaling-stroke;
}
.zone-shape-vertex:active { cursor: grabbing; }
.zone-shape-poly-preview { position: absolute; pointer-events: none; }
.zone-shape-poly-preview polyline,
.zone-shape-poly-preview circle { vector-effect: non-scaling-stroke; }

/* ── Measurement overlays (floor SVG) ──────────────────────────────────────── */
.measure-svg { position: absolute; pointer-events: none; }
.measure-svg polyline,
.measure-svg polygon {
  fill: rgba(251, 191, 36, .18);
  stroke: var(--warn);
  stroke-width: 2;
  stroke-dasharray: 4, 3;
  vector-effect: non-scaling-stroke;
}
.measure-svg polygon { stroke-dasharray: none; }
.measure-svg.measure-scale polyline { stroke: var(--accent); stroke-dasharray: 6, 2; }
.measure-preview { position: absolute; pointer-events: none; }
.measure-label {
  position: absolute;
  background: rgba(10, 14, 22, .88);
  color: var(--warn);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: .2px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transform: translate(-50%, -50%) scale(var(--inv-zoom, 1));
  transform-origin: center;
  pointer-events: none;
  z-index: 9;
}
.measure-label-scale { color: var(--accent-text); }
.measure-label-quiet,
.measure-label.floor-scale-bar {
  background: transparent;
  padding: 0;
  color: var(--text-1);
  font-weight: 500;
}
.measure-svg.floor-scale-bar polyline {
  fill: none;
  stroke: var(--text-1);
  stroke-dasharray: none;
  stroke-width: 1.5;
}
.measure-label-uncalibrated { color: var(--danger); }
.map-sources-head[aria-expanded="true"] .adm-chevron,
.map-spot-scans-head[aria-expanded="true"] .adm-chevron {
  transform: rotate(90deg);
}
.measure-tip { background: rgba(10, 14, 22, .9); color: var(--warn); border: none; }

/* ── Plan picker rows (rename / reorder inline) ────────────────────────────── */
.plan-picker-row {
  display: flex;
  align-items: center;
  gap: var(--s1);
  width: 100%;
  padding: 6px 10px;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  color: var(--text-1);
  font-size: 12px;
}
.plan-picker-row:hover { background: var(--bg-raised); }
.plan-picker-row.current { color: var(--accent-text); background: var(--bg-raised); }
.plan-picker-row-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-picker-row-up,
.plan-picker-row-down,
.plan-picker-row-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px var(--s1);
  flex-shrink: 0;
  border-radius: var(--r-sm);
  line-height: 1;
}
.plan-picker-row-up:hover:not([disabled]),
.plan-picker-row-down:hover:not([disabled]),
.plan-picker-row-edit:hover { color: var(--text-1); background: var(--bg-2); }
.plan-picker-row-up[disabled],
.plan-picker-row-down[disabled] { opacity: .25; cursor: default; }
.plan-picker-row.editing { gap: var(--s1); padding: 6px var(--s2); }
.plan-picker-row-save,
.plan-picker-row-cancel,
.plan-picker-row-delete {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.plan-picker-row-save { color: var(--accent-text); border-color: var(--accent-soft); }
.plan-picker-row-delete { color: var(--danger); border-color: var(--danger-dim); }
.plan-picker-row-delete:hover { background: var(--danger-dim); color: #ffb4b4; }

/* PDF multi-page upload grid (in the upload modal). */
.fp-page-grid-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-mono);
}
.fp-page-grid-header button {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  font-size: 11px;
  padding: 2px var(--s2);
  cursor: pointer;
}
.fp-thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--s2);
  max-height: 320px;
  overflow-y: auto;
}
.fp-page-thumb {
  border: 2px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 6px;
  background: var(--bg-raised);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}
.fp-page-thumb.selected { border-color: var(--accent); }
.fp-page-thumb img { width: 100%; height: 70px; object-fit: contain; background: var(--bg-0); border-radius: 3px; }
.fp-page-thumb .fp-page-label { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
/* The page name field is the kit compact .input.input-sm (map.js). */

/* Source cards: the ONE corner control in a card's top-right - the expand /
   collapse chevron on a card with child traces, the instrument "?" on a trace
   card (owner, 2026-10-13). A 28px hit box with a 14-16px icon, absolutely
   positioned in the row (which is position:relative), so it adds no height; the
   name line reserves its width and ellipsizes before it. */
.map-sidebar .source-row .source-corner {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  line-height: 1;
}
.map-sidebar .source-row .source-corner:hover,
.map-sidebar .source-row .source-corner[aria-expanded="true"].source-info { color: var(--text-1); background: var(--bg-2); }
.map-sidebar .source-row .source-corner:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* The 28px box IS the hit area; help-tip's -12px touch halo would spill past the card's edge. */
.map-sidebar .source-row .source-corner::after { content: none; }
.map-sidebar .source-row .source-chevron svg { transition: transform .15s ease; }
.map-sidebar .source-row .source-chevron[data-collapsed="1"] svg { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .map-sidebar .source-row .source-chevron svg { transition: none; } }

/* Zone card: the marker count is a small muted number in the header row,
   immediately left of the "?" (replaces the "24 markers" line). */
.map-sidebar .zone-row .zone-marker-count {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 1.5ch;
  text-align: right;
}

/* ── View chrome, sidebar and dialogs (UI audit D3, N42/N44) ─────────────────
   These were style.cssText strings in js/views/map.js. Same declarations,
   moved as-is (no visual change), so tokens and themes now reach them. This
   block sits above the phone media query below, so its !important overrides
   still win. Kit nodes (Button / Badge / Chip), the local <input> styles,
   the bespoke plan-picker buttons (they become kit Buttons, see
   btn-selector-ratchet) and the per-item colours still set inline are the
   second D3 PR. */

/* View roots + layout (both the event map and the fleet map #/map). */
.map-view { display: flex; flex-direction: column; flex: 1 1 0; background: var(--bg-1); position: relative; }
.map-view--event { height: 100%; min-height: 0; }
.map-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }
#map-canvas { flex: 1; min-width: 0; position: relative; background: var(--bg-0); overflow: hidden; display: flex; flex-direction: column; }
#map-leaflet-container { width: 100%; flex: 1; min-height: 0; position: relative; z-index: var(--z-local); }
.map-sidebar { width: 280px; flex-shrink: 0; background: var(--bg-card); border-left: 1px solid var(--border-subtle); overflow-y: auto; display: flex; flex-direction: column; }
.map-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg-0); color: var(--text-muted); }
.map-placeholder-label { font-family: var(--font-mono); font-size: 13px; letter-spacing: .6px; color: var(--text-muted); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: var(--s4) 28px; background: var(--bg-card); }
.map-placeholder-coord { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.map-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 600; background: rgba(11,17,28,.92); border: 1px solid var(--accent); border-radius: var(--r-md); padding: 7px var(--s4); font-size: 12px; font-family: var(--font-mono); color: var(--accent-text); letter-spacing: .4px; display: none; pointer-events: none; backdrop-filter: blur(8px); text-align: center; max-width: 90%; }

/* Fleet map (#/map) head + event list. */
.map-xev-chip { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 2px var(--s2); letter-spacing: .3px; white-space: nowrap; }
.map-xev-list-head { padding: 14px 14px var(--s2); font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; font-family: var(--font-mono); }
.btn.map-xev-row { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-radius: 0; background: transparent; }
.map-xev-row-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Event map head: event chip + plan picker. */
.map-event-chip { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 2px var(--s2); letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.map-plan-picker { display: none; align-items: center; gap: 6px; }
.map-plan-picker-label { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.map-plan-picker-name { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.map-plan-picker-caret { flex-shrink: 0; opacity: .7; }

/* Sidebar sections. */
.map-side-section { padding: 14px; }
.map-side-divider { height: 1px; background: var(--border-subtle); margin: 0 14px; }
.map-side-label { font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; font-family: var(--font-mono); }
.map-side-head { margin-bottom: 10px; }
.map-side-head-left { display: flex; align-items: center; gap: 7px; }
.map-fill { flex: 1; }
.map-fill-min0 { flex: 1; min-width: 0; }

/* Sources section + rows. */
.map-sources-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); cursor: pointer; user-select: none; }
.map-sources-head-left { display: flex; align-items: center; gap: 6px; }
.map-sources-count { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); text-align: right; min-width: 0; }
.map-sources-count-seg { white-space: nowrap; }
.map-sources-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.source-name-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.source-name { font-size: 12px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.source-line1 { display: flex; align-items: center; gap: var(--s1); min-width: 0; }
.source-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.source-sub { font-size: 10px; line-height: 1.35; color: var(--text-muted); font-family: var(--font-mono); min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.source-ctrl-spacer { flex: 1 1 0; min-width: 0; }

/* Zones section + rows. .zone-name is scoped: views-dect.css has one too. */
.map-zones-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.map-zones-list { display: flex; flex-direction: column; gap: 6px; }
.zone-row { display: flex; flex-direction: column; gap: 6px; padding: var(--s2) 10px; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-md); }
.zone-row-top { display: flex; align-items: center; gap: var(--s2); }
.zone-swatch-wrap { position: relative; display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.zone-color-reset { background: none; border: none; padding: 0 2px; color: var(--text-muted); font-size: 9px; line-height: 1; cursor: pointer; font-family: inherit; }
.zone-color-reset:hover { color: var(--text-2); }
.zone-row .zone-name { font-size: 12px; color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: none; padding: 0; text-align: left; cursor: pointer; font-family: inherit; }
.zone-everywhere-tag { flex-shrink: 0; font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent-text); border: 1px solid var(--accent); border-radius: var(--r-sm); padding: 1px 5px; line-height: 1.3; }
.zone-placements { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; min-width: 0; }
.zone-placement { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); background: none; border: none; padding: 0; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.zone-draw-wrap { position: relative; display: flex; align-items: center; }
.zone-everywhere { display: flex; flex-direction: column; gap: 2px; }
.zone-everywhere-label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); cursor: pointer; }
.zone-counts { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.zone-meta-sep { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); flex-shrink: 0; }
.zone-geo-shape-popup { display: flex; flex-direction: column; gap: var(--s2); min-width: 150px; }
.zone-geo-shape-popup-title { font-size: 12px; color: var(--text-1); }

/* Plan setup, georeference and sheet overlay rows. */
.map-plan-setup { margin-bottom: 14px; }
.map-setup-row { display: flex; flex-direction: column; gap: var(--s1); margin: 10px 0 var(--s2); }
.map-setup-row-tight { display: flex; flex-direction: column; gap: var(--s1); margin: 0 0 var(--s2); }
.map-setup-line { display: flex; align-items: center; gap: var(--s2); font-size: 11px; color: var(--text-2); }
.map-setup-hint { font-size: 10px; color: var(--text-muted); line-height: 1.35; }
.map-georef-row { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--s2); }
.map-georef-head { display: flex; align-items: baseline; gap: var(--s2); font-size: 11px; color: var(--text-2); }
.map-georef-title { flex: 1; font-weight: 500; }
.map-georef-steps { display: flex; flex-direction: column; gap: var(--s2); padding: 6px var(--s2); background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); }
.map-georef-step { display: flex; flex-direction: column; gap: 3px; }
.map-georef-step-head { display: flex; align-items: center; gap: var(--s1); font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); letter-spacing: .3px; }
.map-georef-warn { font-size: 10px; color: var(--warn); line-height: 1.35; }
.map-georef-tail { display: flex; justify-content: flex-end; }
.map-georef-ties { display: flex; flex-direction: column; gap: 3px; }
.map-georef-ties-note { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); padding: 2px 0; }
.map-georef-tie { display: flex; align-items: flex-start; gap: 6px; padding: var(--s1) 6px; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 10px; color: var(--text-2); cursor: pointer; }
.map-georef-tie-num { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; flex-shrink: 0; cursor: pointer; padding: 0; font-family: var(--font-mono); margin-top: 1px; }
.map-georef-tie-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.4; white-space: normal; word-break: break-word; }
.map-georef-tie-det { margin-top: 3px; padding-top: 3px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 1px; color: var(--text-2); }
.map-sheet-line { display: flex; align-items: center; gap: var(--s2); font-size: 11px; color: var(--text-2); flex-wrap: wrap; }
.map-sheet-toggle { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; cursor: pointer; }
.map-sheet-opacity { display: flex; align-items: center; gap: var(--s2); font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
.map-sheet-opacity-val { width: 34px; text-align: right; }

/* Measure section. */
.map-measure-tools { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: var(--s2); }
.map-measure-cancel { background: var(--bg-raised); border: 1px solid var(--border-subtle); color: var(--text-2); font-size: 11px; padding: var(--s1) 9px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; }
.map-measure-list { display: flex; flex-direction: column; gap: var(--s1); }
.map-measure-empty { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); padding: 6px 0; }
.map-measure-row { display: flex; align-items: center; gap: 6px; padding: 5px var(--s2); background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); }
.map-measure-row-icon { font-size: 11px; flex-shrink: 0; width: 14px; display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.measure-row-title { font-size: 11px; color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.map-measure-row-sep { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.measure-row-value { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.map-measure-row-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; flex-shrink: 0; display: inline-flex; align-items: center; }

/* Spot scans section + popup. The head's bottom gap follows aria-expanded. */
.map-spot-scans-head { display: flex; align-items: center; width: 100%; background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 0; }
.map-spot-scans-head[aria-expanded="true"] { margin-bottom: 10px; }
.map-spot-scans-list { flex-direction: column; gap: var(--s1); }
.map-spot-empty { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); padding: var(--s1) 0; }
.map-spot-row { display: flex; align-items: center; gap: var(--s2); width: 100%; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 7px 10px; cursor: pointer; text-align: left; }
.map-spot-row:hover { border-color: var(--accent); }
.map-spot-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(245,158,11,.85); flex-shrink: 0; }
.map-spot-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.map-spot-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s1); }
.map-spot-time { font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); }
.map-spot-dbm { font-size: 11px; font-family: var(--font-mono); color: var(--text-1); font-weight: 500; }
.map-spot-freq { font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); }
.map-spot-pop { display: flex; flex-direction: column; gap: var(--s3); min-width: 280px; max-width: 340px; padding: var(--s1) 0; }
.map-spot-pop-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.map-spot-pop-key { color: var(--text-muted); padding: var(--s1) 10px var(--s1) 0; white-space: nowrap; vertical-align: top; font-size: 11px; font-family: var(--font-mono); }
.map-spot-pop-val { color: var(--text-1); padding: var(--s1) 0; font-size: 12px; font-family: var(--font-mono); }
.map-spot-pop-chart { background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); height: 80px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.map-spot-pop-canvas { position: absolute; top: 5px; left: 0; right: 0; margin: auto; opacity: .85; }
.map-spot-pop-chart-label { position: absolute; bottom: 4px; right: 8px; font-size: 9px; font-family: var(--font-mono); color: var(--text-muted); letter-spacing: .3px; }

/* Licensed incumbents section. */
.map-inc-head { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-bottom: 6px; }
.map-inc-head-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.inc-layer-toggle { background: var(--bg-2); border: 1px solid var(--border-subtle); color: var(--text-2); font-size: 10px; padding: 3px var(--s2); border-radius: var(--r-sm); cursor: pointer; flex-shrink: 0; line-height: 1.4; }
.inc-provenance { font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); background: var(--bg-2); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); padding: 2px 6px; display: inline-block; margin-bottom: var(--s1); }
.inc-advisory { font-size: 10px; color: var(--text-muted); margin-bottom: var(--s2); }
.inc-rows { display: flex; flex-direction: column; gap: var(--s1); }
.inc-empty { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); padding: var(--s1) 0; }
.inc-row { display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-sm); }
.inc-row-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.inc-call { font-size: 11px; font-family: var(--font-mono); font-weight: 600; color: var(--text-1); }
.inc-tag { font-size: 9px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .5px; border-radius: var(--r-sm); padding: 1px 5px; flex-shrink: 0; color: var(--text-muted); background: var(--bg-2); }
.inc-tag.inc-tag-area { color: var(--warn); background: rgba(245,158,11,.12); }
.inc-licensee { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inc-band { font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); }

/* Survey heatmap section. */
.map-survey-head { display: flex; align-items: center; gap: 7px; margin-bottom: var(--s2); }

/* Floor-plan canvas messages + georeference tie pins. */
.map-fp-msg { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-family: var(--font-mono); font-size: 13px; }
.map-fp-msg-error { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--danger); font-family: var(--font-mono); font-size: 13px; }
.map-fp-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.fp-img-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--danger); font-family: var(--font-mono); font-size: 13px; }
.fp-pin.georef-tie-pin { width: 16px; height: 16px; background: var(--accent); border: 2px solid #fff; color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); pointer-events: none; }

/* Plan picker popover (rows: .plan-picker-row above). */
.map-plan-picker-pop { display: flex; flex-direction: column; gap: 0; min-width: 240px; max-height: 340px; overflow-y: auto; }
.map-plan-picker-empty { padding: 14px var(--s3); color: var(--text-muted); font-size: 12px; text-align: center; font-family: var(--font-mono); }
.plan-picker-check { color: var(--accent-text); width: 12px; flex-shrink: 0; display: flex; align-items: center; opacity: 0; }
.plan-picker-check.is-on { opacity: 1; }
.plan-picker-row.plan-picker-row-single { border-top: 1px solid var(--border-subtle); padding: 7px 10px 7px var(--s4); gap: var(--s2); }
.plan-picker-group { display: flex; align-items: center; gap: var(--s1); padding: var(--s2) 10px var(--s1); font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: .8px; text-transform: uppercase; font-family: var(--font-mono); border-top: 1px solid var(--border-subtle); }
.plan-picker-row.plan-picker-row-single.plan-picker-first,
.plan-picker-group.plan-picker-first { border-top: none; }
.plan-picker-group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dialogs: add zone, set scale, rename plan, use my position. */
.map-dlg-form { display: flex; flex-direction: column; gap: 10px; }
.map-dlg-label { font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: var(--s1); }
.map-dlg-footer { display: flex; gap: var(--s2); justify-content: flex-end; }
.map-dlg-footer-split { display: flex; gap: var(--s2); justify-content: space-between; }
.map-dlg-footer-group { display: flex; gap: var(--s2); }
.map-add-zone-hint { font-size: 12px; color: var(--text-muted); padding: var(--s2); background: var(--bg-raised); border-radius: var(--r-sm); border: 1px solid var(--border-subtle); margin: 0; }
.map-scale-row { display: flex; align-items: center; gap: 6px; }
.map-gps-body { display: flex; flex-direction: column; gap: var(--s2); min-width: 240px; }
.map-gps-note { font-size: 11px; color: var(--text-2); line-height: 1.4; }
.map-gps-live { font-family: var(--font-mono); font-size: 12px; color: var(--text-1); }

/* Floor-plan upload dialog + crop editor (crop stage/handles further down). */
.map-upload-body { display: flex; flex-direction: column; gap: var(--s3); }
.map-upload-hint { color: var(--text-2); font-size: 13px; margin: 0; }
.map-upload-drop { border: 2px dashed var(--border); border-radius: var(--r-md); padding: var(--s5); text-align: center; color: var(--text-muted); font-size: 13px; cursor: pointer; background: var(--bg-input); }
.map-upload-drop:hover { border-color: var(--accent); }
.map-upload-state { font-size: 12px; color: var(--text-muted); min-height: 16px; }
.map-upload-img { display: none; flex-direction: column; gap: var(--s1); font-size: 12px; color: var(--text-2); }
.map-upload-img-crop { display: none; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.map-upload-pdf { display: none; flex-direction: column; gap: 10px; }
.map-upload-modes { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-1); }
.map-upload-mode { display: flex; align-items: center; gap: var(--s2); cursor: pointer; }
.map-upload-pages { display: none; flex-direction: column; gap: var(--s2); }
.map-upload-pages-head { display: flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--text-muted); }
.map-upload-thumbs { display: grid; grid-template-columns: repeat(auto-fill,minmax(120px,1fr)); gap: 10px; max-height: 340px; overflow-y: auto; }
.fp-upload-page { display: flex; flex-direction: column; gap: var(--s1); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px; background: var(--bg-input); }
.fp-upload-page-top { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.fp-upload-page-check { display: flex; align-items: center; gap: 6px; cursor: pointer; flex: 1; min-width: 0; }
.fp-upload-page-img { width: 100%; height: auto; border-radius: var(--r-sm); background: #fff; }
.map-crop-section { display: none; flex-direction: column; gap: 10px; }
.map-crop-hint { margin: 0; font-size: 13px; color: var(--text-2); }
.map-crop-stage-wrap { display: flex; justify-content: center; max-width: 100%; overflow: hidden; }
.map-crop-status { font-size: 12px; color: var(--text-muted); min-height: 16px; }
.map-upload-footer { display: flex; gap: var(--s2); justify-content: flex-end; align-items: center; flex: 1; min-width: 0; }
.map-upload-footer-main { display: flex; gap: var(--s2); justify-content: flex-end; flex: 1; }
.fp-crop-footer { display: none; gap: var(--s2); align-items: center; flex: 1; min-width: 0; }
.fp-crop-summary { flex: 1; min-width: 0; font-size: 12px; color: var(--text-2); font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Fleet map (#/map): an immersive route (no topbar), and #app > .view is a
   plain block, so the root's height must be definite here or the map
   collapses to its content height (~135 px strip on desktop, audit N01).
   The phone rule below lets the column grow past the viewport instead,
   because the sidebar stacks under the map there. */
.map-view--cross-event { height: 100vh; height: 100dvh; min-height: 0; }

/* Mobile: collapse the sidebar under the map. */
@media (max-width: 720px) {
  .map-view--cross-event { height: auto; min-height: 100vh; min-height: 100dvh; }
  .map-body { flex-direction: column !important; }
  .map-sidebar {
    width: 100% !important;
    max-height: 42vh;
    border-left: none !important;
    border-top: 1px solid var(--border-subtle);
  }
  #map-canvas { min-height: 48vh; }
}

/* Touch: keep the Place button's 44px hit area without its 44px box.
   The sidebar is NOT hidden on a phone (it goes full width under the map,
   above), so this button really is tapped. It is the only `.btn` in the
   sidebar, and its inline `height:24px;min-height:0` — needed so it matches the
   ONLINE pill — beats components.css's `(pointer:coarse),(max-width:760px)
   .btn{min-height:var(--tap-min)}` rule (WCAG 2.5.5 / Apple HIG). Growing the
   box back would undo the owner's ask, so the hit area is restored with a
   transparent overlay instead: the pseudo-element belongs to the button, so a
   tap on it activates the button. It spans only the button's width and ~11px
   above/below, which stays inside the card — no neighbouring control is in
   reach. `position` is not set inline, so no !important is needed. */
@media (pointer: coarse), (max-width: 760px) {
  .map-sidebar .source-row .btn { position: relative; }
  .map-sidebar .source-row .btn::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: var(--tap-min);
    transform: translateY(-50%);
  }
}

/* Zone card placement lines ("Area · Hall 3"): 10px text in a 24px line box
   (WCAG 2.5.8), so wrapped lines sit 24px apart. The -5px margin hands the
   extra height to the card's 6px row gaps, so the card does not grow (only
   when a placement is there; a counts-only line keeps its own height). */
.zone-placements:has(.zone-placement) { margin: -5px 0; }
.zone-placement {
  font-size: 10px; line-height: 24px; color: var(--text-muted); font-family: var(--font-mono);
  background: none; border: none; padding: 0; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Licensed incumbents (FCC ULS) — R2 legal-map layer ─────────────────────
   Neutral steel-blue shield pin, deliberately distinct from analyzer / Pi /
   zone / trace / spot-scan pins. Advisory display only. */
.incumbent-pin { background: none; border: none; }
.inc-shield {
  width: 18px;
  height: 20px;
  background: linear-gradient(180deg, #55759b, #3d5a7a);
  color: #dbe7f4;
  font: 700 10px/16px var(--font-mono);
  text-align: center;
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .55));
}

/* Dark-theme popup for incumbent markers (Leaflet's default is white). */
.inc-leaflet-popup .leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.inc-leaflet-popup .leaflet-popup-tip { background: var(--bg-card); }
.inc-leaflet-popup .leaflet-popup-close-button { color: var(--text-muted); }
.inc-popup { font-size: 11px; line-height: 1.5; max-width: 220px; }
.inc-popup-name { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.inc-popup-line { color: var(--text-2); font-family: var(--font-mono); }
.inc-popup-advisory { margin-top: 6px; color: var(--warn); font-size: 10px; }
.inc-popup-note { color: var(--text-muted); font-size: 10px; }

/* ── Floor-plan upload: per-page crop editor ─────────────────────────────────
   Opened inline inside the upload modal (a nested modal would share the
   document Escape handler and close the whole dialog). The modal grows to the
   editor width while a page is being cropped; the stage shows the ORIGINAL
   rendered page with a dimmed mask outside the crop rect + 8 resize handles.
   Rect geometry is kept in image px and rendered as percentages, so it is
   independent of the displayed size. */
.modal.modal--crop { width: min(940px, 90vw); }
@media (max-width: 640px) { .modal.modal--crop { width: 100%; } }

.fp-crop-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.fp-crop-stage:focus-visible { outline: none; box-shadow: var(--ring); } /* was 0 0 0 2px var(--ring): invalid, no ring at all */
.fp-crop-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 300px);
  background: #fff;
  pointer-events: none;
  -webkit-user-drag: none;
}
.fp-crop-overlay { position: absolute; inset: 0; cursor: crosshair; }
.fp-crop-rect {
  position: absolute;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  cursor: move;
  box-sizing: border-box;
}
.fp-crop-rect[hidden] { display: none; }
.fp-crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--accent);
  border: 1px solid #fff;
  border-radius: 2px;
  box-sizing: border-box;
}
.fp-crop-handle[data-handle="n"]  { left: 50%;  top: 0;    cursor: ns-resize; }
.fp-crop-handle[data-handle="s"]  { left: 50%;  top: 100%; cursor: ns-resize; }
.fp-crop-handle[data-handle="e"]  { left: 100%; top: 50%;  cursor: ew-resize; }
.fp-crop-handle[data-handle="w"]  { left: 0;    top: 50%;  cursor: ew-resize; }
.fp-crop-handle[data-handle="nw"] { left: 0;    top: 0;    cursor: nwse-resize; }
.fp-crop-handle[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.fp-crop-handle[data-handle="ne"] { left: 100%; top: 0;    cursor: nesw-resize; }
.fp-crop-handle[data-handle="sw"] { left: 0;    top: 100%; cursor: nesw-resize; }
@media (pointer:coarse), (max-width:760px) {
  .fp-crop-handle { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
}

/* Thumbnail crop badge (upload dialog page cards). */
.fp-crop-badge {
  font-size: 10px;
  color: var(--accent-text);
  font-family: var(--font-mono);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Page readiness badge (plan picker) ──────────────────────────────────────
   A page is a floor in Spatial only once it has a scale AND a north. The badge
   states which of the two is missing, on the row where the page is chosen. It
   is a STATUS, so components/badge.js — a pill is a toggle (SPA control
   standard), and these rows are buttons already. Colours come from the badge
   variants (ok / warn / danger / neutral); only the fit is set here. */
.plan-picker-readiness { margin-left: auto; flex-shrink: 0; cursor: default; }
.plan-picker-page-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── "No scale on this page" strip (above the sheet, floor-plan mode) ────────
   Does not auto-dismiss: it states the one thing that silently keeps a page
   out of Spatial. Sits in the flow above the map, never over it. */
.map-setup-strip {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  flex-shrink: 0;
  z-index: 2;
}
.map-setup-strip[hidden] { display: none; }
.map-setup-strip-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-1);
}
@media (max-width: 700px) {
  .map-setup-strip { align-items: flex-start; flex-wrap: wrap; gap: var(--s2); }
}

/* "Back to venue" (map.js addHomeControl): a house button appended to Leaflet's
   +/- zoom bar, so .leaflet-bar a already gives it the zoom buttons' size,
   colour and hover. Only centre the glyph (the zoom glyphs are text). */
.leaflet-bar a.map-home-btn{display:flex;align-items:center;justify-content:center}
.map-home-btn svg{display:block}
