:root { --bg: #f4f6f9; --sidebar: #ffffff; --text: #333; --accent: #0056b3; --border: #dee2e6; --stale: #fd7e14; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 0; display: flex; height: 100vh; height: 100dvh; background: var(--bg); color: var(--text); overflow: hidden; }

#data-loader { position: fixed; bottom: 35px; right: 100px; background: white; padding: 10px 20px; border-radius: 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); z-index: 2000; display: none; align-items: center; gap: 10px; font-weight: bold; font-size: 0.9rem; color: var(--accent); border: 1px solid var(--border); transition: 0.3s; }
#zoom-hint { position: fixed; bottom: 35px; left: 50%; transform: translateX(-50%); background: white; padding: 10px 20px; border-radius: 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); z-index: 2000; display: none; align-items: center; font-weight: bold; font-size: 0.85rem; color: var(--accent); border: 1px solid var(--border); white-space: nowrap; }
.mini-spinner { width: 16px; height: 16px; border: 3px solid rgba(0, 86, 179, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.fullscreen-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 9999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.modal-content { background: white; padding: 30px; border-radius: 12px; max-width: 500px; max-height: 85vh; overflow-y: auto; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); margin: 20px; position: relative; }
.modal-content h3 { color: #dc3545; margin-top: 0; }
.modal-content p { font-size: 0.95rem; color: #555; line-height: 1.5; margin-bottom: 20px; text-align: left; }

#help-modal .modal-content { max-width: 700px; text-align: left; }
#help-modal h3 { color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 10px; margin-bottom: 20px; }

#fuel-history-modal .modal-content { max-width: 620px; text-align: left; }
#fuelChartContainer svg { display: block; width: 100%; height: auto; }
.fuel-hit-point { cursor: crosshair; }
.fuel-tooltip { position: fixed; background: #212529; color: white; padding: 6px 10px; border-radius: 6px; font-size: 0.78rem; line-height: 1.4; pointer-events: none; z-index: 10001; transform: translate(-50%, -100%); white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.fuel-tooltip strong { display: block; font-size: 0.85rem; }
.fuel-history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.fuel-history-table th { text-align: left; color: #6c757d; font-weight: bold; padding: 6px 8px; border-bottom: 2px solid var(--border); }
.fuel-history-table td { padding: 6px 8px; border-bottom: 1px solid #f1f3f5; font-variant-numeric: tabular-nums; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.help-section { background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid var(--accent); }
.help-section h4 { margin: 0 0 8px 0; color: #333; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.help-section p, .help-section ul { margin: 0; font-size: 0.85rem; color: #555; line-height: 1.6; padding-left: 15px; }
.help-section ul { padding-left: 25px; }
.help-close-btn { position: sticky; bottom: 0; background: var(--accent); color: white; border: none; padding: 12px; width: 100%; border-radius: 6px; font-weight: bold; cursor: pointer; margin-top: 10px; box-shadow: 0 -10px 20px white; }

.fullscreen-ctrl { position: absolute; top: 20px; right: 20px; z-index: 1000; background: white; border: 2px solid rgba(0,0,0,0.2); border-radius: 4px; width: 40px; height: 40px; cursor: pointer; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; color: #333; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.fullscreen-ctrl:hover { background: #f4f4f4; color: var(--accent); }

.floating-help-btn { position: fixed; bottom: 30px; right: 30px; width: 55px; height: 55px; border-radius: 50%; background: var(--accent); color: white; border: none; font-size: 1.8rem; font-weight: bold; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 2000; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; padding: 0; box-sizing: border-box; }
.floating-weather-btn { position: fixed; bottom: 95px; right: 30px; width: 55px; height: 55px; border-radius: 50%; background: #17a2b8; color: white; border: none; font-size: 1.8rem; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 2000; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; padding: 0; box-sizing: border-box; }
.floating-refresh-btn { position: fixed; bottom: 160px; right: 30px; width: 55px; height: 55px; border-radius: 50%; background: #ffffff; color: var(--accent); border: 2px solid var(--accent); font-size: 1.8rem; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 2000; display: flex; align-items: center; justify-content: center; transition: all 0.4s; padding: 0; box-sizing: border-box; }
.floating-help-btn:hover, .floating-weather-btn:hover { transform: scale(1.1); }
.floating-refresh-btn:hover { transform: scale(1.1) rotate(180deg); background: var(--accent); color: white; }

#windy-wrapper { background: #222; width: 90%; max-width: 1000px; height: 85%; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.windy-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #111; color: white; font-weight: bold; }
.windy-close { background: #dc3545; border: none; color: white; padding: 6px 15px; border-radius: 4px; cursor: pointer; font-weight: bold; }

#sidebar-wrapper { display: flex; align-items: center; height: 100%; z-index: 2000; background: transparent; position: relative; }
#sidebar { width: 360px; height: 100%; background: var(--sidebar); display: flex; flex-direction: column; overflow: hidden; transition: width 0.3s ease; box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
#sidebar.collapsed { width: 0; }

.sidebar-content { width: 360px; height: 100%; padding: 20px; display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden; }
h2 { flex-shrink: 0; margin: 0 0 15px 0; color: #249be5; font-size: 1.4rem; display: flex; justify-content: space-between; align-items: center; }

.sidebar-scroll-area { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 5px; margin-bottom: 10px; }
.sidebar-scroll-area::-webkit-scrollbar { width: 6px; }
.sidebar-scroll-area::-webkit-scrollbar-thumb { background-color: #ced4da; border-radius: 4px; }
.sidebar-scroll-area::-webkit-scrollbar-track { background: transparent; }

#sidebar-toggle-btn { position: absolute; right: -24px; top: 50%; transform: translateY(-50%); width: 24px; height: 60px; background: var(--accent); color: white; border: none; border-radius: 0 8px 8px 0; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; box-shadow: 3px 0 6px rgba(0,0,0,0.15); transition: background 0.2s; z-index: 2001; padding: 0; }
#sidebar-toggle-btn:hover { background: #004494; }

.sidebar-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-shrink: 0; }
.sidebar-tab { flex: 1; padding: 10px 6px; font-size: 0.78rem; font-weight: bold; background: #f1f3f5; color: #495057; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: 0.2s; text-align: center; }
.sidebar-tab:hover { background: #e9ecef; }
.sidebar-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.tab-panel { display: flex; flex-direction: column; gap: 14px; }

.sidebar-footer { flex-shrink: 0; padding-top: 15px; border-top: 1px solid var(--border); text-align: center; font-size: 0.8rem; color: #6c757d; }
.sidebar-footer img { max-width: 160px; margin: 0 auto 10px auto; display: block; }
.sidebar-footer a { color: #249be5; text-decoration: none; font-weight: bold; }
.app-version { margin-top: 5px; font-family: monospace; color: #adb5bd; background: #f1f3f5; display: inline-block; padding: 2px 8px; border-radius: 12px; }

#map-container { display: flex; flex-direction: column; flex-grow: 1; position: relative; background: #222; transition: width 0.3s ease; }
#disclaimer-banner { background: white; color: #c82333; border: 1px solid #c82333; text-align: center; font-size: 0.75rem; padding: 6px 0; z-index: 1000; font-weight: bold; }
#map { flex-grow: 1; width: 100%; z-index: 1; }

.control-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; color: #495057; }
.search-row { display: flex; gap: 8px; position: relative; }
.search-row input, input[type="datetime-local"], input[type="number"], select { flex-grow: 1; padding: 10px 12px; border-radius: 6px; border: 1px solid #ced4da; font-size: 0.95rem; outline: none; box-sizing: border-box; width: 100%; transition: border-color 0.2s; }
.search-row input:focus, input[type="datetime-local"]:focus, input[type="number"]:focus, select:focus { border-color: var(--accent); }

#searchResults { font-size: 0.85rem; font-weight: bold; margin-top: 4px; display: none; }

.search-dropdown { width: 100%; background: #f8f9fa; border: 1px solid var(--accent); border-radius: 6px; max-height: 220px; overflow-y: auto; display: none; margin-top: 5px; }
.search-dropdown-item { padding: 10px 15px; border-bottom: 1px solid #e9ecef; cursor: pointer; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; transition: 0.2s; }
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover, .search-dropdown-item.first-result { background: #e9ecef; color: var(--accent); padding-left: 20px; }
.search-dropdown-item small { color: #6c757d; font-family: monospace; }

.search-dimmed svg, .search-dimmed div { filter: grayscale(100%) !important; opacity: 0.2 !important; }
.custom-vessel-icon { transition: all 0.4s ease; display: flex; align-items: center; justify-content: center; }

.feed-toggle-group { display: flex; width: 100%; border-radius: 6px; overflow: hidden; border: 1px solid var(--accent); margin-bottom: 5px; }
.feed-btn { flex: 1; padding: 8px 4px; font-size: 0.75rem; font-weight: bold; background: #fff; color: var(--accent); border: none; border-right: 1px solid var(--accent); cursor: pointer; transition: 0.2s; }
.feed-btn:last-child { border-right: none; }
.feed-btn:hover { background: #e9ecef; }
.feed-btn.active { background: var(--accent); color: #fff; }

.btn { padding: 12px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; color: white; display: flex; align-items: center; justify-content: center; gap: 8px; transition: opacity 0.2s; }
.btn:hover { opacity: 0.9; }
.btn-play { background: #28a745; width: 100px; } .btn-pause { background: #dc3545; width: 100px; }
.btn-primary { background: var(--accent); } .btn-secondary { background: #6c757d; }
.btn-agree { background: #dc3545; font-size: 1.1rem; padding: 14px; width: 100%; } 

/* Timeline HUD & Minimize Toggle */
#timeline-hud { 
    position: absolute; 
    bottom: 30px; 
    left: 50%; 
    transform: translateX(-50%); 
    width: 90%; 
    max-width: 700px; 
    background: rgba(255, 255, 255, 0.95); 
    padding: 15px; 
    border-radius: 12px; 
    z-index: 1000; 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    transition: transform 0.3s ease-in-out; 
}
#timeline-hud.collapsed { 
    transform: translate(-50%, calc(100% + 30px)); 
}

.hud-toggle-btn { 
    position: absolute; 
    top: -28px; 
    left: 50%; 
    transform: translateX(-50%); 
    background: rgba(255,255,255,0.95); 
    border: 1px solid var(--border); 
    border-bottom: none; 
    border-radius: 8px 8px 0 0; 
    padding: 4px 20px; 
    cursor: pointer; 
    font-size: 0.85rem; 
    font-weight: bold; 
    color: var(--accent); 
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1); 
    z-index: 1001; 
}

#timeline-hud input { flex-grow: 1; cursor: pointer; }
.hud-center { display: flex; flex-direction: column; flex-grow: 1; align-items: center; gap: 5px; }
#timestamp-display { font-family: monospace; font-size: 0.95rem; font-weight: bold; color: var(--accent); background: #e9ecef; padding: 4px 10px; border-radius: 4px; }

.vessel-popup { min-width: 260px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #333; }
.v-header { font-size: 1.2rem; font-weight: bold; margin-bottom: 8px; color: var(--accent); text-transform: uppercase; display: flex; align-items: center; flex-wrap: wrap; row-gap: 6px; column-gap: 10px; }
.v-header .v-name { flex: 1 1 auto; min-width: 140px; }
.v-badge-emission { background: #dc3545; color: white; padding: 3px 9px; border-radius: 4px; font-size: 0.68rem; letter-spacing: 0.3px; white-space: nowrap; flex-shrink: 0; }
.v-stat { display: flex; justify-content: space-between; font-size: 0.95rem; margin-bottom: 6px; border-bottom: 1px solid #f1f3f5; padding-bottom: 4px; }
.v-stat span:first-child { color: #555; }
.v-stat span:last-child { font-weight: 600; text-align: right; max-width: 65%; word-wrap: break-word; }
.radar-bubble { animation: radar-pulse 3s infinite ease-in-out; }
@keyframes radar-pulse { 0% { fill-opacity: 0.05; stroke-opacity: 0.2; } 50% { fill-opacity: 0.15; stroke-opacity: 0.8; } 100% { fill-opacity: 0.05; stroke-opacity: 0.2; } }

.high-emission-glow svg, .high-emission-glow > div { filter: drop-shadow(0px 0px 6px #ff0000) drop-shadow(0px 0px 10px #ff8800) !important; animation: pulse-fire 1.5s infinite alternate; }
@keyframes pulse-fire { 0% { filter: drop-shadow(0px 0px 4px #ff0000); } 100% { filter: drop-shadow(0px 0px 12px #ff4500) drop-shadow(0px 0px 20px #ff0000); } }

/* Custom vessel-cluster icons: accent palette instead of the plugin's default green/yellow/orange,
   plus a soft red glow when a cluster contains 1+ high-emission vessel so the same red = high-emissions
   language used on individual markers carries through when zoomed out.
   NOTE: do not set `position` here — Leaflet's own .leaflet-marker-icon rule requires position:absolute
   for correct map placement, and this class lands on the same element; overriding it misplaces the icon. */
.marker-cluster-custom { background: transparent !important; }
.marker-cluster-custom div { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(0,86,179,0.8); color: white; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.9); font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.25); }
.marker-cluster-custom.cl-sm div { font-size: 0.72rem; }
.marker-cluster-custom.cl-md div { font-size: 0.82rem; background: rgba(0,64,133,0.82); }
.marker-cluster-custom.cl-lg div { font-size: 0.9rem; background: rgba(0,48,100,0.85); }
.marker-cluster-custom.has-high-emission div { box-shadow: 0 0 8px 3px rgba(220,53,69,0.6), 0 2px 5px rgba(0,0,0,0.25); }

.intel-status { display: none; align-items: center; margin-left: 4px; font-size: 0.68rem; font-weight: normal; text-transform: none; color: #6c757d; }
.intel-status.visible { display: inline-flex; }
.intel-spinner { width: 11px; height: 11px; border-width: 2px; }

.hazard-legend { display: none; background: rgba(255,255,255,0.95); padding: 8px 12px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.25); font-size: 0.75rem; color: #333; margin: 0 0 10px 10px; }
.hazard-legend.visible { display: block; }
.hazard-legend-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.hazard-legend-item + .hazard-legend-item { margin-top: 4px; }
.hazard-legend-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.hazard-layers-control { margin: 0 0 10px 10px; }
.hazard-layers-btn { display: flex; align-items: center; gap: 8px; background: var(--accent); border: none; border-radius: 8px; padding: 10px 14px; font-weight: bold; font-size: 0.85rem; cursor: pointer; box-shadow: 0 3px 10px rgba(0,86,179,0.4); color: white; transition: transform 0.15s, box-shadow 0.15s; }
.hazard-layers-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,86,179,0.5); }
.hazard-layers-count { display: none; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; background: #dc3545; color: white; border-radius: 999px; font-size: 0.7rem; font-weight: bold; box-shadow: 0 0 0 2px rgba(255,255,255,0.6); }
.hazard-layers-panel { display: none; flex-direction: column; gap: 10px; background: white; border-radius: 8px; padding: 12px; margin-top: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.25); width: 250px; max-height: 55vh; overflow-y: auto; }
.hazard-layers-panel.open { display: flex; }
.hazard-toggle-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: bold; text-transform: none; cursor: pointer; }

#mobileToggle, #closeMenuBtn { display: none; }

@media (max-width: 768px) {
    .help-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
    #sidebar-toggle-btn { display: none; } 
    #sidebar-wrapper { position: absolute; height: 100%; width: 85vw; max-width: 340px; transform: translateX(-100%); transition: transform 0.3s ease; z-index: 3000; background: var(--sidebar); box-shadow: 2px 0 10px rgba(0,0,0,0.3); } 
    #sidebar-wrapper.open { transform: translateX(0); }
    #sidebar { width: 100%; border: none; box-shadow: none; }
    
    .sidebar-content { width: 100%; padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
    
    #mobileToggle { display: block; position: absolute; bottom: 25px; left: 50%; transform: translateX(-50%); z-index: 1000; background: var(--accent); color: white; border: none; padding: 14px 28px; border-radius: 30px; font-weight: bold; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
    
    #timeline-hud { 
        bottom: 85px; 
        flex-wrap: wrap; 
    }
    #timeline-hud.collapsed { 
        transform: translate(-50%, calc(100% + 85px)); 
    }
    #timeline-hud .hud-center { 
        width: 100%; 
        order: -1; 
        margin-bottom: 10px; 
    }
    
    #closeMenuBtn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: #f1f3f5; border-radius: 50%; border: none; font-size: 1.1rem; color: #333; cursor: pointer; transition: 0.2s; }
    #closeMenuBtn:active { background: #dee2e6; }
    h2 { font-size: 1.25rem; margin-bottom: 15px; }
    
    .fullscreen-ctrl { top: 10px; right: 10px; width: 35px; height: 35px; font-size: 1.2rem; }
    .floating-help-btn { bottom: 90px; right: 20px; width: 45px; height: 45px; font-size: 1.4rem; padding: 0; margin: 0; box-sizing: border-box; } 
    .floating-weather-btn { bottom: 145px; right: 20px; width: 45px; height: 45px; font-size: 1.4rem; padding: 0; margin: 0; box-sizing: border-box; } 
    .floating-refresh-btn { bottom: 200px; right: 20px; width: 45px; height: 45px; padding: 0; margin: 0; box-sizing: border-box; } 
    .floating-refresh-btn svg { width: 20px; height: 20px; }
    
    #data-loader { bottom: 95px; right: 75px; padding: 8px 15px; font-size: 0.8rem; }

    .leaflet-bottom { margin-bottom: 70px; }
    .hazard-layers-panel { width: 200px; }
}