:root {
  --text: #17242e;
  --muted: #64707b;
  --line: rgba(23, 36, 46, 0.1);
  --panel: rgba(255, 255, 255, 0.94);
  --shadow: 0 18px 40px rgba(15, 29, 39, 0.18);
  --teal: #247b72;
  --radius-lg: 22px;
  --radius-md: 14px;
  --sidebar-offset: 16px;
  --sidebar-width: min(360px, calc(100vw - 32px));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Manrope', sans-serif;
  color: var(--text);
  background: #ede7db;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.layout {
  position: relative;
  z-index: 500;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sidebar,
.sidebar-trigger,
.filters-panel,
.mobile-backdrop,
.empty-results {
  pointer-events: auto;
}

.sidebar {
  position: absolute;
  top: var(--sidebar-offset);
  left: var(--sidebar-offset);
  display: grid;
  gap: 14px;
  align-content: start;
  width: var(--sidebar-width);
  max-height: calc(100vh - 32px);
  padding: 14px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 220ms ease, opacity 220ms ease;
}

body.filters-hidden .sidebar {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.sidebar-trigger {
  position: absolute;
  top: calc(var(--sidebar-offset) + 18px);
  left: calc(var(--sidebar-offset) + var(--sidebar-width) - 1px);
  z-index: 560;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 0 14px 14px 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(15, 29, 39, 0.16);
  cursor: pointer;
  transition: left 220ms ease, background-color 180ms ease, color 180ms ease;
}

body.filters-hidden .sidebar-trigger {
  left: 0;
  background: rgba(255, 255, 255, 0.98);
}

.sidebar-header {
  display: grid;
  gap: 14px;
}

.sidebar-heading {
  display: grid;
  gap: 4px;
}

.sidebar-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
}

.sidebar-heading strong {
  font-size: 20px;
  font-weight: 800;
  color: #14212b;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-panel {
  max-height: calc(100vh - 160px);
  padding: 4px;
  border-radius: 18px;
  background: rgba(23, 36, 46, 0.04);
  border: 1px solid rgba(23, 36, 46, 0.06);
  overflow: hidden;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
}

.filters-list {
  max-height: calc(100vh - 176px);
  overflow: auto;
  padding: 2px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.filters-list::-webkit-scrollbar {
  width: 8px;
}

.filters-list::-webkit-scrollbar-thumb {
  background: rgba(23, 36, 46, 0.16);
  border-radius: 999px;
}

.filter-group {
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 36, 46, 0.08);
  overflow: hidden;
}

.filter-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.filter-title {
  min-width: 0;
  display: block;
}

.filter-title strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.category-check,
.sub-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--teal);
}

.filter-toggle,
.icon-btn {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.filter-toggle {
  width: 28px;
  height: 28px;
  border-radius: 10px;
}

.filter-toggle[aria-expanded="false"] i {
  transform: rotate(-90deg);
}

.filter-options {
  display: grid;
  gap: 2px;
  padding: 0 8px 8px;
}

.sub-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 160ms ease;
}

.sub-option:hover {
  background: rgba(23, 36, 46, 0.04);
}

.sub-option-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}

.icon-btn,
.sidebar-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 29, 39, 0.1);
}

.sidebar-actions a:hover {
  background: rgba(36, 123, 114, 0.12);
  color: var(--teal);
}

.sidebar-trigger:hover {
  background: #ffffff;
  color: var(--teal);
}

.mobile-backdrop {
  position: absolute;
  inset: 0;
  z-index: 490;
  background: rgba(23, 36, 46, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.filters-panel-open .mobile-backdrop {
  opacity: 0;
}

.empty-results {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 12px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(23, 36, 46, 0.08);
  box-shadow: var(--shadow);
  z-index: 600;
}

.empty-results.show {
  display: flex;
}

.empty-results i {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(36, 123, 114, 0.1);
  color: var(--teal);
  flex: 0 0 auto;
}

.leaflet-popup-content-wrapper {
  border-radius: 18px;
  box-shadow: 0 20px 44px rgba(20, 33, 43, 0.18);
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-family: 'Manrope', sans-serif;
}

.popup-card {
  min-width: 200px;
  display: grid;
  gap: 10px;
}

.popup-title {
  margin-bottom: 4px;
  font-size: 16px;
  font-weight: 800;
  color: #14212b;
}

.popup-subtitle {
  font-size: 13px;
  line-height: 1.5;
  color: #5b6874;
}

.popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.popup-tag {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.popup-tag-category {
  background: rgba(36, 123, 114, 0.12);
  color: #247b72;
}

.popup-tag-subcategory {
  background: rgba(208, 122, 47, 0.12);
  color: #b9621e;
}

.popup-route-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(23, 36, 46, 0.06);
  border: 1px solid rgba(23, 36, 46, 0.08);
  color: #17242e;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.popup-route-link:hover {
  background: rgba(36, 123, 114, 0.12);
  color: #247b72;
}

@media (max-width: 980px) {
  :root {
    --sidebar-offset: 12px;
    --sidebar-width: min(360px, calc(100vw - 24px));
  }

  .sidebar {
    max-height: calc(100vh - 24px);
  }

  .sidebar-trigger {
    top: calc(var(--sidebar-offset) + 18px);
  }

  .filters-panel {
    max-height: calc(100vh - 168px);
    background: rgba(255, 255, 255, 0.97);
  }

  .filters-list {
    max-height: calc(100vh - 184px);
  }

  body.filters-panel-open .mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 640px) {
  :root {
    --sidebar-width: calc(100vw - 24px);
  }

  .sidebar {
    width: var(--sidebar-width);
  }

  .sidebar-header {
    gap: 12px;
  }

  .filter-group-header {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-controls {
    justify-content: space-between;
  }

  .filter-title strong {
    white-space: normal;
  }

  .empty-results {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    max-width: none;
  }
}
