        /* --- Base Styles --- */
        html, body {
            margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif;
            background-color: #f4f4f9; color: #333;
        }
        .page-header {
            display: flex; align-items: center; gap: 15px;
            border-bottom: 2px solid #AECDFE; padding-bottom: 10px; margin-bottom: 15px;
        }
        .page-header a { display: flex; align-items: center; text-decoration: none; }
        .page-header a img { height: 45px; width: auto; max-width: 100%; object-fit: contain; }
        h1 { color: #2E4651; font-size: 1.4em; margin: 0; padding: 0; line-height: 1.2; }

        body { padding: 15px; box-sizing: border-box; min-height: 100vh; }
        .container {
            width: 100%; max-width: 1600px; margin: 0 auto; background: #fff;
            padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            box-sizing: border-box; display: flex; flex-direction: column;
        }
        .layout-wrapper { display: flex; flex-direction: column; gap: 20px; margin-top: 10px; }
        
        /* Mobile Layout Ordering */
        .left-panel, .right-panel { display: contents; }
        .controls { order: 1; margin-bottom: 0 !important; }
        #map-section { order: 2; }
        #chart-section { order: 3; }

        .fullscreen {
            position: fixed !important; top: 0; left: 0; right: 0; bottom: 0;
            width: 100vw !important; height: 100vh !important; z-index: 9999 !important;
            background: white; margin: 0; border-radius: 0; padding: 20px; box-sizing: border-box;
            display: flex; flex-direction: column;
        }
        .fullscreen #map-container, .fullscreen .chart-wrapper {
            flex: 1; height: auto !important; min-height: 0;
        }

        .panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
        .panel-header h2 { margin: 0; font-size: 1.1em; color: #2E4651; display: flex; align-items: center; flex-wrap: wrap;}
        
        .header-controls { display: flex; gap: 6px; align-items: center; }
        
        /* Hide expand buttons on mobile */
        .expand-btn { display: none; background-color: #6c757d; padding: 4px 10px; font-size: 0.85em; color: white; border: none; border-radius: 4px; cursor: pointer; }
        .expand-btn:hover { background-color: #5a6268; }

        /* Map Header Export Dropdown Styles */
        .dropdown { position: relative; display: inline-block; }
        #main-export-btn { background-color: #5cb85c; padding: 4px 10px; font-size: 0.85em; color: white; border: none; border-radius: 4px; cursor: pointer; }
        #main-export-btn:hover { background-color: #4cae4c; }
        .dropdown-content { 
            display: none; position: absolute; right: 0; background-color: #fff; 
            min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); 
            z-index: 2000; border-radius: 4px; border: 1px solid #ddd; overflow: hidden; margin-top: 4px;
        }
        .dropdown-content button { 
            color: #333; padding: 10px 12px; text-decoration: none; display: block; 
            width: 100%; text-align: left; border: none; background: none; 
            font-size: 0.85em; cursor: pointer; border-radius: 0; font-weight: normal;
        }
        .dropdown-content button:hover:not(:disabled) { background-color: #eef5fa; color: #2E4651; }
        .show { display: block; }

        #map-container { width: 100%; height: 400px; border-radius: 5px; border: 1px solid #ddd; z-index: 1; }

        .chart-wrapper {
            width: 100%; height: 350px; position: relative; margin-bottom: 10px;
            border: 1px solid #ddd; background: #fafafa; border-radius: 5px; box-sizing: border-box;
        }
        #chart-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; }

        /* Shifts Plotly's Modebar left to make room for Expand Button */
        .modebar-container { right: 75px !important; top: 3px !important; }

        /* Top right chart expand button */
        .chart-expand-btn {
            position: absolute;
            top: 8px;
            right: 8px; 
            z-index: 1000;
            padding: 4px 8px;
            font-size: 0.8em;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        @media (min-width: 992px) {
            html, body { height: 100%; overflow: hidden; }
            body { display: flex; justify-content: center; align-items: center; }
            .container { height: 100%; padding: 15px 25px; }
            .layout-wrapper { flex-direction: row; flex: 1; min-height: 0; }
            
            /* Restore desktop specific flex behavior */
            .left-panel { display: flex; flex-direction: column; flex: 4; min-width: 350px; max-width: 500px; min-height: 0; overflow-y: auto; padding-right: 15px; position: relative;}
            .right-panel { display: flex; flex-direction: column; flex: 7; min-width: 450px; min-height: 0; position: relative;}
            
            /* Reset orders */
            .controls, #map-section, #chart-section { order: 0; }
            .controls { margin-bottom: 15px !important; }
            
            #map-container { flex: 1; height: auto; min-height: 300px; }

            /* Show expand buttons on desktop */
            .expand-btn { display: block; }
        }

        .custom-marker { background: transparent; border: none; }
        
        .leaflet-tooltip.contour-label { 
            background: transparent; border: none; box-shadow: none; color: #2E4651; 
            font-weight: 800; font-size: 0.9em; padding: 0;
            text-shadow: -1.5px -1.5px 0 #fff, 1.5px -1.5px 0 #fff, -1.5px 1.5px 0 #fff, 1.5px 1.5px 0 #fff, 0px 0px 4px #fff;
        }
        .leaflet-tooltip.contour-label::before, .leaflet-tooltip.contour-label::after { display: none !important; }

        .leaflet-tooltip.water-level-label { 
            background: transparent !important; 
            border: none !important; 
            box-shadow: none !important; 
            color: #0000FF !important; 
            font-size: 0.75em; 
            padding: 0;
            z-index: 1000 !important; /* Forces the label above other map layers */
        }
        .leaflet-tooltip.water-level-label::before, 
        .leaflet-tooltip.water-level-label::after { 
            display: none !important; 
        }

        .leaflet-popup-content-wrapper { background: #fff; color: #333; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); border: 1px solid #ddd; }
        .leaflet-popup-tip { background: #fff; }
        .leaflet-popup-content { font-family: Arial, sans-serif; margin: 10px; font-size: 13px; line-height: 1.5; text-align: center;}
        
        .leaflet-tooltip { font-family: Arial, sans-serif; color: #333; border: 1px solid #AECDFE; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
        .popup-buttons { display: flex; gap: 5px; justify-content: center; margin-top: 10px; }

        .controls { display: flex; flex-direction: column; gap: 10px; background: #f9f9f9; padding: 12px; border: 1px solid #ddd; border-radius: 5px; margin-bottom: 15px; }
        .control-group { display: flex; flex-direction: column; width: 100%; }
        
        .contour-box { background: #eef5fa; border: 1px solid #AECDFE; border-radius: 5px; padding: 10px; }
        .contour-box h3 { margin: 0 0 8px 0; font-size: 0.9em; color: #2E4651; }
        .contour-inputs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;}
        .contour-inputs select, .contour-inputs input { flex: 1; min-width: 70px;}

        label { font-weight: bold; margin-bottom: 3px; font-size: 0.85em; color: #333;}
        input[type="number"], select { padding: 6px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.9em; background-color: #fff; box-sizing: border-box; }
        
        button { padding: 8px 15px; background-color: #2E4651; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 0.95em; font-weight: bold; transition: background-color 0.2s; }
        button:hover:not(:disabled) { background-color: #1a2a31; }
        
        #compare-btn { background-color: #337ab7; padding: 4px 8px; font-size: 0.85em; } #compare-btn:hover { background-color: #286090; }
        #plot-popup-btn { background-color: #2E4651; padding: 4px 8px; font-size: 0.85em; }
        
        .clear-buttons-wrapper { display: flex; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
        
        #clear-graph-btn { flex: 1; background-color: #d9534f; margin: 0; padding: 5px 8px; font-size: 0.8em; display: none; } 
        #clear-graph-btn:hover { background-color: #c9302c; }
        #clear-contours-btn { flex: 1; background-color: #d9534f; margin: 0; padding: 5px 8px; font-size: 0.8em; display: none; } 
        #clear-contours-btn:hover { background-color: #c9302c; }
        #plot-visible-btn { flex: 1; background-color: #17a2b8; margin: 0; padding: 5px 8px; font-size: 0.8em; display: none; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold;} 
        #plot-visible-btn:hover { background-color: #138496; }
        
        .contour-btn { background-color: #20c997; padding: 6px 10px; font-size: 0.85em; } .contour-btn:hover { background-color: #17a2b8; }
        
        #top-chart-tools { display: none; justify-content: space-between; align-items: center; margin-bottom: 5px; }
        .fullscreen #top-chart-tools { display: flex; }
        #zoom-instructions { font-size: 0.85em; color: #555; margin: 0; }

        .placeholder-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #888; font-size: 0.95em; text-align: center; width: 100%; }
        
        .plot-tools { display: none; justify-content: space-between; align-items: center; background: #fdfdfd; padding: 10px 15px; border: 1px solid #ddd; border-radius: 5px; flex-shrink: 0; margin-bottom: 10px;}
        #trend-btn { background-color: #337ab7; padding: 6px 12px; } #trend-btn:hover { background-color: #286090; }
        #clear-trend-btn { background-color: #d9534f; padding: 6px 12px; margin-left: 10px; display: none; } #clear-trend-btn:hover { background-color: #c9302c; }
        #trend-result { font-size: 0.85em; color: #333; margin-top: 5px; display: block; }

        #global-loader {
            position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.9); z-index: 1000;
            display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 1.2em; font-weight: bold; color: #2E4651; border-radius: 5px;
        }
        .spinner { width: 40px; height: 40px; border: 4px solid #e0e0e0; border-top: 4px solid #2E4651; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        
        .help-link-btn {
            padding: 6px 12px; background-color: #eef5fa; color: #2E4651 !important; border: 1px solid #AECDFE; 
            border-radius: 4px; text-decoration: none !important; font-weight: bold; font-size: 0.9em; 
            transition: background-color 0.2s; margin-left: auto;
        }
        .help-link-btn:hover:not(:disabled) { background-color: #AECDFE; }
        
        /* --- Modal Styles --- */
        .modal-overlay {
            display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.6); z-index: 10000; 
            justify-content: center; align-items: center; padding: 20px;
        }
        .modal-content {
            background: #fff; border-radius: 8px; width: 100%; max-width: 900px;
            max-height: 90vh; display: flex; flex-direction: column;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        }
        .modal-header {
            display: flex; justify-content: space-between; align-items: center;
            padding: 15px 25px; border-bottom: 2px solid #AECDFE; background: #fdfdfd;
            border-radius: 8px 8px 0 0;
        }
        .modal-header h2 { margin: 0; color: #2E4651; font-size: 1.4em; }
        .close-modal-btn { background: #d9534f; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 0.9em; }
        .close-modal-btn:hover { background: #c9302c; }
        .modal-body { padding: 25px; overflow-y: auto; line-height: 1.6; color: #333; }
        .modal-body h3 { color: #337ab7; margin-top: 25px; margin-bottom: 10px; }
        .modal-body ul { margin-bottom: 20px; }
        .modal-body li { margin-bottom: 8px; }
