:root {
  --bg: #0b2540;
  --bg-pane: #102e54;
  --fg: #f0f4fa;
  --muted: #aab4c5;
  --accent: #4cc9f0;
  --green: #5cb85c;
  --yellow: #f0ad4e;
  --gray: #7d8893;
  --red: #d9534f;
  --blue: #3b82f6;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* HTML `hidden` attribute must beat #id rules that set display:flex/block. */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body { display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: env(safe-area-inset-top, 8px) 12px 8px;
  background: var(--bg); border-bottom: 1px solid #1e3a5f;
  position: sticky; top: 0; z-index: 1000;
}
#topbar #menu-btn {
  background: transparent; border: 0; color: var(--fg);
  font-size: 22px; cursor: pointer; padding: 4px 10px;
}
#title { flex: 1; display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
#title strong { font-size: 16px; }
#title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #1e3a5f; color: var(--muted); white-space: nowrap; border: 0; font-family: inherit; cursor: default; text-decoration: none; display: inline-flex; align-items: center; }
button.pill, a.pill { cursor: pointer; }
button.pill:hover, a.pill:hover { background: #2a4a73; color: var(--fg); }
.pill.cta { background: var(--accent); color: #02233a; font-weight: 600; }
.pill.cta:hover { background: #6fd6f5; color: #02233a; }
.pill.ghost { background: transparent; }
.pill.online { background: rgba(92, 184, 92, 0.25); color: #b3e3b3; }
.pill.offline { background: rgba(217, 83, 79, 0.25); color: #f1bcbb; }
.pill.idle { color: var(--muted); }
.pill.queued { background: rgba(240, 173, 78, 0.25); color: #f8d699; }
.pill.syncing { background: rgba(76, 201, 240, 0.25); color: #b8e9fa; }
#user-pill { font-family: monospace; }

main { flex: 1; position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0a1d33; }

#sidepanel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(340px, 88vw);
  background: var(--bg-pane); border-right: 1px solid #1e3a5f;
  display: flex; flex-direction: column; z-index: 1100;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #1e3a5f; }
.panel-head button { background: transparent; border: 0; color: var(--fg); font-size: 16px; cursor: pointer; }
#sidepanel input#search {
  margin: 8px 12px; padding: 8px 10px; border-radius: 6px; border: 1px solid #1e3a5f;
  background: #0a1d33; color: var(--fg); font-size: 14px;
}
#territory-list { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
#territory-list li { padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
#territory-list li:hover, #territory-list li.active { background: #1a3866; }
#territory-list li strong { min-width: 48px; font-family: monospace; color: var(--accent); }
#territory-list li .meta { font-size: 11px; color: var(--muted); margin-left: auto; }

#session-bar {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; gap: 10px; align-items: center;
  background: rgba(11, 37, 64, 0.92); backdrop-filter: blur(8px);
  border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow);
  z-index: 1050;
}
#session-bar button.primary {
  background: var(--accent); color: #02233a; font-weight: 600; border: 0;
  border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer;
}
#session-bar button.primary.active { background: var(--red); color: #fff; }
#session-stats { font-size: 12px; color: var(--muted); }

#visit-prompt {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 2000;
}
#visit-prompt .dialog {
  background: var(--bg-pane); padding: 18px; border-radius: 12px; width: 100%;
  max-width: 340px; box-shadow: var(--shadow);
}
#visit-prompt h3 { margin: 0 0 6px; font-size: 16px; }
#visit-prompt p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
#visit-prompt .row { display: flex; gap: 8px; margin-top: 8px; }
#visit-prompt button {
  flex: 1; padding: 12px; border: 0; border-radius: 8px; font-size: 14px;
  cursor: pointer; font-weight: 600;
}
#visit-prompt button[data-status="contacted"] { background: var(--green); color: #fff; }
#visit-prompt button[data-status="not_contacted"] { background: var(--yellow); color: #2a2103; }
#visit-prompt button.ghost { background: #1e3a5f; color: var(--muted); font-weight: 400; }

#toast {
  position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: rgba(11, 37, 64, 0.95); color: var(--fg);
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  z-index: 1500;
}
#toast.show { opacity: 1; }

#alert-toggle.muted { background: #4a2828; color: #f1bcbb; }
#alert-toggle:not(.muted) { background: rgba(217, 83, 79, 0.25); color: #f8b3b3; }

/* Motion pill: live accelerometer-derived class. Colours mirror the
 * semantic of each state — stationary is calm grey, walking is
 * neutral, running is hot. The pill is informational; the same
 * signal silently gates DNC hard alarms.
 */
#motion-pill { font-family: monospace; }
#motion-pill.motion-stationary     { background: rgba(125, 136, 147, 0.30); color: #d3dae3; }
#motion-pill.motion-walking_slow   { background: rgba(76, 201, 240, 0.20); color: #b8e9fa; }
#motion-pill.motion-walking_normal { background: rgba(92, 184, 92, 0.25);  color: #b3e3b3; }
#motion-pill.motion-running        { background: rgba(240, 173, 78, 0.30); color: #f8d699; }
#motion-pill.motion-unknown        { background: #2a3a52; color: #aab4c5; }

/* Admin debug toggle for the territory card outline. The "on" state
 * uses the same cyan as the outline itself so it's instantly obvious
 * what's being shown.
 */
#debug-card-outline { font-family: monospace; }
#debug-card-outline.on {
  background: rgba(76, 201, 240, 0.25);
  color: var(--accent);
  border: 1px dashed var(--accent);
}

#dnc-banner {
  position: absolute; left: 12px; right: 12px; top: 12px;
  z-index: 2500;
  animation: dnc-pulse 1.0s ease-in-out infinite alternate;
}
/* Soft variant: DNC nearby but the publisher is walking past or
 * through, not approaching the door. No animation, calmer amber
 * palette, no audio/vibrate (gated in maybeFireDncAlert). The
 * publisher still sees the warning, they just don't get the loud
 * alarm reserved for door-approach.
 */
#dnc-banner.soft { animation: none; }
#dnc-banner.soft .dnc-banner-inner {
  background: #5a4214; color: #f8d699;
  border: 1px solid #f0ad4e;
}
#dnc-banner.soft strong { color: #fce0a8; }
#dnc-banner.soft button {
  background: #f0ad4e; color: #3a2a08;
}
#dnc-banner .dnc-banner-inner {
  display: flex; align-items: center; gap: 10px;
  background: #d9534f; color: #fff;
  padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(217, 83, 79, 0.6);
  border: 2px solid #fff;
}
#dnc-banner strong { font-size: 15px; letter-spacing: 0.5px; }
#dnc-banner span { flex: 1; font-size: 13px; }
#dnc-banner button {
  background: #fff; color: #d9534f; border: 0;
  padding: 6px 12px; border-radius: 6px; font-weight: 700; cursor: pointer;
}
@keyframes dnc-pulse {
  from { box-shadow: 0 6px 24px rgba(217, 83, 79, 0.45); }
  to   { box-shadow: 0 8px 32px rgba(217, 83, 79, 0.95); }
}

/* --- Assignment / lease state pill ---------------------------------- */
/*
 * The state pill is the authoritative on-screen indicator of the
 * publisher's current activity-lease state. Color-coded so the
 * publisher sees the band (active / warning / expired) at a glance.
 */
.state-pill { font-weight: 600; }
.pill.state-none    { background: #2a3a52; color: #aab4c5; }
.pill.state-pending { background: rgba(76, 201, 240, 0.20); color: #b8e9fa; }
.pill.state-active  { background: rgba(92, 184, 92, 0.30);  color: #b3e3b3; }
.pill.state-warning {
  background: rgba(240, 173, 78, 0.30); color: #f8d699;
  animation: state-pulse 1.5s ease-in-out infinite alternate;
}
.pill.state-expired   { background: rgba(217, 83, 79, 0.30); color: #f1bcbb; }
.pill.state-ended     { background: #2a3a52; color: #aab4c5; }
.pill.state-cancelled { background: #2a3a52; color: #aab4c5; text-decoration: line-through; }

/* F2e: field-status chip. Distinct color per state so a publisher
   can tell at-a-glance whether they're at the meeting (yellow), on
   their way (cyan-pulsing), or actively working (green). Idle is
   the catch-all and is hidden by default — see field-status-idle's
   display:none rule below. */
.field-status { font-weight: 600; }
.pill.field-status-in_meeting   {
  background: rgba(248, 214, 153, 0.28); color: #f8d699;
}
.pill.field-status-in_transit   {
  background: rgba(76, 201, 240, 0.22); color: #b8e9fa;
  animation: state-pulse 2.4s ease-in-out infinite alternate;
}
.pill.field-status-in_territory {
  background: rgba(92, 184, 92, 0.30); color: #b3e3b3;
}
.pill.field-status-idle { display: none; }
@keyframes state-pulse {
  from { background: rgba(240, 173, 78, 0.18); }
  to   { background: rgba(240, 173, 78, 0.42); }
}

#reviews-btn { background: rgba(240, 173, 78, 0.22); color: #f8d699; font-weight: 600; }
#reviews-btn:hover { background: rgba(240, 173, 78, 0.36); }

#drive-badge {
  background: rgba(125, 136, 147, 0.30); color: #d3dae3;
  font-weight: 600; letter-spacing: 0.04em;
}

/* --- Sidepanel "My assignments" section ----------------------------- */
.panel-section { border-top: 1px solid #1e3a5f; padding: 8px 0; }
.panel-section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 12px; font-size: 12px; color: var(--muted);
}
.panel-section-head strong { color: var(--fg); font-size: 13px; }
.muted { color: var(--muted); }

#assignment-list { list-style: none; margin: 0; padding: 0; }
#assignment-list li {
  padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,0.04);
  display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
#assignment-list li:hover { background: #1a3866; }
#assignment-list li.active { background: #214178; }
#assignment-list .row1 { display: flex; gap: 8px; align-items: baseline; }
#assignment-list .tnum { font-family: monospace; color: var(--accent); }
#assignment-list .countdown { margin-left: auto; font-size: 11px; color: var(--muted); }

/* --- WARNING banner ------------------------------------------------- */
#lease-banner {
  position: absolute; left: 12px; right: 12px; top: 12px;
  z-index: 2400;
}
#lease-banner .lease-banner-inner {
  display: flex; align-items: center; gap: 10px;
  background: var(--yellow); color: #2a2103;
  padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(240, 173, 78, 0.55);
  border: 2px solid #fff;
  font-weight: 600;
}
#lease-banner strong { font-size: 14px; }
#lease-banner span   { flex: 1; font-size: 13px; font-weight: 500; }
#lease-banner button { background: #2a2103; color: var(--yellow); border: 0; }
#lease-banner button:hover { background: #3d3104; }

/* --- EXPIRED block-screen overlay ----------------------------------- */
/*
 * Per spec: when the lease lands on EXPIRED, ALL access is revoked
 * (GPS visit creation, parcel tracking, map access, new sessions).
 * The overlay sits above #map at z-index 3000 and fully covers the
 * map, leaving only the "Sync now" affordance and a non-destructive
 * dismiss (closes the modal but keeps the underlying lockout enforced
 * via separate body-level CSS — see body.lease-locked below).
 */
#lease-expired-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 3000;
}
#lease-expired-overlay .dialog {
  background: var(--bg-pane); padding: 22px; border-radius: 12px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow);
  border-top: 4px solid var(--red);
}
#lease-expired-overlay h3 { margin: 0 0 10px; color: var(--red); }
#lease-expired-overlay p  { margin: 0 0 10px; font-size: 14px; }
#lease-expired-overlay .row { display: flex; gap: 8px; margin-top: 12px; }
#lease-expired-overlay button {
  flex: 1; padding: 10px; border-radius: 8px; border: 0;
  font-size: 14px; cursor: pointer; font-weight: 600;
}
#lease-expired-overlay button.primary { background: var(--accent); color: #02233a; }
#lease-expired-overlay button.ghost { background: #1e3a5f; color: var(--muted); font-weight: 400; }

/*
 * body.lease-locked is set by app.js whenever the projected state is
 * EXPIRED / ENDED / CANCELLED. It hard-disables the session toggle and
 * dims the map so the publisher sees the lockout even after dismissing
 * the modal. Pointer events on the map remain enabled (so they can
 * still pan / read prior visits) but session controls are dead.
 */
body.lease-locked #map { filter: grayscale(0.7) brightness(0.6); }
body.lease-locked #session-bar button.primary {
  background: #4a2828 !important; color: #f1bcbb !important;
  cursor: not-allowed;
}
body.lease-locked #session-bar button.primary:disabled { opacity: 0.7; }

/* --- Review queue modal --------------------------------------------- */
#review-modal {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 2200;
}
#review-modal .dialog {
  background: var(--bg-pane); padding: 16px; border-radius: 12px;
  width: 100%; max-width: 420px; max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
#review-modal .dialog.wide { max-width: 480px; }
#review-modal .dialog-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
#review-modal h3 { margin: 0; font-size: 16px; }
#review-modal #review-empty { margin: 16px 4px; font-size: 13px; }
#review-modal ul {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto; flex: 1;
}
#review-modal li {
  padding: 10px 4px; border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 6px;
}
#review-modal .review-meta { font-size: 12px; color: var(--muted); }
#review-modal .review-actions { display: flex; gap: 6px; }
#review-modal .review-actions button {
  flex: 1; padding: 7px; border-radius: 6px; border: 0;
  font-size: 12px; cursor: pointer; font-weight: 600;
}
#review-modal button.contacted     { background: var(--green);  color: #fff; }
#review-modal button.not_contacted { background: var(--yellow); color: #2a2103; }
#review-modal button.unknown       { background: #1e3a5f;       color: var(--muted); font-weight: 400; }

/* --- Map controls (follow-self + find-publisher) -------------------- */
/* Stack on the right side of the map, just below the Leaflet zoom
 * control. Pure CSS positioning so we can stay out of Leaflet's
 * control mechanism (the picker bottom sheet needs its own z-index
 * stacking anyway). */
#map-controls {
  position: absolute; top: 92px; right: 12px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 1040;
}
#map-controls button {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(11, 37, 64, 0.92); border: 1px solid #1e3a5f;
  color: var(--fg); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
#map-controls button:hover { background: #1a3866; }
#map-controls button.on {
  background: var(--accent); color: #02233a; border-color: var(--accent);
}
/* Follow-self cycle. Three classes set by paintFollowSelfButton:
   .mode-off (passive), .mode-follow (camera-locks-on-fix),
   .mode-heading (locks AND shows heading arrow). The two locked
   modes keep the existing accent fill from .on; .mode-heading
   gets a small upward chevron in the corner so it's visually
   distinct from .mode-follow at a glance. */
#map-controls button.mode-heading {
  background: var(--green); color: #02233a; border-color: var(--green);
}
#map-controls button.mode-heading::after {
  content: "↑"; position: absolute; top: 2px; right: 5px;
  font-size: 11px; font-weight: 700;
}
#map-controls button { position: relative; }
#map-controls svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Heading-up arrow overlay drawn by paintHeadingMarker. Wraps the
   user dot when FollowSelf is in HEADING mode and the platform
   reports a heading angle. transform: rotate(...) is set inline. */
.heading-arrow-icon { background: transparent; border: 0; }
.heading-arrow {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  transform-origin: 50% 50%;
  transition: transform 250ms ease-out;
  pointer-events: none;
}
.heading-arrow svg {
  width: 28px; height: 28px;
  fill: var(--accent);
  stroke: #02233a; stroke-width: 1.5; stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* --- Walking pin (other publishers on the map) --------------------- */
/* Leaflet stamps inline `transform: translate3d(...)` on the marker
 * wrapper to position it. CSS transition picks that up and gives the
 * pin a visible "walking" interpolation between successive
 * heartbeats. 800ms matches roughly half the throttle and keeps the
 * motion legible without lagging the live position. */
.leaflet-marker-icon.walking-pin {
  transition: transform 800ms ease-in-out;
  background: transparent; border: 0;
  pointer-events: auto;
}
.walking-pin-ring {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--green);
  background: rgba(11, 37, 64, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  box-sizing: border-box;
}
.walking-pin-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #1e3a5f; color: var(--fg);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.walking-pin-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.walking-pin-initials {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.walking-pin-tag {
  position: absolute; top: 38px; left: 50%; transform: translateX(-50%);
  background: rgba(11, 37, 64, 0.92); color: var(--fg);
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  white-space: nowrap; max-width: 120px; overflow: hidden;
  text-overflow: ellipsis;
}
/* Status ring color encodes the walking-pin status. Defaults to
 * green (walking); at_door is yellow (publisher is engaged at a
 * door); idle is gray (no recent fix); offline shouldn't render
 * because the Drop is emitted, but we cover it for safety. */
.walking-pin-walking  .walking-pin-ring { border-color: var(--green); }
.walking-pin-at_door  .walking-pin-ring { border-color: var(--yellow); }
.walking-pin-idle     .walking-pin-ring { border-color: var(--gray); }
.walking-pin-available .walking-pin-ring { border-color: var(--accent); }

/* Motion-class overlays: layered on top of status so the ring color
 * still answers "what are they doing in the workflow?" while the
 * animation answers "is the device actually moving?". Stationary
 * pins are visibly still; walking variants bounce in cadence with
 * the publisher's actual step rate; running pulses with a faster,
 * tighter ring. respect prefers-reduced-motion. */
@keyframes walking-pin-footfall {
  0%, 100% { transform: translateY(0);    }
  50%      { transform: translateY(-2px); }
}
@keyframes walking-pin-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(46, 204, 113, 0);  }
}
.walking-pin-motion-stationary    .walking-pin-ring {
  animation: none;
  filter: saturate(0.7);
}
.walking-pin-motion-walking_slow   .walking-pin-ring {
  animation: walking-pin-footfall 1100ms ease-in-out infinite;
}
.walking-pin-motion-walking_normal .walking-pin-ring {
  animation: walking-pin-footfall 750ms ease-in-out infinite;
}
.walking-pin-motion-running        .walking-pin-ring {
  animation:
    walking-pin-footfall 480ms ease-in-out infinite,
    walking-pin-pulse    480ms ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .walking-pin-motion-walking_slow   .walking-pin-ring,
  .walking-pin-motion-walking_normal .walking-pin-ring,
  .walking-pin-motion-running        .walking-pin-ring {
    animation: none;
  }
}

/* --- Slice B: "presenting at door" badge -------------------------- */
/* The "show" badge appears on the publisher's pin whenever their
 * Slice B AND-gate is active (held_reading + stationary + slow +
 * in-visit, sustained for >= PRESENTING_SUSTAIN_MS client-side).
 * The element is always rendered in the HTML but hidden by default;
 * the .walking-pin-presenting modifier on the wrapper reveals it.
 * Solid amber to read at a glance against both light and dark map
 * tiles; the gentle pulse echoes the at_door pin's color cue
 * without competing with the motion-class animations on the ring. */
.walking-pin-badge {
  position: absolute;
  top: -6px; right: -8px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2b1f00;
  background: #ffb302;
  border: 1.5px solid #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  display: none;             /* hidden until walking-pin-presenting opts it in */
  pointer-events: none;
}
.walking-pin-presenting .walking-pin-badge {
  display: inline-block;
  animation: walking-pin-badge-pulse 1500ms ease-in-out infinite;
}
.walking-pin-presenting .walking-pin-ring {
  /* A double-ring "presenting" cue that complements the
   * status-color border without overriding it; survives the
   * motion-class filter:saturate dim that "stationary" applies. */
  box-shadow: 0 0 0 2px #ffb302, 0 0 0 4px rgba(255, 179, 2, 0.35);
  filter: saturate(1);       /* override the stationary dim */
}
@keyframes walking-pin-badge-pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
  50%      { transform: scale(1.08); box-shadow: 0 2px 6px rgba(255,179,2,0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .walking-pin-presenting .walking-pin-badge { animation: none; }
}

/* --- Find-publisher picker bottom sheet ---------------------------- */
#publisher-picker {
  position: absolute; left: 12px; right: 12px; bottom: 80px;
  max-height: 50vh; overflow: hidden;
  background: var(--bg-pane); border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  z-index: 1060;
}
.publisher-picker-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid #1e3a5f;
}
#publisher-picker-close {
  background: transparent; border: 0; color: var(--fg);
  font-size: 16px; cursor: pointer;
}
#publisher-picker ul {
  list-style: none; margin: 0; padding: 0; overflow-y: auto;
}
.publisher-picker-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
}
.publisher-picker-row:first-child { border-top: 0; }
.publisher-picker-row:hover { background: #1a3866; }
.publisher-picker-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #1e3a5f; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.publisher-picker-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.publisher-picker-initials { color: var(--muted); }
.publisher-picker-meta {
  display: flex; flex-direction: column; min-width: 0; flex: 1;
}
.publisher-picker-meta strong {
  font-size: 14px; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.publisher-picker-meta span { font-size: 11px; }
.publisher-picker-age { font-size: 11px; color: var(--muted); margin-left: auto; }
.publisher-picker-empty {
  padding: 14px; text-align: center; color: var(--muted); font-size: 13px;
}
.publisher-picker-row.status-at_door .publisher-picker-avatar {
  box-shadow: 0 0 0 2px var(--yellow);
}
.publisher-picker-row.status-walking .publisher-picker-avatar {
  box-shadow: 0 0 0 2px var(--green);
}
.publisher-picker-row.status-idle .publisher-picker-avatar {
  box-shadow: 0 0 0 2px var(--gray);
}

/* ----------------------------------------------------------------
   Phase G: geolocation capability banner + Fix-it modal.

   The banner is a full-width strip the page chooses to anchor right
   after the topbar (or right after <body> on /manage, which has no
   topbar of its own). Color tone is driven by the data-tone attr
   set by geo-ui.js so the JS only renders text — no class-juggling.
   ---------------------------------------------------------------- */
.geo-banner {
  position: sticky;
  top: 0;
  z-index: 1200;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-size: 13px; line-height: 1.3;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  background: rgba(240, 173, 78, 0.18);
  color: #f6dca0;
}
.geo-banner[data-tone="red"]    { background: rgba(217, 83, 79, 0.22);  color: #f5c6c4; }
.geo-banner[data-tone="yellow"] { background: rgba(240, 173, 78, 0.20); color: #f6dca0; }
.geo-banner[data-tone="gray"]   { background: rgba(125, 136, 147, 0.20); color: #cfd6df; }
.geo-banner-headline { font-weight: 600; white-space: nowrap; }
.geo-banner-detail   { flex: 1; min-width: 0; color: inherit; opacity: 0.92;
                       overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geo-banner-fix {
  background: var(--accent); color: #02233a; font-weight: 600; border: 0;
  padding: 4px 12px; border-radius: 99px; cursor: pointer; font-family: inherit;
  font-size: 12px;
}
.geo-banner-fix:hover { background: #6fd6f5; }
.geo-banner-dismiss {
  background: transparent; border: 0; color: inherit; opacity: 0.7;
  font-size: 16px; padding: 0 4px; cursor: pointer; line-height: 1;
}
.geo-banner-dismiss:hover { opacity: 1; }

/* On narrow viewports collapse the detail line to keep the banner
   single-row. Headline + Fix-it button are the must-haves. */
@media (max-width: 540px) {
  .geo-banner-detail { display: none; }
}

/* ----------------------------------------------------------------
   Geo modal. Uses the native <dialog>; we only style its inner card
   plus the ::backdrop. Falls back to a plain attribute-driven layout
   on browsers that don't support showModal(), since geo-ui.js
   degrades to setAttribute("open").
   ---------------------------------------------------------------- */
.geo-modal {
  border: 0; padding: 0; background: transparent; color: inherit;
  max-width: 92vw; width: 460px;
}
.geo-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.geo-modal[open] {
  animation: geo-modal-pop 140ms ease-out;
}
@keyframes geo-modal-pop {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.geo-modal-card {
  background: var(--bg-pane);
  color: var(--fg);
  border: 1px solid #1e3a5f;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
}
.geo-modal-head {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid #1e3a5f; padding-bottom: 8px; margin-bottom: 10px;
}
.geo-modal-head h2 { margin: 0; font-size: 16px; flex: 1; }
.geo-modal-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 4px 8px;
}
.geo-modal-close:hover { color: var(--fg); }
.geo-status { display: grid; gap: 4px; margin-bottom: 12px; }
.geo-status-row {
  display: grid; grid-template-columns: 90px auto 1fr;
  gap: 8px; align-items: center; font-size: 13px;
}
.geo-status-label { color: var(--muted); }
.geo-status-value { color: var(--fg); }
.geo-status-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
  background: var(--gray);
}
.geo-tone-green  { background: var(--green); }
.geo-tone-yellow { background: var(--yellow); }
.geo-tone-red    { background: var(--red); }
.geo-tone-gray   { background: var(--gray); }
.geo-instructions {
  background: #0a1d33; border: 1px solid #1e3a5f; border-radius: 8px;
  padding: 10px 12px 10px 28px; margin-bottom: 12px; font-size: 13px;
  line-height: 1.45;
}
.geo-steps { margin: 0; padding: 0 0 0 4px; }
.geo-steps li { margin: 4px 0; color: var(--fg); }
.geo-steps li strong { color: var(--accent); }
.geo-steps li em { color: var(--yellow); font-style: normal; font-weight: 600; }
.geo-modal-foot { display: flex; gap: 8px; justify-content: flex-end; }
.geo-modal-foot button {
  background: #1e3a5f; color: var(--fg); border: 0;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-family: inherit;
  font-size: 13px;
}
.geo-modal-foot button:hover { background: #2a4a73; }
.geo-modal-test { font-weight: 600; }
.geo-modal-ok   { background: var(--accent) !important; color: #02233a !important; font-weight: 600; }
.geo-modal-ok:hover { background: #6fd6f5 !important; }

/* G6 admin geo-override chip — appears inline in /manage publisher
   rows next to the state pill. Two visual states keyed off the
   `.active` class: neutral (off) and accent green (on, with the
   minutes left in the label). */
.geo-override-chip {
  background: transparent; border: 1px dashed #1e3a5f; color: var(--muted);
  padding: 2px 8px; border-radius: 99px; font-size: 11px; cursor: pointer;
  font-family: inherit; line-height: 1.4;
}
.geo-override-chip:hover { color: var(--fg); border-color: var(--accent); }
.geo-override-chip.active {
  background: var(--green); color: #02233a; border: 1px solid var(--green);
  font-weight: 600;
}
.geo-override-chip.active:hover { background: #4ec07c; }

/* iOS Add-to-Home-Screen hint. Bottom-anchored fixed strip so it
   doesn't compete with the (top-anchored) geo banner. ios-install.js
   shows it once on iOS Safari tabs that aren't already standalone;
   user dismissal is persisted via localStorage. Subtle accent
   border + gentle blue background to read as "info, not alarm". */
.ios-install-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  z-index: 1300;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(11, 37, 64, 0.95);
  border: 1px solid var(--accent);
  color: var(--fg); font-size: 13px; line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
}
.ios-install-icon { font-size: 20px; line-height: 1; }
.ios-install-text { flex: 1; min-width: 0; }
.ios-install-text strong { color: var(--accent); }
.ios-share-glyph {
  display: inline-block; padding: 0 2px; color: var(--accent);
  font-weight: 700;
}
.ios-install-dismiss {
  background: transparent; border: 0; color: var(--muted);
  font-size: 16px; padding: 4px 8px; cursor: pointer; line-height: 1;
}
.ios-install-dismiss:hover { color: var(--fg); }

/* G-Device platform glyph rendered inline next to the cap-dot in
   /manage rows. Pure-emoji content; the .device-glyph wrapper is
   only there to give it a stable hover target and a consistent
   line-height with the surrounding flex row. cursor:help cues that
   the tooltip is the value (full capability rundown). */
.device-glyph {
  display: inline-block; line-height: 1; font-size: 14px;
  cursor: help; user-select: none;
  /* Light desaturation so the emoji doesn't out-shout the cap dot;
     hover restores full color. */
  filter: saturate(0.7);
}
.device-glyph:hover { filter: saturate(1); }

/* Capability dot used inline in /manage publisher rows (G5). Same
   tone palette as the modal status dots so the visual language is
   consistent. */
.cap-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  background: var(--gray); flex: none;
}
.cap-dot[data-cap="precise"]   { background: var(--green); }
.cap-dot[data-cap="imprecise"] { background: var(--yellow); }
.cap-dot[data-cap="coarse"]    { background: var(--red); }
.cap-dot[data-cap="denied"]    { background: var(--red); box-shadow: 0 0 0 2px rgba(217,83,79,0.3); }
.cap-dot[data-cap="unknown"]   { background: var(--gray); }


/* --- In-app updater (Capacitor APK only) ----------------------------- */
/*
 * The banner sits below #topbar and above the map. It's intentionally
 * less aggressive than #lease-banner / #dnc-banner -- "an update is
 * available" is informational, not urgent, and a publisher in the
 * middle of a session shouldn't have it hijack visual attention.
 *
 * Z-index 2400 puts it above the map / map-controls / sidepanel
 * (all 1000-1500) but below the lease-warning banner (2400) and the
 * EXPIRED overlay (3000). Functionally the banner and lease-banner
 * never coexist (the lease-banner appears in WARNING; the EXPIRED
 * overlay covers everything in EXPIRED) so the equal z-index is
 * fine.
 *
 * #tfp-update-modal is the must-update full-screen path, used when
 * the running APK is below min_supported_version_code. It mirrors
 * #lease-expired-overlay structurally so users in the field see a
 * familiar layout.
 */
#tfp-update-banner {
  position: absolute; left: 12px; right: 12px; top: 12px;
  z-index: 2400;
}
#tfp-update-banner .tfp-update-banner-inner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-pane); color: var(--fg);
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--accent);
  box-shadow: 0 6px 24px rgba(76, 201, 240, 0.25);
  font-weight: 500;
}
#tfp-update-banner .tfp-update-banner-title {
  font-size: 14px; color: var(--accent); letter-spacing: 0.3px;
}
#tfp-update-banner .tfp-update-banner-meta {
  font-size: 13px; color: var(--fg);
}
#tfp-update-banner .tfp-update-banner-notes {
  flex-basis: 100%; font-size: 12px; color: var(--muted);
  margin: 0; padding-left: 0;
}
#tfp-update-banner .tfp-update-banner-cta {
  margin-left: auto;
  text-decoration: none;
}
#tfp-update-banner .tfp-update-banner-dismiss {
  background: transparent; color: var(--muted); border: 0;
  font-size: 16px; cursor: pointer; padding: 4px 8px;
}
#tfp-update-banner .tfp-update-banner-dismiss:hover { color: var(--fg); }

#tfp-update-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 3100;
}
#tfp-update-modal .tfp-update-modal-inner {
  background: var(--bg-pane); padding: 22px; border-radius: 12px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow);
  border-top: 4px solid var(--accent);
}
#tfp-update-modal h3 { margin: 0 0 10px; color: var(--accent); }
#tfp-update-modal p { margin: 0 0 10px; font-size: 14px; }
#tfp-update-modal .tfp-update-modal-meta { font-weight: 600; }
#tfp-update-modal .tfp-update-modal-notes { font-size: 13px; color: var(--muted); white-space: pre-line; }
#tfp-update-modal .row { display: flex; gap: 8px; margin-top: 12px; }
#tfp-update-modal .tfp-update-modal-cta {
  flex: 1; padding: 12px; border-radius: 8px; border: 0;
  font-size: 14px; font-weight: 600; text-align: center;
  background: var(--accent); color: #02233a; text-decoration: none;
}

