/* ========================================================
   PSTWQGIS - Environmental GIS & Spatial Analytics Platform
   Main Application Stylesheet (Bootstrap 5 Integrated)
   ======================================================== */

/* Prevent Bootstrap from breaking Leaflet tile layers */
.leaflet-container img {
    max-width: none !important;
}

/* Form check input styling for GIS layers */
.accordion-item-row.form-check {
    min-height: 28px;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

.accordion-item-row .form-check-input {
    float: none !important;
    margin-left: 0 !important;
    margin-top: 0 !important;
    cursor: pointer;
}

.accordion-item-row .form-check-label {
    cursor: pointer;
    margin-bottom: 0;
}


        :root {

            --bg-nav: rgba(11, 15, 25, 0.94);

            --bg-glass: rgba(15, 23, 42, 0.92);

            --bg-card: rgba(30, 41, 59, 0.75);

            --border-glass: rgba(255, 255, 255, 0.12);

            --primary: #38bdf8;

            --primary-hover: #0ea5e9;

            --qgis-blue: #2b7ac7;

            --qgis-blue-hover: #1d68b0;

            --river-cyan: #00d2ff;

            --fire-red: #ef4444;

            --accent-green: #34d399;

            --accent-amber: #f59e0b;

            --accent-orange: #f97316;

            --accent-purple: #a855f7;

            --text-main: #f8fafc;

            --text-muted: #94a3b8;

        }



        * { box-sizing: border-box; }

        body, html { margin: 0; padding: 0; height: 100%; width: 100%; font-family: 'Inter', sans-serif; background: #0b0f19; overflow: hidden; }

        #map { height: 100vh; width: 100vw; z-index: 1; }



        /* ========================================================

           1. FULL-WIDTH TOP NAVIGATION BAR

           ======================================================== */

        .top-navbar {

            position: absolute;

            top: 0; left: 0; right: 0; height: 54px;

            z-index: 1100;

            background: var(--bg-nav);

            backdrop-filter: blur(18px);

            -webkit-backdrop-filter: blur(18px);

            border-bottom: 1px solid var(--border-glass);

            display: flex; align-items: center; justify-content: space-between;

            padding: 0 16px;

            box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);

        }



        .brand-section { display: flex; align-items: center; gap: 12px; }

        .brand-logo-badge {

            width: 32px; height: 32px; border-radius: 8px;

            background: linear-gradient(135deg, #0284c7 0%, #6366f1 100%);

            display: flex; align-items: center; justify-content: center;

            box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);

        }



        .brand-title-wrap { display: flex; flex-direction: column; }

        .brand-title {

            font-size: 14px; font-weight: 800; letter-spacing: -0.02em;

            background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);

            -webkit-background-clip: text; -webkit-text-fill-color: transparent;

            line-height: 1.2;

        }



        .brand-sub { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }

        .pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px #22c55e; }



        .nav-tools-group { display: flex; align-items: center; gap: 8px; }

        .nav-tool-btn {

            background: rgba(255, 255, 255, 0.06);

            border: 1px solid var(--border-glass);

            color: var(--text-main);

            height: 32px; padding: 0 10px; border-radius: 6px;

            font-size: 11.5px; font-weight: 600; cursor: pointer;

            display: flex; align-items: center; gap: 6px;

            transition: all 0.15s ease;

        }

        .nav-tool-btn:hover { background: rgba(56, 189, 248, 0.18); border-color: var(--primary); }

        .nav-tool-btn.active {

            background: #0284c7; color: #ffffff;

            border-color: #38bdf8;

            box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);

        }



        /* ========================================================

           2. GIS QUICK ACTION TOOLBAR (MATCHING USER SCREENSHOT)

           ======================================================== */

        .gis-action-toolbar {

            position: absolute;

            top: 66px;

            left: 16px;

            z-index: 1050;

            display: flex;

            align-items: center;

            background: #2b7ac7;

            border-radius: 6px;

            padding: 3px;

            gap: 3px;

            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);

            border: 1px solid rgba(255, 255, 255, 0.25);

        }



        .gis-tool-icon-btn {

            width: 30px;

            height: 30px;

            background: #2b7ac7;

            border: 1px solid transparent;

            border-radius: 4px;

            display: flex;

            align-items: center;

            justify-content: center;

            color: #ffffff;

            cursor: pointer;

            transition: all 0.15s ease;

            position: relative;

        }



        .gis-tool-icon-btn:hover {

            background: #1d68b0;

            border-color: rgba(255, 255, 255, 0.4);

            transform: translateY(-1px);

        }



        .gis-tool-icon-btn.active {

            background: #ffffff;

            color: #2b7ac7;

            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);

        }



        /* Clear button on the left with eraser emblem */

        .gis-eraser-btn {

            background: #1e62a3;

            border-color: rgba(255, 255, 255, 0.3);

        }



        /* ========================================================

           3. FLOATING "LAYER" DIALOG (EXACT MATCH TO ATTACHED SCREENSHOT)

           ======================================================== */

        .layer-modal-dialog {

            position: absolute;

            top: 108px;

            left: 16px;

            width: 350px;

            max-width: calc(100vw - 32px);

            max-height: calc(100vh - 160px);

            background: #ffffff;

            border-radius: 8px;

            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

            border: 1px solid rgba(0, 0, 0, 0.12);

            z-index: 1060;

            display: flex;

            flex-direction: column;

            overflow: hidden;

            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

            animation: fadeInDialog 0.18s ease;

        }



        @keyframes fadeInDialog {

            from { opacity: 0; transform: translateY(-8px); }

            to { opacity: 1; transform: translateY(0); }

        }



        .layer-dialog-header {

            display: flex;

            justify-content: space-between;

            align-items: center;

            padding: 10px 14px;

            border-bottom: 1px solid #e2e8f0;

            background: #ffffff;

            position: sticky;

            top: 0;

            z-index: 20;

            flex-shrink: 0;

        }



        .layer-dialog-title {

            font-size: 14.5px;

            font-weight: 700;

            color: #0f172a;

        }



        .layer-dialog-close {

            background: transparent;

            border: none;

            font-size: 18px;

            color: #64748b;

            cursor: pointer;

            padding: 0 4px;

            line-height: 1;

        }

        .layer-dialog-close:hover { color: #0f172a; }



        .layer-hdr-action-btn {

            background: rgba(2, 132, 199, 0.08);

            color: #0284c7;

            border: 1px solid rgba(2, 132, 199, 0.3);

            border-radius: 4px;

            padding: 2px 7px;

            font-size: 10.5px;

            font-weight: 600;

            cursor: pointer;

            transition: all 0.15s ease;

        }

        .layer-hdr-action-btn:hover {

            background: #0284c7;

            color: #ffffff;

        }



        /* Dialog Top Tabs */

        .layer-tabs-bar {

            display: flex;

            border-bottom: 2px solid #e2e8f0;

            background: #f8fafc;

            position: sticky;

            top: 41px;

            z-index: 19;

            flex-shrink: 0;

        }



        .layer-tab-btn {

            flex: 1;

            padding: 9px 12px;

            text-align: center;

            font-size: 12px;

            font-weight: 600;

            color: #64748b;

            cursor: pointer;

            border: none;

            background: transparent;

            border-bottom: 2px solid transparent;

            margin-bottom: -2px;

            transition: all 0.15s ease;

        }



        .layer-tab-btn.active {

            color: #0284c7;

            font-weight: 700;

            border-bottom-color: #0284c7;

            background: #ffffff;

        }



        .layer-dialog-body, #tab-pane-basemaps, #tab-pane-env {

            padding: 10px 12px;

            overflow-y: auto !important;

            overflow-x: hidden !important;

            display: flex;

            flex-direction: column;

            gap: 8px;

            flex: 1 1 auto;

            min-height: 0;

            max-height: calc(100vh - 240px);

            scrollbar-width: thin !important;

            scrollbar-color: #94a3b8 #f1f5f9 !important;

            scrollbar-gutter: stable;

        }



                /* High-Contrast Visible Blue Scrollbars */

        ::-webkit-scrollbar,

        .layer-modal-dialog::-webkit-scrollbar,

        #layer-modal-dialog::-webkit-scrollbar,

        .layer-dialog-body::-webkit-scrollbar,

        #tab-pane-basemaps::-webkit-scrollbar,

        #tab-pane-env::-webkit-scrollbar,

        .basemap-modal-body::-webkit-scrollbar,

        #buffer-modal-dialog::-webkit-scrollbar,

        #basemap-modal-dialog::-webkit-scrollbar,

        #measure-modal-dialog::-webkit-scrollbar {

            width: 10px !important;

            height: 10px !important;

            display: block !important;

        }



        ::-webkit-scrollbar-track,

        .layer-modal-dialog::-webkit-scrollbar-track,

        #layer-modal-dialog::-webkit-scrollbar-track,

        .layer-dialog-body::-webkit-scrollbar-track,

        #tab-pane-basemaps::-webkit-scrollbar-track,

        #tab-pane-env::-webkit-scrollbar-track,

        .basemap-modal-body::-webkit-scrollbar-track,

        #buffer-modal-dialog::-webkit-scrollbar-track,

        #basemap-modal-dialog::-webkit-scrollbar-track,

        #measure-modal-dialog::-webkit-scrollbar-track {

            background: #e2e8f0 !important;

            border-radius: 5px !important;

            border: 1px solid #cbd5e1 !important;

        }



        ::-webkit-scrollbar-thumb,

        .layer-modal-dialog::-webkit-scrollbar-thumb,

        #layer-modal-dialog::-webkit-scrollbar-thumb,

        .layer-dialog-body::-webkit-scrollbar-thumb,

        #tab-pane-basemaps::-webkit-scrollbar-thumb,

        #tab-pane-env::-webkit-scrollbar-thumb,

        .basemap-modal-body::-webkit-scrollbar-thumb,

        #buffer-modal-dialog::-webkit-scrollbar-thumb,

        #basemap-modal-dialog::-webkit-scrollbar-thumb,

        #measure-modal-dialog::-webkit-scrollbar-thumb {

            background: #0284c7 !important;

            border-radius: 5px !important;

            border: 2px solid #e2e8f0 !important;

        }



        ::-webkit-scrollbar-thumb:hover,

        .layer-modal-dialog::-webkit-scrollbar-thumb:hover,

        #layer-modal-dialog::-webkit-scrollbar-thumb:hover,

        .layer-dialog-body::-webkit-scrollbar-thumb:hover,

        #tab-pane-basemaps::-webkit-scrollbar-thumb:hover,

        #tab-pane-env::-webkit-scrollbar-thumb:hover,

        .basemap-modal-body::-webkit-scrollbar-thumb:hover,

        #buffer-modal-dialog::-webkit-scrollbar-thumb:hover,

        #basemap-modal-dialog::-webkit-scrollbar-thumb:hover,

        #measure-modal-dialog::-webkit-scrollbar-thumb:hover {

            background: #0369a1 !important;

        }.basemap-modal-body::-webkit-scrollbar {

            width: 8px !important;

            display: block !important;

        }



        .basemap-modal-body::-webkit-scrollbar-track {

            background: #f1f5f9 !important;

            border-radius: 4px;

        }



        .basemap-modal-body::-webkit-scrollbar-thumb {

            background: #0284c7 !important;

            border-radius: 4px;

            border: 1px solid #e2e8f0;

        }



        .basemap-modal-body::-webkit-scrollbar-thumb:hover {

            background: #0369a1 !important;

        }



        .basemap-grid {

            display: grid;

            grid-template-columns: repeat(2, 1fr);

            gap: 20px 14px;

            justify-items: center;

        }



        .basemap-card-item {

            display: flex;

            flex-direction: column;

            align-items: center;

            cursor: pointer;

            user-select: none;

            text-align: center;

            gap: 8px;

            width: 100%;

            transition: transform 0.15s ease;

        }



        .basemap-circle-thumb {

            width: 76px;

            height: 76px;

            border-radius: 50%;

            background-size: cover;

            background-position: center;

            background-repeat: no-repeat;

            border: 2px solid #cbd5e1;

            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);

            transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

        }



        .basemap-card-item:hover .basemap-circle-thumb {

            transform: scale(1.06);

            border-color: #0284c7;

            box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);

        }



        .basemap-card-item.active .basemap-circle-thumb {

            border: 3px solid #0284c7;

            box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25), 0 6px 16px rgba(2, 132, 199, 0.45);

        }



        .basemap-label-text {

            font-size: 11.5px;

            color: #334155;

            font-weight: 500;

            line-height: 1.25;

            max-width: 110px;

        }



        .basemap-card-item.active .basemap-label-text {

            font-weight: 800;

            color: #0f172a;

        }



        /* ArcGIS Hierarchy Tree & Card Box Styling */

        .layer-card-box {

            border: 1px solid #e2e8f0;

            border-radius: 6px;

            padding: 6px 8px;

            display: flex;

            flex-direction: column;

            gap: 4px;

            background: #f8fafc;

            margin-bottom: 2px;

        }

        .accordion-section {

            border: 1px solid #cbd5e1;

            border-radius: 6px;

            overflow: hidden;

            background: #ffffff;

            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);

            margin-bottom: 2px;

        }

        .accordion-header {

            background: #2b7ac7;

            color: #ffffff;

            padding: 7px 10px;

            font-size: 12px;

            font-weight: 700;

            display: flex;

            align-items: center;

            gap: 8px;

            cursor: pointer;

            user-select: none;

            transition: background 0.15s ease;

        }

        .accordion-header:hover {

            background: #1d65b0;

        }

        .accordion-header .header-icon {

            font-size: 10px;

            display: inline-flex;

            align-items: center;

            justify-content: center;

            width: 14px;

            height: 14px;

            transition: transform 0.15s ease;

            flex-shrink: 0;

        }

        .accordion-content {

            display: flex;

            flex-direction: column;

            gap: 2px;

            padding: 6px 8px;

            background: #ffffff;

        }

        /* Checkbox & Layer Item Row */

        .accordion-item-row {

            display: flex;

            align-items: center;

            gap: 8px;

            padding: 5px 8px;

            border-radius: 4px;

            cursor: pointer;

            user-select: none;

            font-size: 12px;

            color: #1e293b;

            line-height: 1.35;

            transition: background 0.12s ease;

            margin: 0;

            width: 100%;

            box-sizing: border-box;

            min-height: 28px;

        }

        .accordion-item-row:hover {

            background: #f1f5f9;

        }

        .accordion-item-row input[type="checkbox"] {

            cursor: pointer;

            margin: 0;

            width: 15px;

            height: 15px;

            accent-color: #0284c7;

            flex-shrink: 0;

        }

        /* Swatches and icons between checkbox and label */

        .accordion-item-row > span {

            display: inline-flex;

            align-items: center;

            flex-shrink: 0;

        }

        /* The label text is the last span */

        .accordion-item-row > span:last-child {

            flex: 1 1 auto;

            min-width: 0;

            font-weight: 500;

            word-break: break-word;

        }

        /* Hierarchy Tree Styling */

        .tree-container {

            display: flex;

            flex-direction: column;

            position: relative;

            width: 100%;

        }

        .tree-parent-row {

            display: flex;

            align-items: center;

            gap: 4px;

            padding: 0;

            width: 100%;

        }

        .tree-parent-row .accordion-item-row {

            flex: 1;

        }

        .tree-toggle-arrow {

            color: #64748b;

            font-size: 11px;

            cursor: pointer;

            user-select: none;

            width: 18px;

            height: 18px;

            display: inline-flex;

            align-items: center;

            justify-content: center;

            border-radius: 3px;

            flex-shrink: 0;

            transition: background 0.12s ease, color 0.12s ease;

        }

        .tree-toggle-arrow:hover {

            background: #e2e8f0;

            color: #0284c7;

        }

        .tree-branch {

            position: relative;

            margin-left: 12px;

            padding-left: 14px;

            display: flex;

            flex-direction: column;

            gap: 2px;

            margin-top: 2px;

            margin-bottom: 4px;

            border-left: 1.5px solid #cbd5e1;

        }

        .tree-leaf {

            position: relative;

            padding-left: 6px;

        }

        .tree-leaf::before {

            content: '';

            position: absolute;

            left: -14px;

            top: 50%;

            width: 12px;

            height: 1px;

            border-top: 1.5px solid #cbd5e1;

            transform: translateY(-50%);

        }



        /* Buffer Modal & Tools Styling */

        .buffer-draw-tool-btn {

            width: 32px;

            height: 32px;

            background: #ffffff;

            border: 1px solid #cbd5e1;

            border-radius: 4px;

            color: #0f172a;

            display: flex;

            align-items: center;

            justify-content: center;

            cursor: pointer;

            transition: all 0.15s ease;

            padding: 0;

            user-select: none;

        }

        .buffer-draw-tool-btn:hover {

            border-color: #0284c7;

            background: #f0f9ff;

            color: #0284c7;

        }

        .buffer-draw-tool-btn.active {

            background: #0284c7 !important;

            border-color: #0284c7 !important;

            color: #ffffff !important;

            box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);

        }

        .buffer-layer-item {

            display: flex;

            justify-content: space-between;

            align-items: center;

            padding: 6px 10px;

            border-radius: 4px;

            font-size: 12px;

            color: #0f172a;

            cursor: pointer;

            border-left: 3px solid transparent;

            transition: all 0.15s ease;

        }

        .buffer-layer-item:hover {

            background: #f1f5f9;

        }

        .buffer-layer-item.selected {

            background: #f0f9ff;

            border-left-color: #0284c7;

            font-weight: 600;

        }

        .buffer-feature-count-badge {

            font-size: 11px;

            color: #10b981;

            font-weight: 600;

        }



        /* Marker Badges */

        .hospital-badge-marker {

            width: 22px;

            height: 22px;

            background: #0284c7;

            border: 2px solid #ffffff;

            border-radius: 5px;

            box-shadow: 0 2px 6px rgba(0,0,0,0.4);

            display: flex;

            align-items: center;

            justify-content: center;

            font-weight: 900;

            color: #ffffff;

            font-size: 12px;

            font-family: sans-serif;

            cursor: pointer;

            transition: transform 0.15s ease;

        }

        .hospital-badge-marker:hover {

            transform: scale(1.3);

            box-shadow: 0 4px 12px rgba(2, 132, 199, 0.6);

        }



        .clinic-badge-marker {

            width: 20px;

            height: 20px;

            background: #10b981;

            border: 1.5px solid #ffffff;

            border-radius: 4px;

            box-shadow: 0 2px 5px rgba(0,0,0,0.3);

            display: flex;

            align-items: center;

            justify-content: center;

            color: #ffffff;

            font-size: 11px;

            cursor: pointer;

            transition: transform 0.15s;

        }

        .clinic-badge-marker:hover { transform: scale(1.3); }



        .fire-badge-marker {

            width: 20px;

            height: 20px;

            background: #ef4444;

            border: 1.5px solid #ffffff;

            border-radius: 4px;

            box-shadow: 0 2px 5px rgba(0,0,0,0.3);

            display: flex;

            align-items: center;

            justify-content: center;

            color: #ffffff;

            font-size: 11px;

            cursor: pointer;

            transition: transform 0.15s;

        }

        .fire-badge-marker:hover { transform: scale(1.3); }



        /* ========================================================

           4. ATTRIBUTE TABLE BOTTOM DRAWER

           ======================================================== */

        .attr-table-drawer {

            position: absolute;

            bottom: 0; left: 0; right: 0;

            height: 260px;

            background: rgba(15, 23, 42, 0.96);

            backdrop-filter: blur(18px);

            border-top: 1px solid var(--border-glass);

            z-index: 1100;

            display: none;

            flex-direction: column;

            color: var(--text-main);

            box-shadow: 0 -10px 30px rgba(0,0,0,0.6);

        }



        .attr-table-header {

            padding: 8px 16px;

            background: rgba(30, 41, 59, 0.6);

            border-bottom: 1px solid rgba(255,255,255,0.08);

            display: flex;

            justify-content: space-between;

            align-items: center;

        }



        .attr-table-body {

            flex: 1;

            overflow: auto;

            padding: 8px 16px;

        }



        .data-grid-table {

            width: 100%;

            border-collapse: collapse;

            font-size: 11.5px;

        }

        .data-grid-table th {

            text-align: left;

            padding: 6px 10px;

            background: rgba(56, 189, 248, 0.1);

            color: var(--primary);

            border-bottom: 1px solid rgba(255,255,255,0.12);

            position: sticky; top: 0;

        }

        .data-grid-table td {

            padding: 5px 10px;

            border-bottom: 1px solid rgba(255,255,255,0.05);

            color: #e2e8f0;

        }

        .data-grid-table tr:hover td {

            background: rgba(56, 189, 248, 0.08);

            cursor: pointer;

        }



        /* Tooltip & Popups */

        .district-label-tooltip {

            background: rgba(15, 23, 42, 0.8) !important;

            border: 1px solid rgba(129, 140, 248, 0.5) !important;

            color: #c7d2fe !important;

            font-size: 9.5px !important;

            font-weight: 600 !important;

            padding: 1px 5px !important;

            border-radius: 3px !important;

            pointer-events: none !important;

        }



        /* Animated Wind & Ocean Streamlets */

        @keyframes streamDashFlow { 0% { stroke-dashoffset: 14; } 100% { stroke-dashoffset: 0; } }

        @keyframes vectorDriftPulse {

            0% { transform: rotate(var(--rot)) translateY(4px); opacity: 0.45; }

            50% { opacity: 0.95; filter: drop-shadow(0 0 5px var(--glow-color, #38bdf8)); }

            100% { transform: rotate(var(--rot)) translateY(-5px); opacity: 0.35; }

        }

        .animated-stream-marker { background: transparent !important; border: none !important; cursor: pointer; }

        .stream-vector-wrapper {

            width: 22px; height: 26px; display: flex; align-items: center; justify-content: center;

            animation: vectorDriftPulse var(--speed-dur, 1.4s) ease-in-out infinite;

            transform-origin: center center;

            transition: filter 0.2s, transform 0.2s;

        }

        .stream-vector-wrapper.static { animation: none !important; transform: rotate(var(--rot)); opacity: 0.85; }

        .stream-vector-wrapper:hover {

            transform: rotate(var(--rot)) scale(1.6) !important;

            animation-play-state: paused;

            filter: drop-shadow(0 0 8px #ffffff) !important;

            z-index: 9999 !important;

        }

        .stream-line-dash { stroke-dasharray: 4 3; animation: streamDashFlow var(--dash-dur, 0.8s) linear infinite; }

        .stream-vector-wrapper.static .stream-line-dash { animation: none !important; }



        /* Live GPS Coordinates Bottom Bar */

        .live-coords-bar {

            position: absolute; bottom: 12px; left: 56px; z-index: 1040;

            display: flex; align-items: center; gap: 8px;

            background: #2b7ac7; border: 1px solid rgba(255, 255, 255, 0.25);

            border-radius: 6px; padding: 3px 4px 3px 6px;

            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);

            user-select: none; transition: all 0.2s ease;

        }

        .live-coords-bar:hover { background: #256bb3; box-shadow: 0 6px 18px rgba(43, 122, 199, 0.45); }

        .coords-xy-badge {

            background: #ffffff; border-radius: 4px; padding: 2px 7px;

            font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;

            letter-spacing: 0.5px; box-shadow: 0 1px 2px rgba(0,0,0,0.15); cursor: pointer;

        }

        .coords-display-val {

            color: #ffffff; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;

            letter-spacing: 0.2px; white-space: nowrap; cursor: pointer; padding: 0 2px;

        }

        .coords-chevron-btn {

            width: 22px; height: 22px; background: #ffffff; border: none; border-radius: 4px;

            display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;

        }



        .coords-popover {

            position: absolute; bottom: 46px; left: 56px; z-index: 1045;

            background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(16px);

            border: 1px solid rgba(56, 189, 248, 0.3); border-radius: 10px;

            padding: 10px 12px; width: 310px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);

            display: none; flex-direction: column; gap: 6px; color: #f8fafc; font-size: 11.5px;

        }

        .coords-popover-item {

            display: flex; justify-content: space-between; align-items: center;

            padding: 5px 8px; border-radius: 6px; cursor: pointer;

        }

        .coords-popover-item:hover { background: rgba(56, 189, 248, 0.15); }

        .coords-popover-item.active { background: rgba(43, 122, 199, 0.35); border: 1px solid rgba(56, 189, 248, 0.4); }



        .coords-toast {

            position: absolute; bottom: 46px; left: 56px; z-index: 1050;

            background: #10b981; color: #ffffff; font-size: 11px; font-weight: 700;

            padding: 4px 10px; border-radius: 6px; display: none;

        }



        /* Right Floating HUD & Legend */

        .hud-panel {

            position: absolute; top: 66px; right: 16px; z-index: 1040;

            background: var(--bg-glass); backdrop-filter: blur(18px);

            border: 1px solid var(--border-glass); border-radius: 14px;

            padding: 12px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);

            color: var(--text-main); display: flex; flex-direction: column; gap: 8px; min-width: 250px;

        }

        .hud-heading { display: flex; justify-content: space-between; align-items: center; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; border-bottom: 1px solid rgba(255, 255, 255, 0.08); padding-bottom: 5px; }

        .metric-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }

        .metric-label { color: var(--text-muted); }

        .metric-value { font-weight: 600; color: var(--primary); }

        .badge-active { background: rgba(56, 189, 248, 0.15); color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }

        .badge-fire { background: rgba(239, 68, 68, 0.2); color: #f87171; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }



        .legend-panel {

            position: absolute; bottom: 20px; right: 16px; z-index: 1040;

            background: var(--bg-glass); backdrop-filter: blur(16px);

            border: 1px solid var(--border-glass); border-radius: 12px;

            padding: 12px 16px; color: var(--text-main); font-size: 11px;

            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); max-width: 280px;

        }

        .legend-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; text-transform: uppercase; color: var(--text-muted); cursor: pointer; }

        .legend-item { display: flex; align-items: center; gap: 9px; margin-top: 6px; }



        /* Leaflet Controls & Popups */

        .leaflet-popup-content-wrapper {

            background: rgba(15, 23, 42, 0.96) !important;

            backdrop-filter: blur(16px) !important;

            border: 1px solid rgba(255, 255, 255, 0.18) !important;

            color: #f8fafc !important; 
            border-radius: 12px !important;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6) !important;

        }

        .leaflet-popup-tip {
            background: rgba(15, 23, 42, 0.96) !important;
            border: 1px solid rgba(255, 255, 255, 0.18) !important;
            box-shadow: none !important;
        }

        .leaflet-popup-close-button {
            color: #94a3b8 !important;
            font-size: 18px !important;
            top: 6px !important;
            right: 8px !important;
            transition: color 0.15s ease, transform 0.15s ease;
        }

        .leaflet-popup-close-button:hover {
            color: #ffffff !important;
            transform: scale(1.1);
        }

        .popup-card {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            color: #f1f5f9;
        }

        .popup-card h4 { 
            margin: 0 0 6px 0; 
            font-size: 14px; 
            font-weight: 700; 
            color: var(--primary) !important; 
        }

        .popup-card p { 
            margin: 4px 0; 
            font-size: 12px; 
            color: #cbd5e1 !important; 
        }

        .popup-card p b {
            color: #94a3b8;
            font-weight: 600;
        }

        /* Station Popup & Telemetry Card Styling */
        .station-popup-card {
            min-width: 250px;
            max-width: 290px;
            padding: 2px 0;
        }

        .station-popup-title {
            margin: 0 0 8px 0 !important;
            color: #38bdf8 !important;
            font-size: 14px !important;
            font-weight: 700 !important;
            letter-spacing: -0.2px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.12);
            padding-bottom: 6px;
        }

        .station-popup-row {
            margin: 5px 0 !important;
            font-size: 12px !important;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }

        .popup-label {
            color: #94a3b8;
            font-weight: 600;
        }

        .popup-value {
            color: #f8fafc;
            font-weight: 600;
        }

        .wqi-badge {
            font-weight: 700;
            font-size: 11.5px;
            padding: 2px 8px;
            border-radius: 5px;
            border: 1px solid;
            display: inline-block;
            letter-spacing: 0.3px;
        }

        .telemetry-params-container {
            margin-top: 10px;
            border-top: 1px solid rgba(255, 255, 255, 0.12);
            padding-top: 8px;
        }

        .telemetry-section-title {
            font-size: 10.5px;
            font-weight: 700;
            text-transform: uppercase;
            color: #94a3b8;
            letter-spacing: 0.6px;
            display: block;
            margin-bottom: 6px;
        }

        .telemetry-params-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 6px;
        }

        .telemetry-param-badge {
            background: rgba(30, 41, 59, 0.95);
            border: 1px solid rgba(56, 189, 248, 0.28);
            padding: 6px 8px;
            border-radius: 6px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
            transition: border-color 0.15s ease, background 0.15s ease;
        }

        .telemetry-param-badge:hover {
            border-color: rgba(56, 189, 248, 0.65);
            background: rgba(30, 41, 59, 1);
        }

        .telemetry-param-key {
            color: #94a3b8;
            font-size: 10px;
            font-weight: 500;
            display: block;
            line-height: 1.25;
            margin-bottom: 2px;
        }

        .telemetry-param-val {
            color: #38bdf8;
            font-size: 12.5px;
            font-weight: 700;
            font-family: 'JetBrains Mono', 'Courier New', monospace;
            display: block;
            letter-spacing: 0.2px;
        }

        .action-btn {

            background: rgba(255, 255, 255, 0.08); color: #ffffff;

            border: 1px solid rgba(255, 255, 255, 0.15); padding: 7px 12px;

            border-radius: 6px; font-size: 11.5px; font-weight: 600; cursor: pointer;

        }

        .action-btn:hover { background: rgba(56, 189, 248, 0.25); }



        /* Measurement & Station Tooltips */

        .measure-tooltip {

            background: rgba(15, 23, 42, 0.92); border: 1px solid var(--primary);

            color: #ffffff; font-family: 'JetBrains Mono', monospace; font-size: 11px;

            padding: 3px 8px; border-radius: 6px;

        }

        .stn-marker-container { width: 160px; height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; cursor: pointer; }

        .stn-box-label { background: #ffffff; color: #0f172a; border: 1.5px solid #1e293b; border-radius: 4px; padding: 2px 8px; text-align: center; }

        .stn-code-text { font-size: 11px; font-weight: 800; }

        .stn-name-text { font-size: 10px; font-weight: 600; }

        .stn-pin-icon { width: 32px; height: 40px; }



        /* Modal Dialogs */

        .math-modal-overlay {

            position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;

            background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px);

            z-index: 2000; display: none; justify-content: center; align-items: center;

        }

        .math-modal {

            background: #0f172a; border: 1px solid rgba(56, 189, 248, 0.35); border-radius: 16px;

            width: 840px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column;

            box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85); color: var(--text-main); overflow: hidden;

        }

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

        .math-modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

        .formula-card { background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08); border-left: 3px solid var(--primary); border-radius: 10px; padding: 12px 16px; }

        .formula-title { font-size: 13.5px; font-weight: 700; color: var(--primary); }

        .formula-math-display { background: rgba(0, 0, 0, 0.4); border-radius: 8px; padding: 10px 14px; font-size: 15px; margin-top: 6px; }



/* ========================================================
   RESTRUCTURED LAYER MODAL (BUFFER MODAL DESIGN MATCH)
   ======================================================== */

.layer-modal-dialog {
    position: absolute;
    top: 108px;
    left: 16px;
    width: 330px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 180px);
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(0, 0, 0, 0.12);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: fadeInDialog 0.18s ease;
    scrollbar-gutter: stable;
    scrollbar-width: thin !important;
    scrollbar-color: #0284c7 #e2e8f0 !important;
}

.layer-modal-dialog::-webkit-scrollbar {
    width: 8px !important;
    display: block !important;
}
.layer-modal-dialog::-webkit-scrollbar-track {
    background: #e2e8f0 !important;
    border-radius: 4px !important;
}
.layer-modal-dialog::-webkit-scrollbar-thumb {
    background: #0284c7 !important;
    border-radius: 4px !important;
    border: 1px solid #e2e8f0 !important;
}
.layer-modal-dialog::-webkit-scrollbar-thumb:hover {
    background: #0369a1 !important;
}

.layer-dialog-header {
    flex-shrink: 0;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layer-dialog-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.layer-hdr-action-btn {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #0284c7;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.12s ease;
}
.layer-hdr-action-btn:hover {
    background: #0284c7;
    color: #ffffff;
}

.layer-dialog-close {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.layer-dialog-close:hover {
    color: #0f172a;
}

.layer-tabs-bar {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.layer-tab-btn {
    flex: 1;
    padding: 9px 4px;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.12s ease;
}

.layer-tab-btn.active {
    color: #0284c7 !important;
    font-weight: 700 !important;
    background: #ffffff !important;
    border-bottom: 2px solid #0284c7 !important;
}

.layer-pane {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
}

.layer-accordion-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.layer-accordion-header-btn {
    width: 100%;
    padding: 7px 12px;
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.12s ease;
}
.layer-accordion-header-btn:hover {
    background: #0369a1;
}

.layer-accordion-body {
    margin-top: 4px;
    padding: 6px 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0 0 6px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 200px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-gutter: stable;
    scrollbar-width: thin !important;
    scrollbar-color: #0284c7 #f1f5f9 !important;
}

.layer-accordion-body::-webkit-scrollbar {
    width: 6px !important;
    display: block !important;
}
.layer-accordion-body::-webkit-scrollbar-track {
    background: #f1f5f9 !important;
    border-radius: 3px !important;
}
.layer-accordion-body::-webkit-scrollbar-thumb {
    background: #0284c7 !important;
    border-radius: 3px !important;
}
.layer-accordion-body::-webkit-scrollbar-thumb:hover {
    background: #0369a1 !important;
}

.layer-item-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: #1e293b;
    line-height: 1.35;
    transition: background 0.12s ease;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 26px;
}
.layer-item-row:hover {
    background: #f1f5f9;
}
.layer-item-row input[type="checkbox"] {
    margin: 0 !important;
    width: 15px;
    height: 15px;
    accent-color: #0284c7;
    flex-shrink: 0;
    cursor: pointer;
}
.layer-item-row .layer-item-label {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    word-break: break-word;
    cursor: pointer;
}

.tree-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}
.tree-parent-row {
    display: flex;
    align-items: center;
    width: 100%;
}
.tree-toggle-btn {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 2px;
    border-radius: 3px;
    flex-shrink: 0;
}
.tree-toggle-btn:hover {
    background: #e2e8f0;
    color: #0284c7;
}
.tree-branch {
    margin-left: 10px;
    padding-left: 10px;
    border-left: 2px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
    margin-bottom: 2px;
}
.tree-leaf {
    position: relative;
    padding-left: 4px;
}

/* Spatial Bookmarks Popover */
#bookmarks-popover {
    position: absolute;
    top: 108px;
    left: 240px;
    width: 260px;
    max-width: calc(100vw - 32px);
    z-index: 1060;
}

.bookmark-item-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    width: 100%;
    box-sizing: border-box;
}

.bookmark-item-btn:hover {
    background: #f0f9ff;
    border-color: #0284c7;
    transform: translateX(2px);
}

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

.bookmark-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.bookmark-name {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
}

.bookmark-desc {
    font-size: 10.5px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Domain Configuration Modal Dialog */
#domain-modal-dialog {
    position: absolute;
    top: 66px;
    right: 16px;
    left: auto;
    width: 350px;
    max-width: calc(100vw - 32px);
    z-index: 1070;
}
