/* Remove Tooltip Arrows (White Flags) */
.leaflet-tooltip-left::before,
.leaflet-tooltip-right::before,
.leaflet-tooltip-top::before,
.leaflet-tooltip-bottom::before {
    display: none !important;
}

/* Global Styles */
body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Inter', sans-serif; /* Modern premium font */
    background-color: #e5e7eb; /* Fallback for loading */
}

#map {
    position: absolute;
    top: 60px; /* Header Height */
    bottom: 36px; /* Footer Height */
    width: 100%;
    z-index: 1;
}

/* Header Bar */
.floating-header {
    position: fixed;
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 60px;
    background: #ffffff !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.05);
    transition: none;
    box-sizing: border-box;
}

/* Flex container is already set in #top-header */

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
}

.header-logo {
    height: 38px;
    /* Fits nicely in 50px header */
    width: auto;
    display: block;
}

.header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    /* Prevent spill on very small screens */
}

.header-text h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.header-text .subtitle {
    font-size: 11px;
    color: #4b5563;
    margin-top: 1px;
    font-weight: 500;
    white-space: nowrap;
}

/* Mobile Tweak: Shrink text if needed */
@media only screen and (max-width: 400px) {
    .floating-header {
        top: 10px;
        padding: 6px 16px;
    }
    .header-logo {
        height: 28px;
    }
    .header-text h2 {
        font-size: 14px;
    }
}

/* Controls Container (Top Right - Dock style) */
.controls-container {
    position: absolute;
    top: 80px; /* Clear the 60px header with 20px gap */
    right: 20px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

/* Ensure boxes fill width or behave nicely */
.control-box {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    margin-bottom: 0; /* Use gap in container instead */
    pointer-events: auto;
    width: auto; /* Shrink to fit contents */
    max-width: 90vw;
    box-sizing: border-box;
}

/* Fix for "Black Box" focus outline on clicked regions */
path.leaflet-interactive:focus {
    outline: none;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 5px;
    position: relative;
    z-index: 9999 !important; /* Ensure search results drop over other controls */
}

.results-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 2px;
}

.result-item {
    padding: 8px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #eee;
    color: #333;
}

.result-item:hover {
    background-color: #f0f0f0;
}

.result-item:last-child {
    border-bottom: none;
}

#address-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    outline: none;
}

#address-input:focus {
    border-color: #007bff;
}

#search-btn {
    background-color: #2196F3;
    /* Blue default */
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

#search-btn:hover {
    background-color: #1976D2;
    /* Darker blue on hover */
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    padding: 8px;
}

/* Fix for Map tools container when stethoscope is removed */
.action-buttons button {
    flex: 1; /* Make them grow to fill space */
}

/* Toggle Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* ==========================================================================
   Hamburger Menu & Side Panel
   ========================================================================== */

.floating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 15px; /* Ensure space for the button */
}

.hamburger-btn {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.2);
    color: #333;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-right: 5px;
}

.hamburger-btn:hover {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.4);
}

.dark-mode .hamburger-btn {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

.dark-mode .hamburger-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.4);
    z-index: 10001; /* Above map and leaflet controls */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.side-menu {
    position: fixed;
    top: 0;
    right: -320px; /* Hidden off screen to the right */
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: #f8f9fa;
    z-index: 10002;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.side-menu.active {
    right: 0;
}

.dark-mode .side-menu {
    background: #1a1a1a;
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
}

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

.side-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.side-menu-user i {
    font-size: 24px;
    color: #666;
}

.dark-mode .side-menu-user {
    color: #f1f1f1;
}

.dark-mode .side-menu-user i {
    color: #aaa;
}

.close-menu-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    padding: 5px;
}

.dark-mode .close-menu-btn {
    color: #fff;
}

.side-menu-content {
    display: flex;
    flex-direction: column;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 25px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s;
    cursor: pointer;
}

.menu-item:hover {
    background: rgba(0,0,0,0.04);
}

.menu-item i {
    font-size: 18px;
    color: #555;
    width: 24px;
    text-align: center;
}

.dark-mode .menu-item {
    color: #e0e0e0;
}

.dark-mode .menu-item:hover {
    background: rgba(255,255,255,0.05);
}

.dark-mode .menu-item i {
    color: #aaa;
}

.menu-divider {
    height: 1px;
    background: rgba(0,0,0,0.06);
    margin: 10px 25px;
}

.dark-mode .menu-divider {
    background: rgba(255,255,255,0.1);
}

.toggle-item {
    justify-content: space-between;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* All tool buttons default to light theme */
.action-buttons button {
    background: transparent;
    color: #4b5563;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.action-buttons button:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #1f2937;
    transform: scale(1.05);
}

#measure-btn.active,
#nearest-btn.active,
#locate-btn.active,
#coverage-btn.active,
#ppm-btn.active,
#info-btn.active {
    background: #3b82f6 !important;
    /* Vibrant blue when active */
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transform: scale(1.05);
}

/* Info Panel */
.info-panel {
    position: relative;
    max-height: 200px;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

.close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #333;
}

#info-content h4 {
    margin: 0 0 5px 0;
    color: #333;
}

#info-content p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: #555;
}

/* Map Popups */
.leaflet-popup-content {
    font-size: 14px;
    line-height: 1.5;
}

.leaflet-popup-content b {
    color: #007bff;
}

/* Pinned Tooltip (Transparency) */
.pinned-tooltip {
    background-color: rgba(255, 255, 255, 0.9) !important;
    /* Semi-transparent background */
    border-color: rgba(200, 200, 200, 0.8) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-tooltip-left.pinned-tooltip::before {
    border-left-color: rgba(255, 255, 255, 0.9) !important;
}

.leaflet-tooltip-right.pinned-tooltip::before {
    border-right-color: rgba(255, 255, 255, 0.9) !important;
}

/* Custom Popup to mimic Tooltip */
.leaflet-popup.custom-popup .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.9);
    /* Transparent match */
    padding: 0;
    /* Remove default padding */
    border-radius: 6px;
    /* Match standard tooltip radius roughly */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.leaflet-popup.custom-popup .leaflet-popup-content {
    margin: 6px 10px;
    /* Re-add tooltip-like padding */
    width: auto !important;
    /* Allow shrink */
}

.leaflet-popup.custom-popup .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.9);
}

/* Station Labels */
.station-label {
    background: none;
    border: none;
    box-shadow: none;
    color: #333;
    font-weight: bold;
    font-size: 12px;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
}

/* Legend (Stacked in Controls) */
.legend-container {
    /* Removed absolute positioning */
    font-size: 12px;
    color: #333;
    max-width: 260px;
    max-height: calc(100vh - 240px);
    overflow-y: auto;
    padding: 8px 12px !important;
    /* width handled by .control-box parent rules */
}

.legend-title {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
}

/* Custom Layer Toggle - Simulated Radio Buttons */
.leaflet-control-layers-selector[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border: 1px solid #999;
    border-radius: 50%;
    /* Make round */
    margin: 3px;
    position: relative;
    vertical-align: middle;
    outline: none;
    cursor: pointer;
}

.leaflet-control-layers-selector[type="checkbox"]:checked {
    background: #007bff;
    border-color: #007bff;
}

.leaflet-control-layers-selector[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
}

.legend-color {
    width: 15px;
    height: 15px;
    display: inline-block;
    margin-right: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

#coverage-btn.active {
    background-color: #28a745;
}

/* Coordinate Display (Bottom Bar) */
.coords-box {
    position: fixed;
    bottom: 0;
    left: 0;
    transform: none;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.85); /* Dark Glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0;
    height: 36px;
    line-height: 36px;
    border-radius: 0;
    font-size: 13px;
    font-family: 'Inter', monospace;
    font-weight: 600;
    color: #f8fafc; /* White text */
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -4px 15px -3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    user-select: none;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
    transition: background 0.3s ease;
}

.coords-box:hover {
    background: rgba(15, 23, 42, 0.95);
    transform: none;
    box-shadow: 0 -4px 15px -3px rgba(0, 0, 0, 0.2);
}

/* Hide mobile-only buttons by default */
.mobile-only-btn {
    display: none !important;
}

/* Mobile Responsiveness */
@media only screen and (max-width: 600px) {
    /* Show mobile-only buttons */
    .mobile-only-btn {
        display: inline-flex !important;
    }


    /* Hide Legend on Mobile */
    .legend-container {
        display: none !important;
    }

    /* Controls: Align Bottom Right */
    .controls-container {
        top: auto;
        bottom: 60px;
        /* Sits cleanly above the attribution text when expanded */
        right: 10px;
        left: 10px;
        /* Constrain width */
        width: auto;
        flex-direction: column;
        /* Search at bottom, action buttons on top */
        align-items: flex-end;
        /* Right align everything */
        pointer-events: none;
        gap: 8px;
    }

    /* Action Buttons (Map Tools) */
    .control-box.action-buttons {
        pointer-events: auto;
        width: auto;
        /* Shrinks to fit content */
        margin: 0;
        padding: 5px 8px;
        /* Compact padding */
        display: flex;
        flex-direction: row;
        /* Horizontal */
        align-items: center;
        gap: 0;
        /* Let children handle gap */
        position: relative;
        z-index: 1 !important;
    }

    .action-buttons>div:first-child {
        /* Hide "MAP TOOLS" label on mobile to save space */
        display: none;
    }

    /* Removed Leaflet Attribution logic */

    /* Search Results pop UPWARDS on mobile */
    .results-list {
        top: auto !important;
        bottom: 100% !important;
        margin-top: 0 !important;
        margin-bottom: 4px !important;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2) !important;
    }



    /* Search Box: Align Right, Matches Tools Width/Edge */
    .control-box.search-box {
        pointer-events: auto;
        width: 100%;
        /* Full width of container (controlled by left/right on container) */
        max-width: 280px;
        /* Cap width matches general feel */
        margin: 0;
        box-sizing: border-box;
    }

    /* Suggestions Pop UP above search bar */
    .results-list {
        top: auto;
        bottom: 100%;
        margin-bottom: 5px;
        max-height: 40vh;
    }

    /* Custom Layer Toggle - REMOVED */

    /* Layout: Top Left Standard */
    .leaflet-top.leaflet-left {
        display: block;
        /* Revert flex */
    }

    .leaflet-top.leaflet-left .leaflet-control {
        margin-top: 10px !important;
        margin-left: 10px !important;
    }

    
    /* Fix Leaflet Attribution overflow on mobile */
    .leaflet-control-attribution {
        max-width: 250px;
        white-space: normal;
        font-size: 9px !important;
        line-height: 1.2;
    }

    /* Header Logic */
    #top-header {
        height: auto;
        min-height: 50px;
        padding: 5px 0;
    }

    .header-content {
        flex-wrap: wrap;
        /* Allow wrapping */
        justify-content: center;
        text-align: center;
    }

    .header-logo {
        height: 30px;
        /* Smaller logo */
    }

    .header-text h2 {
        font-size: 14px;
        white-space: normal;
        /* Allow text wrap */
        line-height: 1.2;
    }

    .header-text .subtitle {
        display: none;
        /* Hide subtitle on very small screens to save vertical space */
    }

    .leaflet-control-layers {
        margin-top: 10px !important;
        z-index: 2000 !important;
    }

    .leaflet-top {
        z-index: 2000 !important;
    }
}

/* MAP TOOLS Heading & Larger Icons on Mobile */
@media (max-width: 600px) {
    .action-buttons button {
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }

    .action-buttons div[style*="font-weight: bold"] {
        display: none !important;
        /* Hide "Map Tools" heading on mobile */
    }
}


/* Move all top-left controls down below the fixed header (if needed, but map starts at 50px) */
/* The map container #map starts at 50px. Leaflet controls are relative to #map. */
/* So top: 0 in leaflet-top is actually 50px down from window top. */
/* User mentioned "gap above address bar". If they mean browser address bar, we can't fix that. */
/* If they mean "gap between header and map controls", we should reduce margin-top of controls. */

/* Force Horizontal Layout for Top Left Controls (Basemap + Toggle) */
/* Vertical Layout for Top Left Controls */
.leaflet-top.leaflet-left {
    display: flex;
    flex-direction: column;
    /* Stack vertically (Toggle Top, Basemap Bottom) */
    align-items: flex-start;
    gap: 10px;
    margin-top: 10px;
    margin-left: 10px;
}

/* Reset default Leaflet control margins to prevent double spacing */
.leaflet-top.leaflet-left .leaflet-control {
    margin: 0 !important;
}

/* Mobile: Increase top margin, reduce gap between controls */
@media (max-width: 600px) {
    .leaflet-top.leaflet-left {
        margin-top: 20px;
        /* More space from top on mobile */
        gap: 5px;
        /* Smaller gap between Toggle and Basemap */
    }
}

/* Hide Info Button on Desktop */
/* Info button now visible on desktop too */
/* @media (min-width: 601px) {
    #info-btn {
        display: none !important;
    }
} */

/* Mobile Info Modal */
.info-modal-backdrop {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Black w/ opacity */
    justify-content: center;
    align-items: center;
}

.info-modal-content {
    background-color: #fefefe;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 400px;
    border-radius: 8px;
    position: relative;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 5px;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Tool Instruction Box (Cursor Follower) */
.tool-instruction {
    position: absolute;
    background: white;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    /* Let clicks pass through */
    z-index: 5000;
    white-space: nowrap;
    transform: translate(15px, 15px);
    /* Offset from cursor */
}

/* Distance Label (Halo Text) */
.distance-label-halo {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 13px;
    font-weight: bold;
    color: #000;
    /* Stronger Halo */
    text-shadow:
        -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 2px 2px 0 #fff,
        -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff,
        0px 0px 4px rgba(255, 255, 255, 1);
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-align: center;
}

/* User Location Marker (Pulse Effect) */
.user-location-dot {
    width: 16px;
    height: 16px;
    background-color: #2196F3;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(33, 150, 243, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
    }
}

.layer-toggle-control {
    background: rgba(255, 255, 255, 0.85); /* White Glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 44px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    overflow: hidden;
    /* margin removed, handled by flex container gap */
    border: 1px solid rgba(255, 255, 255, 0.4);
    font-size: 13px;
    font-weight: 500;
}

.layer-toggle-btn {
    padding: 6px 12px;
    cursor: pointer;
    background: transparent;
    color: #333;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: background 0.2s, color 0.2s;
}

.layer-toggle-btn:last-child {
    border-right: none;
}

.layer-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.layer-toggle-btn.active {
    background: #007bff;
    color: white;
}

/* Weather Widget Overlay */
.weather-overlay-control {
    background: rgba(15, 23, 42, 0.75); /* Dark Glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', sans-serif;
    color: #f8fafc; /* White text */
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto;
    margin-bottom: 20px !important;
    margin-left: 20px !important; 
    width: 320px;
    box-sizing: border-box;
    z-index: 1500;
}

.weather-header {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
    color: #f8fafc;
}

.weather-days-container {
    display: flex;
    justify-content: space-between;
}

.weather-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 45px;
}

.weather-day-name {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: #cbd5e1; /* Lighter gray text */
    margin-bottom: 4px;
}

.weather-icon {
    font-size: 18px;
    margin-bottom: 4px;
    color: #e2e8f0;
}

.weather-temp {
    font-size: 12px;
    font-weight: bold;
    display: flex;
    gap: 3px;
}

.weather-temp-max {
    color: #e74c3c;
}

.weather-temp-min {
    color: #3498db;
    font-weight: normal;
}

.weather-wind {
    font-size: 10px;
    color: #888;
    margin-top: 3px;
    white-space: nowrap;
}

/* Mobile Tweak for Weather Widget */
@media only screen and (max-width: 600px) {
    .weather-overlay-control {
        position: fixed !important;
        top: 125px !important; /* Align with basemap layer toggle */
        right: 10px !important;
        left: auto !important; /* Override Leaflet left positioning */
        bottom: auto !important; /* Override Leaflet bottom positioning */
        margin: 0 !important; /* Remove the desktop margins */
        width: 275px !important; /* Reduced width to bring days closer together */
        max-width: calc(100vw - 20px); /* Keep it within screen bounds */
        padding: 6px 8px !important; /* Reduced padding */
    }
    .weather-header {
        font-size: 11px;
        margin-bottom: 6px;
    }
    .weather-day {
        min-width: 40px; /* Reduced spacing */
    }
    .weather-day-name {
        font-size: 9px;
        margin-bottom: 2px;
    }
    .weather-icon {
        font-size: 14px;
        margin-bottom: 2px;
    }
    .weather-temp {
        font-size: 10px;
    }
    .weather-wind {
        font-size: 8px;
        margin-top: 1px;
    }
    .weather-attribution {
        font-size: 8px;
        margin-top: 2px;
    }
}

/* --- Diagnostics Modal --- */
.diagnostics-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: calc(100% - 40px);
    background: rgba(15, 23, 42, 0.85); /* Dark Glass */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 5000;
    color: #f8fafc;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

#mobile-ports-content {
    background: #ffffff;
    color: #333;
    border-radius: 8px;
}

.diagnostics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.diagnostics-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.diagnostics-header .close-btn {
    position: static;
    color: #94a3b8;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
}

.diagnostics-header .close-btn:hover {
    color: #f8fafc;
}

.diagnostics-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.diagnostics-subtitle {
    color: #94a3b8;
    margin: 0 0 16px 0;
    font-size: 14px;
}

.diagnostics-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#diag-username {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

#diag-username:focus {
    border-color: #3b82f6;
}

#diag-submit-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#diag-submit-btn:hover {
    background: #2563eb;
}

.diag-result-card {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
    padding: 16px;
    border-left: 5px solid #64748b;
    margin-bottom: 20px;
}

.diag-status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.diag-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #64748b;
    box-shadow: 0 0 8px #64748b;
}

.diag-status-title {
    font-size: 16px;
    font-weight: 600;
}

.diag-status-detail {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.diag-troubleshooting {
}

.diag-troubleshooting h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #f8fafc;
}

.wizard-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    text-align: left;
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wizard-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.wizard-btn i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    opacity: 0.8;
}

.wizard-btn.external-link {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.wizard-btn.external-link:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
    border-color: rgba(59, 130, 246, 0.3);
}

.wizard-btn.external-link i {
    color: #60a5fa;
}

.wiz-advice-box {
    margin-top: 12px;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 0 4px 4px 0;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

/* Mobile Responsiveness for Diagnostics Modal */
@media only screen and (max-width: 600px) {
    .diagnostics-modal {
        width: 95%;
        max-height: calc(100% - 20px);
    }
    .diagnostics-content {
        overflow-y: auto;
        padding: 15px;
        flex: 1;
        min-height: 0;
    }
}

.hillshade-overlay {
    mix-blend-mode: multiply;
    opacity: 0.65;
}

.dark-basemap .hillshade-overlay {
    mix-blend-mode: soft-light;
    opacity: 1.0;
}


/* Hourly Weather Modal Styles */
.hourly-weather-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 5px; border-bottom: 1px solid #eee; font-size: 13px; }
.hourly-weather-row:last-child { border-bottom: none; }
.hourly-time { width: 45px; font-weight: bold; color: #f1f5f9; }
.hourly-icon { width: 30px; text-align: center; font-size: 16px; color: #f1f5f9; }
.hourly-temp { width: 40px; text-align: right; font-weight: bold; }
.hourly-pop { width: 50px; text-align: right; color: #3b82f6; font-size: 12px; }
.hourly-wind { width: 55px; text-align: right; color: #9ca3af; font-size: 12px; }

/* Colored Weather Icons */
.fa-sun { color: #f59e0b !important; }
.fa-cloud-sun { 
    background: linear-gradient(135deg, #f59e0b 45%, #9ca3af 45%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}
.fa-cloud, .fa-smog { color: #9ca3af !important; }
.fa-cloud-rain { color: #3b82f6 !important; }
.fa-cloud-showers-heavy { color: #2563eb !important; }
.fa-snowflake { color: #06b6d4 !important; }
.fa-bolt { color: #eab308 !important; }

/* =========================================================
   SPACE WEATHER WARNING STYLES (NEW LEAFLET STYLE)
   ========================================================= */

.space-weather-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    clear: both; /* Leaflet requirement for controls */
}

/* Fix for Leaflet layers control opening behind space weather */
.leaflet-control-layers {
    z-index: 10000 !important;
}

.sw-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
}

.sw-icon-btn {
    width: 36px;
    height: 36px;
    background-color: #fff;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 5px rgba(0,0,0,0.65);
    transition: background-color 0.2s, color 0.2s;
    font-size: 16px;
    box-sizing: border-box; /* Revert to standard button sizing */
}

.sw-icon-btn:hover {
    background-color: #f4f4f4;
}

/* Status Colors (Text Only, Keep Border Default) */
.sw-icon-btn.status-normal {
    color: #22c55e;
}
.status-normal-text { color: #22c55e; }

.sw-icon-btn.status-elevated {
    color: #eab308;
}
.status-elevated-text { color: #eab308; }

.sw-icon-btn.status-high {
    color: #ef4444;
}
.status-high-text { color: #ef4444; }

.sw-icon-btn.status-high-iono {
    color: #f59e0b;
}
.status-high-iono-text { color: #f59e0b; }

.sw-card {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: #f8fafc;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: 250px;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 6px;
    position: absolute;
    left: 54px; /* 44px button + 10px gap */
    top: 0;
    animation: fadeInRight 0.3s ease forwards;
}

.sw-card.active {
    display: flex;
}

.sw-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}

.sw-desc {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.3;
    margin: 0 0 6px 0;
}

.sw-link-btn {
    background: #3b82f6;
    color: #ffffff !important;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
}

.sw-link-btn:hover {
    background: #2563eb;
    color: #ffffff !important;
}

/* =========================================================
   PWA INSTALL BANNER
   ========================================================= */

.pwa-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10000;
    font-family: 'Inter', sans-serif;
    transition: bottom 0.3s ease, opacity 0.3s ease;
}

.pwa-banner.hidden {
    bottom: -100px;
    opacity: 0;
    pointer-events: none;
}

.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.pwa-text {
    display: flex;
    flex-direction: column;
}

.pwa-text strong {
    font-size: 14px;
    color: #333;
}

.pwa-text span {
    font-size: 12px;
    color: #666;
}

.pwa-btn {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    margin-left: 10px;
}

.pwa-close {
    background: transparent;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
}

.dark-mode .pwa-text strong { color: #fff; }
.dark-mode .pwa-text span { color: #cbd5e1; }

/* =========================================================
   NOTIFICATIONS FEED & CRITICAL POPUP
   ========================================================= */

.notif-badge {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.notif-badge.hidden {
    display: none;
}

.notifications-feed {
    padding: 0;
    overflow-y: auto;
    height: calc(100vh - 60px);
}

.notif-card {
    padding: 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.notif-card:hover {
    background: #f8fafc;
}

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

.notif-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    color: white;
}

.notif-tag.network-alert { background: #ef4444; }
.notif-tag.maintenance { background: #f59e0b; }
.notif-tag.news { background: #3b82f6; }

.notif-time {
    font-size: 12px;
    color: #94a3b8;
}

.notif-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.notif-body {
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-card.expanded .notif-body {
    -webkit-line-clamp: initial;
}

/* Critical Popup */
.critical-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 10001;
    overflow: hidden;
    animation: slideDown 0.3s ease-out forwards;
}

.critical-popup.hidden {
    display: none;
}

.critical-popup-header {
    background: #ef4444;
    color: white;
    padding: 10px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-critical-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

.critical-popup-body {
    padding: 15px;
}

.critical-popup-body h4 {
    margin: 0 0 5px 0;
    color: #1e293b;
    font-size: 15px;
}

.critical-popup-body p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.4;
}

.critical-read-more {
    width: 100%;
    padding: 10px;
    background: #f8fafc;
    border: none;
    border-top: 1px solid #eee;
    color: #3b82f6;
    font-weight: 600;
    cursor: pointer;
}

.critical-read-more:hover {
    background: #f1f5f9;
}

@keyframes slideDown {
    from { top: -100px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

.dark-mode .notif-card { border-color: rgba(255,255,255,0.1); }
.dark-mode .notif-card:hover { background: #334155; }
.dark-mode .notif-title { color: #f8fafc; }
.dark-mode .notif-body { color: #94a3b8; }
.dark-mode .critical-popup { background: #1e293b; border: 1px solid rgba(255,255,255,0.1); }
.dark-mode .critical-popup-body h4 { color: #f8fafc; }
.dark-mode .critical-popup-body p { color: #cbd5e1; }
.dark-mode .critical-read-more { background: #0f172a; border-color: rgba(255,255,255,0.1); }

