:root {
  --bg-dark: #0c1626;
  --bg-dark-soft: #111e33;
  --bg-light: #0a1221;
  --panel: rgba(17, 30, 51, 0.72);
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --accent-warm: #ff8a4c;
  --text-main: #f5f7fd;
  --text-muted: #c1cadd;
  --border: #203149;
  --border-strong: #304664;
  --glow: 0 16px 50px rgba(34, 197, 94, 0.12);
  --blur: blur(14px);
  --topbar-from: rgba(21, 30, 46, 0.9);
  --topbar-to: rgba(12, 24, 43, 0.92);
  --sidebar-from: rgba(15, 27, 45, 0.92);
  --sidebar-to: rgba(15, 27, 45, 0.85);
  --surface-soft: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  --nav-surface: linear-gradient(135deg, rgba(26, 41, 65, 0.8), rgba(25, 40, 64, 0.65));
  --nav-surface-hover: linear-gradient(135deg, rgba(41, 64, 99, 0.9), rgba(34, 54, 86, 0.8));
  --card-surface: linear-gradient(145deg, rgba(24, 38, 61, 0.9), rgba(17, 30, 51, 0.9));
  --content-surface: linear-gradient(145deg, #0c1626, #0d182b);
  --layer-surface: rgba(17, 30, 51, 0.9);
  --pill-surface: rgba(17, 30, 51, 0.7);
  --pill-highlight: linear-gradient(135deg, #67e8f9, #22d3ee);
  --color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(45, 212, 191, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(255, 138, 76, 0.06), transparent 40%),
    var(--bg-light);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color-scheme: var(--color-scheme, dark);
}

.topbar {
  height: 64px;
  background: linear-gradient(120deg, var(--topbar-from), var(--topbar-to));
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.6px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.brand:hover {
  opacity: 0.8;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  font-size: 14px;
}

.back-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.back-button:active {
  transform: translateY(0);
}

.back-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.back-icon {
  font-size: 18px;
  line-height: 1;
}

.back-label {
  font-size: 14px;
}

.back-button.hidden {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.3s ease;
}

.status-indicator .status-icon {
  font-size: 8px;
  color: #10b981;
  animation: status-pulse 2s ease-in-out infinite;
}

.status-indicator.offline .status-icon {
  color: #ef4444;
}

.status-indicator.offline .status-text {
  color: #ef4444;
}

.status-indicator .status-text {
  font-size: 12px;
  letter-spacing: 0.3px;
}

@keyframes status-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.theme-toggle {
  position: relative;
  width: 70px;
  height: 36px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.theme-toggle-track {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.15);
  /* Neumorphic shadow - inset effect */
  box-shadow: 
    inset 2px 2px 4px rgba(0, 0, 0, 0.1),
    inset -2px -2px 4px rgba(255, 255, 255, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.theme-toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Neumorphic raised effect */
  box-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.2),
    -2px -2px 4px rgba(255, 255, 255, 0.1);
  z-index: 2;
}

.theme-toggle-active .theme-toggle-slider {
  transform: translateX(37px);
  background: rgba(30, 30, 40, 0.3);
  box-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.3),
    -2px -2px 4px rgba(255, 255, 255, 0.05);
}

.theme-toggle-icon {
  font-size: 14px;
  line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
  position: absolute;
}

.theme-toggle-icon-sun {
  opacity: 1;
  transform: scale(1);
}

.theme-toggle-icon-moon {
  opacity: 0;
  transform: scale(0.8);
}

.theme-toggle-active .theme-toggle-icon-sun {
  opacity: 0;
  transform: scale(0.8);
}

.theme-toggle-active .theme-toggle-icon-moon {
  opacity: 1;
  transform: scale(1);
}


.theme-toggle:hover .theme-toggle-track {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.theme-toggle:active .theme-toggle-slider {
  transform: translateX(37px) scale(0.98);
}

.theme-toggle:not(.theme-toggle-active):active .theme-toggle-slider {
  transform: translateX(0) scale(0.98);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 21px;
}

.menu-button {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  display: grid;
  gap: 5px;
  padding: 8px;
  cursor: pointer;
}

.menu-button span {
  display: block;
  height: 3px;
  background: var(--text-main);
  border-radius: 2px;
}

.layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  flex: 1;
  margin-top: 64px;
  min-height: calc(100vh - 64px);
  height: auto;
  overflow: visible;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
  color: var(--text-main);
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border);
  backdrop-filter: var(--blur);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  min-height: 0;
}

.sidebar-header {
  padding: 12px 10px 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  box-shadow: var(--glow);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 1.2px;
}

.headline {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
}

.subtitle {
  color: var(--text-muted);
  margin: 6px 0 4px;
  line-height: 1.4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--border);
  background: var(--card-surface);
  border-radius: 14px;
  padding: 12px 12px 14px;
  color: var(--text-main);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.stat-card.active {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18), rgba(34, 197, 94, 0.2));
  box-shadow: 0 18px 42px rgba(45, 212, 191, 0.2);
}

.stat-card.active .stat-label {
  color: rgba(255, 255, 255, 0.9);
}

.stat-card.active .stat-sub {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.stat-card.active .stat-value {
  color: #ffffff;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.stat-label {
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.stat-sub {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

  .nav-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
  }

  .nav.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    background: var(--surface-soft);
    box-shadow: var(--glow);
  }

  .nav-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .nav-item {
    width: 100%;
    text-align: left;
    background: var(--nav-surface);
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
  }
  
  .nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    transform: scaleY(0);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .nav-item:hover::before,
  .nav-item.active::before {
    transform: scaleY(1);
  }

  .nav-item:hover {
    background: var(--nav-surface-hover);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transform: translateX(2px);
  }

  .nav-item.active {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.12));
    border-color: rgba(34, 197, 94, 0.3);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
  }
  
  .nav-item.active .nav-label-main {
    color: #ffffff;
    font-weight: 700;
  }
  
  .nav-item.active .nav-label-sub {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
  }
  
  .nav-item.active .nav-icon {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
  }

  .nav-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 20px;
    flex-shrink: 0;
  }

  .nav-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
  }

  .nav-label-main {
    font-weight: 700;
  }

  .nav-label-sub {
    color: var(--text-muted);
    font-size: 13px;
  }


.headline.small {
  font-size: 16px;
}

.stat-chip.subtle {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  opacity: 0.9;
}

.content {
  position: relative;
  background: radial-gradient(circle at 15% 20%, rgba(45, 212, 191, 0.08), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(255, 138, 76, 0.08), transparent 45%),
    var(--content-surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.notice-banner {
  margin: 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: #f97316;
  color: #ffffff;
  border: 1px solid #ea580c;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 11px;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  white-space: normal;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}

.notice-label {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.dashboard-strip {
  padding: 14px 18px 6px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(17, 30, 51, 0.9), rgba(12, 23, 41, 0.88));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dashboard-grid {
  margin-top: 6px;
}

.view-container {
  position: relative;
  flex: 1;
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.view {
  width: 100%;
  min-height: 480px;
  flex: 1 1 auto;
}

.map-view {
  display: flex;
  min-height: clamp(540px, 68vh, 880px);
}

#map {
  width: 100%;
  height: clamp(560px, 70vh, 900px);
  min-height: 480px;
  flex: 1;
  background: #f5f5f5;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
}

.map-error {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 15px;
  padding: 16px;
  text-align: center;
  background: #f5f5f5;
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: 12px;
}

.map-overlay {
  position: absolute;
  z-index: 900;
  top: 18px;
  right: 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.greenspace-banner {
  min-width: 200px;
  padding: 10px 14px;
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.95), rgba(245, 158, 11, 0.9));
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 12px;
  color: #78350f;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.3);
  font-weight: 600;
  font-size: 13px;
}

.greenspace-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.greenspace-banner-icon {
  font-size: 16px;
  line-height: 1;
}

.greenspace-banner-text {
  line-height: 1.4;
}

.layer-switcher {
  min-width: 160px;
  padding: 10px 12px;
  background: var(--layer-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  color: var(--text-main);
  backdrop-filter: var(--blur);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.layer-switcher-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.layer-switcher-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.layer-switcher-row + .layer-switcher-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.layer-switcher-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #38bdf8;
  cursor: pointer;
}

.pill {
  background: var(--pill-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  backdrop-filter: var(--blur);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.pill.secondary {
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.04);
}

.pill.primary {
  background: var(--pill-highlight);
  color: #0b1220;
  border: none;
}

.pill-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(17, 30, 51, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  backdrop-filter: var(--blur);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.pill-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-button:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.pill-button.active {
  background: linear-gradient(135deg, #f9a8d4, #ec4899);
  color: #0f172a;
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(236, 72, 153, 0.35);
}

:root[data-theme="light"] {
  --bg-dark: #f4f6fb;
  --bg-dark-soft: #e8edf6;
  --bg-light: #f9fafb;
  --panel: rgba(255, 255, 255, 0.96);
  --accent: #16a34a;
  --accent-strong: #15803d;
  --accent-warm: #d97706;
  --text-main: #0f172a;
  --text-muted: #4b5563;
  --border: #d4dbe8;
  --border-strong: #9fb0c8;
  --glow: 0 16px 40px rgba(14, 165, 233, 0.14);
  --topbar-from: #ffffff;
  --topbar-to: #f8fafc;
  --sidebar-from: #ffffff;
  --sidebar-to: #f8fafc;
  --surface-soft: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.92));
  --nav-surface: linear-gradient(135deg, #ffffff, #f8fafc);
  --nav-surface-hover: linear-gradient(135deg, #eff6ff, #e2e8f0);
  --card-surface: linear-gradient(145deg, #ffffff, #f5f7fb);
  --content-surface: linear-gradient(145deg, #ffffff, #f2f5fc);
  --layer-surface: rgba(255, 255, 255, 0.98);
  --pill-surface: rgba(255, 255, 255, 0.92);
  --pill-highlight: linear-gradient(135deg, #bfdbfe, #7dd3fc);
  --color-scheme: light;
}

:root[data-theme="light"] body {
  background: radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.1), transparent 32%),
    radial-gradient(circle at 80% 0%, rgba(217, 119, 6, 0.08), transparent 36%),
    var(--bg-light);
}

:root[data-theme="light"] .topbar {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .theme-toggle-track {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.1);
  /* Neumorphic shadow for light mode */
  box-shadow: 
    inset 2px 2px 4px rgba(0, 0, 0, 0.05),
    inset -2px -2px 4px rgba(255, 255, 255, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.05);
}

:root[data-theme="light"] .theme-toggle:hover .theme-toggle-track {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.15);
}

:root[data-theme="light"] .theme-toggle-slider {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.1),
    -2px -2px 4px rgba(255, 255, 255, 0.9);
}

:root[data-theme="light"] .theme-toggle-active .theme-toggle-slider {
  background: rgba(30, 30, 40, 0.15);
  box-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.15),
    -2px -2px 4px rgba(255, 255, 255, 0.7);
}


:root[data-theme="light"] .back-button {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.9));
  border-color: rgba(15, 23, 42, 0.08);
  color: var(--text-main);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .back-button:hover {
  border-color: rgba(15, 23, 42, 0.14);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .sidebar {
  border-right: 1px solid var(--border);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.02);
}

:root[data-theme="light"] .sidebar-header {
  border-color: var(--border);
}

:root[data-theme="light"] .nav.panel {
  border-color: var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .nav-item {
  border-color: rgba(15, 23, 42, 0.06);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
}

:root[data-theme="light"] .nav-item:hover {
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .nav-item.active {
  background: linear-gradient(135deg, #dcfce7, #d1fae5);
  border-color: #bbf7d0;
  color: #0f172a;
  box-shadow: 0 12px 28px rgba(34, 197, 94, 0.16);
}

:root[data-theme="light"] .nav-item.active .nav-label-main {
  color: #14532d;
  font-weight: 700;
}

:root[data-theme="light"] .nav-item.active .nav-label-sub {
  color: #166534;
  font-weight: 600;
}

:root[data-theme="light"] .nav-item.active .nav-icon {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.3);
}

:root[data-theme="light"] .stat-card {
  border-color: var(--border);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .stat-card:hover {
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .stat-card.active {
  background: linear-gradient(135deg, #dcfce7, #d1fae5);
  border-color: #bbf7d0;
  box-shadow: 0 18px 36px rgba(34, 197, 94, 0.18);
}

:root[data-theme="light"] .stat-card.active .stat-label {
  color: #166534;
  font-weight: 700;
}

:root[data-theme="light"] .stat-card.active .stat-sub {
  color: #15803d;
  font-weight: 600;
}

:root[data-theme="light"] .stat-card.active .stat-value {
  color: #14532d;
  font-weight: 800;
}

:root[data-theme="light"] .stat-card.active .stat-chip {
  background: rgba(16, 185, 129, 0.2);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.3);
}

:root[data-theme="light"] .content {
  background: linear-gradient(145deg, #ffffff, #f2f5fc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

:root[data-theme="light"] .dashboard-strip {
  background: linear-gradient(135deg, #ffffff, #eef2ff);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  border-color: var(--border);
}

:root[data-theme="light"] .greenspace-banner {
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.95), rgba(245, 158, 11, 0.9));
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.25);
  color: #78350f;
}

:root[data-theme="light"] .layer-switcher {
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .layer-switcher-row + .layer-switcher-row {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .pill,
:root[data-theme="light"] .pill-group,
:root[data-theme="light"] .pill-button {
  border-color: rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .pill-button:hover {
  border-color: rgba(15, 23, 42, 0.14);
  color: var(--text-main);
}

:root[data-theme="light"] .map-placeholder {
  background: #e7eef9;
  border-color: var(--border);
}

.hidden {
  display: none !important;
}

/* Mobile optimizations */
@media (max-width: 960px) {
  /* Better touch targets - minimum 44x44px */
  .nav-item,
  .stat-card,
  .back-button,
  .theme-toggle,
  .menu-button {
    min-height: 44px;
    min-width: 44px;
  }

  /* Better spacing for touch */
  .nav-list {
    gap: 12px;
  }

  .nav-item {
    padding: 14px 16px;
  }

  .stat-card {
    padding: 16px;
  }

  /* Prevent text selection on buttons during touch */
  .nav-item,
  .stat-card,
  .back-button,
  .theme-toggle,
  .menu-button {
    -webkit-tap-highlight-color: rgba(45, 212, 191, 0.2);
    -webkit-touch-callout: none;
    user-select: none;
  }

  /* Better scrolling */
  .content,
  .sidebar,
  .stream-view,
  .waste-view,
  .hasici-view,
  .kriminalita-view {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Prevent zoom on double tap */
  .nav-item:active,
  .stat-card:active,
  .back-button:active {
    transform: scale(0.98);
  }

  /* Better sidebar on mobile */
  .sidebar {
    width: min(85vw, 320px);
    max-width: 320px;
  }

  /* Better map viewport */
  #map {
    min-height: 60vh;
    height: calc(100vh - 64px);
  }

  /* Dashboard cards - better mobile layout */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Better popup sizing on mobile - ALL popups, not just expanded */
  .leaflet-popup-content-wrapper {
    max-width: calc(100vw - 40px) !important;
    max-height: 75vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
  }
  
  /* Ensure Leaflet popup container allows scrolling */
  .leaflet-popup {
    max-height: 75vh !important;
  }
  
  /* Ensure popup tip doesn't interfere */
  .leaflet-popup-tip {
    z-index: 1001 !important;
  }

  .leaflet-popup-content {
    font-size: 14px;
    line-height: 1.5;
    max-height: none !important;
    overflow-y: visible !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Ensure popup content is scrollable on mobile */
  .leaflet-popup-content-wrapper .leaflet-popup-content {
    overflow-y: visible !important;
    padding-bottom: 20px !important;
  }

  /* Make forms in popups scrollable on mobile */
  .leaflet-popup-content .lamp-report-form {
    max-height: none !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding-bottom: 20px !important;
  }

  /* Ensure submit button is always visible at bottom */
  .leaflet-popup-content .lamp-report-form .popup-button[type="submit"],
  .leaflet-popup-content .lamp-report-form button[type="submit"] {
    flex-shrink: 0 !important;
    margin-top: auto !important;
    margin-bottom: 10px !important;
    position: sticky !important;
    bottom: 0 !important;
    background: linear-gradient(135deg, #f97316, #f59e0b) !important;
    z-index: 10 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2) !important;
  }
  
  /* Ensure wrapper itself is scrollable when expanded */
  .leaflet-popup-content-wrapper.popup-expanded {
    max-height: 75vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
  }
  
  /* Ensure popup content in expanded wrapper is scrollable */
  .leaflet-popup-content-wrapper.popup-expanded .leaflet-popup-content {
    overflow-y: visible !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    padding-bottom: 20px !important;
  }
  
  /* Force scrolling on ALL popups with forms on mobile */
  .leaflet-popup-content-wrapper:has(.lamp-report-form) {
    max-height: 75vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Ensure form fields have proper spacing on mobile */
  .leaflet-popup-content .lamp-report-form .popup-form-label {
    margin-bottom: 12px !important;
  }
  
  .leaflet-popup-content .lamp-report-form .popup-form-input,
  .leaflet-popup-content .lamp-report-form .popup-form-textarea {
    margin-bottom: 8px !important;
  }

  /* Better button spacing in popups */
  .popup-button {
    min-height: 44px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Prevent horizontal scroll */
  body {
    overflow-x: hidden;
  }

  /* Better topbar on mobile */
  .topbar {
    padding: 0 12px;
  }

  .topbar-left {
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
    align-items: flex-start;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    flex-shrink: 0;
  }
  
  .notice-banner {
    font-size: 9px;
    padding: 4px 8px;
    margin-left: 4px;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 200px);
    line-height: 1.3;
  }
  
  .notice-label {
    letter-spacing: 0.2px;
    word-wrap: break-word;
    word-break: break-word;
  }

  .back-button {
    padding: 8px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .back-label {
    display: none;
  }

  .back-icon {
    font-size: 20px;
  }

  /* Better stat cards on mobile */
  .stat-value {
    font-size: 28px;
  }

  /* Better chart on mobile */
  #levelChart {
    height: 240px;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .brand {
    max-width: 140px;
    font-size: 14px;
  }
  
  .notice-banner {
    font-size: 8px;
    padding: 3px 6px;
    max-width: calc(100vw - 180px);
    line-height: 1.2;
  }

  .topbar-actions {
    gap: 6px;
  }
  
  .status-indicator {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  .status-indicator .status-text {
    font-size: 11px;
  }
  
  .status-indicator .status-icon {
    font-size: 7px;
  }

  .theme-toggle {
    width: 64px;
    height: 32px;
    min-width: 64px;
    min-height: 32px;
    /* Ensure touch target is large enough */
    padding: 4px;
    margin: -4px;
  }
  
  .theme-toggle-track {
    width: 100%;
    height: 100%;
  }
  
  .theme-toggle-slider {
    width: 28px;
    height: 28px;
  }
  
  .theme-toggle-active .theme-toggle-slider {
    transform: translateX(32px);
  }
  
  .theme-toggle:active .theme-toggle-slider {
    transform: translateX(32px) scale(0.95);
  }
  
  .theme-toggle:not(.theme-toggle-active):active .theme-toggle-slider {
    transform: translateX(0) scale(0.95);
  }
  
  .theme-toggle-icon {
    font-size: 13px;
  }
  
  .theme-toggle-label {
    display: none;
  }
  
  /* Better touch feedback */
  .theme-toggle:active .theme-toggle-track {
    opacity: 0.8;
  }


  .stat-value {
    font-size: 24px;
  }

  #levelChart {
    height: 200px;
  }
}

/* Toast notification */
.toast-notification {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
  border-radius: 14px;
  border: 2px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(16, 185, 129, 0.2);
  min-width: 320px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast-notification.toast-show {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

.toast-notification.toast-hide {
  opacity: 0;
  transform: translateX(400px);
}

.toast-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 16px;
  font-weight: 800;
  color: #0b1220;
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.toast-message {
  font-size: 13px;
  color: #334155;
  line-height: 1.4;
  font-weight: 600;
}

.toast-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
}

.toast-close:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0b1220;
}

.toast-notification.toast-success {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.2), 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.toast-notification.toast-error {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 12px 32px rgba(239, 68, 68, 0.2), 0 0 0 1px rgba(239, 68, 68, 0.2);
}

/* Light theme for toast */
:root[data-theme="light"] .toast-notification {
  background: linear-gradient(145deg, #ffffff, #f8fafc);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(16, 185, 129, 0.25);
}

:root[data-theme="light"] .toast-notification.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.25), 0 0 0 1px rgba(16, 185, 129, 0.3);
}

/* Mobile toast */
@media (max-width: 960px) {
  .toast-notification {
    top: 70px;
    right: 12px;
    left: 12px;
    max-width: none;
    min-width: auto;
  }
  
  .toast-notification.toast-show {
    transform: translateY(0);
  }
  
  .toast-notification {
    transform: translateY(-100px);
  }
  
  .toast-notification.toast-hide {
    transform: translateY(-100px);
  }
}

