html, body {
      margin: 0; padding: 0; height: 100%; width: 100%;
      overflow: hidden; font-family: Arial, sans-serif; background: #0b1120;
      -webkit-font-smoothing: antialiased;
    }

    #map { position: absolute; inset: 0; }

    /* --- КНОПКА ПОШУКУ (ЛУПА) --- */
    #searchBtnSide {
      position: absolute; 
      top: 165px; right: 12px;
      width: 48px; height: 48px;
      border-radius: 14px; border: none;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; z-index: 500;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
      outline: none;
      -webkit-tap-highlight-color: transparent;
      transition: opacity 0.25s ease, transform 0.25s ease;
    }
    #searchBtnSide:focus {
      outline: none;
    }
    .icon-loupe {
      width: 24px; height: 24px;
      fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
    }

    /* --- БУРГЕР --- */
    #menuBtn {
      position: absolute; top: 50px; left: 12px; width: 48px; height: 48px;
      border-radius: 14px; border: none; display: flex; align-items: center; justify-content: center;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); cursor: pointer; z-index: 500; font-size: 26px;
      transition: opacity 0.25s ease, transform 0.25s ease;
    }

    /* --- НИЖНІ КНОПКИ (FAB) --- */
    .bottom-bar {
      position: absolute; left: 0; right: 0; bottom: 85px;
      z-index: 500; pointer-events: auto;
      transition: opacity 0.25s ease, transform 0.25s ease;
    }
    .bottom-inner {
      max-width: 520px; margin: 0 auto; display: flex;
      justify-content: space-between; align-items: center; padding: 0 18px;
      pointer-events: auto;
    }

    .fab {
      width: 68px; height: 68px;
      border: none; background: transparent; padding: 0;
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      -webkit-tap-highlight-color: transparent;
      transform: translateZ(0); transition: transform 0.1s ease;
    }
    .fab:active { transform: scale(0.95); }

    .fab-inner {
      width: 64px; height: 64px; border-radius: 50%;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
      display: flex; align-items: center; justify-content: center;
      position: relative; font-weight: 800; font-size: 22px;
    }

    /* ЛІВА КНОПКА (Приціл) */
    .icon-crosshair::before, .icon-crosshair::after {
      content: ""; position: absolute; background: currentColor;
    }
    .icon-crosshair::before { width: 4px; height: 16px; top: 6px; left: 30px; box-shadow: 0 36px 0 currentColor; }
    .icon-crosshair::after { width: 16px; height: 4px; left: 6px; top: 30px; box-shadow: 36px 0 0 currentColor; }

    /* ПРАВА КНОПКА (Знак оклику) */
    .fab-inner.report-btn-style {
      border: 2px solid #facc15; background-color: #ffffff; color: #000000;
      box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    }
    .alert-sign { font-size: 40px; font-weight: 900; line-height: 1; font-family: Arial, sans-serif; }

    /* --- СТАТИСТИКА --- */
    
    /* Route sheet styles */
    /* Згорнутий стан панелі маршруту - тільки інфо, без кнопок */
    #routeSheet.route-collapsed .route-actions {
      display: none;
    }
    #routeSheet.route-collapsed .route-summary-sub {
      margin-bottom: 4px;
    }

    /* Кнопки в тему день/ніч - фон */
    body.theme-day .route-btn {
      background: #ffffff;
    }
    body.theme-night .route-btn {
      background: #020617;
    }
    body.theme-night .route-summary-main,
    body.theme-night .route-summary-sub {
      color: #e5e7eb;
    }

    /* Коли відкрита панель маршруту - трохи піднімаємо нижню панель */
    body.has-route-panel .bottom-bar {
      bottom: 135px;
    }

    #routeSheet {
      height: auto;
      margin-bottom: 0px;
    }
    /* Розміри панелі маршруту як у Waze */
    #routeSheet.full-open {
      height: 45vh;
      max-height: 45vh;
      transform: translateY(0);
    }
    #routeSheet.half-open {
      height: 95px;
      max-height: 95px;
      transform: translateY(0);
    }
    #routeSheet.route-collapsed {
      height: 32px;
      max-height: 32px;
      overflow: hidden;
    }
    .route-summary-main {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 4px;
    }
    .route-summary-sub {
      font-size: 13px;
      color: #6b7280;
      margin-bottom: 10px;
    }
    .route-actions {
      display: flex;
      gap: 10px;
      margin-top: 4px;
    }
    .route-btn {
      flex: 1;
      padding: 10px 0;
      border-radius: 999px;
      border: 2px solid transparent;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      background: #ffffff;
    }
    .route-btn-cancel {
      border-color: #ef4444;
      color: #b91c1c;
    }
    .route-btn-go {
      border-color: #22c55e;
      color: #15803d;
    }
    
#statsBar {
      position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
      display: none; flex-direction: row; gap: 16px;
      align-items: center; justify-content: center;
      padding: 6px 14px; border-radius: 99px;
      font-size: 14px; line-height: 1;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
      z-index: 500; pointer-events: auto;
    }

/* Постійний навігаційний щит */
#navInfoBar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  z-index: 500;
  pointer-events: auto;
  display: flex;
  justify-content: center;
}

.nav-info-inner {
  max-width: 520px;
  width: calc(100% - 36px);
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}


#navInfoMain {
  font-size: 18px;
  font-weight: 700;
}

#navInfoSub {
  font-size: 13px;
  opacity: 0.9;
}

/* Тема день */
body.theme-day #navInfoBar .nav-info-inner {
  background: rgba(255, 255, 255, 0.98);
  color: #111827;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* Тема ніч */
body.theme-night #navInfoBar .nav-info-inner {
  background: rgba(0, 0, 0, 0.9);
  color: #f9fafb;
  border: 1px solid rgba(148, 163, 184, 0.45);
}


    #statsBar > div { display: flex; align-items: center; white-space: nowrap; }
    .stat-value { font-weight: 700; margin-left: 5px; font-size: 14px; }

    /* --- МАРКЕР КОРИСТУВАЧА --- */
    .user-dot {
      width: 24px; height: 24px;
      background: #3b82f6; border: 3px solid #ffffff;
      border-radius: 50%; box-shadow: 0 0 8px rgba(59, 130, 246, 0.9);
      position: relative; z-index: 100;
    }
    .user-dot::after {
      content: ''; position: absolute;
      top: -10px; left: -10px; right: -10px; bottom: -10px;
      background: rgba(59, 130, 246, 0.4);
      border-radius: 50%; animation: pulse 2s infinite; z-index: -1;
    }
    @keyframes pulse {
      0% { transform: scale(0.5); opacity: 1; }
      100% { transform: scale(1.2); opacity: 0; }
    }
    .user-arrow-nav {
      width: 48px; height: 48px;
      display: flex; align-items: center; justify-content: center;
      filter: drop-shadow(0 0 10px rgba(59, 130, 246, 1));
      transform-origin: center center;
      transition: transform 0.3s ease;
      z-index: 100;
    }

    /* --- ПОШУК (ВІКНО) --- */
    .search-input-container {
      display: flex; align-items: center;
      background: #f3f4f6; border-radius: 12px;
      padding: 8px 12px; margin-bottom: 12px;
    }
    .search-input {
      flex: 1; border: none; background: transparent;
      font-size: 16px; outline: none; color: inherit; padding: 4px 0;
    }
    .search-results {
      list-style: none; margin: 0; padding: 0;
      overflow-y: auto;
    }
    .search-item {
      padding: 12px 0; border-bottom: 1px solid #e5e7eb;
      cursor: pointer; display: flex; align-items: center; gap: 12px;
    }
    .search-item:last-child { border-bottom: none; }
    .search-dist {
      font-size: 11px; font-weight: 700; color: #3b82f6;
      min-width: 45px; text-align: right;
      display: flex; flex-direction: column; align-items: flex-end;
      line-height: 1.2;
    }
    .search-text { font-size: 15px; display: flex; flex-direction: column; flex: 1; }
    .search-subtext { font-size: 12px; color: #6b7280; margin-top: 2px; }
    .search-marker { width: 18px; height: 18px; border-radius: 50%; background: #ef4444; border: 3px solid #ffffff; box-shadow: 0 0 8px rgba(239, 68, 68, 0.9); }

    /* --- ПЕРЕМИКАЧ РЕЖИМІВ --- */
    .mode-switcher {
      display: flex; background: #e5e7eb; border-radius: 10px; padding: 4px; margin: 10px 0;
    }
    .mode-btn {
      flex: 1; border: none; background: transparent; padding: 8px 0;
      border-radius: 8px; font-size: 14px; font-weight: 600; color: #6b7280; cursor: pointer; transition: all 0.2s;
    }
    .mode-btn.active { background: #ffffff; color: #111827; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

    /* --- ТЕМИ --- */
    body.theme-day #menuBtn, body.theme-day .sheet { background: #ffffff; color: #111827; }
    body.theme-day #searchBtnSide { background: rgba(255, 255, 255, 0.5); color: #111827; }
    body.theme-day #statsBar { background: rgba(255, 255, 255, 0.25); color: #000000; border: 1px solid rgba(0, 0, 0, 0.1); }
    body.theme-day #locateBtn .fab-inner { background: #ffffff; color: #111827; }
    body.theme-day .fab-inner.report-btn-style { background: #ffffff; color: #000000; border-color: #facc15; }
    body.theme-day .search-input-container { background: #f3f4f6; color: #111827; }
    body.theme-day .search-item { border-bottom-color: #e5e7eb; }
    body.theme-day .mode-switcher { background: #f3f4f6; }
    body.theme-day .mode-btn.active { background: #ffffff; color: #000000; }

    body.theme-night #menuBtn { background: #1f2937; color: #f9fafb; border-color: #4b5563; }
    body.theme-night #searchBtnSide { background: rgba(31, 41, 55, 0.5); color: #f9fafb; }
    body.theme-night .sheet { background: #111827; color: #e5e7eb; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.9); }
    body.theme-night .sheet-sub { color: #9ca3af; }
    body.theme-night .sheet-handle { background: #4b5563; }
    body.theme-night .event-card { background: #1f2937; border-color: #4b5563; }
    body.theme-night .event-card.selected { background: #064e3b; border-color: #22c55e; }
    body.theme-night .event-label { color: #e5e7eb; }
    body.theme-night #statsBar { background: rgba(15, 23, 42, 0.25); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.15); }
    body.theme-night .menu-user-card { background: rgba(255,255,255,0.05); }
    body.theme-night .menu-user-desc { color: #9ca3af; }
    body.theme-night .menu-item-row, body.theme-night .menu-item-btn { border-bottom-color: #374151; color: #e5e7eb; }
    body.theme-night .slider { background-color: #4b5563; }
    body.theme-night input:checked + .slider { background-color: #3b82f6; }
    body.theme-night #locateBtn .fab-inner { background: #1f2937; color: #f9fafb; border: 1px solid #4b5563; }
    body.theme-night .user-dot { box-shadow: 0 0 12px rgba(96, 165, 250, 0.9); }
    body.theme-night .search-input-container { background: #1f2937; color: #f9fafb; border: 1px solid #374151; }
    body.theme-night .search-item { border-bottom-color: #374151; }
    body.theme-night .search-subtext { color: #9ca3af; }
    body.theme-night .search-dist { color: #60a5fa; }
    body.theme-night .fab-inner.report-btn-style { background: #1f2937; color: #facc15; border-color: #facc15; }
    body.theme-night .mode-switcher { background: #374151; }
    body.theme-night .mode-btn { color: #9ca3af; }
    body.theme-night .mode-btn.active { background: #1f2937; color: #f9fafb; }

    /* Sheet Styles (OVERLAYS) */
    .sheet-backdrop { 
        position: fixed; inset: 0; 
        background: transparent; 
        display: none; align-items: flex-end; justify-content: center; 
        z-index: 2000; 
    }

    .sheet { 
        width: 100%; max-width: 520px; 
        background: #ffffff; 
        border-radius: 18px 18px 0 0; 
        padding: 12px 18px 14px; 
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5); 
        box-sizing: border-box; 
        transform: translateY(100%); 
        transition: transform 0.6s cubic-bezier(0.33, 1, 0.68, 1); 
        display: flex; flex-direction: column; 
        height: auto;
        max-height: 90vh; 
    }

    #searchSheet {}
    #searchSheet.half-open {
        height: 45vh;
        transform: translateY(0);
    }
    #searchSheet.full-open {
        height: 90vh;
        transform: translateY(0);
    }

    .sheet.dragging { transition: none; }
    .sheet-handle { width: 60px; height: 5px; border-radius: 18px; background: #d1d5db; margin: 0 auto 12px; flex-shrink: 0; }
    .sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-shrink: 0; }
    .sheet-title { font-size: 20px; font-weight: 700; }
    .sheet-close { border: none; background: transparent; font-size: 28px; color: #6b7280; cursor: pointer; padding: 0 10px; }
    .sheet-sub { font-size: 15px; color: #6b7280; margin-bottom: 14px; }

    /* Menu elements */
    .menu-user-card { display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,0.04); padding: 14px; border-radius: 14px; margin-bottom: 18px; cursor: pointer; }
    .menu-user-icon { font-size: 26px; }
    .menu-user-info { display: flex; flex-direction: column; }
    .menu-user-name { font-weight: 700; font-size: 17px; }
    .menu-user-desc { font-size: 14px; color: #6b7280; }
    .menu-list { display: flex; flex-direction: column; gap: 6px; }
    .menu-item-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid #f3f4f6; font-size: 17px; color: #111827; }
    .menu-item-row:last-child { border-bottom: none; }
    .menu-item-btn { background: transparent; border: none; text-align: left; width: 100%; padding: 16px 0; font-size: 17px; cursor: pointer; border-bottom: 1px solid #f3f4f6; color: #111827; }
    .toggle-switch { position: relative; display: inline-block; width: 50px; height: 28px; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .slider { position: absolute; cursor: pointer; inset: 0; background-color: #d1d5db; transition: .3s; border-radius: 34px; }
    .slider:before { position: absolute; content: ""; height: 22px; width: 22px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
    input:checked + .slider { background-color: #3b82f6; }
    input:checked + .slider:before { transform: translateX(22px); }
    .events-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
    .event-card { background: #f3f4f6; border-radius: 16px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; border: 2px solid transparent; }
    .event-card.selected { border-color: #22c55e; background: #dcfce7; }
    .event-icon-wrap { width: 68px; height: 68px; display: flex; align-items: center; justify-content: center; }
    .event-icon-wrap img { width: 100%; height: 100%; object-fit: contain; }
    .event-label { font-size: 14px; text-align: center; color: #111827; font-weight: 500; }

    /* Overlays */
    #authOverlay, #infoOverlay { 
        position: fixed; inset: 0; 
        background: rgba(0,0,0,0.55); 
        display: none; align-items: center; justify-content: center; 
        z-index: 2000; 
    }
    #toast { 
        position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); 
        background: rgba(0, 0, 0, 0.85); color: #f9fafb; 
        padding: 10px 16px; border-radius: 12px; font-size: 15px; 
        z-index: 3000; display: none; max-width: 80%; text-align: center; 
    }
    

    /* --- Адмінське контекстне меню --- */
    #adminContextMenu {
      position: absolute;
      z-index: 3500;
      background: #111827;
      color: #e5e7eb;
      border-radius: 12px;
      box-shadow: 0 12px 30px rgba(0,0,0,0.7);
      padding: 6px 0 8px 0;
      min-width: 210px;
      font-size: 14px;
      display: none;
    }
    .admin-menu-header {
      padding: 6px 12px 8px 12px;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #9ca3af;
      border-bottom: 1px solid #374151;
    }
    .admin-status-toggle {
      display: flex;
      padding: 6px 8px 6px 8px;
      gap: 4px;
      border-bottom: 1px solid #374151;
    }
    .admin-status-toggle .status-btn {
      flex: 1;
      border-radius: 18px;
      border: none;
      background: #1f2937;
      color: #e5e7eb;
      font-size: 12px;
      padding: 4px 0;
      cursor: pointer;
    }
    .admin-status-toggle .status-btn.active {
      background: #22c55e;
      color: #052e16;
      font-weight: 600;
    }
    .admin-menu-list {
      max-height: 260px;
      overflow-y: auto;
    }
    .admin-menu-item {
      padding: 8px 12px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .admin-menu-item:hover {
      background: #1f2937;
    }

    .admin-menu-icon {
      width: 18px;
      height: 18px;
      object-fit: contain;
    }

    .admin-menu-dot {
      width: 10px;
      height: 10px;
      border-radius: 18px;
    }
    .admin-menu-dot.green { background: #22c55e; }
    .admin-menu-dot.blue { background: #3b82f6; }
    .admin-menu-dot.red { background: #ef4444; }
    .admin-menu-dot.yellow { background: #eab308; }
    .admin-menu-dot.gray { background: #9ca3af; }

    /* --- Ховання кнопок при відкритих шитах --- */
    body.sheet-open #menuBtn,
    body.sheet-open #searchBtnSide,
    body.sheet-open .bottom-bar {
      opacity: 0;
      pointer-events: auto;
      transform: translateY(20px);
    }

/* Ховаємо підпис © MapTiler © OpenStreetMap */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-attrib {
  display: none !important;
}


/* Автозакриття попапів та прихований хрестик */
.maplibregl-popup-close-button {
  display: none !important;
}

.maplibregl-popup {
  animation: nav-popup-autohide 3s ease-out forwards;
}

@keyframes nav-popup-autohide {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
}


/* Попап як чатова бульбашка над міткою */




.tg-thread {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tg-bubble {
  border-radius: 16px;
  padding: 8px 10px;
}

/* День */
body.theme-day .tg-bubble {
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
}

/* Ніч */
body.theme-night .tg-bubble {
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.tg-user {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
}

.tg-message {
  font-size: 14px;
  margin-top: 2px;
}

.tg-time {
  font-size: 11px;
  margin-top: 4px;
  text-align: right;
  opacity: 0.75;
}

/* Попап як чатова бульбашка над міткою */
.maplibregl-popup-content {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.maplibregl-popup-tip {
  display: none !important;
}

.tg-thread {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tg-bubble {
  border-radius: 16px;
  padding: 8px 10px;
}

/* День */
body.theme-day .tg-bubble {
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
}

/* Ніч */
body.theme-night .tg-bubble {
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.tg-user {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
}

.tg-message {
  font-size: 14px;
  margin-top: 2px;
}

.tg-time {
  font-size: 11px;
  margin-top: 4px;
  text-align: right;
  opacity: 0.75;
}
