/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #0a0e17; color: #e2e8f0; }

#map { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; }

/* ── Glass-morphism Panel ──────────────────────────────────── */
.glass-panel {
    background: rgba(12, 17, 30, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.04);
    color: #e2e8f0;
    padding: 16px;
    max-height:1000px;
}

/* ── Logo ──────────────────────────────────────────────────── */
#logo-container {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
}
#logo-container img {
    height: 48px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

/* ── Side Panels ───────────────────────────────────────────── */
.side-panel {
    position: fixed;
    top: 100px;
    width: 270px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    z-index: 1000;
}
.left-panel { left: 16px; }
.right-panel { right: 16px; }

.side-panel::-webkit-scrollbar { width: 4px; }
.side-panel::-webkit-scrollbar-track { background: transparent; }
.side-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

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

.panel-section { margin-bottom: 16px; }
.panel-section:last-child { margin-bottom: 0; }

.panel-section-title {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.71);
    margin-bottom: 8px;
}
.panel-empty-state {
    font-weight: 600;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.71);
    text-align: center;
    padding: 16px 8px;
    font-size: 12px;
}

.collapsible-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    margin-bottom: 0;
}
.collapsible-toggle::after {
    content: '\25B6';
    font-size: 8px;
    color: #94a3b8;
    transition: transform 0.2s ease;
}
.collapsible.open > .collapsible-toggle::after {
    transform: rotate(90deg);
}
.collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.collapsible.open > .collapsible-body {
    max-height: 500px;
    margin-top: 8px;
}

/* ── Mode Badge ────────────────────────────────────────────── */
.mode-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}
.mode-observation { background: #1d4ed8; color: #dbeafe; }
.mode-forecast {
    background: #dc2626;
    color: #fecaca;
    animation: pulse-forecast 1.5s ease-in-out infinite;
}
@keyframes pulse-forecast {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { opacity: 0.85; box-shadow: 0 0 12px 4px rgba(220, 38, 38, 0.2); }
}

/* Forecast mode tint on events panel */
#events-panel.forecast-mode {
    border-color: rgba(220, 38, 38, 0.25);
    box-shadow: 0 8px 32px rgba(220, 38, 38, 0.12), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* ── AI Slide-out Panel ────────────────────────────────────── */
.ai-panel-overlay {
    display: none !important;
}
.ai-slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 33vw;
    max-width: 450px;
    min-width: 300px;
    z-index: 2000;
    background: rgb(12, 17, 30);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.ai-slide-panel.open {
    transform: translateX(0);
}
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.ai-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    letter-spacing: 0.5px;
}
.ai-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(100,116,139,0.3) transparent;
}
.ai-panel-body::-webkit-scrollbar { width: 4px; }
.ai-panel-body::-webkit-scrollbar-thumb { background: rgba(100,116,139,0.3); border-radius: 2px; }
.ai-panel-body::-webkit-scrollbar-track { background: transparent; }
.ai-panel-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #94a3b8;
    padding: 8px 0;
}
.ai-loading .small-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    flex-shrink: 0;
}
#ai-analysis-content {
    font-size: 13px;
    line-height: 1.7;
    color: #cbd5e1;
}
#ai-analysis-content p {
    margin: 0 0 10px;
}
#ai-analysis-content h1, #ai-analysis-content h2, #ai-analysis-content h3,
#ai-analysis-content h4, #ai-analysis-content h5, #ai-analysis-content h6 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #e2e8f0;
    margin: 16px 0 8px;
}
#ai-analysis-content h1:first-child, #ai-analysis-content h2:first-child,
#ai-analysis-content h3:first-child {
    margin-top: 0;
}
#ai-analysis-content strong {
    color: #e2e8f0;
}
#ai-analysis-content ul {
    margin: 4px 0 10px;
    padding-left: 18px;
}
#ai-analysis-content li {
    margin-bottom: 4px;
}
#ai-analysis-content .ai-date {
    color: #60a5fa;
    font-weight: 600;
    cursor: pointer;
}
#ai-analysis-content .ai-date:hover {
    text-decoration: underline;
}

.btn-ai-action {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
    color: #60a5fa;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ai-action:hover {
    background: rgba(96, 165, 250, 0.25);
    border-color: rgba(96, 165, 250, 0.5);
    color: #93bbfd;
}
.btn-ai-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#btn-ai-panel.ai-active {
    background: rgba(96, 165, 250, 0.2);
    border-color: rgba(96, 165, 250, 0.5);
    color: #60a5fa;
}

/* ── Date Display ──────────────────────────────────────────── */
.date-display {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Event Cards ───────────────────────────────────────────── */
.event-card {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}
.event-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}
.event-card.focused {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.3);
}
.event-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.event-label {
    font-size: 11px;
    font-weight: 600;
}
.bloom-age {
    font-size: 9px;
    color: #475569;
    margin-top: 1px;
}
#events-list {
    margin-bottom:20px;
}
.event-area {
    font-size: 10px;
    color: #64748b;
}
.intensity-bar-bg {
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    margin-bottom: 4px;
}
.intensity-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.event-stats {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #64748b;
}
/* ── Dodge Tide Cards ──────────────────────────────────────── */
.dodge-tide-risk {
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.dodge-tide-detail {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
}
.dt-panel-action {
    padding: 8px 0 4px;
    text-align: center;
}
.dt-panel-action-link {
    font-size: 11px;
    color: #60a5fa;
    cursor: pointer;
    transition: color 0.15s;
}
.dt-panel-action-link:hover {
    color: #93c5fd;
}
.dt-panel-action-link i {
    margin-right: 4px;
}
.dt-panel-action-hint {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
}
/* ── Dodge Tide Modal ──────────────────────────────────────── */
.dodge-tide-modal-content {
    position: relative;
    width: 780px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1051;
}
#dodge-tide-modal .buoy-nav-prev { left: max(8px, calc(50% - 440px)); }
#dodge-tide-modal .buoy-nav-next { right: max(8px, calc(50% - 440px)); }
.dodge-tide-modal-content::-webkit-scrollbar { width: 4px; }
.dodge-tide-modal-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.dt-date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}
.dt-date-label {
    font-size: 11px;
    color: #94a3b8;
}
.dt-date-arrow {
    font-size: 10px;
    color: #64748b;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.dt-date-arrow:hover:not(.dt-date-nav-disabled) {
    color: #e2e8f0;
    background: rgba(255,255,255,0.08);
}
.dt-date-nav-disabled {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
}
.dt-section {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.dt-section:last-child { border-bottom: none; }
.dt-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748b;
    margin-bottom: 10px;
}
/* Header */
.dt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.dt-header-info { flex: 1; }
.dt-aoi-name {
    font-size: 16px;
    font-weight: 700;
    color: #e2e8f0;
}
.dt-date {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}
.dt-risk-badge {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    letter-spacing: 0.5px;
 
}
.dt-risk-badge.risk-low { background: #c2410c; box-shadow: 0 0 12px rgba(194,65,12,0.4); }
.dt-risk-badge.risk-medium { background: #9a3412; box-shadow: 0 0 12px rgba(154,52,18,0.4); }
.dt-risk-badge.risk-high { background: #991b1b; box-shadow: 0 0 12px rgba(153,27,27,0.4); }
.dt-risk-badge.risk-critical { background: #7f1d1d; box-shadow: 0 0 16px rgba(127,29,29,0.5); }
.dt-risk-badge.risk-none { background: #334155; box-shadow: none; }
/* Risk Windows */
.dt-window-bar {
    position: relative;
    height: 32px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    margin-bottom: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}
.dt-window-fill {
    position: absolute;
    top: 0; bottom: 0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
    min-width: 60px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.dt-window-label {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #94a3b8;
    margin-bottom: 4px;
}
.dt-no-windows {
    font-size: 11px;
    color: #475569;
    font-style: italic;
    padding: 8px 0;
}
/* Chart containers */
.dt-combined-chart-wrap {
    position: relative;
    height: 200px;
    margin-top: 8px;
}
/* Wind direction arrows row */
.dt-wind-arrows {
    display: flex;
    justify-content: space-between;
    padding: 0 30px 0 55px;
    margin-top: 4px;
}
.dt-wind-arrow {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    color: #94a3b8;
    transition: transform 0.2s;
}
/* ── Combined Chart Legend ────────────────────────────────── */
.dt-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.dt-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    color: #94a3b8;
}
.dt-chart-legend-line {
    width: 14px;
    height: 3px;
    border-radius: 1px;
}
.dt-chart-legend-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
.dt-chart-legend-dash {
    width: 14px;
    height: 0;
    border-top: 2px dashed rgba(148, 163, 184, 0.5);
}
.dt-chart-legend-bar {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ── Ocean Profile Heatmap ───────────────────────────────── */
.ocean-profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}
.ocean-profile-header-spacer {
    width: 50px;
    flex-shrink: 0;
}
.ocean-profile-header-titles {
    display: flex;
    flex: 1;
    gap: 3px;
}
.ocean-profile-header-titles span {
    flex: 1;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.ocean-depth-row {
    display: flex;
    align-items: center;
    height: 22px;
}
.ocean-depth-label {
    width: 50px;
    text-align: right;
    padding-right: 10px;
    font-size: 10px;
    color: #64748b;
    flex-shrink: 0;
}
.ocean-heatmap-cols {
    display: flex;
    flex: 1;
    gap: 2px;
}
.ocean-heatmap-cell {
    flex: 1;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}
.ocean-thermocline-row {
    display: flex;
    align-items: center;
    height: 18px;
    margin: 1px 0;
}
.ocean-thermocline-spacer {
    width: 50px;
    flex-shrink: 0;
}
.ocean-thermocline-line-area {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ocean-thermocline-dashed {
    flex: 1;
    height: 0;
    border-top: 2px dashed #f97316;
}
.ocean-thermocline-label {
    font-size: 9px;
    font-weight: 700;
    color: #f97316;
    white-space: nowrap;
}
.ocean-legend-row {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.ocean-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: #94a3b8;
}
.ocean-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}
.ocean-legend-line {
    width: 16px;
    height: 0;
    border-top: 2px dashed #f97316;
}

/* ── N² Stratification Chart ─────────────────────────────── */
.n2-row {
    display: flex;
    align-items: center;
    height: 28px;
}
.n2-row.n2-highlight {
    background: rgba(249, 115, 22, 0.08);
    border-radius: 4px;
}
.n2-depth {
    width: 70px;
    text-align: right;
    padding-right: 10px;
    font-size: 10px;
    color: #64748b;
    flex-shrink: 0;
}
.n2-depth.n2-highlight {
    color: #f97316;
    font-weight: 700;
}
.n2-bar-area {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.n2-bar-track {
    flex: 1;
    height: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
}
.n2-bar-fill {
    height: 100%;
    border-radius: 3px;
}
.n2-value {
    font-size: 9px;
    color: #94a3b8;
    width: 50px;
    text-align: right;
    flex-shrink: 0;
}
.n2-value.n2-highlight {
    color: #f97316;
    font-weight: 700;
}
.n2-desc {
    font-size: 9px;
    width: 100px;
    flex-shrink: 0;
}
.n2-desc-strong { color: #f97316; font-weight: 700; }
.n2-desc-moderate { color: #facc15; font-weight: 600; }
.n2-desc-weak { color: #64748b; }

/* Stat tiles grid */
.dt-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.dt-stat-tile {
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    text-align: center;
}
.dt-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #e2e8f0;
}
.dt-stat-label {
    font-size: 9px;
    color: #64748b;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dt-stat-tile.stratified-yes { border-color: rgba(220,38,38,0.3); background: rgba(220,38,38,0.06); }
.dt-stat-tile.stratified-no { border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.06); }
/* Compound risk cards */
.dt-compound-card {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dt-compound-detail {
    font-size: 10px;
    color: #94a3b8;
    flex: 1;
}
.dt-compound-detail span { display: block; margin-bottom: 2px; }

/* ── Buoys Panel ──────────────────────────────────────────── */
#buoys-panel {
    top: 100px;
}
#buoys-panel .panel-title {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
#buoys-list {
    margin-top: 8px;
}
.buoy-card {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.buoy-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}
.buoy-card.alarm-healthy {
    border-left: 3px solid #22c55e;
    background: rgba(34, 197, 94, 0.06);
}
.buoy-card.alarm-high {
    border-left: 3px solid #f59e0b;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.35);
}
.buoy-card.alarm-high:hover {
    background: rgba(245, 158, 11, 0.22);
}
.buoy-card.alarm-critical {
    border-left: 3px solid #dc2626;
    background: rgba(220, 38, 38, 0.14);
    border-color: rgba(220, 38, 38, 0.35);
}
.buoy-card.alarm-critical:hover {
    background: rgba(220, 38, 38, 0.22);
}
.buoy-card-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.buoy-card-info {
    flex: 1;
    min-width: 0;
}
.buoy-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.buoy-card-alarm {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}
.buoy-card-alarm.alarm-healthy {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
}
.buoy-card-alarm.alarm-high {
    color: #eab308;
    background: rgba(234, 179, 8, 0.15);
}
.buoy-card-alarm.alarm-critical {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}
.buoy-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 8px;
}
.buoy-card-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #94a3b8;
}
.buoy-card-stat svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}
.buoy-card-stat .stat-value {
    color: #cbd5e1;
    font-weight: 500;
}

/* ── Layer Buttons ─────────────────────────────────────────── */
.layer-btn-group {
    display: flex;
    flex-direction: row;
    gap: 4px;
}
.layer-btn {
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;

}
.layer-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
}
.layer-btn.active {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.5);
    color: #60a5fa;
}

/* ── Toggle Switches ───────────────────────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    cursor: pointer;
    font-size: 12px;
    color: #94a3b8;
}
.toggle-row input[type="checkbox"] {
    display: none;
}
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #64748b;
    transition: all 0.2s;
}
.toggle-row input:checked + .toggle-switch {
    background: rgba(37, 99, 235, 0.5);
}
.toggle-row input:checked + .toggle-switch::after {
    left: 18px;
    background: #60a5fa;
}

/* ── Intensity Legend ──────────────────────────────────────── */
.legend-gradient {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #00ff00, #adff2f, #ffff00, #ffa500, #ff4500, #ff0000, #8b0000);
    margin-bottom: 4px;
}
.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #64748b;
}

/* ── Timeline Panel (above events panel) ───────────────────── */
.timeline-panel-left {
    position: fixed;
    top: 100px;
    left: 16px;
    width: 270px;
    z-index: 1000;
    padding: 0;
}

/* ── Timeline Slider ───────────────────────────────────────── */
.timeline-slider-wrap {
    position: relative;
    height: 28px;
    margin-bottom: 8px;
}
.timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    background: rgba(255,255,255,0.06);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}
/* Hide native thumbs — custom overlay used instead */
.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: grab;
}
.timeline-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
}
.timeline-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: grab;
}
.timeline-slider::-moz-range-thumb:active {
    cursor: grabbing;
}
.timeline-slider::-moz-range-track {
    height: 12px;
    border-radius: 6px;
    background: transparent;
}
/* Custom FA icon thumb overlay */
.timeline-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fde68a, #fbbf24 50%, #d97706);
    border: 2px solid rgba(0,0,0,0.25);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.5), 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: box-shadow 0.1s ease;
    z-index: 1;
}
.timeline-thumb i {
    font-size: 10px;
    color: #422006;
    margin-left: 2px;
}
.timeline-thumb.playing i {
    margin-left: 0;
}
.timeline-slider-wrap:hover .timeline-thumb {
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.7), 0 2px 8px rgba(0,0,0,0.3);
}
.timeline-thumb.pulse-hint {
    animation: slider-thumb-pulse 2s ease-in-out infinite;
}
@keyframes slider-thumb-pulse {
    0%   { box-shadow: 0 0 12px rgba(251, 191, 36, 0.5), 0 2px 6px rgba(0,0,0,0.3); transform: translate(-50%, -50%) scale(1); }
    50%  { box-shadow: 0 0 28px rgba(251, 191, 36, 0.9), 0 0 50px rgba(251, 191, 36, 0.3); transform: translate(-50%, -50%) scale(1.3); }
    100% { box-shadow: 0 0 12px rgba(251, 191, 36, 0.5), 0 2px 6px rgba(0,0,0,0.3); transform: translate(-50%, -50%) scale(1); }
}

#timeline-date-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #f7f7f7;
    background: rgba(22, 22, 22, 0.2);
    border: 1px solid rgba(11, 11, 11, 0.2);
    border-radius: 10px;
    padding: 3px 10px;
    margin-top: 10px;
    text-align:center;
    width: 100%;
}

/* ── Loading Overlay ───────────────────────────────────────── */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(8, 12, 24, 0.96);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#loading-content {
    text-align: center;
    max-width: 360px;
}
.loading-logo {
    height: 64px;
    margin-bottom: 32px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.08);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}
.small-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin: 0 0 0 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
#loading-text {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 16px;
    min-height: 20px;
}
.loading-progress-track {
    width: 280px;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}
#loading-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ── Error Overlay ─────────────────────────────────────────── */
#error-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(8, 12, 24, 0.96);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#error-content {
    text-align: center;
    max-width: 400px;
}
#error-text {
    font-size: 15px;
    color: #94a3b8;
    margin-bottom: 24px;
    line-height: 1.6;
}
.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ── User Bar ──────────────────────────────────────────────── */
#user-bar {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(12, 17, 30, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 6px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
#user-name {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#btn-logout {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
#btn-logout:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-glass {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.btn-glass:hover { background: #1d4ed8; }
.btn-glass-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
}
.btn-glass-outline:hover {
    background: rgba(255,255,255,0.05);
    color: #e2e8f0;
}
.btn-glass-danger {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-glass-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fca5a5;
}

/* ── Small Loader ──────────────────────────────────────────── */
#small-loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
}
.small-loader-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(12, 17, 30, 0.88);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
    color: #94a3b8;
}

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 100px;
    right: 16px;
    z-index: 1800;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast-msg {
    background: rgba(12, 17, 30, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: #94a3b8;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    #logo-container {
        left: 50%;
        transform: translateX(-50%);
    }
    #logo-container img {
        height: 36px;
    }

    /* Hide AI panel on mobile */
    .ai-slide-panel {
        display: none !important;
    }

    /* Make panels responsive on mobile */
    .side-panel,
    .timeline-panel-left,
    #buoys-panel {
        width: calc(100vw - 32px);
        max-width: 190px;
    }


    /* Buoy modal: stack image above status table */
    .buoy-info-header {
        flex-direction: column;
        gap: 12px;
    }
    .buoy-image-col {
        flex: none;
    }
    .buoy-image-col img {
        width: 100%;
        max-height: 180px;
    }
    .buoy-status-label {
        min-width: 90px;
    }

    #user-bar {
        top: 20px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        padding: 4px 10px;
    }
    #user-name {
        max-width: 120px;
        font-size: 11px;
    }
}

/* ── User Bar Icon Buttons ─────────────────────────────────── */
.user-bar-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 13px;
    transition: all 0.2s;
}
.user-bar-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Tooltips ─────────────────────────────────────────────── */
.app-tooltip {
    position: fixed;
    z-index: 3000;
    padding: 6px 12px;
    background: rgba(12, 17, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.app-tooltip::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid rgba(255, 255, 255, 0.1);
}

/* ── Tips & Tricks Modal ──────────────────────────────────── */
.tips-modal-content {
    width: 380px;
    text-align: center;
}
.tips-body {
    padding: 16px 0 20px;
}
.tips-icon {
    font-size: 36px;
    color: #60a5fa;
    margin-bottom: 16px;
}
.tips-title {
    font-size: 15px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 10px;
}
.tips-text {
    font-size: 13px;
    line-height: 1.7;
    color: #94a3b8;
    margin: 0;
}
.tips-counter {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}
.tips-nav {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.tips-nav .btn-glass,
.tips-nav .btn-glass-outline {
    flex: 1;
    margin-top: 0;
    padding: 8px 16px;
    font-size: 12px;
}
.tips-startup-toggle {
    margin-top: 12px;
    padding-top: 8px;
    justify-content: center;
    gap: 10px;
}

/* ── Modal Overlay ────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}
.modal-content {
    position: relative;
    width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1051;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.modal-title {
    font-weight: 600;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.91);
    font-size: 1rem;
    margin: 0;
}
.modal-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover {
    color: #e2e8f0;
}

/* ── AOI List Items ───────────────────────────────────────── */
.aoi-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}
.aoi-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}
.aoi-color-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.aoi-item-info {
    flex: 1;
    min-width: 0;
}
.aoi-item-name {
    font-size: 12px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aoi-item-radius {
    font-size: 10px;
    color: #64748b;
}
.aoi-item-modules {
    font-size: 10px;
    color: #60a5fa;
    margin-top: 1px;
}
.aoi-item-modules i {
    font-size: 9px;
    margin-right: 1px;
}
.aoi-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.aoi-item-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 12px;
    transition: all 0.2s;
}
.aoi-item-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}
.aoi-item-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}
.aoi-empty {
    text-align: center;
    padding: 20px 0;
    font-size: 12px;
    color: #64748b;
}

/* ── AOI Form ─────────────────────────────────────────────── */
.aoi-form-group {
    margin-bottom: 14px;
}
.aoi-form-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748b;
    margin-bottom: 6px;
}
.aoi-form-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.aoi-form-input:focus {
    border-color: rgba(96, 165, 250, 0.5);
}
.aoi-form-range {
    width: 100%;
    accent-color: #60a5fa;
}
.aoi-form-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.aoi-form-select:focus {
    border-color: rgba(96, 165, 250, 0.5);
}
.aoi-form-select option {
    background: #1a1f2e;
    color: #e2e8f0;
}
.aoi-form-color {
    width: 40px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    padding: 1px;
}
/* ── AOI Module Options ── */
.aoi-module-section {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    margin-top: 10px;
    overflow: hidden;
}
.aoi-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
}
.aoi-module-header.aoi-module-enabled {
    background: rgba(96, 165, 250, 0.16);
}
.aoi-module-header.aoi-module-disabled {
    background: rgba(239, 68, 68, 0.16);
}
.aoi-module-chevron {
    font-size: 10px;
    color: #64748b;
    transition: transform 0.2s;
}
.aoi-module-chevron.open {
    transform: rotate(90deg);
}
.aoi-module-name {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}
.aoi-module-body {
    padding: 8px 12px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.aoi-module-body .aoi-form-group {
    margin-bottom: 8px;
}
.aoi-module-body .aoi-form-group:last-child {
    margin-bottom: 0;
}

.aoi-form-input.error {
    border-color: rgba(239, 68, 68, 0.6);
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.aoi-name-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
    padding: 8px 0;
}
.aoi-name-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(96, 165, 250, 0.3);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Placement Mode ───────────────────────────────────────── */
.placement-mode .leaflet-container {
    cursor: crosshair !important;
}

/* ── AOI Marker Icon ──────────────────────────────────────── */
.aoi-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* ── Buoy Map Markers ─────────────────────────────────────── */
.buoy-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    transition: transform 0.15s ease;
    overflow: visible;
    position: relative;
}
.buoy-marker-icon:hover {
    transform: scale(1.2);
}
.buoy-marker-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
    position: relative;
    z-index: 2;
}

/* ── Buoy Pulse Rings ────────────────────────────────────── */
.buoy-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin-top: -18px;
    margin-left: -18px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    z-index: 1;
    animation: buoy-pulse 2.8s ease-out infinite;
    pointer-events: none;
}
.buoy-pulse-ring.ring-2 { animation-delay: 0.9s; }
.buoy-pulse-ring.ring-3 { animation-delay: 1.8s; }
.pulse-healthy { color: #22c55e; }
.pulse-high    { color: #eab308; }
.pulse-critical { color: #ef4444; }
/* Dodge tide risk pulse colors */
.pulse-low         { color: #fb923c; }
.pulse-medium      { color: #f97316; }
.pulse-high-dt     { color: #dc2626; }
.pulse-critical-dt { color: #991b1b; }
/* AOI pulse rings — same animation as buoy rings */
.aoi-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin-top: -18px;
    margin-left: -18px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    z-index: 0;
    animation: buoy-pulse 2.8s ease-out infinite;
    pointer-events: none;
}
.aoi-pulse-ring.ring-2 { animation-delay: 0.9s; }
.aoi-pulse-ring.ring-3 { animation-delay: 1.8s; }
.aoi-marker-icon { position: relative; overflow: visible; }
.aoi-pulse-center { position: relative; overflow: visible; }
@keyframes buoy-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(2.8);
        opacity: 0;
    }
}

/* ── Buoy Modal ──────────────────────────────────────────── */
.buoy-modal-content {
    position: relative;
    width: 580px;
    max-width: 95vw;
    max-height: 85vh;
    overflow: hidden;
    z-index: 1051;
    transition: width 0.3s ease, max-width 0.3s ease, max-height 0.3s ease;
}
.buoy-modal-content.telemetry-fullscreen {
    width: 98vw;
    max-width: 98vw;
    height: 96vh;
    max-height: 96vh;
}
.buoy-carousel-wrapper {
    position: relative;
    overflow: hidden;
}
.buoy-carousel-track {
    display: flex;
    transition: transform 0.35s ease;
}
.buoy-slide {
    min-width: 100%;
    overflow-y: auto;
    max-height: calc(85vh - 70px);
    padding: 0 4px;
}

/* Navigation arrows — positioned outside the modal */
.buoy-nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2010;
    background: rgba(12, 17, 30, 0.85);
    border: 1px solid rgba(255,255,255,0.1);
    color: #e2e8f0;
    font-size: 28px;
    line-height: 1;
    width: 40px;
    height: 52px;
    border-radius: 6px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s;
}
.buoy-nav-arrow:hover { background: rgba(30, 40, 60, 0.95); }
.buoy-nav-prev { left: max(8px, calc(50% - 342px)); }
.buoy-nav-next { right: max(8px, calc(50% - 342px)); }
.buoy-nav-counter {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}

/* Info header row */
.buoy-info-header {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}
.buoy-image-col {
    flex: 0 0 160px;
}
.buoy-image-col img {
    width: 160px;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
}
.buoy-status-col {
    flex: 1;
    min-width: 0;
}
.buoy-device-type {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #60a5fa;
    margin-bottom: 10px;
}
.buoy-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 12px;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.buoy-status-row:last-child { border-bottom: none; }
.buoy-status-icon {
    flex: 0 0 16px;
    width: 16px;
    font-size: 13px;
    text-align: center;
    color: #64748b;
}
.buoy-status-label {
    color: #64748b;
    flex: 0 0 auto;
    min-width: 110px;
}
.buoy-status-value {
    color: #e2e8f0;
    font-weight: 500;
}

/* Measurement group tabs */
.buoy-group-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 0;
}
.buoy-group-tab {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}
.buoy-group-tab:hover { color: #94a3b8; }
.buoy-group-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* Measurement tiles */
.buoy-measurements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.buoy-measurement-tile {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background 0.4s, border-color 0.4s;
}
.buoy-measurement-tile.telemetry-updated {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.3);
}
.buoy-measurement-value.telemetry-stale {
    opacity: 0.4;
    animation: stale-pulse 1.5s ease-in-out infinite;
    transition: opacity 0.4s ease;
}
@keyframes stale-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}
.buoy-measurement-tile[data-field] {
    cursor: pointer;
}
.buoy-measurement-tile[data-field]:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
}

/* ── Telemetry Chart Overlay ─────────────────────────────── */
.telemetry-chart-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background: rgba(12, 17, 30, 0.98);
    z-index: 10;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
}
.telemetry-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.telemetry-chart-device {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #64748b;
    margin-bottom: 2px;
}
.telemetry-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}
.telemetry-chart-value {
    font-size: 22px;
    font-weight: 700;
    color: #60a5fa;
    margin-left: 12px;
}
.telemetry-chart-uom {
    font-size: 12px;
    font-weight: 400;
    color: #64748b;
    margin-left: 3px;
}
.telemetry-chart-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.telemetry-chart-close:hover {
    color: #e2e8f0;
}
.telemetry-chart-body {
    flex: 1;
    padding: 12px 16px;
    min-height: 0;
    position: relative;
}
.telemetry-chart-body canvas {
    width: 100% !important;
    height: 100% !important;
}
.telemetry-chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 12px;
    background: rgba(12, 17, 30, 0.98);
    z-index: 2;
}
.telemetry-chart-icon {
    margin-right: 4px;
    color: #60a5fa;
}
.telemetry-chart-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.chart-window-btn {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}
.chart-window-btn:hover {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
}
.chart-window-btn.active {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.5);
    color: #60a5fa;
}
.chart-pause-btn {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
}
.chart-pause-btn:hover {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
}
.chart-pause-btn.paused {
    background: rgba(234, 179, 8, 0.15);
    border-color: rgba(234, 179, 8, 0.4);
    color: #eab308;
}

/* ── Chart Legend Row ── */
.chart-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-wrap: wrap;
    position: relative;
}
.chart-legend-items {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.chart-legend-item.hidden {
    opacity: 0.35;
}
.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.chart-legend-remove {
    background: none;
    border: none;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.chart-legend-remove:hover {
    color: #ef4444;
}
.chart-add-series-btn {
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    background: rgba(96, 165, 250, 0.08);
    color: #60a5fa;
    cursor: pointer;
    transition: all 0.2s;
}
.chart-add-series-btn:hover {
    background: rgba(96, 165, 250, 0.15);
}
.chart-add-series-dropdown {
    position: absolute;
    top: 100%;
    left: 16px;
    z-index: 20;
    background: rgba(12, 17, 30, 0.98);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.chart-series-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    font-size: 12px;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.15s;
}
.chart-series-option:hover {
    background: rgba(255,255,255,0.05);
}
.chart-series-option.disabled {
    color: #475569;
    cursor: default;
}
.chart-series-option.disabled:hover {
    background: none;
}
.chart-series-option-value {
    color: #64748b;
    font-size: 11px;
}

/* ── Analytics Toolbar ── */
.chart-analytics-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-wrap: wrap;
}
.chart-analytics-pill {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}
.chart-analytics-pill:hover {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
}
.chart-analytics-pill.active {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.5);
    color: #60a5fa;
}
.chart-ma-window {
    display: flex;
    gap: 4px;
    align-items: center;
}
.chart-ma-btn {
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: #64748b;
    cursor: pointer;
}
.chart-ma-btn.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
    color: #60a5fa;
}
.chart-threshold-pills {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.chart-threshold-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid;
    background: rgba(255,255,255,0.03);
}
.chart-threshold-pill-edit,
.chart-threshold-pill-delete {
    background: none;
    border: none;
    color: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 0 1px;
    line-height: 1;
    opacity: 0.6;
}
.chart-threshold-pill-edit:hover { opacity: 1; }
.chart-threshold-pill-delete:hover { opacity: 1; color: #ef4444; }
.chart-threshold-save,
.chart-threshold-cancel {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
}
.chart-threshold-save {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.3);
}
.chart-threshold-save:hover { background: rgba(96, 165, 250, 0.25); }
.chart-threshold-cancel {
    background: rgba(255,255,255,0.03);
    color: #94a3b8;
}
.chart-threshold-cancel:hover { background: rgba(255,255,255,0.07); }
.chart-threshold-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}
.chart-threshold-select, .chart-threshold-input {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: #e2e8f0;
}
.chart-threshold-input {
    width: 80px;
}
.btn-reset-zoom {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    cursor: pointer;
    margin-left: auto;
}
.btn-reset-zoom:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ── Stats Bar ── */
.chart-stats-bar {
    padding: 8px 16px;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.chart-stats-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.chart-stats-label {
    font-weight: 600;
    min-width: 100px;
}
.chart-correlation {
    padding: 4px 0;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.chart-corr-strong { color: #4ade80; }
.chart-corr-moderate { color: #f59e0b; }
.chart-corr-weak { color: #64748b; }
.chart-stats-export {
    padding: 2px 10px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: #94a3b8;
    cursor: pointer;
}
.chart-stats-export:hover {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
}

.buoy-measurement-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.buoy-measurement-icon {
    width: 22px;
    font-size: 18px;
    text-align: center;
    color: #60a5fa;
    flex-shrink: 0;
}
.buoy-measurement-name {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin-top: 2px;
}
.buoy-measurement-value {
    font-size: 22px;
    font-weight: 700;
    color: #e2e8f0;
    line-height: 1.1;
}
.buoy-measurement-uom {
    font-size: 11px;
    font-weight: 400;
    color: #64748b;
    margin-left: 2px;
}

/* ── Buoy Alarm Items (modal) ─────────────────────────────── */
.buoy-alarms-section {
    margin-bottom: 8px;
}
.buoy-alarm-item {
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.buoy-alarm-item.alarm-high {
    background: rgba(234, 179, 8, 0.08);
    border-left: 3px solid #eab308;
}
.buoy-alarm-item.alarm-critical {
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid #ef4444;
}
.buoy-alarm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.buoy-alarm-severity {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.alarm-high .buoy-alarm-severity { color: #eab308; }
.alarm-critical .buoy-alarm-severity { color: #ef4444; }
.buoy-alarm-date {
    font-size: 9px;
    color: #64748b;
}
.buoy-alarm-name {
    font-size: 11px;
    font-weight: 600;
    color: #e2e8f0;
}
.buoy-alarm-status {
    font-size: 9px;
    color: #94a3b8;
    margin-top: 1px;
}

/* ── Leaflet Overrides ─────────────────────────────────────── */
.leaflet-control-zoom a {
    background: rgba(12, 17, 30, 0.8) !important;
    color: #e2e8f0 !important;
    border-color: rgba(255,255,255,0.1) !important;
    backdrop-filter: blur(8px);
}
.leaflet-control-zoom a:hover {
    background: rgba(30, 40, 60, 0.9) !important;
}
.leaflet-control-attribution {
    background: rgba(12, 17, 30, 0.6) !important;
    color: #64748b !important;
    font-size: 9px !important;
}
.leaflet-control-attribution a { color: #94a3b8 !important; }
