/* ==========================================================================
   Wind + Solar Power Forecasting Dashboard
   Main Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. FONTS
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   2. CSS CUSTOM PROPERTIES  --  Dark Mode (default)
   -------------------------------------------------------------------------- */
:root {
    /* Background */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-card-solid: #1e293b;
    --bg-overlay: rgba(15, 23, 42, 0.6);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accents */
    --accent-cyan: #22d3ee;
    --accent-amber: #f59e0b;
    --accent-emerald: #34d399;
    --accent-rose: #fb7185;
    --accent-violet: #a78bfa;

    /* Accent subdued (for backgrounds, glows) */
    --accent-cyan-dim: rgba(34, 211, 238, 0.15);
    --accent-amber-dim: rgba(245, 158, 11, 0.15);
    --accent-emerald-dim: rgba(52, 211, 153, 0.15);
    --accent-rose-dim: rgba(251, 113, 133, 0.15);
    --accent-violet-dim: rgba(167, 139, 250, 0.15);

    /* Borders */
    --border: rgba(148, 163, 184, 0.15);
    --border-strong: rgba(148, 163, 184, 0.3);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-cyan: 0 0 20px rgba(34, 211, 238, 0.3);
    --shadow-glow-amber: 0 0 20px rgba(245, 158, 11, 0.3);
    --shadow-glow-emerald: 0 0 20px rgba(52, 211, 153, 0.3);
    --shadow-glow-rose: 0 0 20px rgba(251, 113, 133, 0.3);

    /* Layout */
    --nav-height: 56px;
    --sidebar-width: 280px;
    --detail-panel-width: 420px;
    --time-bar-height: 64px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 9999px;

    /* Typography */
    --font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-data: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Z-index layers */
    --z-map: 1;
    --z-canvas: 10;
    --z-panels: 500;
    --z-nav: 1000;
    --z-overlay: 2000;
    --z-tooltip: 3000;
}

/* --------------------------------------------------------------------------
   3. CSS CUSTOM PROPERTIES  --  Light Mode
   -------------------------------------------------------------------------- */
body.light-mode {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-solid: #ffffff;
    --bg-overlay: rgba(248, 250, 252, 0.6);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: rgba(15, 23, 42, 0.1);
    --border-strong: rgba(15, 23, 42, 0.2);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow-cyan: 0 0 20px rgba(34, 211, 238, 0.2);
    --shadow-glow-amber: 0 0 20px rgba(245, 158, 11, 0.2);
    --shadow-glow-emerald: 0 0 20px rgba(52, 211, 153, 0.2);
    --shadow-glow-rose: 0 0 20px rgba(251, 113, 133, 0.2);

    --accent-cyan-dim: rgba(34, 211, 238, 0.1);
    --accent-amber-dim: rgba(245, 158, 11, 0.1);
    --accent-emerald-dim: rgba(52, 211, 153, 0.1);
    --accent-rose-dim: rgba(251, 113, 133, 0.1);
    --accent-violet-dim: rgba(167, 139, 250, 0.1);
}

/* --------------------------------------------------------------------------
   4. RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
    line-height: 1.5;
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--text-primary);
}

button {
    font-family: var(--font-ui);
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input,
select,
textarea {
    font-family: var(--font-ui);
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
}

img {
    max-width: 100%;
    display: block;
}

ul, ol {
    list-style: none;
}

/* --------------------------------------------------------------------------
   5. SCROLLBAR STYLING
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

/* --------------------------------------------------------------------------
   6. GLOBE CONTAINER (full background)
   -------------------------------------------------------------------------- */
#globe-container,
.globe-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-map);
    overflow: hidden;
}

/* Hide Cesium default UI chrome */
.cesium-viewer-toolbar,
.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer,
.cesium-viewer-bottom,
.cesium-credit-logoContainer { display: none !important; }
.cesium-credit-textContainer { font-size: 9px; opacity: 0.4; }
.cesium-widget canvas { outline: none; }

/* --------------------------------------------------------------------------
   7. CANVAS OVERLAYS (wind particles, heatmaps, etc.)
   -------------------------------------------------------------------------- */
.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-canvas);
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   8. TOP NAVIGATION BAR
   -------------------------------------------------------------------------- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: var(--z-nav);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav-brand .brand-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.nav-brand .brand-separator {
    width: 1px;
    height: 20px;
    background: var(--border-strong);
    margin: 0 4px;
}

.nav-brand .brand-sub {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --------------------------------------------------------------------------
   9. VIEW TOGGLE (Wind / Solar / Combined pill buttons)
   -------------------------------------------------------------------------- */
.view-toggle {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 3px;
    gap: 2px;
}

.view-toggle button {
    padding: 6px 18px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    transition: all var(--transition-base);
    position: relative;
    white-space: nowrap;
}

.view-toggle button:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.view-toggle button.active {
    color: var(--bg-primary);
    background: var(--accent-cyan);
    font-weight: 600;
    box-shadow: var(--shadow-glow-cyan);
}

.view-toggle button.active[data-view="solar"] {
    background: var(--accent-amber);
    box-shadow: var(--shadow-glow-amber);
}

.view-toggle button.active[data-view="combined"] {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-amber));
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.2), 0 0 20px rgba(245, 158, 11, 0.2);
}

/* --------------------------------------------------------------------------
   10. LEFT SIDEBAR
   -------------------------------------------------------------------------- */
.sidebar-left {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: var(--time-bar-height);
    width: var(--sidebar-width);
    z-index: var(--z-panels);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-base), width var(--transition-base);
    box-shadow: var(--shadow-lg);
}

.sidebar-left.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Floating "show filters" pill that appears when the sidebar is collapsed.
   Positioned on the top-left of the map area, above other overlays. */
.sidebar-reopen-btn {
    position: fixed;
    left: 14px;
    top: calc(var(--nav-height) + 14px);
    z-index: calc(var(--z-panels) + 1);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    font: 600 0.78rem/1 "DM Sans", sans-serif;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}
.sidebar-reopen-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: translateY(-1px);
}
.sidebar-reopen-btn[hidden] { display: none !important; }
.sidebar-reopen-btn svg { color: var(--accent-cyan); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding-bottom: 4px;
}

/* --------------------------------------------------------------------------
   11. RIGHT DETAIL PANEL
   -------------------------------------------------------------------------- */
.detail-panel {
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: var(--time-bar-height);
    width: var(--detail-panel-width);
    z-index: var(--z-panels);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.detail-panel.open {
    transform: translateX(0);
}

.detail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.detail-panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-panel-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.detail-panel-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-panel-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-panel-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   12. BOTTOM TIME BAR
   -------------------------------------------------------------------------- */
.time-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--time-bar-height);
    z-index: var(--z-nav);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.time-bar-label {
    font-family: var(--font-data);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 120px;
}

.time-bar-label strong {
    color: var(--text-primary);
    font-weight: 600;
}

.time-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    outline: none;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-cyan);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-glow-cyan);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 28px rgba(34, 211, 238, 0.5);
}

.time-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-cyan);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-glow-cyan);
}

.time-bar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-bar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.time-bar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.time-bar-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

/* --------------------------------------------------------------------------
   13. STAT CARDS (glassmorphism)
   -------------------------------------------------------------------------- */
.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-cyan), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.wind::before {
    background: linear-gradient(90deg, var(--accent-cyan), transparent);
}

.stat-card.solar::before {
    background: linear-gradient(90deg, var(--accent-amber), transparent);
}

.stat-card.combined::before {
    background: linear-gradient(90deg, var(--accent-emerald), transparent);
}

.stat-value {
    font-family: var(--font-data);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.stat-value .stat-unit {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-change {
    font-family: var(--font-data);
    font-size: 0.7rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
}

.stat-change.up {
    color: var(--accent-emerald);
}

.stat-change.down {
    color: var(--accent-rose);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

/* --------------------------------------------------------------------------
   14. FARM MARKERS (map markers)
   -------------------------------------------------------------------------- */
.farm-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--accent-cyan);
    background: var(--accent-cyan-dim);
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease-out, box-shadow var(--transition-base), border-color var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    transform-origin: center center;
}

.farm-marker::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid transparent;
    transition: border-color var(--transition-base);
}

.farm-marker:hover {
    transform: scale(1.3);
    box-shadow: var(--shadow-glow-cyan);
}

.farm-marker:hover::after {
    border-color: var(--accent-cyan);
}

.farm-marker.solar {
    border-color: var(--accent-amber);
    background: var(--accent-amber-dim);
}

.farm-marker.solar:hover {
    box-shadow: var(--shadow-glow-amber);
}

.farm-marker.solar:hover::after {
    border-color: var(--accent-amber);
}

.farm-marker.active {
    transform: scale(1.4);
    box-shadow: var(--shadow-glow-cyan);
    z-index: 10;
}

.farm-marker.solar.active {
    box-shadow: var(--shadow-glow-amber);
}

.farm-marker-inner {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
}

.farm-marker.solar .farm-marker-inner {
    background: var(--accent-amber);
}

/* Pulsing animation for active / alerted markers */
@keyframes marker-pulse {
    0%   { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

.farm-marker.pulsing::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent-cyan);
    animation: marker-pulse 1.8s ease-out infinite;
}

.farm-marker.solar.pulsing::before {
    border-color: var(--accent-amber);
}

/* --------------------------------------------------------------------------
   15. REGION FILTER BUTTONS
   -------------------------------------------------------------------------- */
.region-btn {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition-base);
    white-space: nowrap;
}

.region-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.region-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.region-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* --------------------------------------------------------------------------
   16. MODEL SELECTOR
   -------------------------------------------------------------------------- */
.model-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.model-selector select {
    appearance: none;
    -webkit-appearance: none;
    padding: 7px 32px 7px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--font-data);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 160px;
}

.model-selector select:hover {
    border-color: var(--border-strong);
}

.model-selector select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px var(--accent-cyan-dim);
}

.model-selector::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   17. CHART CONTAINER
   -------------------------------------------------------------------------- */
.chart-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    padding: 16px;
    overflow: hidden;
}

.chart-container canvas {
    width: 100% !important;
    max-height: 240px;
}

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

.chart-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-subtitle {
    font-family: var(--font-data);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   18. TYPE BADGES (Wind / Solar)
   -------------------------------------------------------------------------- */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.type-badge.wind {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.3);
}

.type-badge.solar {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.type-badge.combined {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

/* --------------------------------------------------------------------------
   19. LOADING OVERLAY
   -------------------------------------------------------------------------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    transition: opacity var(--transition-slow);
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-family: var(--font-data);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.loading-bar {
    width: 240px;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-amber));
    border-radius: var(--radius-pill);
    animation: loading-progress 2s ease-in-out infinite;
}

@keyframes loading-progress {
    0%   { width: 0%; transform: translateX(0); }
    50%  { width: 60%; }
    100% { width: 100%; transform: translateX(0); }
}

/* --------------------------------------------------------------------------
   20. SEARCH INPUT
   -------------------------------------------------------------------------- */
.search-input {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    font-size: 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.search-input input::placeholder {
    color: var(--text-muted);
}

.search-input input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px var(--accent-cyan-dim);
}

.search-input .search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   21. RISK BADGES (Icing / Thermal / Clipping)
   -------------------------------------------------------------------------- */
.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.risk-badge.low {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.risk-badge.medium {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.risk-badge.high {
    background: var(--accent-rose-dim);
    color: var(--accent-rose);
    border: 1px solid rgba(251, 113, 133, 0.3);
}

.risk-badge .risk-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.risk-badge.low .risk-dot {
    background: var(--accent-emerald);
}

.risk-badge.medium .risk-dot {
    background: var(--accent-amber);
}

.risk-badge.high .risk-dot {
    background: var(--accent-rose);
    animation: risk-blink 1.5s ease-in-out infinite;
}

@keyframes risk-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* --------------------------------------------------------------------------
   22. FARM LIST ITEMS
   -------------------------------------------------------------------------- */
.farm-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.farm-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.farm-list-item:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.farm-list-item.active {
    background: var(--accent-cyan-dim);
    border-color: rgba(34, 211, 238, 0.25);
}

.farm-list-item.solar.active {
    background: var(--accent-amber-dim);
    border-color: rgba(245, 158, 11, 0.25);
}

.farm-list-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.farm-list-item.solar .farm-list-item-icon {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
}

.farm-list-item-info {
    flex: 1;
    min-width: 0;
}

.farm-list-item-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.farm-list-item-meta {
    font-family: var(--font-data);
    font-size: 0.68rem;
    color: var(--text-muted);
}

.farm-list-item-value {
    font-family: var(--font-data);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   23. TOOLTIP (map hover tooltip)
   -------------------------------------------------------------------------- */
.tooltip {
    position: absolute;
    z-index: var(--z-tooltip);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    max-width: 280px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}

.tooltip-row-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.tooltip-row-value {
    font-family: var(--font-data);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tooltip-arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--bg-card-solid);
    border-right: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
}

/* --------------------------------------------------------------------------
   24. MAP LEGEND
   -------------------------------------------------------------------------- */
.legend {
    position: absolute;
    bottom: calc(var(--time-bar-height) + 16px);
    right: 16px;
    z-index: var(--z-panels);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    min-width: 160px;
    box-shadow: var(--shadow-md);
}

.legend-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    font-size: 0.73rem;
    color: var(--text-secondary);
}

.legend-gradient {
    width: 100%;
    height: 8px;
    border-radius: var(--radius-pill);
    margin: 8px 0 4px;
}

.legend-gradient-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-data);
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   25. GENERAL BUTTON STYLES
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-color: var(--accent-cyan);
    font-weight: 600;
}

.btn-primary:hover {
    background: #06b6d4;
    border-color: #06b6d4;
    color: var(--bg-primary);
    box-shadow: var(--shadow-glow-cyan);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.72rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   26. THEME TOGGLE BUTTON
   -------------------------------------------------------------------------- */
.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   27. DATA TABLE (inside detail panel)
   -------------------------------------------------------------------------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.data-table th {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .data-value {
    font-family: var(--font-data);
    font-weight: 500;
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   28. TABS (for detail panel sub-sections)
   -------------------------------------------------------------------------- */
.tab-group {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.tab-btn {
    padding: 10px 16px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --------------------------------------------------------------------------
   29. NOTIFICATION / ALERT BANNER
   -------------------------------------------------------------------------- */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
}

.alert-banner.info {
    background: var(--accent-cyan-dim);
    border: 1px solid rgba(34, 211, 238, 0.25);
    color: var(--accent-cyan);
}

.alert-banner.warning {
    background: var(--accent-amber-dim);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: var(--accent-amber);
}

.alert-banner.danger {
    background: var(--accent-rose-dim);
    border: 1px solid rgba(251, 113, 133, 0.25);
    color: var(--accent-rose);
}

.alert-banner.success {
    background: var(--accent-emerald-dim);
    border: 1px solid rgba(52, 211, 153, 0.25);
    color: var(--accent-emerald);
}

/* --------------------------------------------------------------------------
   30. STATUS INDICATORS
   -------------------------------------------------------------------------- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--accent-emerald);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.status-dot.offline {
    background: var(--text-muted);
}

.status-dot.warning {
    background: var(--accent-amber);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.status-dot.error {
    background: var(--accent-rose);
    box-shadow: 0 0 6px rgba(251, 113, 133, 0.5);
    animation: risk-blink 1.5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   31. PROGRESS BAR
   -------------------------------------------------------------------------- */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--accent-cyan);
    transition: width var(--transition-base);
}

.progress-bar-fill.amber {
    background: var(--accent-amber);
}

.progress-bar-fill.emerald {
    background: var(--accent-emerald);
}

.progress-bar-fill.rose {
    background: var(--accent-rose);
}

/* --------------------------------------------------------------------------
   32. CAPACITY FACTOR MINI GAUGE
   -------------------------------------------------------------------------- */
.capacity-gauge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.capacity-gauge-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.capacity-gauge-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width var(--transition-base);
}

.capacity-gauge-value {
    font-family: var(--font-data);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 36px;
    text-align: right;
}

/* --------------------------------------------------------------------------
   33. UTILITY CLASSES
   -------------------------------------------------------------------------- */
.font-data {
    font-family: var(--font-data);
}

.font-ui {
    font-family: var(--font-ui);
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-cyan { color: var(--accent-cyan); }
.text-amber { color: var(--accent-amber); }
.text-emerald { color: var(--accent-emerald); }
.text-rose { color: var(--accent-rose); }
.text-violet { color: var(--accent-violet); }

.bg-cyan-dim { background: var(--accent-cyan-dim); }
.bg-amber-dim { background: var(--accent-amber-dim); }
.bg-emerald-dim { background: var(--accent-emerald-dim); }
.bg-rose-dim { background: var(--accent-rose-dim); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   34. DIVIDERS
   -------------------------------------------------------------------------- */
.divider {
    width: 100%;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.divider-vertical {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    margin: 0 4px;
}

/* --------------------------------------------------------------------------
   35. ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slide-in-right {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

@keyframes slide-in-left {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

@keyframes slide-in-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@keyframes scale-in {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.animate-fade-in    { animation: fade-in 0.3s ease forwards; }
.animate-slide-up   { animation: slide-in-up 0.3s ease forwards; }
.animate-scale-in   { animation: scale-in 0.3s ease forwards; }

/* --------------------------------------------------------------------------
   36. RESPONSIVE  --  Tablet (max-width: 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
        --detail-panel-width: 360px;
    }

    .nav-brand .brand-sub {
        display: none;
    }

    .nav-brand .brand-separator {
        display: none;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .legend {
        bottom: calc(var(--time-bar-height) + 12px);
        right: 12px;
    }

    .time-bar {
        padding: 0 12px;
        gap: 10px;
    }

    .time-bar-label {
        min-width: 100px;
        font-size: 0.7rem;
    }
}

/* --------------------------------------------------------------------------
   37. RESPONSIVE  --  Mobile (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    :root {
        --nav-height: 48px;
        --sidebar-width: 100vw;
        --detail-panel-width: 100vw;
        --time-bar-height: 56px;
    }

    .nav-bar {
        padding: 0 12px;
    }

    .nav-brand {
        font-size: 0.9rem;
    }

    .nav-center {
        display: none;
    }

    .sidebar-left {
        bottom: var(--time-bar-height);
        border-right: none;
        border-radius: 0;
    }

    .sidebar-left.collapsed {
        transform: translateX(-100%);
    }

    .detail-panel {
        width: 100vw;
        border-left: none;
    }

    .view-toggle {
        position: fixed;
        top: calc(var(--nav-height) + 8px);
        left: 50%;
        transform: translateX(-50%);
        z-index: var(--z-panels);
        box-shadow: var(--shadow-md);
    }

    .view-toggle button {
        padding: 6px 14px;
        font-size: 0.75rem;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .time-bar {
        padding: 0 10px;
        gap: 8px;
    }

    .time-bar-label {
        min-width: auto;
        font-size: 0.65rem;
    }

    .time-bar-controls {
        gap: 4px;
    }

    .time-bar-btn {
        width: 28px;
        height: 28px;
    }

    .legend {
        bottom: calc(var(--time-bar-height) + 8px);
        right: 8px;
        left: 8px;
        min-width: auto;
    }

    .chart-container canvas {
        max-height: 180px;
    }

    .farm-list-item {
        padding: 8px 10px;
    }

    .tooltip {
        max-width: 220px;
    }

    .detail-panel-body {
        padding: 16px;
    }
}

/* --------------------------------------------------------------------------
   38. RESPONSIVE  --  Small Mobile (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .region-btn-group {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .view-toggle button {
        padding: 5px 10px;
        font-size: 0.7rem;
    }
}

/* --------------------------------------------------------------------------
   39. PRINT STYLES
   -------------------------------------------------------------------------- */
@media print {
    .nav-bar,
    .sidebar-left,
    .time-bar,
    .loading-overlay,
    .legend,
    .tooltip {
        display: none !important;
    }

    .detail-panel {
        position: static;
        width: 100%;
        transform: none;
        background: #fff;
        color: #000;
        box-shadow: none;
        border: none;
    }

    body {
        background: #fff;
        overflow: visible;
        height: auto;
    }
}

/* --------------------------------------------------------------------------
   40. REDUCED MOTION PREFERENCE
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .farm-marker:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }

    .time-slider::-webkit-slider-thumb:hover {
        transform: none;
    }
}

/* ==========================================================================
   HTML CLASS BRIDGE — Maps HTML class names to existing CSS styles
   ========================================================================== */

/* --- Main layout --- */
.main-content {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: var(--time-bar-height);
    overflow: hidden;
}

/* --- Right panel: HTML uses sidebar-right, CSS uses detail-panel --- */
.sidebar.sidebar-right {
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: var(--time-bar-height);
    width: var(--detail-panel-width);
    z-index: var(--z-panels);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.sidebar.sidebar-right.open { transform: translateX(0); }

/* --- Canvas overlays --- */
.map-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 400;
}

/* --- Map wrapper --- */
.map-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}

/* --- Map controls --- */
.map-controls {
    position: absolute;
    top: 16px; right: 16px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.map-ctrl-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}
.map-ctrl-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.map-ctrl-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}
.map-ctrl-divider {
    width: 100%; height: 1px;
    background: var(--border);
    margin: 2px 0;
}

/* --- Map coordinates --- */
.map-coords {
    position: absolute;
    bottom: 8px; left: 8px;
    z-index: 500;
    font-family: var(--font-data);
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: flex; gap: 12px;
}

/* --- Map no-results overlay --- */
.map-no-results {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    text-align: center;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    padding: 32px 40px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: none;
}
.map-no-results.visible { display: block; }
.map-no-results h3 { color: var(--text-primary); margin-bottom: 8px; }
.map-no-results p { color: var(--text-secondary); font-size: 0.85rem; }

/* --- Nav layout --- */
.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-left { flex-shrink: 0; }
.nav-right { flex-shrink: 0; }
.nav-divider {
    width: 1px; height: 24px;
    background: var(--border);
    margin: 0 4px;
}

/* --- Fleet stats in nav --- */
.fleet-stats {
    display: flex; align-items: center; gap: 2px;
    font-size: 0.75rem;
}
.stat-item {
    display: flex; flex-direction: column;
    align-items: center; padding: 0 12px;
}
.stat-divider {
    width: 1px; height: 20px;
    background: var(--border);
}
.stat-wind .stat-value { color: var(--accent-cyan); }
.stat-solar .stat-value { color: var(--accent-amber); }
.stat-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 2px;
}

/* --- Nav timestamp --- */
.nav-timestamp {
    font-family: var(--font-data);
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(34, 211, 238, 0.06);
    border: 1px solid rgba(34, 211, 238, 0.18);
    border-radius: var(--radius-sm, 6px);
}
.nav-timestamp svg { color: var(--accent-cyan); }
.nav-timestamp-sep {
    color: var(--text-muted);
    opacity: 0.6;
    padding: 0 2px;
}
.nav-model-label {
    color: var(--accent-cyan);
    font-weight: 600;
    letter-spacing: 0.02em;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- View toggle buttons --- */
.view-btn {
    padding: 6px 16px;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    background: none;
    border: none;
    white-space: nowrap;
}
.view-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.view-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    box-shadow: var(--shadow-glow-cyan);
}
.view-btn .view-icon { margin-right: 6px; }

/* --- Sidebar filter sections --- */
.filter-section {
    display: flex; flex-direction: column; gap: 10px;
}
.filter-label, .sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding-bottom: 4px;
}
.filter-header {
    display: flex; align-items: center; justify-content: space-between;
}

/* --- Search input wrapper --- */
.search-input-wrapper {
    position: relative; display: flex; align-items: center;
}
.search-input-wrapper .search-icon {
    position: absolute; left: 10px;
    color: var(--text-muted); font-size: 0.85rem;
    pointer-events: none;
}
.search-input-wrapper .search-input,
.search-input-wrapper input {
    width: 100%;
    padding: 8px 32px 8px 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    transition: border-color var(--transition-fast);
}
.search-input-wrapper input:focus {
    border-color: var(--accent-cyan);
    outline: none;
}
.search-clear {
    position: absolute; right: 8px;
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 0.85rem;
}
.search-results-count {
    font-size: 0.7rem; color: var(--text-muted);
    margin-top: 4px;
}

/* --- Region type toggle --- */
.region-type-btn {
    padding: 4px 12px;
    font-size: 0.72rem; font-weight: 500;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: none; border: none;
}
.region-type-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.region-buttons {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.filter-clear-btn {
    font-size: 0.7rem; color: var(--text-muted);
    background: none; border: none; cursor: pointer;
    padding: 4px 0;
}
.filter-clear-btn:hover { color: var(--accent-rose); }

/* --- Time aggregation toggle --- */
.time-agg-btn {
    padding: 4px 12px;
    font-size: 0.72rem; font-weight: 500;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: none; border: none;
}
.time-agg-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

/* --- Model selector --- */
.select-wrapper {
    position: relative;
}
.select-wrapper select,
.model-select {
    width: 100%;
    padding: 8px 32px 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.select-chevron {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* --- Legend inside sidebar --- */
.sidebar-body .legend {
    position: static;
    background: none; border: none;
    box-shadow: none; backdrop-filter: none;
    padding: 0;
}
.legend-marker {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-text, .legend-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- CF range --- */
.cf-range {
    display: flex; flex-direction: column; gap: 6px;
}
.cf-bar {
    position: relative;
    height: 6px; width: 100%;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.cf-fill {
    position: absolute; top: 0; height: 100%;
    background: linear-gradient(90deg, var(--accent-rose), var(--accent-amber), var(--accent-emerald));
    border-radius: var(--radius-pill);
}
.cf-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px; background: transparent;
    margin-top: -5px; position: relative; z-index: 2;
}
.cf-labels {
    display: flex; justify-content: space-between;
    font-size: 0.65rem; color: var(--text-muted);
    font-family: var(--font-data);
}

/* --- Sidebar title (h2 support) --- */
.sidebar-header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}
.sidebar-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

/* --- Time scrubber elements --- */
.scrubber-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.scrubber-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: none; border: none;
    cursor: pointer; font-size: 0.9rem;
    transition: all var(--transition-fast);
}
.scrubber-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.scrubber-play { position: relative; }
.play-icon, .pause-icon { display: flex; align-items: center; justify-content: center; }
.scrubber-speed { display: flex; gap: 4px; margin-left: 4px; }
.speed-btn {
    padding: 2px 8px; font-size: 0.65rem;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    background: none; border: none; cursor: pointer;
    transition: all var(--transition-fast);
}
.speed-btn.active { background: var(--accent-cyan-dim); color: var(--accent-cyan); }
.scrubber-track-wrapper {
    flex: 1; display: flex; align-items: center; gap: 12px;
}
.scrubber-time {
    font-family: var(--font-data);
    font-size: 0.7rem; color: var(--text-muted);
    white-space: nowrap; min-width: 80px;
}
.scrubber-time-end { text-align: right; }
.scrubber-track {
    flex: 1; position: relative; height: 32px;
    display: flex; align-items: center;
}
.scrubber-progress {
    position: absolute; top: 50%; transform: translateY(-50%);
    left: 0; height: 4px;
    background: var(--accent-cyan);
    border-radius: var(--radius-pill);
    pointer-events: none; z-index: 1;
}
.scrubber-tick-marks {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; z-index: 0;
}
.scrubber-slider {
    width: 100%; position: relative; z-index: 2;
    -webkit-appearance: none; appearance: none;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    outline: none; cursor: pointer;
}
.scrubber-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px;
    background: var(--accent-cyan);
    border-radius: 50%; cursor: pointer;
    box-shadow: var(--shadow-glow-cyan);
    transition: transform var(--transition-fast);
}
.scrubber-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.scrubber-slider::-moz-range-thumb {
    width: 16px; height: 16px;
    background: var(--accent-cyan);
    border: none; border-radius: 50%;
    cursor: pointer;
}
.scrubber-tooltip {
    position: absolute; top: -28px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-data);
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
}
.scrubber-current {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0; white-space: nowrap;
}
.scrubber-current-label { font-size: 0.7rem; color: var(--text-muted); }
.scrubber-current-value {
    font-family: var(--font-data);
    font-size: 0.75rem; font-weight: 600;
    color: var(--accent-cyan);
}
.scrubber-current-offset { font-size: 0.65rem; color: var(--text-muted); }

/* --- Loading overlay bridge --- */
.loading-content {
    display: flex; flex-direction: column;
    align-items: center; gap: 16px;
}
.loading-title {
    font-size: 1.3rem; font-weight: 700;
    color: var(--text-primary);
}
.loading-status {
    font-size: 0.85rem; color: var(--text-secondary);
}
.loading-progress {
    width: 240px; height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet));
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
}
.loading-steps {
    display: flex; flex-direction: column; gap: 8px;
    align-items: flex-start; margin-top: 8px;
}
.loading-step {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.75rem; color: var(--text-muted);
}
.loading-step[data-status="done"] { color: var(--accent-emerald); }
.loading-step[data-status="active"] { color: var(--accent-cyan); }
.step-icon { width: 16px; text-align: center; }
.spinner-ring, .spinner-glow {
    position: absolute;
    animation: spin 1.2s linear infinite;
}
.spinner-glow {
    animation-duration: 2s;
    animation-direction: reverse;
    opacity: 0.4;
    color: var(--accent-violet);
}
.spinner-ring { color: var(--accent-cyan); }
.loading-spinner {
    position: relative;
    width: 64px; height: 64px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Detail panel content --- */
.detail-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 40px;
    color: var(--text-muted);
}
.detail-empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.detail-empty-text { font-size: 0.85rem; line-height: 1.5; }
.detail-content { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.sidebar-right.open .detail-empty { display: none; }
.sidebar-right.open .detail-content { display: flex; }

/* --- Farm detail header --- */
.detail-farm-header { padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.farm-header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.farm-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.farm-type-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    border-radius: var(--radius-pill);
}
.farm-type-badge.wind { background: rgba(34,211,238,0.15); color: var(--accent-cyan); }
.farm-type-badge.solar { background: rgba(245,158,11,0.15); color: var(--accent-amber); }
.farm-location {
    font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px;
}
.farm-region { display: flex; gap: 6px; margin-top: 6px; }
.region-tag, .region-state {
    font-size: 0.65rem; padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* --- Detail stats grid --- */
.detail-stats {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; padding: 16px 20px;
}
.detail-stats .stat-card {
    background: var(--bg-tertiary);
    padding: 12px; border-radius: var(--radius-md);
}
.stat-card-label {
    font-size: 0.65rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); margin-bottom: 4px;
}
.stat-card-value {
    font-family: var(--font-data);
    font-size: 1.3rem; font-weight: 700;
    color: var(--text-primary);
}
.stat-card-bar {
    height: 3px; width: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius-pill);
    margin-top: 6px; overflow: hidden;
}
.stat-card-fill {
    height: 100%;
    background: var(--accent-cyan);
    border-radius: var(--radius-pill);
    transition: width 0.5s ease;
}

/* --- Specs grid --- */
.detail-specs {
    padding: 0 20px;
}
.detail-section-title {
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 10px;
}
.specs-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.spec-item {
    display: flex; justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.spec-label {
    font-size: 0.75rem; color: var(--text-muted);
}
.spec-value {
    font-family: var(--font-data);
    font-size: 0.75rem; font-weight: 500;
    color: var(--text-primary);
}

/* --- Chart sections --- */
.detail-chart-section {
    padding: 0 20px;
}
.chart-controls {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 8px;
}
.chart-range-btn {
    padding: 3px 10px; font-size: 0.65rem;
    border-radius: var(--radius-pill);
    background: none; border: none; cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}
.chart-range-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* --- Curtailment section --- */
.detail-curtailment { padding: 0 20px; }
.curtailment-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.curtailment-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px; border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}
.curtailment-label { font-size: 0.65rem; color: var(--text-muted); }
.curtailment-value {
    font-family: var(--font-data);
    font-size: 0.85rem; font-weight: 600;
    color: var(--text-primary);
}

/* --- Alerts section --- */
.detail-alerts { padding: 0 20px; }
.alerts-list { display: flex; flex-direction: column; gap: 6px; }

/* --- Download section --- */
.detail-download {
    padding: 16px 20px;
    display: flex; gap: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.btn-download, .btn-download-secondary {
    flex: 1; padding: 8px 12px;
    font-size: 0.78rem; font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition-fast);
    display: flex; align-items: center; justify-content: center; gap: 6px;
    border: none;
}
.btn-download {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}
.btn-download:hover { background: var(--accent-cyan); color: var(--bg-primary); }
.btn-download-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.btn-download-secondary:hover { background: var(--bg-card); color: var(--text-primary); }

/* --- Toast container --- */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: 16px; z-index: 9999;
    display: flex; flex-direction: column;
    gap: 8px; pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.8rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.info { border-left: 3px solid var(--accent-cyan); }
.toast.success { border-left: 3px solid var(--accent-emerald); }
.toast.warning { border-left: 3px solid var(--accent-amber); }
.toast.error { border-left: 3px solid var(--accent-rose); }

/* --- Theme toggle icons --- */
.icon-sun, .icon-moon { display: flex; align-items: center; justify-content: center; }
body:not(.light-mode) .icon-sun { display: none; }
body.light-mode .icon-moon { display: none; }

/* --- Brand title --- */
.brand-title {
    font-weight: 700;
    white-space: nowrap;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}
.brand-accent {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

/* ==========================================================================
   FLEET FILTER SLIDERS
   ========================================================================== */

.range-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 12px;
}

.range-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.range-filter-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.range-filter-values {
    font-family: var(--font-data);
    font-size: 0.68rem;
    color: var(--text-muted);
}

.dual-range {
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

.dual-range-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    pointer-events: none;
}

.dual-range-fill {
    position: absolute;
    height: 100%;
    background: var(--accent-cyan);
    border-radius: var(--radius-pill);
    opacity: 0.6;
}

.dual-range-input {
    position: absolute;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    height: 24px;
    margin: 0;
    padding: 0;
    z-index: 2;
}

.dual-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-cyan);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.4);
    transition: transform 0.15s ease;
}

.dual-range-input::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.dual-range-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-cyan);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
}

.range-filter-wind {
    /* Hidden when solar-only view */
}
body[data-view="solar"] .range-filter-wind {
    display: none;
}

/* ==========================================================================
   WIND ROSE / SQUARE CHART CONTAINER
   ========================================================================== */

.chart-container-square {
    aspect-ratio: 1;
    max-width: 340px;
    margin: 0 auto;
}

.chart-container-square canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    display: block;
}

/* ==========================================================================
   FULL REPORT BUTTON
   ========================================================================== */

.detail-actions {
    padding: 8px 20px;
    display: flex;
    gap: 8px;
}

.btn-report {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-cyan);
    background: var(--accent-cyan-dim);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.btn-report:hover {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    box-shadow: var(--shadow-glow-cyan);
}

/* Single range slider */
.single-range-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    outline: none;
    cursor: pointer;
}
.single-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    background: var(--accent-cyan);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.4);
}
.single-range-input::-moz-range-thumb {
    width: 14px; height: 14px;
    background: var(--accent-cyan);
    border: none; border-radius: 50%;
    cursor: pointer;
}

/* Size mode button group */
.btn-group-sm {
    display: flex; gap: 4px;
}
.size-mode-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 0.68rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}
.size-mode-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border-color: rgba(34, 211, 238, 0.3);
}
.size-mode-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Sun illumination overlay */
#canvas-sun-illumination {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 399;
}

/* ==========================================================================
   DASHBOARD PANEL
   ========================================================================== */
.dashboard-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 450;
    background: var(--bg-primary);
    overflow-y: auto;
    padding: 24px 32px;
}
.dashboard-header {
    margin-bottom: 24px;
}
.dashboard-header h2 {
    font-size: 1.3rem; font-weight: 700; color: var(--text-primary);
}
.dashboard-subtitle {
    font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-data);
}
.dashboard-section-title {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 10px;
}
.conus-chart-section { margin-bottom: 24px; }
.conus-chart-section .chart-container { height: 280px; }
.iso-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.iso-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.iso-card:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
}
.iso-card.active {
    border-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.08);
    box-shadow: 0 0 0 1px var(--accent-cyan) inset;
}
.btn-dashboard-back {
    margin-left: auto;
    padding: 6px 14px;
    background: rgba(34, 211, 238, 0.12);
    border: 1px solid rgba(34, 211, 238, 0.35);
    color: var(--accent-cyan);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.btn-dashboard-back:hover { background: rgba(34, 211, 238, 0.2); }
.iso-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.iso-card-name { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.iso-card-capacity {
    font-family: var(--font-data); font-size: 0.7rem; color: var(--text-muted);
}
.iso-card-stats {
    display: flex; gap: 16px; margin-bottom: 8px; font-size: 0.75rem;
}
.iso-card-stat-value {
    font-family: var(--font-data); font-weight: 600; color: var(--accent-cyan);
}
.iso-card-stat-label { color: var(--text-muted); font-size: 0.65rem; }
.iso-card-sparkline { height: 50px; }
.iso-card-sparkline canvas { width: 100%; height: 100%; }

/* Nav gradient animation */
@keyframes nav-gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.nav-bar {
    background: linear-gradient(135deg,
        var(--bg-card) 0%,
        rgba(34,211,238,0.03) 25%,
        var(--bg-card) 50%,
        rgba(245,158,11,0.03) 75%,
        var(--bg-card) 100%) !important;
    background-size: 400% 400% !important;
    animation: nav-gradient-shift 20s ease infinite;
}

/* Marker glow pulse */
@keyframes marker-glow-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px var(--glow-color, rgba(34,211,238,0.3))); }
    50% { filter: drop-shadow(0 0 10px var(--glow-color, rgba(34,211,238,0.5))); }
}
.farm-marker {
    animation: marker-glow-pulse 3s ease-in-out infinite;
}

/* Confidence bar */
.confidence-bar {
    height: 4px; width: 100%;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, #34d399 0%, #f59e0b 50%, #fb7185 100%);
    margin-top: 6px; opacity: 0.7;
}
.confidence-label {
    display: flex; justify-content: space-between;
    font-size: 0.6rem; color: var(--text-muted); margin-top: 2px;
}

/* ==========================================================================
   UPGRADE MODAL
   ========================================================================== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.modal-overlay[hidden] { display: none !important; }
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 440px; width: 90%;
    position: relative;
    box-shadow: var(--shadow-lg);
}
.modal-close {
    position: absolute; top: 12px; right: 16px;
    background: none; border: none;
    color: var(--text-muted); font-size: 1.5rem;
    cursor: pointer;
}
.modal-title {
    font-size: 1.2rem; font-weight: 700;
    color: var(--text-primary); margin-bottom: 8px;
}
.modal-text { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 16px; }
.upgrade-features-list {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 20px;
}
.upgrade-feature-item {
    font-size: 0.8rem; color: var(--accent-emerald); padding: 4px 0;
}
.upgrade-input-row {
    display: flex; gap: 8px;
}
.upgrade-input {
    flex: 1; padding: 10px 14px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 0.85rem;
}
.upgrade-input:focus { border-color: var(--accent-cyan); outline: none; }
.btn-upgrade-activate {
    padding: 10px 20px;
    background: var(--accent-cyan); color: var(--bg-primary);
    border: none; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 0.85rem; cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-upgrade-activate:hover { box-shadow: var(--shadow-glow-cyan); }
.upgrade-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 10px; text-align: center; }

/* Tier badge */
.tier-badge {
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 2px 8px; border-radius: var(--radius-pill);
    margin-left: 8px;
}
.tier-badge.free { background: rgba(251,146,60,0.2); color: #fb923c; }
.tier-badge.pro { background: rgba(52,211,153,0.2); color: #34d399; }

/* Nav upgrade button */
.nav-upgrade-btn {
    padding: 6px 14px; font-size: 0.72rem; font-weight: 600;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
    color: white; border: none; border-radius: var(--radius-pill);
    cursor: pointer; transition: all var(--transition-fast);
    animation: nav-gradient-shift 3s ease infinite;
    background-size: 200% 200%;
}
.nav-upgrade-btn:hover { box-shadow: 0 0 20px rgba(34,211,238,0.4); }

/* ============================================================================
   Add Farm modal + button (Phase 1)
   ============================================================================ */
.add-farm-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.08);
    border: 1px dashed rgba(34, 211, 238, 0.4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.add-farm-btn:hover {
    background: rgba(34, 211, 238, 0.16);
    border-color: rgba(34, 211, 238, 0.7);
}

.add-farm-card {
    max-width: 540px;
    width: calc(100% - 32px);
}
.add-farm-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-row-2col > div { display: flex; flex-direction: column; gap: 4px; }
.form-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-label .req { color: #f87171; margin-left: 2px; }
.add-farm-form input,
.add-farm-form select {
    padding: 8px 10px;
    font-size: 0.85rem;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}
.add-farm-form input:focus,
.add-farm-form select:focus {
    outline: none;
    border-color: var(--accent-cyan);
}
.form-advanced {
    margin-top: 4px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: var(--radius-sm);
}
.form-advanced summary {
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
    list-style: none;
}
.form-advanced summary::before {
    content: "▶ ";
    display: inline-block;
    transition: transform var(--transition-fast);
    font-size: 0.6rem;
}
.form-advanced[open] summary::before { content: "▼ "; }
.form-advanced[open] { padding-bottom: 16px; }
.form-advanced .form-row-2col { margin-top: 12px; }

.form-error {
    padding: 8px 12px;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 0.8rem;
}
.form-success {
    padding: 8px 12px;
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.4);
    border-radius: var(--radius-sm);
    color: #6ee7b7;
    font-size: 0.8rem;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.btn-primary, .btn-secondary {
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
    color: white;
    border: none;
}
.btn-primary:hover { box-shadow: 0 0 16px rgba(34, 211, 238, 0.4); }
.btn-primary:disabled {
    background: rgba(148, 163, 184, 0.3);
    cursor: wait;
    box-shadow: none;
}
.btn-secondary {
    background: transparent;
    color: var(--text-muted, #94a3b8);
    border-color: rgba(148, 163, 184, 0.3);
}
.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-primary, #e2e8f0);
}

/* Data quality badge — used on farm cards for inferred-spec farms */
.data-quality-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: var(--radius-pill);
    letter-spacing: 0.04em;
}
.data-quality-badge.high   { background: rgba(52, 211, 153, 0.2); color: #34d399; }
.data-quality-badge.medium { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }
.data-quality-badge.low    { background: rgba(248, 113, 113, 0.2); color: #fca5a5; }
