:root {
  /* ── z-index stack ──────────────────────────────────────────────
     map=0  ambient=1  vignette=500  ui=1000  global-btn=1100
     backdrop=1400  drawers=1500  topbar-mobile=1600
     site-dropdown-mobile=1700  dropdowns/toast=2000  dt-panel-mobile=3000
  ─────────────────────────────────────────────────────────────── */

  /* ── Backgrounds ── */
  --bg-primary: #0b0d11;
  --bg-secondary: #141821;
  --bg-tertiary: #1b2130;
  --bg-card: #171d29;
  --bg-hover: #222a3a;

  /* ── Borders ── */
  --border: #2a3448;
  --border-light: #394766;

  /* ── Text — all pass WCAG AA on --bg-card ──
     --text-primary   #edf2ff → 13.5:1 ✅
     --text-secondary #a3afc5 →  5.4:1 ✅
     --text-muted     #7e8fa8 →  4.6:1 ✅  (was #67748f → 3.1:1 ❌)
  ── */
  --text-primary: #edf2ff;
  --text-secondary: #a3afc5;
  --text-muted: #7e8fa8;

  /* ── Accent — #6496ff passes AA on --bg-card (4.7:1) ── */
  --accent: #6496ff;
  --accent-bright: #7aa5ff;
  --accent-glow: rgba(100, 150, 255, 0.18);

  /* ── Semantic colours ── */
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --rose: #f472b6;
  --rose-dim: rgba(244, 114, 182, 0.12);
  --violet: #a78bfa;
  --violet-dim: rgba(167, 139, 250, 0.12);
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.12);

  /* ── Typography scale ── */
  --text-2xs: 9px;   /* absolute minimum — avoid for body copy */
  --text-xs:  10px;  /* labels, microcopy, section headers      */
  --text-sm:  12px;  /* secondary content, metadata             */
  --text-base: 13px; /* primary UI text                         */
  --text-lg:  16px;  /* sub-headings                            */
  --text-xl:  24px;  /* stat values (upper bound)               */

  /* ── Border radius ── */
  --radius-sm: 6px;
  --radius-icon: 8px; /* brand icon, avatar                     */
  --radius: 10px;
  --radius-lg: 14px;

  /* ── Shadows ── */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);

  /* ── Motion ── */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Layout ── */
  --top-offset: 72px;
  --timeline-safe-height: 245px;
  --density-panel-padding: 13px;
  --density-control-height: 32px;
  --density-control-radius: var(--radius-sm);
  --entity-max-visible-rows: 5;
  --entity-row-height: 52px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Skip navigation link (keyboard/screen reader accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--bg-card);
  color: var(--accent-bright);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 8px;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  letter-spacing: 0.01em;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(circle at 14% 12%, rgba(34, 211, 238, 0.04), transparent 34%),
    radial-gradient(circle at 84% 18%, rgba(93, 143, 255, 0.06), transparent 40%),
    radial-gradient(circle at 52% 84%, rgba(167, 139, 250, 0.05), transparent 36%);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Blue-gray patina over the tiles — sits above tilePane (200) but below
   Leaflet's overlay/marker/popup panes (400+), so it never dims markers/popups. */
#map::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 250;
  pointer-events: none;
  background: rgba(70, 100, 150, 0.16);
  mix-blend-mode: overlay;
}

.map-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(10, 11, 14, 0.45) 100%);
}

.leaflet-tile-pane {
  /* Tuned for OpenStreetMap standard tiles: low saturate mutes OSM's
     colorful POI icons (hospital/parking/shop symbols that CARTO Voyager
     didn't render this vividly), low contrast avoids the near-black/
     high-contrast look, and blur() softens OSM's crisper line/label
     rendering. The blue-gray patina itself comes from the #map::after
     overlay, not from this filter. */
  filter: brightness(0.8) contrast(1.0) saturate(0.15) hue-rotate(180deg) invert(1) blur(0.5px);
}

.leaflet-control-zoom {
  border: none !important;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 16px !important;
  border-radius: var(--radius-sm) !important;
  backdrop-filter: blur(12px);
}

.leaflet-control-zoom a:hover {
  background: var(--bg-hover) !important;
}

/* ── Map Layers sidebar control (.clc-*) ── */

/* Layer list — used directly inside .filter-card in the sidebar */
.clc-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background var(--transition);
}

.clc-item:hover {
  background: var(--bg-hover);
}

/* Layer icon */
.clc-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.clc-icon svg {
  width: 14px;
  height: 14px;
}

.clc-icon--accent  { color: var(--accent); }
.clc-icon--rose    { color: var(--rose); }
.clc-icon--violet  { color: var(--violet); }
.clc-icon--cyan    { color: var(--cyan); }
.clc-icon--green   { color: var(--green); }
.clc-icon--amber   { color: var(--amber); }
.clc-icon--muted   { color: var(--text-muted); }

/* Layer label */
.clc-label {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  user-select: none;
  transition: color var(--transition);
}

.clc-item:hover .clc-label {
  color: var(--text-primary);
}

/* Toggle pill */
.clc-toggle {
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  outline: none;
}

.clc-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-glow);
  border-color: var(--accent);
}

.clc-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
}

.clc-toggle.on {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.clc-toggle.on .clc-thumb {
  transform: translateX(14px);
  background: var(--accent-bright);
}

.top-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  justify-content: space-between;
  border-radius: 50px;
  padding: 5px 8px 5px 14px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 24px);
  width: fit-content;
  min-width: 80px;
  animation: topBarIn 420ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
  isolation: isolate;
  transition: height 220ms cubic-bezier(0.4, 0, 0.2, 1), padding 220ms cubic-bezier(0.4, 0, 0.2, 1), min-width 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.top-bar > .bar-body {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  flex: 1 1 auto;
  min-width: 0;
  transition: opacity 180ms cubic-bezier(0.4, 0, 0.2, 1), visibility 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.top-bar::before {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01));
}

@keyframes topBarIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── Top bar collapsed ── */
.top-bar.is-collapsed {
  height: 6px;
  padding: 0;
  overflow: visible;
}

.top-bar.is-collapsed::before {
  top: 50%;
  right: 8%;
  bottom: auto;
  left: 8%;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(93, 143, 255, 0.45) 18%,
    rgba(122, 165, 255, 0.6) 50%,
    rgba(93, 143, 255, 0.45) 82%,
    transparent 100%
  );
  border-radius: 999px;
  box-shadow:
    0 0 6px 3px rgba(93, 143, 255, 0.28),
    0 0 18px 7px rgba(93, 143, 255, 0.16),
    0 0 40px 14px rgba(93, 143, 255, 0.08);
  z-index: 0;
}

.top-bar.is-collapsed > .bar-body {
  opacity: 0;
  visibility: hidden;
  flex: 0 0 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.top-bar.is-collapsed .bar-toggle-btn-top svg {
  transform: rotate(180deg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.brand-icon {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  border-radius: var(--radius-icon);
  display: grid;
  place-items: center;
}

.brand-icon svg {
  width: 16px;
  height: 16px;
}

.brand-name {
  font-weight: 600;
  font-size: var(--text-base);
  letter-spacing: 0.04em;
}

.site-selector {
  position: relative;
  min-width: 0;
  max-width: min(56vw, 300px);
}

#selectedSite {
  display: block;
  max-width: clamp(110px, 20vw, 210px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--density-control-height);
  padding: 0 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  border-radius: 20px;
  transition: var(--transition);
}

.site-btn:hover {
  background: var(--bg-hover);
}

.site-btn:active {
  transform: translateY(1px);
}

.site-btn:focus-visible,
.ep-action-btn:focus-visible,
.env-chip:focus-visible,
.tl-btn:focus-visible,
.speed-btn:focus-visible,
.jump-live-btn:focus-visible,
.dt-now-btn:focus-visible,
.dt-confirm-btn:focus-visible,
.site-floor-sub-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.site-btn svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

@keyframes fadeScaleOut {
  from { opacity: 1; transform: scale(1)    translateY(0); }
  to   { opacity: 0; transform: scale(0.95) translateY(-4px); }
}

.site-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  /* visibility/opacity toggle for animated close */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95) translateY(-4px);
  transition: opacity var(--transition), transform var(--transition), visibility 0ms var(--transition);
  z-index: 2000;
}

.site-dropdown.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
  transition: opacity var(--transition), transform var(--transition), visibility 0ms;
}

.site-dropdown-list {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
}

.site-dropdown-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-secondary);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.site-dropdown-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 20%;
  bottom: 20%;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background var(--transition);
}

.site-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.site-dropdown-item:active {
  background: var(--bg-hover);
  transform: translateY(1px);
}

.site-dropdown-item.active {
  background: var(--accent-glow);
  color: var(--accent-bright);
}

.site-dropdown-item.active::before {
  background: var(--accent);
}

.site-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition);
}

.site-dropdown-item.active .site-dot {
  background: var(--accent);
}

/* Floor sub-row shown inside dropdown below the active site */
.site-floor-sub {
  padding: 0 10px 10px 10px;
  margin-top: 2px;
}

.site-floor-sub-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.site-floor-sub-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.site-floor-sub-btn {
  min-width: 38px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1;
}
.site-floor-sub-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}
.site-floor-sub-btn:active {
  transform: translateY(1px);
}
.site-floor-sub-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.site-option-empty {
  padding: 12px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── Site floor-plan label on map ── */
.site-map-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.80);
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow-sm);
  transform: translate(-50%, -50%);
}
.sml-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sml-floor {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--violet);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-left: 1px solid rgba(167, 139, 250, 0.3);
  padding-left: 7px;
}

/* ── Entity Panel (.ep-*) ── */
.ep-count-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.ep-filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.ep-filter-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.ep-chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ep-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(var(--entity-max-visible-rows) * var(--entity-row-height));
  min-height: 0;
  overflow-y: auto;
  overflow-x: visible;
  scroll-behavior: smooth;
  margin-top: 4px;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(93, 143, 255, 0.3) transparent;
}

.ep-list::-webkit-scrollbar {
  width: 5px;
}

.ep-list::-webkit-scrollbar-thumb {
  background: rgba(93, 143, 255, 0.35);
  border-radius: 999px;
}

.ep-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  position: relative;
}

.ep-item:hover {
  background: var(--bg-hover);
  border-color: rgba(100, 150, 255, 0.12);
}

.ep-item:active {
  background: var(--bg-hover);
  transform: scale(0.99);
}

.ep-item.selected {
  background: var(--accent-glow);
  border-color: rgba(100, 150, 255, 0.2);
  box-shadow: inset 2px 0 0 var(--accent);
}

.ep-item.selected::after {
  content: none;
}

#entityPanelCard .ep-list {
  flex: 0 0 auto;
  min-height: calc(var(--entity-row-height));
}

#entityPanelCard .ep-filter-group,
#entityPanelCard .search-wrap,
#entityPanelCard .ep-actions {
  flex: 0 0 auto;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 56px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  z-index: 10;
  box-shadow: var(--shadow);
  transition: color var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.sidebar-toggle-btn svg {
  width: 11px;
  height: 11px;
  transition: transform var(--transition);
}

.sidebar-toggle-btn:hover {
  color: var(--accent-bright);
  border-color: rgba(93, 143, 255, 0.55);
  background: var(--bg-hover);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 16px 5px rgba(93, 143, 255, 0.2);
}

.sidebar-toggle-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sidebar-toggle-btn-left {
  right: -10px;
  border-left: none;
  border-radius: 0 10px 10px 0;
}

.sidebar-toggle-btn-right {
  left: -10px;
  border-right: none;
  border-radius: 10px 0 0 10px;
}

/* ── Global Sidebar Toggle ── */
.global-sidebar-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  top: auto;
  z-index: 1100;
  width: var(--density-control-height);
  height: var(--density-control-height);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.global-sidebar-btn svg {
  width: 15px;
  height: 15px;
  transition: transform var(--transition);
}

.global-sidebar-btn:hover {
  color: var(--accent-bright);
  border-color: var(--border-light);
  background: var(--bg-hover);
  box-shadow: var(--shadow), 0 0 12px 3px rgba(93, 143, 255, 0.15);
}

.global-sidebar-btn[aria-pressed="true"] svg {
  transform: scaleX(-1);
}

.global-sidebar-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Bar toggle buttons (top-bar and timeline-bar) ── */
.bar-toggle-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  z-index: 10;
  box-shadow: var(--shadow);
  transition: color var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.bar-toggle-btn svg {
  width: 11px;
  height: 11px;
  transition: transform var(--transition);
}

.bar-toggle-btn:hover {
  color: var(--accent-bright);
  border-color: rgba(93, 143, 255, 0.55);
  background: var(--bg-hover);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 16px 5px rgba(93, 143, 255, 0.2);
}

.bar-toggle-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Hangs below the top-bar pill */
.bar-toggle-btn-top {
  bottom: -20px;
  border-top: none;
  border-radius: 0 0 10px 10px;
}

/* Hangs above the timeline-bar */
.bar-toggle-btn-bottom {
  top: -20px;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}

.panel-left.is-collapsed,
.panel-right.is-collapsed {
  width: 6px !important;
  min-width: 6px;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.panel-left.is-collapsed::before,
.panel-right.is-collapsed::before {
  content: '';
  position: absolute;
  top: 8%;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(93, 143, 255, 0.45) 18%,
    rgba(122, 165, 255, 0.6) 50%,
    rgba(93, 143, 255, 0.45) 82%,
    transparent 100%
  );
  border-radius: 999px;
  box-shadow:
    0 0 6px 3px rgba(93, 143, 255, 0.28),
    0 0 18px 7px rgba(93, 143, 255, 0.16),
    0 0 40px 14px rgba(93, 143, 255, 0.08);
}

.panel-left.is-collapsed .panel-body,
.panel-right.is-collapsed .panel-body {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.panel-left.is-collapsed .sidebar-toggle-btn-left svg,
.panel-right.is-collapsed .sidebar-toggle-btn-right svg {
  transform: rotate(180deg);
}

.ep-item:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 2px 0 0 var(--accent);
}

.ep-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-icon);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ep-avatar svg {
  width: 13px;
  height: 13px;
}

.ep-info {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.ep-row-compact {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.ep-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 120px;
  min-width: 0;
}

.ep-meta-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.ep-lastseen {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
}

.ep-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.ep-jump-btn {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
  margin-left: auto;
}

.ep-jump-btn svg {
  width: 10px;
  height: 10px;
}

.ep-jump-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-bright);
  border-color: var(--accent);
}

.ep-jump-btn:active {
  transform: translateY(1px);
}

.ep-jump-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.ep-tag {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  flex-shrink: 0;
}

.ep-tag-compact {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: var(--text-xs);
  font-weight: 700;
}

.ep-empty {
  padding: 16px 8px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.ep-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.ep-action-btn {
  flex: 1;
  height: var(--density-control-height);
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.ep-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.ep-action-btn.ep-action-muted:hover {
  border-color: var(--rose);
  color: var(--rose);
}

.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.env-badge.indoor {
  color: var(--cyan);
  background: var(--cyan-dim);
  border: 1px solid rgba(34, 211, 238, 0.28);
}

.env-badge.outdoor {
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

.status-dot.offline {
  background: var(--text-muted);
}

.env-chip-row,
.ep-chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.env-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  min-height: 22px;
  padding: 0 8px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}

.env-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.env-chip:active {
  transform: translateY(1px);
  background: var(--bg-hover);
}

.env-chip.active {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* Prevent lift on already-selected chips */
.env-chip.active:hover {
  transform: none;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  transition: background var(--transition-slow), border-color var(--transition-slow), color var(--transition-slow);
}

/* Historical mode — amber, no pulse */
.live-badge[data-mode="historical"] {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
  color: var(--amber);
}

.live-badge[data-mode="historical"] .live-dot {
  background: var(--amber);
  animation: none;
  opacity: 0.7;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease infinite;
  flex-shrink: 0;
}

/* ‘Go Live’ button */
.jump-live-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid rgba(79, 140, 255, 0.35);
  background: var(--accent-glow);
  color: var(--accent-bright);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(109, 160, 255, 0.16);
}

.jump-live-btn:hover {
  background: rgba(100, 150, 255, 0.22);
  border-color: var(--accent);
  color: #fff;
}

.jump-live-btn:active {
  transform: translateY(1px);
}

.jump-live-btn:disabled,
.jump-live-btn[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
  border-color: var(--border);
  background: transparent;
  color: var(--text-muted);
}

/* In live mode, dim the playback controls */
.timeline-bar[data-mode="live"] .tl-btn:not(#playBtn),
.timeline-bar[data-mode="live"] .speed-btn {
  opacity: 0.45;
}

/* ── Playback no-data toast ────────────────────────────────── */
#playbackToast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 2000;
  background: var(--bg-card);
  border: 1px solid rgba(251,191,36,0.35);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--amber);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
  white-space: normal;
  max-width: min(560px, calc(100vw - 32px));
  text-align: center;
  line-height: 1.35;
}
#playbackToast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Playback-focused entity in the list ───────────────────── */
.ep-item.selected.playback-focus {
  background: rgba(251,191,36,0.07);
  border-color: rgba(251,191,36,0.3);
}

.ep-item.selected.playback-focus .ep-name {
  color: var(--amber);
}

.panel-left,
.panel-right {
  position: fixed;
  top: var(--top-offset);
  bottom: calc(var(--timeline-safe-height) + 2px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: none;
  box-shadow: var(--shadow);
  max-height: none;
  overflow: visible;
  animation: panelIn 420ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
  transition: width var(--transition), min-width var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-left {
  left: 12px;
  width: clamp(228px, 22vw, 252px);
}

.panel-right {
  right: 12px;
  width: clamp(258px, 26vw, 306px);
  min-height: 0;
}

/* ── Inner scroll container inside each sidebar ── */
.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  display: flex;
  flex-direction: column;
  border-radius: inherit;
  transition: opacity var(--transition), visibility var(--transition);
}

.panel-body > section {
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-body > section:first-child {
  border-top: 0;
}

.panel-left .left-block {
  padding: var(--density-panel-padding) 12px;
}

.panel-left .left-block--environment {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
  padding-bottom: 10px;
}

.panel-left .left-section-header {
  display: flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-left .left-env-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.panel-left .env-card {
  padding: 3px 0 1px 8px;
  border: 0;
  border-radius: var(--radius-sm);
}

.panel-left .env-card-indoor {
  border-left: 2px solid rgba(34, 211, 238, 0.55);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.08), transparent 62%);
}

.panel-left .env-card-outdoor {
  border-left: 2px solid rgba(251, 191, 36, 0.55);
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.08), transparent 62%);
}

.panel-left .left-block--legend {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-left .left-block--legend .stat-label {
  flex: 0 0 auto;
}

.panel-left .left-block--legend .category-list,
.panel-left .left-block--legend .legend {
  display: block;
  flex: 1 1 auto;
  max-height: min(42vh, 360px);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-left .left-block--environment .left-env-grid,
.panel-left .left-block--environment .category-list {
  min-height: 0;
}

.panel-left .left-block--legend .category-list::-webkit-scrollbar,
.panel-left .left-block--legend .legend::-webkit-scrollbar {
  width: 4px;
}

.panel-left .left-block--legend .category-list::-webkit-scrollbar-thumb,
.panel-left .left-block--legend .legend::-webkit-scrollbar-thumb {
  background: rgba(57, 71, 102, 0.8);
  border-radius: 999px;
}

.stat-card,
.filter-card {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: var(--density-panel-padding) 12px;
  backdrop-filter: none;
  box-shadow: none;
  position: relative;
  overflow: visible;
  min-width: 0;
}

.stat-label,
.filter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 9px;
  line-height: 1.2;
  position: relative;
}


#entityPanelCard {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding-bottom: 4px;
}

#mapLayersCard {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

#mapLayersCard .clc-list {
  overflow-y: visible;
  padding-right: 2px;
}

#confidenceFilterCard {
  flex: 0 0 auto;
  overflow-y: visible;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(20px, 1.8vw, 24px);
  font-weight: 500;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.value-cyan { color: var(--cyan); }
.value-amber { color: var(--amber); }

.stat-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#entityStatus {
  color: var(--text-secondary);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-mini .stat-value {
  font-size: clamp(16px, 1.4vw, 18px);
}

.stat-label-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shape-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--text-xs);
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-secondary);
  font-weight: 500;
}

.shape-icon {
  width: 10px;
  height: 10px;
  background: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

.shape-icon.square {
  border-radius: 2px;
}

.shape-icon.circle {
  border-radius: 50%;
}

.stat-mini .stat-sub {
  margin-top: 4px;
  font-size: var(--text-xs);
}

.stat-metric {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 4px 0;
}

.stat-metric strong {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.category-list,
.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-item,
.legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.category-item:last-child,
.legend-item:last-child {
  border-bottom: 0;
}

.category-left,
.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-dot,
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.category-count {
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.search-box,
.filter-select,
.date-input {
  width: 100%;
  height: var(--density-control-height);
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--density-control-radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.3;
  outline: none;
}

.search-box {
  padding-left: 36px;
}

.search-wrap:focus-within svg {
  color: var(--accent-bright);
}

.filter-select,
.date-input {
  transition: var(--transition);
}

.filter-select:focus,
.date-input:focus,
.search-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.toggle-item input {
  accent-color: var(--accent);
}

.env-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.env-box strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xl);
  color: var(--text-primary);
}

.indoor-box {
  background: rgba(34, 211, 238, 0.06);
  border-color: rgba(34, 211, 238, 0.25);
}

.outdoor-box {
  background: rgba(251, 191, 36, 0.06);
  border-color: rgba(251, 191, 36, 0.25);
}

.env-hint {
  margin-top: 8px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.35;
}

.timeline-bar {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: min(920px, calc(100vw - 24px));
  background: linear-gradient(180deg, rgba(16, 20, 30, 0.94), rgba(13, 16, 24, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 12px 11px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  animation: timelineIn 460ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
  user-select: none;
  overflow: visible;
  transition: height 220ms cubic-bezier(0.4, 0, 0.2, 1), padding 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Timeline inner body wrapper ── */
.timeline-bar > .timeline-body {
  transition: opacity 180ms cubic-bezier(0.4, 0, 0.2, 1), visibility 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Timeline collapsed ── */
.timeline-bar.is-collapsed {
  height: 6px;
  padding: 0;
  overflow: visible;
}

.timeline-bar.is-collapsed::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 8%;
  right: 8%;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(93, 143, 255, 0.45) 18%,
    rgba(122, 165, 255, 0.6) 50%,
    rgba(93, 143, 255, 0.45) 82%,
    transparent 100%
  );
  border-radius: 999px;
  box-shadow:
    0 0 6px 3px rgba(93, 143, 255, 0.28),
    0 0 18px 7px rgba(93, 143, 255, 0.16),
    0 0 40px 14px rgba(93, 143, 255, 0.08);
}

.timeline-bar.is-collapsed > .timeline-body {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

.timeline-bar.is-collapsed .bar-toggle-btn-bottom svg {
  transform: rotate(180deg);
}

/* ── Sidebars adapt when timeline is collapsed ── */
body.timeline-collapsed {
  --timeline-safe-height: 24px;
}

.timeline-bar.is-floating {
  left: 0;
  transform: none;
  animation: none;
}

.timeline-bar.is-locked {
  border-color: rgba(79, 140, 255, 0.42);
}

body.timeline-dragging,
body.timeline-dragging * {
  cursor: grabbing !important;
}

@keyframes timelineIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.timeline-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-panel-actions {
  display: inline-flex;
  gap: 4px;
}

.panel-mini-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  width: 28px;
  height: var(--density-control-height);
  padding: 0;
  cursor: pointer;
  transition: var(--transition);
}

.panel-mini-btn svg {
  width: 13px;
  height: 13px;
}

.panel-mini-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.panel-mini-btn:active {
  transform: translateY(1px);
}

.panel-mini-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.panel-mini-btn[aria-pressed="true"] {
  color: #fff;
  border-color: rgba(100, 150, 255, 0.6);
  background: rgba(100, 150, 255, 0.22);
}

.timeline-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.timeline-actions-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  max-width: clamp(300px, 46%, 500px);
  min-width: 0;
}

.tl-btn,
.speed-btn {
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: var(--transition);
  cursor: pointer;
}

.tl-btn {
  width: var(--density-control-height);
  height: var(--density-control-height);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}

.tl-btn:hover,
.speed-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.tl-btn:active,
.speed-btn:active {
  transform: translateY(1px);
}

.tl-btn.active,
.speed-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tl-btn svg {
  width: 14px;
  height: 14px;
}

.speed-btn {
  width: 38px;
  height: var(--density-control-height);
  padding: 0;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  line-height: 1;
}

.divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 4px;
}

.current-time-display {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent-bright);
  min-width: 48px;
}

.timeline-dates {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  gap: 4px;
  flex-wrap: nowrap;
}

.arrow {
  color: var(--text-muted);
  text-align: center;
}

.preset-select {
  font-family: 'DM Sans', sans-serif;
  min-width: clamp(100px, 14vw, 130px);
  max-width: clamp(112px, 16vw, 140px);
  height: var(--density-control-height);
  font-size: var(--text-sm);
  padding: 0 24px 0 8px;
}

.timeline-track {
  position: relative;
  height: 36px;
  margin-top: 2px;
}

.track-bg {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.track-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  border-radius: 3px;
  width: 0%;
  box-shadow: 0 0 16px rgba(79, 140, 255, 0.24);
}

.track-activity {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 5px;
  display: flex;
  gap: 1px;
  pointer-events: none;
}

.activity-bar {
  flex: 1;
  background: rgba(79, 140, 255, 0.15);
  border-radius: 1px;
}

.track-thumb {
  position: absolute;
  top: 11px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 3px solid var(--bg-card);
  border-radius: 50%;
  transform: translateX(-50%);
  cursor: grab;
  touch-action: none; /* prevent scroll hijacking during thumb drag */
  box-shadow: 0 0 10px var(--accent-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 2;
  left: 0%;
  transition: box-shadow var(--transition), transform var(--transition);
}

.track-thumb:hover {
  box-shadow: 0 0 0 6px rgba(100, 150, 255, 0.15), 0 0 10px var(--accent-glow), var(--shadow-sm);
}

.timeline-bar[data-playing="true"] .track-thumb {
  box-shadow: 0 0 0 6px rgba(100, 150, 255, 0.12), 0 0 16px rgba(100, 150, 255, 0.28), var(--shadow-sm);
}

.track-thumb:active {
  cursor: grabbing;
  transform: translateX(-50%) scale(1.06);
}

.time-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 21px;
  padding: 0 2px;
}

.time-tick {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}

/* Disable thumb animation during pointer drag to eliminate drag lag */
.track-thumb.is-dragging {
  transition: none !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
}

/* Dark-themed entity popup */
.entity-popup .leaflet-popup-content-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
}

.entity-popup .leaflet-popup-tip {
  background: var(--bg-card);
}

.entity-popup .leaflet-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 18px !important;
  top: 6px !important;
  right: 8px !important;
}

.entity-popup .leaflet-popup-close-button:hover {
  color: var(--text-primary) !important;
}

.custom-marker .marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0,0,0,0.18);
  position: relative;
}

.custom-marker .marker-dot.indoor {
  border-radius: var(--radius-sm);
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 2.5px rgba(255,255,255,0.2), var(--shadow-sm);
}

.custom-marker .marker-dot.outdoor {
  border-radius: 50%;
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.18), var(--shadow-sm);
}

/* Live mode ping animation */
.custom-marker .marker-dot.live::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  border: 2px solid currentColor;
  opacity: 0;
  animation: markerPing 2s ease-out infinite;
}

@keyframes markerPing {
  0%   { opacity: 0.7; transform: scale(0.85); }
  100% { opacity: 0;   transform: scale(1.9); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── Confidence circle (accuracy ring shown on popup open) ── */
.confidence-circle {
  /* Sits above the heatmap canvas (z-index 200) but below markers (z-index 600+).
     Leaflet SVG overlay uses z-index 200 by default; this keeps the circle
     clearly visible without obscuring other interactive elements. */
  pointer-events: none;
}

/* ── Accuracy / Confidence filter card ── */
.conf-sub-section {
  padding: 4px 0;
}
.conf-sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.conf-sub-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.conf-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}
.conf-filter-body {
  margin-top: 10px;
  /* visibility/opacity toggle for animated close */
  visibility: hidden;
  opacity: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity var(--transition), visibility 0ms var(--transition);
}

.conf-filter-body.open {
  visibility: visible;
  opacity: 1;
  height: auto;
  overflow: visible;
  pointer-events: auto;
  transition: opacity var(--transition), visibility 0ms;
}
.conf-range-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 6px;
}
.conf-dual-range {
  position: relative;
  height: 24px;
  margin: 4px 0 12px;
}
.conf-track-bg {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}
.conf-track-fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--green), var(--amber), var(--rose));
  pointer-events: none;
  left: 0%;
  width: 100%;
}
.conf-slider {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 4px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  margin: 0;
  padding: 0;
}
.conf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e8eaf0;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--accent);
  cursor: pointer;
  pointer-events: all;
  transition: box-shadow var(--transition), transform var(--transition);
}
.conf-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.conf-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e8eaf0;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--accent);
  cursor: pointer;
  pointer-events: all;
}
.conf-value-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.conf-val-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex: 1;
}
.conf-num-input {
  width: 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  padding: 3px 5px;
  text-align: center;
  outline: none;
}
.conf-num-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.conf-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
/* Offline marker — no pulse, desaturated, semi-transparent */
.custom-marker .marker-dot.offline {
  opacity: 0.45;
  filter: grayscale(0.75) brightness(0.85);
}
/* Explicitly block the ping wave for offline dots even if .live is also present */
.custom-marker .marker-dot.offline::after {
  display: none !important;
}

/* Dimmed marker — entity accuracy is outside the selected range */
.custom-marker.marker-dimmed .marker-dot {
  opacity: 0.2;
  filter: grayscale(0.9);
  transform: scale(0.65);
}

/* ── Entity name tooltip (hover) ── */
.leaflet-tooltip.entity-name-tip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 3px 8px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  pointer-events: none;
}
.leaflet-tooltip.entity-name-tip::before {
  border-top-color: var(--border) !important;
}

/* ── Custom Date Picker ── */
.dt-picker-wrap {
  position: relative;
  flex: 0 1 clamp(100px, 14vw, 126px);
  min-width: clamp(94px, 12vw, 122px);
  max-width: clamp(104px, 15vw, 132px);
}

.dt-trigger {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
  height: var(--density-control-height);
  padding: 0 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--density-control-radius);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.dt-trigger span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.dt-trigger:hover, .dt-trigger:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.dt-trigger svg {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  color: var(--text-muted);
}

.dt-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 2000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  width: 238px;
  /* visibility/opacity for animated close */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity var(--transition), transform var(--transition), visibility 0ms var(--transition);
  user-select: none;
}
.dt-panel.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity var(--transition), transform var(--transition), visibility 0ms;
}

.dt-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dt-nav-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: var(--text-base);
  transition: var(--transition);
}
.dt-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.dt-nav-btn:active { transform: translateY(1px); }
.dt-nav-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.dt-month-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.dt-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 3px;
}

.dt-dow {
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  padding: 2px 0;
  text-transform: uppercase;
}

.dt-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.dt-day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-family: 'JetBrains Mono', monospace;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.dt-day:hover { background: var(--bg-hover); color: var(--text-primary); }
.dt-day:active { background: var(--bg-hover); transform: scale(0.94); }
.dt-day.today { color: var(--accent-bright); font-weight: 600; }
.dt-day.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.dt-day.other-month { color: var(--text-muted); opacity: 0.45; }
.dt-day.disabled {
  color: var(--text-muted);
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.dt-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.dt-time-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex-shrink: 0;
  white-space: nowrap;
}

.dt-time-input {
  width: 36px;
  min-width: 0;          /* allow shrinking in Firefox flex containers */
  flex-shrink: 1;
  box-sizing: border-box;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-base);
  text-align: center;
  padding: 4px 2px;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}
.dt-time-input::-webkit-inner-spin-button,
.dt-time-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.dt-time-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

.dt-time-sep { color: var(--text-muted); font-weight: 700; font-size: var(--text-base); flex-shrink: 0; }

.dt-now-btn {
  margin-left: auto;
  flex-shrink: 0;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.dt-now-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.dt-now-btn:active { transform: translateY(1px); }

.dt-confirm-btn {
  margin-left: 4px;
  flex-shrink: 0;
  padding: 4px 12px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.dt-confirm-btn:hover { background: var(--accent-bright); }
.dt-confirm-btn:active { transform: translateY(1px); }

/* ── Track playback visualization ── */
.track-trail-layer path {
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Mobile panel backdrop ── */
.mobile-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1400;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.mobile-panel-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 1200px) {
  :root {
    --top-offset: 72px;
    --timeline-safe-height: 230px;
    --density-panel-padding: 12px;
    --density-control-height: 30px;
  }

  .panel-left {
    width: clamp(214px, 23vw, 238px);
    left: 10px;
  }

  .panel-right {
    width: clamp(244px, 29vw, 286px);
    right: 10px;
  }

  .timeline-bar { width: min(860px, calc(100vw - 20px)); }
}

@media (max-width: 1024px) {
  :root {
    --timeline-safe-height: 200px;
  }

  .panel-left {
    width: clamp(208px, 24vw, 236px);
    left: 8px;
  }

  .panel-right {
    width: clamp(238px, 31vw, 286px);
    right: 8px;
  }

  .timeline-controls {
    gap: 6px;
  }

  .timeline-actions-row {
    gap: 4px;
  }

  .speed-btn {
    width: 34px;
    font-size: 9px;
  }

  .current-time-display {
    min-width: 44px;
    font-size: 11px;
  }
}

@media (max-width: 920px) {
  :root {
    --timeline-safe-height: 170px;
    --density-panel-padding: 10px;
    --density-control-height: 28px;
    --entity-row-height: 46px;
  }

  .panel-left {
    left: 8px;
    width: min(236px, calc(50vw - 12px));
    max-height: min(52vh, 420px);
    top: auto;
    bottom: calc(var(--timeline-safe-height) + 8px);
  }

  .panel-right {
    top: auto;
    bottom: calc(var(--timeline-safe-height) + 8px);
    right: 8px;
    width: min(260px, calc(50vw - 12px));
    max-height: min(52vh, 420px);
  }

  #entityPanelCard {
    min-height: 220px;
    max-height: 100%;
  }

  #entityPanelCard .ep-list {
    min-height: calc(3 * var(--entity-row-height));
    max-height: calc(5 * var(--entity-row-height));
  }

  .timeline-dates {
    flex: 1 1 100%;
    min-width: 0;
    order: 2;
    margin-top: 4px;
    width: 100%;
  }

  .timeline-controls {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .timeline-actions-row {
    order: 1;
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }

  .arrow { display: none; }

  .top-bar {
    left: 8px;
    right: 8px;           /* global-sidebar-btn is now below the bar, no overlap */
    width: auto;
    transform: none;
    top: 8px;
    justify-content: space-between;
  }

  .brand-name { display: none; }
  .live-badge { display: none; }
  .jump-live-btn { display: none; }
}

@media (max-width: 760px) {
  :root {
    --entity-row-height: 38px;
  }

  .panel-left {
    left: 6px;
    width: min(218px, calc(50vw - 10px));
    max-height: min(50vh, 420px);
  }

  .panel-right {
    right: 6px;
    width: min(236px, calc(50vw - 10px));
    max-height: min(50vh, 420px);
  }

  .ep-name {
    flex-basis: 92px;
    font-size: 11px;
  }

  .ep-meta-inline {
    font-size: 9px;
  }

  .timeline-bar {
    width: calc(100vw - 10px);
  }

  .timeline-controls {
    gap: 5px;
  }

  .timeline-actions-row {
    flex-wrap: wrap;
  }

  .preset-select {
    min-width: 96px;
    max-width: 112px;
  }

  .dt-picker-wrap {
    min-width: 96px;
    max-width: 112px;
  }
}

/* ════════════════════════════════════════════════════
   MOBILE  ≤ 600px  —  drawer / bottom-sheet layout
   ════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  :root {
    --top-offset: 56px;
    --timeline-safe-height: 142px;
    --density-panel-padding: 12px;
    --density-control-height: 40px;
    --density-control-radius: 8px;
    --entity-row-height: 52px;
  }

  /* ── Enable backdrop ── */
  .mobile-panel-backdrop {
    display: block;
  }

  /* ── Top bar: full-width strip ── */
  .top-bar {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    transform: none !important;
    border-radius: 0 !important;
    padding: 0 12px 0 14px !important;
    height: var(--top-offset) !important;
    min-height: var(--top-offset) !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    /* kill fill-mode animation that keeps translateX(-50%) on iOS */
    animation: none !important;
    /* stay above drawers (1500) and backdrop (1400) */
    z-index: 1600 !important;
    overflow: visible !important;
    backdrop-filter: none !important;
  }

  .top-bar.is-collapsed {
    height: 6px !important;
    min-height: 0 !important;
    padding: 0 !important;
    z-index: 1600 !important;
    overflow: visible !important;
  }

  .top-bar > .bar-body {
    height: var(--top-offset);
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }

  /* site button: full touch target */
  .site-btn {
    height: var(--density-control-height);
    padding: 0 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* dropdown becomes a fixed sheet anchored below the bar */
  .site-dropdown {
    position: fixed !important;
    top: var(--top-offset) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
    border-top: none !important;
    box-shadow: var(--shadow-lg) !important;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1700 !important;
  }

  .site-dropdown-list {
    max-height: none;
  }

  .bar-toggle-btn-top {
    width: 64px;
    height: 22px;
    bottom: -22px;
  }

  /* site selector – wider text area on mobile */
  #selectedSite {
    max-width: clamp(110px, 45vw, 200px);
  }

  /* ── Global sidebar button: hidden on mobile ── */
  .global-sidebar-btn {
    display: none !important;
  }

  /* ── Sidebar drawers: slide in from edges ── */
  .panel-left,
  .panel-right {
    top: 0 !important;
    bottom: 0 !important;
    max-height: none !important;
    width: min(88vw, 320px) !important;
    z-index: 1500 !important;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 0 !important;
  }

  /* Left drawer: slides in from left */
  .panel-left {
    left: 0 !important;
    transform: translateX(0) !important;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0 !important;
  }

  .panel-left.is-collapsed {
    width: min(88vw, 320px) !important;
    min-width: 0 !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
    transform: translateX(-101%) !important;
  }

  .panel-left.is-collapsed::before {
    display: none !important;
  }

  /* Right drawer: slides in from right */
  .panel-right {
    right: 0 !important;
    transform: translateX(0) !important;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important;
  }

  .panel-right.is-collapsed {
    width: min(88vw, 320px) !important;
    min-width: 0 !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
    transform: translateX(101%) !important;
  }

  .panel-right.is-collapsed::before {
    display: none !important;
  }

  /* Keep drawer content visible at all times (slide handles visibility) */
  .panel-left.is-collapsed .panel-body,
  .panel-right.is-collapsed .panel-body {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Toggle buttons: visible as close-handle on open drawer edge */
  .sidebar-toggle-btn {
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 24px !important;
    height: 60px !important;
    touch-action: manipulation;
  }

  .sidebar-toggle-btn-left {
    right: -24px !important;
  }

  .sidebar-toggle-btn-right {
    left: -24px !important;
  }

  /* ── Timeline: full-width bottom sheet ── */
  .timeline-bar {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: none !important;
    transform: none !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    padding: 8px 12px env(safe-area-inset-bottom, 12px) !important;
  }

  .timeline-bar.is-floating {
    left: 0 !important;
    transform: none !important;
  }

  .bar-toggle-btn-bottom {
    width: 64px;
    height: 22px;
    top: -22px;
  }

  /* Timeline controls – 2-row layout */
  .timeline-controls {
    gap: 8px;
  }

  .timeline-actions-row {
    order: 1;
    width: 100%;
    max-width: none;
    flex-wrap: nowrap !important;
    justify-content: space-between;
    gap: 6px;
  }

  .timeline-dates {
    order: 2;
    width: 100%;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 0;
  }

  .tl-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  .tl-btn svg {
    width: 16px;
    height: 16px;
  }

  .speed-btn {
    height: 40px !important;
    width: 42px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  .panel-mini-btn {
    width: 40px !important;
    height: 40px !important;
    touch-action: manipulation;
  }

  .current-time-display {
    font-size: 12px;
    min-width: 50px;
  }

  .preset-select {
    min-width: 96px;
    max-width: 130px;
    height: 40px;
    font-size: 12px;
  }

  /* Track scrubber: bigger thumb */
  .track-bg,
  .track-activity {
    top: 16px;
    height: 6px;
  }

  .track-thumb {
    width: 22px !important;
    height: 22px !important;
    top: 8px !important;
  }

  .timeline-track {
    height: 40px;
  }

  /* Date picker: fixed above timeline on mobile */
  .dt-trigger {
    height: 40px;
    font-size: 11px;
  }

  .dt-picker-wrap {
    min-width: 96px;
    max-width: 130px;
    flex: 0 1 130px;
  }

  .dt-panel {
    position: fixed !important;
    bottom: calc(var(--timeline-safe-height) + 8px) !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    width: auto !important;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 3000 !important;
  }

  /* ── Entity panel ── */
  #entityPanelCard {
    min-height: 0 !important;
    max-height: none !important;
  }

  .ep-item {
    padding: 10px 8px !important;
    min-height: 48px;
    touch-action: manipulation;
  }

  /* Restore ep-name size overridden at 760px */
  .ep-name {
    font-size: 12px;
    flex-basis: 110px;
  }

  .ep-meta-inline {
    font-size: 10px;
  }

  .ep-avatar {
    width: 32px;
    height: 32px;
  }

  .ep-jump-btn {
    width: 32px !important;
    height: 32px !important;
    touch-action: manipulation;
  }

  /* ── Filter chips ── */
  .env-chip {
    min-height: 34px !important;
    padding: 0 12px !important;
    font-size: 10px !important;
    touch-action: manipulation;
  }

  /* ── Search ── */
  .search-box {
    height: 40px;
    font-size: 14px;
  }

  .search-wrap svg {
    width: 15px;
    height: 15px;
  }

  /* ── Ep action buttons ── */
  .ep-action-btn {
    height: 40px !important;
    font-size: 11px !important;
    touch-action: manipulation;
  }

  /* ── Layer toggle list ── */
  .clc-item {
    padding: 10px 8px !important;
    min-height: 44px;
    touch-action: manipulation;
  }

  .clc-toggle {
    width: 34px;
    height: 19px;
    touch-action: manipulation;
  }

  .clc-thumb {
    width: 13px;
    height: 13px;
  }

  .clc-toggle.on .clc-thumb {
    transform: translateX(15px);
  }

  /* ── Stats ── */
  .stat-value {
    font-size: clamp(22px, 5vw, 26px);
  }

  /* ── Leaflet controls ── */
  .leaflet-top.leaflet-left {
    top: calc(var(--top-offset) + 10px) !important;
  }

  .leaflet-bottom.leaflet-right {
    bottom: calc(var(--timeline-safe-height) + 4px) !important;
  }

  /* ── Playback toast ── */
  #playbackToast {
    bottom: calc(var(--timeline-safe-height) + 12px);
  }
}

@media (max-width: 620px) {
  :root {
    --entity-row-height: 36px;
  }

  .panel-left {
    left: 6px;
    width: min(204px, calc(50vw - 10px));
    max-height: min(45vh, 370px);
    bottom: calc(var(--timeline-safe-height) + 8px);
  }

  .panel-right {
    right: 6px;
    width: min(220px, calc(50vw - 10px));
    max-height: min(45vh, 370px);
    bottom: calc(var(--timeline-safe-height) + 8px);
  }

  .panel-left .left-block--legend .category-list,
  .panel-left .left-block--legend .legend {
    max-height: min(18vh, 180px);
  }

  .timeline-bar {
    width: calc(100vw - 12px);
    bottom: 6px;
    padding: 8px 10px 10px;
    border-radius: var(--radius);
  }

  .timeline-controls {
    flex-wrap: wrap;
    gap: 6px;
  }

  .timeline-actions-row {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }

  .timeline-dates {
    width: 100%;
    min-width: 0;
    gap: 3px;
    justify-content: space-between;
  }

  .timeline-panel-actions {
    gap: 4px;
  }

  .panel-mini-btn {
    width: 26px;
    height: 22px;
  }

  .speed-btn {
    width: 30px;
    font-size: 8.5px;
  }

  .current-time-display {
    min-width: 40px;
    font-size: 10px;
  }

  .divider { display: none; }
}

@media (max-width: 520px) {
  :root {
    --density-control-height: 27px;
  }

  .top-bar {
    top: 6px;
    left: 6px;
    width: calc(100vw - 12px);
    padding-left: 8px;
    padding-right: 6px;
    gap: 6px;
  }

  .site-btn {
    padding: 0 8px;
    font-size: 12px;
  }

  #selectedSite {
    max-width: 118px;
  }

  .panel-left {
    left: 4px;
    width: min(194px, calc(50vw - 8px));
    max-height: min(42vh, 340px);
    bottom: calc(var(--timeline-safe-height) + 6px);
  }

  .panel-right {
    right: 4px;
    width: min(208px, calc(50vw - 8px));
    bottom: calc(var(--timeline-safe-height) + 6px);
    max-height: min(42vh, 340px);
  }

  #entityPanelCard .ep-list {
    min-height: calc(5 * var(--entity-row-height));
    max-height: calc(8 * var(--entity-row-height));
  }

  .sidebar-toggle-btn {
    width: 24px;
    height: 36px;
  }

  .timeline-bar {
    width: calc(100vw - 8px);
    bottom: 4px;
    padding: 7px 8px 9px;
  }

  .time-tick {
    font-size: 9px;
  }

  .stat-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COLLECTION POINTS
═══════════════════════════════════════════════════════════════════════════ */

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.cp-fab {
  position: fixed;
  bottom: 62px; /* above global-sidebar-btn */
  right: 20px;
  z-index: 1100;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.cp-fab svg { width: 17px; height: 17px; }
.cp-fab .cp-fab-icon-exit { display: none; }

.cp-fab:hover {
  color: var(--amber);
  border-color: var(--border-light);
  background: var(--bg-hover);
  box-shadow: var(--shadow), 0 0 12px 3px rgba(251,191,36,0.14);
}

.cp-fab.active {
  color: var(--amber);
  border-color: var(--amber);
  background: color-mix(in srgb, var(--bg-card) 85%, var(--amber));
  box-shadow: var(--shadow), 0 0 14px 4px rgba(251,191,36,0.22);
}

.cp-fab.active .cp-fab-icon-add  { display: none; }
.cp-fab.active .cp-fab-icon-exit { display: block; }

.cp-fab:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Pick-mode crosshair ─────────────────────────────────────────────────── */
.leaflet-container.cp-picking,
.leaflet-container.cp-picking .leaflet-interactive {
  cursor: crosshair !important;
}

/* ── Banner ──────────────────────────────────────────────────────────────── */
.cp-banner {
  position: fixed;
  top: 82px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--amber);
  background: color-mix(in srgb, var(--bg-card) 90%, var(--amber));
  color: var(--amber);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: cpBannerIn 200ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cp-banner[hidden] { display: none; }

@keyframes cpBannerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Marker pin ──────────────────────────────────────────────────────────── */
.cp-marker-wrap {
  background: transparent;
  border: none;
}

.cp-pin {
  position: relative;
  width: 40px;
  height: 44px;
  color: var(--amber);
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.6));
  transition: transform 140ms ease;
}

.cp-pin:hover { transform: scale(1.12); }

.cp-pin svg {
  width: 40px;
  height: 44px;
}

.cp-pin-index {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
  pointer-events: none;
}

/* ── Popup ───────────────────────────────────────────────────────────────── */
.cp-popup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.cp-popup-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cp-popup-index {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
}

.cp-popup-coords {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Scan button ─────────────────────────────────────────────────────────── */
.cp-scan-btn {
  width: 100%;
  min-height: 44px;   /* WCAG 2.5.5 touch target */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--green);
  background: var(--green-dim);
  color: var(--green);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cp-scan-btn:hover {
  background: color-mix(in srgb, var(--green-dim) 60%, var(--green));
  border-color: var(--green);
  box-shadow: 0 0 10px 2px rgba(52,211,153,0.2);
}

.cp-scan-btn.scanning {
  border-color: var(--amber);
  background: var(--amber-dim);
  color: var(--amber);
  cursor: default;
}

.cp-scan-btn.completed {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
  cursor: default;
  opacity: 0.85;
}

.cp-scan-btn.completed:hover {
  background: var(--green-dim);
  box-shadow: none;
}

/* ── Completed pin (green) ───────────────────────────────────────────────── */
.cp-pin--completed {
  color: var(--green);
}

/* ── Delete button ───────────────────────────────────────────────────────── */
.cp-delete-btn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--rose);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  touch-action: manipulation;
}

.cp-delete-btn:hover {
  background: var(--rose-dim);
  border-color: var(--rose);
}

/* ── Spinning icon for scanning state ───────────────────────────────────── */
@keyframes cpSpin {
  to { transform: rotate(360deg); }
}

.cp-spin {
  animation: cpSpin 0.9s linear infinite;
  flex-shrink: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .cp-fab {
    bottom: 56px;
    right: 4px;
    width: 36px;
    height: 36px;
  }

  .cp-banner {
    top: 68px;
    font-size: 11px;
    padding: 7px 12px;
  }

  .cp-scan-btn { font-size: 12px; }
}

/* ── CP distance-line tooltip ─────────────────────────────────────────────── */
.cp-dist-tooltip {
  background: rgba(13, 16, 23, 0.88);
  border: 1px solid rgba(100, 150, 255, 0.3);
  border-radius: 6px;
  color: #edf2ff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  pointer-events: none;
  white-space: nowrap;
  /* Remove default Leaflet tooltip arrow */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
.cp-dist-tooltip::before { display: none; }

/* ── Prevent body scroll when modal is open ─────────────────────────────── */
body.modal-open { overflow: hidden; }

/* ── Overlay backdrop ────────────────────────────────────────────────────── */
.device-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: dmFadeIn 180ms ease both;
}

.device-modal-overlay[hidden] { display: none; }

@keyframes dmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Sheet/dialog ────────────────────────────────────────────────────────── */
.device-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -6px 40px rgba(0, 0, 0, 0.5);
  animation: dmSlideUp 260ms cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes dmSlideUp {
  from { transform: translateY(48px); opacity: 0.7; }
  to   { transform: translateY(0);    opacity: 1;   }
}

/* ── Drag handle (cosmetic) ─────────────────────────────────────────────── */
.device-modal-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-light);
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.device-modal-header {
  padding: 16px 20px 14px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.device-modal-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(100, 150, 255, 0.12);
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  color: var(--accent);
}

.device-modal-icon svg { width: 20px; height: 20px; }

.device-modal-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.device-modal-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* ── Device list ─────────────────────────────────────────────────────────── */
.device-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overscroll-behavior: contain;
}

/* ── Device item ─────────────────────────────────────────────────────────── */
.device-modal-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.device-modal-item:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.device-modal-item.selected {
  border-color: var(--accent);
  background: rgba(100, 150, 255, 0.10);
}

/* ── Status dot ─────────────────────────────────────────────────────────── */
.dm-item-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-light);
  flex-shrink: 0;
}

.dm-item-status.online {
  background: var(--green);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.55);
}

/* ── Item text ──────────────────────────────────────────────────────────── */
.dm-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dm-item-name {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-item-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Radio check circle ─────────────────────────────────────────────────── */
.dm-item-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border-light);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.dm-item-check svg {
  width: 11px;
  height: 11px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.device-modal-item.selected .dm-item-check {
  background: var(--accent);
  border-color: var(--accent);
}

.device-modal-item.selected .dm-item-check svg {
  opacity: 1;
  stroke: #0b0d11;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.device-modal-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Footer buttons ─────────────────────────────────────────────────────── */
.device-modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.dm-btn {
  flex: 1;
  min-height: 50px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.dm-btn--cancel {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.dm-btn--cancel:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.dm-btn--confirm {
  border: 1px solid var(--green);
  background: var(--green-dim);
  color: var(--green);
}

.dm-btn--confirm:hover:not(:disabled) {
  background: color-mix(in srgb, var(--green-dim) 40%, var(--green));
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.25);
}

.dm-btn--confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Desktop: centered dialog ───────────────────────────────────────────── */
@media (min-width: 600px) {
  .device-modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .device-modal {
    border-radius: var(--radius-lg);
    max-height: 72vh;
    box-shadow: var(--shadow-lg);
  }

  .device-modal-handle { display: none; }
}

/* ── Very small screens ─────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .device-modal { max-height: 90vh; }
  .device-modal-header { padding: 12px 16px 10px; }
  .dm-btn { min-height: 46px; font-size: var(--text-sm); }
}

/* ════════════════════════════════════════════════════════════════════════════
   Login overlay
   ════════════════════════════════════════════════════════════════════════════ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 23, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.login-overlay[hidden] { display: none; }

.login-card {
  background: var(--surface-2, #1a2035);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 16px;
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}

.login-subtitle {
  color: var(--text-secondary, #94a3b8);
  font-size: var(--text-sm, 0.82rem);
  margin: 0 0 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-field label {
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-field input {
  background: var(--surface-1, #131929);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 8px;
  color: var(--text-primary, #e2e8f0);
  padding: 10px 12px;
  font-size: var(--text-sm, 0.82rem);
  outline: none;
  transition: border-color 0.15s;
}

.login-field input:focus {
  border-color: var(--accent, #3b82f6);
}

.login-error {
  font-size: var(--text-xs, 0.75rem);
  color: #f87171;
  margin: 0;
  padding: 8px 10px;
  background: rgba(248,113,113,0.1);
  border-radius: 6px;
  border: 1px solid rgba(248,113,113,0.25);
}
.login-error[hidden] { display: none; }

.login-submit {
  margin-top: 4px;
  padding: 11px;
  background: var(--accent, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: var(--text-sm, 0.82rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.login-submit:hover { background: #2563eb; }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Logout button in top bar ─────────────────────────────────────────────── */
.logout-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 6px;
  color: var(--text-secondary, #94a3b8);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.logout-btn:hover {
  color: var(--text-primary, #e2e8f0);
  border-color: rgba(255,255,255,0.25);
}

/* ── Password show/hide toggle ───────────────────────────────────────────── */
.login-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-password-wrap input {
  width: 100%;
  padding-right: 38px;
}

.login-pw-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.login-pw-toggle:hover {
  color: var(--text-primary, #e2e8f0);
}

.login-pw-toggle svg[hidden] { display: none; }
