/* ============================================================
   SENTINEL DIGITAL AGRICULTURE — Design System
   Theme: "Harvest Intelligence" (Concept 3)
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Inter:wght@300;400;500;600;700&family=Cairo:wght@300;400;500;600;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    /* Colour Palette — Nimbus Earth / OPAL */
    --color-bg-primary: #000000;
    --color-bg-secondary: #080808;
    --color-bg-card: rgba(10, 10, 15, 0.7);
    --color-bg-card-hover: rgba(255, 255, 255, 0.05);
    --color-bg-nav: rgba(0, 0, 0, 0.6);

    /* Brand colours */
    --color-brand-cyan: #ffab00;
    --color-brand-navy: #2979ff;
    --color-brand-sage: #00b0ff;

    --color-emerald: #ffab00;
    --color-blue: #2979ff;
    --color-amber: #ffab00;
    --color-red: #ff1744;
    --color-teal-light: #111111;

    /* Typography */
    --font-tech: 'Space Grotesk', sans-serif;

    --color-text-primary: #ffffff;
    --color-text-secondary: rgba(255, 255, 255, 0.72);
    --color-text-muted: rgba(255, 255, 255, 0.48);

    /* Status Colours */
    --color-status-online: #00e676;
    --color-status-offline: #ffab00;
    --color-status-error: #ff1744;

    /* Advisory Colours */
    --color-advisory-irrigate: #ff1744;
    --color-advisory-monitor: #ffab00;
    --color-advisory-ok: #34d399;

    /* Gauge Colours */
    --color-gauge-red: #ff1744;
    --color-gauge-yellow: #ffeb3b;
    --color-gauge-green: #34d399;
    --color-gauge-track: rgba(255, 255, 255, 0.08);
    --color-gauge-glow: rgba(52, 211, 153, 0.25);

    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius — sharp corners to match Nimbus design language */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 4px;
    --radius-xl: 6px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-nav: 0 -4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow-emerald: 0 0 20px rgba(52, 211, 153, 0.3);
    --shadow-glow-red: 0 0 20px rgba(255, 23, 68, 0.3);
    --shadow-glow-amber: 0 0 20px rgba(255, 171, 0, 0.3);

    /* Font families */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: clamp(0.65rem, 1.5vw, 0.75rem);
    --font-size-sm: clamp(0.75rem, 2vw, 0.875rem);
    --font-size-base: clamp(0.875rem, 2.5vw, 1rem);
    --font-size-lg: clamp(1rem, 3vw, 1.25rem);
    --font-size-xl: clamp(1.25rem, 4vw, 1.5rem);
    --font-size-2xl: clamp(1.5rem, 5vw, 2rem);
    --font-size-gauge: clamp(2rem, 8vw, 3.5rem);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-gauge: 1200ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --nav-height: 64px;
    --header-height: 56px;
    --max-width: 480px;
}

/* ---------- Light Theme ---------- */
/* Chrome (header, nav, sidebar) stays black.
   Only data cards/panels shift to mid-grey. */

html.light-theme {
    --color-bg-card: rgba(52, 54, 64, 0.95);
    --color-bg-card-hover: rgba(65, 68, 80, 0.95);
}

/* Field tiles in the sidebar */
html.light-theme .field-card {
    background: rgba(52, 54, 64, 0.95);
    border-color: rgba(255, 255, 255, 0.12);
}
html.light-theme .field-card:hover,
html.light-theme .field-card.active {
    background: rgba(65, 68, 80, 0.95);
}

/* Below-map data panels */
html.light-theme .soil-analysis-panel,
html.light-theme .map-history-panel {
    background: rgba(52, 54, 64, 0.95);
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 5px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}
.theme-toggle:hover {
    color: var(--color-text-primary);
    border-color: rgba(255, 255, 255, 0.3);
}
/* Show sun in dark mode, moon in light mode */
.theme-icon-moon { display: none; }
html.light-theme .theme-icon-sun { display: none; }
html.light-theme .theme-icon-moon { display: block; }

/* ---------- Print styles ---------- */

@media print {
    :root {
        --color-bg-primary: #ffffff;
        --color-bg-secondary: #ffffff;
        --color-bg-card: #f8f9fa;
        --color-text-primary: #0f172a;
        --color-text-secondary: #475569;
        --color-text-muted: #64748b;
        --shadow-card: none;
    }
    body::before { display: none; }
    .bottom-nav, #sidebar-open-btn, .theme-toggle { display: none !important; }
    .brand { background: transparent; border-color: rgba(0, 0, 0, 0.1); }
    .brand-tagline { color: rgba(15, 23, 42, 0.45); border-left-color: rgba(0, 0, 0, 0.12); }
    .map-history-panel, .soil-analysis-panel { background: #f8f9fa; border-top-color: rgba(0, 0, 0, 0.07); }
}



/* ---------- Reset & Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior-x: none; /* prevent browser swipe-back-to-exit gesture */
    padding-bottom: calc(var(--nav-height) + var(--space-lg));
}

/* Noise/grain overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}


/* ---------- App Container ---------- */

.app-container {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* Desktop: remove mobile max-width so app can fill the screen */
/* Desktop: remove mobile max-width so app can fill the screen */
@media (min-width: 768px) {
    #app-main.app-container {
        max-width: 100% !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* app-container drops its padding on desktop, so the header needs its
       own horizontal inset to keep the brand pill off the screen edge */
    #app-main .app-header {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }
}


/* ---------- Header ---------- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
    height: var(--header-height);
}

/* Brand pill */
.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md) var(--space-xs) var(--space-xs);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.brand-icon {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 2px;
    background: transparent;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-name {
    font-family: var(--font-tech);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--color-text-primary);
}

.brand-tagline {
    font-family: var(--font-family);
    font-size: 0.55rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    padding-left: var(--space-sm);
    white-space: nowrap;
}

.header-end {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.status-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.demo-banner {
    margin: calc(var(--space-md) / 2) 0 var(--space-md);
    padding: calc(var(--space-sm) * 0.9) var(--space-md);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    text-align: center;
    color: #92400e;
    background: rgba(253, 186, 116, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.24);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--color-status-online);
    box-shadow: 0 0 6px var(--color-status-online);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--color-status-offline);
    box-shadow: 0 0 6px var(--color-status-offline);
    animation: none;
}

.sync-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.85);
    }
}


/* ---------- Gauge Section ---------- */

.gauge-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-lg) 0 var(--space-md);
    position: relative;
}

.gauge-wrapper {
    position: relative;
    width: 220px;
    height: 220px;
}

.gauge-canvas {
    width: 100%;
    height: 100%;
}

.gauge-value-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.gauge-value {
    font-size: var(--font-size-gauge);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    text-shadow: 0 0 30px rgba(0, 200, 83, 0.3);
}

.gauge-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-xs);
    font-weight: 500;
}

.gauge-sublabel {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ============================================================
   MAP VIEW LAYOUT — Base (Mobile-first)
   ============================================================ */

/* Remove scrolling & padding from main-content when map is showing */
.main-content:has(#view-map.active-view) {
    padding: 0;
    overflow: hidden;
}

/* Override .view.active-view { display:block } — map needs flex */
#view-map.active-view {
    display: flex !important;
    flex-direction: column;
    height: calc(100dvh - var(--header-height) - var(--nav-height));
    overflow: hidden;
}

/* Mobile: the map page scrolls as a normal document — a fixed-height
   flex column can't fit field list + map + legend + trend on a phone */
@media (max-width: 767px) {
    #view-map.active-view {
        height: auto;
        overflow: visible;
    }

    .map-view-layout,
    .map-wrapper {
        overflow: visible;
    }

    .map-wrapper .map-container {
        flex: none;
        height: 48vh;
        min-height: 250px;
        border-radius: var(--radius-md);
    }
}

.map-view-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

.map-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* Mobile-only header — hidden on desktop where sidebar shows */
.map-header-mobile {
    padding: var(--space-sm) var(--space-md);
}

/* ---------- Desktop / Tablet Split View ---------- */
@media (min-width: 768px) {
    .map-view-layout {
        flex-direction: row;
    }

    .map-sidebar {
        width: 320px;
        min-width: 320px;
        max-width: 350px;
        max-height: none;
        /* Floating rounded card, inset to match the map card opposite it.
           Right margin is 0 — the map card's own inset provides the gap. */
        margin: var(--space-md) 0 var(--space-md) var(--space-md);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        /* Glassmorphism & Transition */
        background: rgba(10, 10, 15, 0.85);
        backdrop-filter: blur(12px);
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1), margin 0.4s ease, padding 0.4s ease, opacity 0.4s ease;
        z-index: 20;
    }

    .map-sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        border: none;
        opacity: 0;
        pointer-events: none;
        /* Prevent clicks when hidden */
    }

    .map-sidebar .sidebar-header,
    .map-sidebar .sidebar-search {
        flex-shrink: 0;
        padding-left: var(--space-md);
        /* Ensure desktop padding matches */
        padding-right: var(--space-md);
        opacity: 1;
        /* Ensure visible */
        transition: opacity 0.2s ease;
    }

    .map-sidebar.collapsed .sidebar-header,
    .map-sidebar.collapsed .sidebar-search,
    .map-sidebar.collapsed #field-list {
        opacity: 0;
        pointer-events: none;
    }

    .map-sidebar .sidebar-header {
        padding-top: var(--space-md);
    }



    #field-list {
        flex: 1;
        overflow-y: auto;
        padding: 0 var(--space-md) var(--space-md) var(--space-md);
        min-height: 0;
    }

    /* Hide mobile header when sidebar is visible */
    .map-header-mobile {
        display: none !important;
    }

    /* Index switcher — floating glass capsule inside the map card */
    .map-wrapper .index-switcher {
        position: absolute;
        top: calc(var(--space-md) + var(--space-xs));
        left: calc(var(--space-md) + var(--space-xs));
        right: calc(var(--space-md) + var(--space-xs));
        z-index: 10;
        background: rgba(10, 10, 15, 0.85);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: var(--radius-lg);
        padding: var(--space-xs) var(--space-sm);
        box-shadow: var(--shadow-card);
    }

    /* Collapsed: anchored at top-left like the expanded bar, so the fixed
       44px square (see the shared .index-switcher.collapsed rule) folds
       toward that corner rather than re-centering. `right` must be freed
       here since the expanded rule above pins it to the map's right edge. */
    .map-wrapper .index-switcher.collapsed {
        right: auto;
    }

    /* Map container — a floating rounded card inset from the wrapper */
    .map-wrapper .map-container {
        position: absolute;
        inset: var(--space-md);
        width: auto;
        height: auto;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
    }

    /* Index legend — floating glass capsule, bottom-left of the map card.
       (MapLibre nav/attribution controls live bottom-right, so this is clear.) */
    .map-wrapper .index-panel {
        position: absolute;
        left: calc(var(--space-md) + var(--space-xs));
        bottom: calc(var(--space-md) + var(--space-xs));
        right: auto;
        width: auto;
        max-width: min(460px, 60%);
        z-index: 10;
        background: rgba(10, 10, 15, 0.85);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
        padding: var(--space-sm) var(--space-md);
    }
}

/* ---------- Stat Bars ---------- */

.stats-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md) 0;
}

@media (min-width: 768px) {
    .stats-section {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-bar {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-bar:hover {
    background: var(--color-bg-card-hover);
}

.stat-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.stat-bar-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
}

.stat-bar-icon {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.stat-bar-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.stat-bar-track {
    width: 100%;
    height: 6px;
    background: var(--color-gauge-track);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--transition-slow);
}

.stat-bar-fill.moisture {
    background: linear-gradient(90deg, #1565c0, #42a5f5, #81d4fa);
    box-shadow: 0 0 8px rgba(66, 165, 245, 0.4);
}

.stat-bar-fill.temperature {
    background: linear-gradient(90deg, #e65100, #ff9800, #ffcc02);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.4);
}

.stat-bar-fill.wind {
    background: linear-gradient(90deg, #546e7a, #90a4ae, #cfd8dc);
    box-shadow: 0 0 8px rgba(144, 164, 174, 0.3);
}


/* ---------- Action Cards ---------- */

.cards-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    padding: var(--space-sm) 0 var(--space-md);
}

.action-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.action-card:hover {
    transform: translateY(-2px);
    background: var(--color-bg-card-hover);
}

.action-card:active {
    transform: translateY(0);
}

/* Advisory Card */
.action-card.advisory {
    border-color: rgba(255, 23, 68, 0.25);
}

.action-card.advisory::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.action-card.advisory.irrigate::before {
    background: var(--color-advisory-irrigate);
    box-shadow: var(--shadow-glow-red);
}

.action-card.advisory.monitor::before {
    background: var(--color-advisory-monitor);
    box-shadow: var(--shadow-glow-amber);
}

.action-card.advisory.ok::before {
    background: var(--color-advisory-ok);
    box-shadow: var(--shadow-glow-emerald);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    padding-bottom: 80px;
    /* Space for bottom nav */
    max-width: 100%;
    /* Allow full width for map */
    margin: 0 auto;
    width: 100%;
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.card-header-icon {
    width: 16px;
    height: 16px;
}

.card-header-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
}

.advisory-status {
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.advisory-status.irrigate {
    color: var(--color-advisory-irrigate);
    text-shadow: 0 0 20px rgba(255, 23, 68, 0.3);
}

.advisory-status.monitor {
    color: var(--color-advisory-monitor);
    text-shadow: 0 0 20px rgba(255, 171, 0, 0.3);
}

.advisory-status.ok {
    color: var(--color-advisory-ok);
    text-shadow: 0 0 20px rgba(0, 200, 83, 0.3);
}

.advisory-detail {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.advisory-icon-large {
    width: 24px;
    height: 24px;
    margin-top: var(--space-sm);
    opacity: 0.5;
}

/* Forecast Card */
.action-card.forecast {
    border-color: rgba(41, 121, 255, 0.15);
}

.forecast-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.forecast-canvas {
    width: 100%;
    height: 60px;
    margin-top: var(--space-sm);
}

.forecast-detail {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
}

.forecast-detail-icon {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}


/* ---------- Bottom Navigation ---------- */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--color-bg-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-nav);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    color: inherit;
    min-width: 60px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-item:active {
    background: rgba(255, 255, 255, 0.10);
}

.nav-icon {
    width: 22px;
    height: 22px;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.nav-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.nav-item.active .nav-icon {
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(255, 171, 0, 0.5));
}

.nav-item.active .nav-label {
    font-family: var(--font-tech);
    color: var(--color-emerald);
    font-weight: 600;
}

.nav-item span {
    font-family: var(--font-tech);
}

/* Dashboard locked until a field is selected */
.nav-item--locked {
    opacity: 0.35;
    cursor: default;
    pointer-events: auto;
}

.nav-item--locked:hover {
    background: transparent;
}


/* ---------- Entrance Animations ---------- */

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

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

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gauge-section {
    animation: scale-in 600ms var(--transition-slow) both;
}

.stat-bar {
    animation: fade-in-up 500ms var(--transition-slow) both;
}

.stat-bar:nth-child(1) {
    animation-delay: 200ms;
}

.stat-bar:nth-child(2) {
    animation-delay: 350ms;
}

.stat-bar:nth-child(3) {
    animation-delay: 500ms;
}

.action-card {
    animation: fade-in-up 500ms var(--transition-slow) both;
}

.action-card:first-child {
    animation-delay: 600ms;
}

.action-card:last-child {
    animation-delay: 750ms;
}


/* ---------- Scrollbar Styling ---------- */

::-webkit-scrollbar {
    width: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
}


/* ---------- Responsive Breakpoints ---------- */

@media (min-width: 480px) {
    .app-container {
        padding: 0 var(--space-lg);
    }

    .gauge-wrapper {
        width: 260px;
        height: 260px;
    }
}

@media (max-width: 360px) {
    .cards-section {
        grid-template-columns: 1fr;
    }

    .gauge-wrapper {
        width: 180px;
        height: 180px;
    }
}

@media (max-width: 479px) {
    .brand-tagline {
        display: none;
    }
}

/* iOS safe area support */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + var(--space-lg));
    }
}


/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary);
    padding: var(--space-md);
}

.login-container {
    width: 100%;
    max-width: 380px;
    text-align: center;
    background: rgba(10, 10, 15, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: var(--space-xl) var(--space-xl);
}

.login-brand {
    margin-bottom: var(--space-xl);
}

.login-brand-icon {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: var(--space-md);
    filter: drop-shadow(0 0 16px rgba(255, 171, 0, 0.2));
}

.login-title {
    font-family: var(--font-tech);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

.login-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.4;
}


/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 3px;
    margin-bottom: var(--space-lg);
}

.auth-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-tab.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-text-primary);
}


/* Auth Forms */
.auth-form {
    text-align: left;
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: border-color var(--transition-fast), background var(--transition-fast);
    outline: none;
}

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

.form-group input:focus {
    border-color: var(--color-emerald);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 2px rgba(255, 171, 0, 0.15);
}

.auth-error {
    background: rgba(255, 23, 68, 0.12);
    color: var(--color-red);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    margin-bottom: var(--space-md);
    border: 1px solid rgba(255, 23, 68, 0.25);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.primary-btn {
    background: var(--color-bg-primary);
    color: var(--color-emerald);
    border: 1px solid var(--color-emerald);
    font-family: var(--font-tech);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: all var(--transition-fast);
}

.primary-btn:hover {
    background: var(--color-emerald);
    color: var(--color-bg-primary);
    box-shadow: 0 0 15px rgba(255, 171, 0, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}


/* Google Button */
.google-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.google-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}


/* Auth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.login-footer {
    margin-top: var(--space-xl);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.login-footer-logo {
    width: 18px;
    height: 18px;
    opacity: 0.55;
    flex-shrink: 0;
}

/* ============================================================
   ACCESS GATE SCREENS — pending / blocked
   ============================================================ */

.access-gate-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    margin-top: 8px;
}

.access-gate-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 171, 0, 0.12);
    border: 1px solid rgba(255, 171, 0, 0.25);
    margin: 0 auto 20px;
    color: #ffab00;
}

.access-gate-icon--blocked {
    background: rgba(255, 23, 68, 0.12);
    border-color: rgba(255, 23, 68, 0.25);
    color: #ff1744;
}

.access-gate-title {
    font-family: var(--font-tech);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 10px;
    letter-spacing: -0.3px;
}

.access-gate-msg {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin: 0 0 12px;
}

.access-gate-email {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0 0 20px;
    word-break: break-all;
}

.access-gate-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0 0 12px;
    min-height: 18px;
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.hidden {
    display: none !important;
}


/* ============================================================
   VIEW ROUTING
   ============================================================ */

.view {
    display: none;
}

.view.active-view {
    display: block;
    animation: fade-in-up 300ms ease both;
}


/* ============================================================
   STAT CARDS (new HTML class mapping)
   ============================================================ */

.stat-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background var(--transition-fast);
    animation: fade-in-up 500ms var(--transition-slow) both;
}

.stat-card:nth-child(1) {
    animation-delay: 200ms;
}

.stat-card:nth-child(2) {
    animation-delay: 350ms;
}

.stat-card:nth-child(3) {
    animation-delay: 500ms;
}

.stat-card:hover {
    background: var(--color-bg-card-hover);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.stat-icon {
    flex-shrink: 0;
}

.stat-name {
    flex: 1;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-left: var(--space-sm);
}

.stat-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

/* Stat fill bars (new HTML class) */
.stat-bar {
    /* Override for when used as track container inside stat-card */
    width: 100%;
    height: 6px;
    background: var(--color-gauge-track);
    border-radius: var(--radius-full);
    overflow: hidden;
    padding: 0;
    border: none;
    backdrop-filter: none;
}

.stat-fill {
    height: 100%;
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--transition-slow);
}

.stat-fill.moisture {
    background: linear-gradient(90deg, #1565c0, #42a5f5, #81d4fa);
    box-shadow: 0 0 8px rgba(66, 165, 245, 0.4);
}

.stat-fill.temperature {
    background: linear-gradient(90deg, #e65100, #ff9800, #ffcc02);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.4);
}

.stat-fill.wind {
    background: linear-gradient(90deg, #546e7a, #90a4ae, #cfd8dc);
    box-shadow: 0 0 8px rgba(144, 164, 174, 0.3);
}


/* ============================================================
   HEADER — User Badge & Connectivity
   ============================================================ */

.user-badge {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: rgba(255, 171, 0, 0.1);
    border: 1px solid rgba(255, 171, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-tech);
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-emerald);
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}

.user-badge:hover {
    box-shadow: 0 0 0 2px rgba(255, 171, 0, 0.3);
}

.connectivity-block {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.status-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
}


/* ============================================================
   ACTION CARDS (updated selectors for new HTML)
   ============================================================ */

.actions-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    padding: var(--space-sm) 0 var(--space-md);
}

.advisory-card {
    border-color: rgba(255, 23, 68, 0.25);
    position: relative;
    overflow: hidden;
}

.advisory-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-advisory-irrigate);
    box-shadow: var(--shadow-glow-red);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.advisory-card.status-monitor::before {
    background: var(--color-advisory-monitor);
    box-shadow: var(--shadow-glow-amber);
}

.advisory-card.status-ok::before {
    background: var(--color-advisory-ok);
    box-shadow: var(--shadow-glow-emerald);
}

.card-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
}

.card-icon {
    opacity: 0.7;
}

.advisory-action {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-advisory-irrigate);
    text-shadow: 0 0 20px rgba(255, 23, 68, 0.3);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: var(--space-xs);
}

.advisory-detail {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
    line-height: 1.4;
}

.forecast-period {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.forecast-summary {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
}

/* Phenology rows inside the yield card */
.phenology-info {
    margin-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: var(--space-sm);
}

.crop-card, .yield-card {
    padding: 20px;
}

.pheno-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-xs);
    margin-bottom: 8px;
}

.pheno-row:last-child {
    margin-bottom: 0;
}

.pheno-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.pheno-value {
    font-size: 11px;
    color: var(--color-text-secondary);
    text-align: right;
}

.forecast-canvas {
    width: 100%;
    height: 60px;
    margin-top: var(--space-sm);
}


/* ============================================================
   NAV ITEM — Updated for inline SVG icons
   ============================================================ */

.nav-item svg {
    opacity: 0.45;
    transition: opacity var(--transition-fast);
}

.nav-item.active svg {
    opacity: 1;
    stroke: var(--color-brand-cyan);
    filter: drop-shadow(0 0 4px rgba(255, 171, 0, 0.5));
}

.nav-item {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-muted);
}

.nav-item.active {
    color: var(--color-brand-cyan);
    font-weight: 600;
}


/* ============================================================
   MAP VIEW
   ============================================================ */

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
}

.map-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    font-family: var(--font-tech);
}

.map-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.map-add-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 171, 0, 0.1);
    border: 1px solid rgba(255, 171, 0, 0.35);
    border-radius: var(--radius-sm);
    color: var(--color-brand-cyan);
    font-family: var(--font-tech);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.map-add-btn:hover {
    background: rgba(255, 171, 0, 0.18);
}

/* Sidebar collapse / exit text buttons */
.sidebar-ctrl-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-family: var(--font-family);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.sidebar-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    color: var(--color-text-primary);
}

.sidebar-ctrl-btn--exit:hover {
    background: rgba(255, 23, 68, 0.10);
    border-color: rgba(255, 23, 68, 0.25);
    color: var(--color-red);
}


/* Index Switcher */
.index-switcher {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) 0;
    min-width: 0;
    overflow: hidden;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), height 0.6s cubic-bezier(0.4, 0, 0.2, 1), padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed: the whole bar folds into a small fixed square holding just the
   handle's icon (both here and on the legend panel below) — an explicit
   size, not width/height:auto, so the fold animates instead of snapping
   (auto isn't a value CSS transitions can interpolate to/from). */
.index-switcher.collapsed,
.index-panel.collapsed {
    width: 44px;
    height: 44px;
    padding: 5px;
}

.index-switcher-scroll {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-width: 0;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: translateY(0);
}

.index-switcher-scroll::-webkit-scrollbar {
    display: none;
}

/* Collapse handle for the index bar / legend panel — stays visible (as a small
   square icon button once collapsed) so users always know the controls exist. */
.bar-collapse-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast), padding 0.5s cubic-bezier(0.4, 0, 0.2, 1), width 0.5s cubic-bezier(0.4, 0, 0.2, 1), height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    color: var(--color-text-primary);
}

.bar-collapse-icon {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

.bar-collapse-label {
    display: inline-block;
    max-width: 120px;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
    opacity: 1;
}

.bar-collapse-chevron {
    font-size: 9px;
    line-height: 1;
    flex-shrink: 0;
    transition: transform var(--transition-fast), max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}

/* Collapsed: fold the whole bar down into a small square holding just the
   icon — label, chevron and pill/legend content fade out (350ms) somewhat
   ahead of the bar itself finishing its shrink (500-600ms), so nothing
   visibly clips as the box narrows/shortens around them. Height itself is
   driven by an inline max-height on the content (see setupBarCollapse in
   map.js) so the transition animates the real content height, not a
   guessed cap. */
.index-switcher.collapsed .index-switcher-scroll {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

.index-switcher.collapsed .bar-collapse-btn,
.index-panel.collapsed .bar-collapse-btn {
    padding: 0;
    width: 34px;
    height: 34px;
}

.index-switcher.collapsed .bar-collapse-label,
.index-panel.collapsed .bar-collapse-label,
.index-switcher.collapsed .bar-collapse-chevron,
.index-panel.collapsed .bar-collapse-chevron {
    max-width: 0;
    opacity: 0;
}

.index-switcher.collapsed .bar-collapse-chevron {
    transform: rotate(180deg);
}

.index-panel-content {
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: translateY(0);
    overflow: hidden;
}

.index-panel.collapsed .index-panel-content {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
}

.index-panel.collapsed .bar-collapse-chevron {
    transform: rotate(180deg);
}

.index-pill {
    flex-shrink: 0;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.index-pill:hover {
    background: rgba(255, 255, 255, 0.10);
}

.index-pill.active {
    background: var(--color-brand-cyan);
    color: #fff;
    border-color: var(--color-brand-cyan);
    box-shadow: 0 0 12px rgba(255, 171, 0, 0.3);
}


/* Map Container */
.map-container {
    width: 100%;
    flex: 1;
    min-height: 250px;
    overflow: hidden;
    background: rgba(15, 23, 36, 1);
    position: relative;
}

/* MapLibre needs its container to have explicit dimensions */
.map-container .maplibregl-map,
.map-container .maplibregl-canvas-container,
.map-container .maplibregl-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Mobile scroll-lock (#4) — transparent shield on top of the map.
   While locked it intercepts touch and lets the browser scroll the page
   (touch-action: pan-y). Long-press on the shield unlocks; map.js then
   adds .unlocked which removes pointer-events so touches reach MapLibre.
   Desktop (pointer: fine) hides the shield completely. */
#map-scroll-shield {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 10;
    touch-action: pan-y;
    cursor: default;
}
@media (pointer: coarse) {
    #map-scroll-shield { display: block; }
    #map-scroll-shield.unlocked { pointer-events: none; }
}

.map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    gap: var(--space-md);
    line-height: 1.5;
}


/* Colour Legend */
.index-legend {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}


/* Pixel Inspector */
.pixel-inspector {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--space-md));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-card);
    z-index: 50;
}

.pixel-index-name {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.pixel-value {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--color-emerald);
}

.pixel-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}


/* ============================================================
   HISTORY VIEW
   ============================================================ */

.history-header,
.settings-header {
    padding: var(--space-md) 0;
}

.history-title,
.settings-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 40vh;
    text-align: center;
    color: var(--color-text-muted);
    gap: var(--space-md);
}

.coming-soon p {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text-secondary);
}

.coming-soon-sub {
    font-size: var(--font-size-sm);
    line-height: 1.5;
}


/* ============================================================
   SETTINGS VIEW
   ============================================================ */

.settings-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    margin-bottom: var(--space-md);
}

.settings-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

/* Index date chip — move below pills on narrow screens to avoid overlap */
@media (max-width: 767px) {
    /* Pills wrap onto multiple rows on narrow screens — keep the collapse
       handle pinned to the top row instead of centering across all rows */
    .index-switcher {
        align-items: flex-start;
    }

    .index-switcher-scroll {
        flex-wrap: wrap;
    }

    .index-date-chip {
        position: static;
        margin-left: auto;
        order: 99;
        margin-top: 4px;
        margin-bottom: 2px;
    }
}

/* Sidebar — Base (Mobile: compact strip above map) */
@media (max-width: 767px) {
    .map-sidebar {
        background: var(--color-bg-secondary);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: var(--radius-md);
        padding: var(--space-sm) var(--space-md);
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        max-height: 300px;
        /* Sidebar wrapper doesn't scroll — only field-list does */
        overflow-y: hidden;
        flex-shrink: 0;
    }

    /* Pin the header and search so they never scroll out of view */
    .map-sidebar .sidebar-header,
    .map-sidebar .sidebar-search {
        flex-shrink: 0;
    }

    /* Only the field list scrolls */
    .map-sidebar #field-list {
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    /* Hide the duplicate "My Fields" heading inside map-wrapper —
       the sidebar header above already carries the title */
    .map-header-mobile {
        display: none;
    }

    /* Desktop-only controls inside the sidebar header */
    #sidebar-toggle {
        display: none;
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: var(--space-sm);
}

.sidebar-search {
    margin-bottom: var(--space-sm);
    flex-shrink: 0;
}

.search-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-group:focus-within {
    border-color: var(--color-brand-cyan);
    box-shadow: 0 0 0 3px rgba(255, 171, 0, 0.12);
}

#map-search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--color-text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    padding: 9px 14px;
    min-width: 0;
}

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

#map-search-btn {
    background: none;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding: 9px 12px;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

#map-search-btn:hover {
    color: var(--color-brand-cyan);
}

#field-filter-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--color-text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    padding: 9px 14px;
    min-width: 0;
}

#field-filter-input::placeholder {
    color: var(--color-text-muted);
}

.sidebar-search-btn {
    background: none;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding: 9px 12px;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

.sidebar-search-btn:hover {
    color: var(--color-brand-cyan);
}

.field-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.field-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    /* Vertical stack */
    gap: var(--space-sm);
}

.field-card:hover,
.field-card.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-brand-cyan);
}

.field-card-top {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
    width: 100%;
}

.field-snapshot {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.snapshot-svg {
    width: 100%;
    height: 100%;
    padding: 4px;
}

.field-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* ... header/meta ... */

.field-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 0;
    /* managed by card gap */
    width: 100%;
}

.field-actions-row .btn-action {
    flex: 1;
    /* Distribute buttons evenly */
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--color-text-secondary);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background var(--transition-fast);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text-primary);
}

.btn-delete:hover {
    background: rgba(255, 23, 68, 0.15);
    color: var(--color-red);
}

.settings-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-brand-cyan), var(--color-brand-navy));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.settings-name {
    font-size: var(--font-size-base);
    font-weight: 600;
}

.settings-email {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.settings-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.settings-value {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.logout-btn {
    background: rgba(255, 23, 68, 0.1);
    color: var(--color-red);
    border: 1px solid rgba(255, 23, 68, 0.2);
}

.logout-btn:hover {
    background: rgba(255, 23, 68, 0.2);
}

/* Privacy & Data controls */
.settings-hint {
    font-size: 0.82rem;
    opacity: 0.7;
    margin-bottom: var(--space-sm, 8px);
    line-height: 1.4;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.18);
    margin-bottom: 8px;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.danger-btn {
    background: rgba(255, 23, 68, 0.1);
    color: var(--color-red);
    border: 1px solid rgba(255, 23, 68, 0.3);
}

.danger-btn:hover {
    background: rgba(255, 23, 68, 0.22);
}

.danger-btn:disabled,
.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.danger-note {
    color: var(--color-red);
    opacity: 0.92;
    margin-top: 4px;
}

.privacy-status {
    margin-top: 10px;
    margin-bottom: 0;
}

.privacy-link {
    color: var(--color-brand-cyan);
    text-decoration: none;
}

.privacy-link:hover {
    text-decoration: underline;
}

.privacy-status.error {
    color: var(--color-red);
    opacity: 0.95;
}


/* ============================================================
   RESPONSIVE — Additional
   ============================================================ */

@media (max-width: 360px) {
    .actions-section {
        grid-template-columns: 1fr;
    }

    .index-pill {
        padding: 5px 10px;
        font-size: 0.65rem;
    }
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

/* Two-panel field setup modal */
.modal-container--panels {
    padding: 0;
    overflow: hidden;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.modal-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal-panel--picker {
    display: none;
    flex: 1;
    min-height: 0;
}

/* When the picker panel is active */
.modal-container--panels.picking .modal-panel:not(.modal-panel--picker) {
    display: none;
}

.modal-container--panels.picking .modal-panel--picker {
    display: flex;
}

.modal-container--panels .modal-header,
.modal-container--panels .modal-footer {
    padding: 20px 20px 16px;
    flex-shrink: 0;
}

.modal-container--panels .modal-header {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.modal-container--panels .modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

.modal-container--panels .modal-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 14px;
}

/* ── Crop Trigger Button ── */
.crop-trigger-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}

.crop-trigger-btn:hover,
.crop-trigger-btn:focus {
    border-color: rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.3);
    outline: none;
}

.crop-trigger-btn.has-crop {
    border-color: rgba(255, 171, 0, 0.4);
    color: var(--color-text-primary);
}

.crop-trigger-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

#crop-trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Selected crop meta row */
.crop-trigger-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.crop-meta-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(255, 171, 0, 0.1);
    color: var(--color-brand-cyan);
    border: 1px solid rgba(255, 171, 0, 0.25);
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

.crop-meta-detail {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* ── Toggle Groups ── */
.toggle-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--color-text-primary);
}

.toggle-btn.active {
    background: rgba(0,200,83,0.12);
    border-color: rgba(0,200,83,0.4);
    color: var(--color-emerald);
}

/* ── Crop Picker Panel ── */
.crop-picker-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px !important;
}

.crop-picker-back {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
    flex-shrink: 0;
}

.crop-picker-back:hover { color: var(--color-text-primary); }

.crop-search-row {
    padding: 0 20px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.crop-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 10px;
}

.crop-search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-family: var(--font-family);
}

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

.crop-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: color 0.15s;
}

.crop-search-clear:hover { color: var(--color-text-primary); }

.crop-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    overscroll-behavior: contain;
}

.crop-cat-header {
    padding: 10px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    position: sticky;
    top: 0;
    background: rgba(13,59,46,0.97);
    backdrop-filter: blur(8px);
    z-index: 1;
}

.crop-list-item {
    padding: 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: background 0.12s;
    border-left: 2px solid transparent;
}

.crop-list-item:hover {
    background: rgba(255,255,255,0.05);
}

.crop-list-item.selected {
    background: rgba(255, 171, 0, 0.08);
    border-left-color: var(--color-brand-cyan);
}

.crop-item-name {
    font-size: 0.875rem;
    color: var(--color-text-primary);
    font-weight: 500;
}

.crop-list-item.selected .crop-item-name {
    color: var(--color-brand-cyan);
}

.crop-item-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.crop-no-results {
    padding: 32px 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

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

.modal-body {
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
    font-size: 0.95rem;
}

.form-input:focus {
    border-color: var(--color-brand-cyan);
    box-shadow: 0 0 0 3px rgba(255, 171, 0, 0.15);
    outline: none;
}

.notepad-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-bottom: var(--space-md);
}

.farm-notepad {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    margin-top: var(--space-sm);
}

.farm-notepad::placeholder {
    color: var(--color-text-muted);
}

.farm-notepad:focus {
    border-color: var(--color-brand-cyan);
    box-shadow: 0 0 0 3px rgba(255, 171, 0, 0.15);
    outline: none;
}

.notepad-status {
    margin-top: 4px;
    font-size: 0.82rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
}

.btn-primary {
    background: var(--color-brand-cyan);
    border: none;
    color: #000;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(255, 171, 0, 0.3);
}

.btn-primary:hover {
    background: #e69a00;
}
/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#sentinel-toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.sentinel-toast {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--color-text-primary);
    font-size: 13px;
    padding: 10px 18px;
    max-width: 320px;
    text-align: center;
    pointer-events: auto;
    animation: toast-in 0.2s ease;
}

.sentinel-toast.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

.sentinel-toast.toast-info {
    border-color: rgba(96, 165, 250, 0.4);
    color: #93c5fd;
}

.sentinel-toast.toast-success {
    border-color: rgba(52, 211, 153, 0.5);
    color: #6ee7b7;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
#sentinel-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sentinel-confirm-overlay.hidden { display: none; }

.sentinel-confirm-box {
    background: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    text-align: center;
}

.sentinel-confirm-box p {
    color: var(--color-text-primary);
    font-size: 14px;
    margin: 0 0 20px;
    line-height: 1.5;
}

.sentinel-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ============================================================
   INDEX PANEL — Legend + Description (Map view)
   ============================================================ */
.index-panel {
    padding: 10px 16px 8px;
    background: rgba(0, 0, 0, 0.75);
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), height 0.6s cubic-bezier(0.4, 0, 0.2, 1), padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.index-panel .bar-collapse-btn {
    align-self: flex-start;
    margin: -4px 0 4px -6px;
}

.index-panel.collapsed .bar-collapse-btn {
    margin: 0;
}

.legend-bar-container {
    margin-bottom: 6px;
}

.index-description:not(:empty) {
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 4px;
}

.legend-gradient {
    height: 10px;
    border-radius: 5px;
    width: 100%;
}

.legend-ticks {
    position: relative;
    height: 28px;
    margin-top: 2px;
}

.legend-tick {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.legend-tick::before {
    content: '';
    display: block;
    width: 1px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    margin-bottom: 2px;
}

.tick-main {
    font-size: 9px;
    color: rgba(255,255,255,0.55);
    white-space: nowrap;
    line-height: 1.2;
}

.tick-sub {
    font-size: 8px;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
    line-height: 1.2;
}

.index-description {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255,255,255,0.5);
}

.desc-name {
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
}

.desc-what {
    color: rgba(255,255,255,0.5);
}

.desc-action {
    color: #fbbf24;
    font-style: italic;
}

/* ============================================================
   HISTORY VIEW
   ============================================================ */
.history-header {
    padding: 16px 16px 0;
}

.history-subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 2px 0 0;
}

.history-controls {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-field-select {
    width: 100%;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
}

.history-field-select option {
    background: #080808;
    color: #fff;
}

.history-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.hist-pill {
    padding: 5px 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.hist-pill.active {
    background: rgba(255, 171, 0, 0.15);
    border-color: #ffab00;
    color: #ffab00;
}

.hist-pill:hover:not(.active) {
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.8);
}

.history-load-btn {
    width: 100%;
    padding: 10px;
    font-size: 13px;
}

.history-load-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.history-chart-wrap {
    padding: 0 16px 80px;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.history-chart-svg {
    width: 100%;
    max-width: 600px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.06);
    display: block;
}

.history-chart-caption {
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    margin-top: 6px;
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 0;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}

.history-loading-sub {
    font-size: 11px;
    color: var(--color-text-muted);
    margin: 0;
}

.history-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255,171,0,0.2);
    border-top-color: #ffab00;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   MAP HISTORY PANEL — Inline trend below the index legend
   ============================================================ */
.map-history-panel {
    padding: 8px 16px 6px;
    background: rgba(0, 0, 0, 0.75);
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.map-history-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.map-history-title {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.map-history-field-name {
    font-size: 10px;
    color: #ffab00;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

.map-history-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.map-history-close:hover {
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.08);
}

.map-history-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    padding: 2px 0;
}

.map-history-svg {
    width: 100%;
    height: 110px;
    display: block;
    overflow: visible;
}

.map-history-caption {
    font-size: 10px;
    color: rgba(255,255,255,0.25);
    text-align: center;
    margin: 0;
}

.map-history-filmstrip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,171,0,0.25) transparent;
}
.map-history-filmstrip::-webkit-scrollbar { height: 3px; }
.map-history-filmstrip::-webkit-scrollbar-thumb {
    background: rgba(255,171,0,0.3);
    border-radius: 2px;
}

.snap-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.snap-img {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    border: 1px solid rgba(255,171,0,0.2);
    object-fit: cover;
    background: rgba(0,0,0,0.3);
    display: block;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.12s;
}
.snap-img:hover { border-color: rgba(255,171,0,0.6); transform: scale(1.05); }

.snap-date {
    font-size: 9px;
    font-family: Inter, sans-serif;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
}

/* ---- NDVI snapshot lightbox ---- */
.snap-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.snap-lightbox.hidden { display: none; }
.snap-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
}
.snap-lightbox-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.snap-lightbox-img {
    max-width: min(80vmin, 512px);
    max-height: min(80vmin, 512px);
    border-radius: 8px;
    border: 1px solid rgba(255,171,0,0.35);
    image-rendering: auto;
    display: block;
}
.snap-lightbox-label {
    font-size: 13px;
    font-family: Inter, sans-serif;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.02em;
}

/* ============================================================
   PIN INSPECTOR POPUP
   ============================================================ */
.sentinel-pin-popup .maplibregl-popup-content {
    background: rgba(9, 38, 30, 0.96);
    border: 1px solid rgba(52, 211, 153, 0.35);
    border-radius: 10px;
    padding: 10px 16px 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.55);
    min-width: 72px;
    text-align: center;
}
.sentinel-pin-popup .maplibregl-popup-tip {
    border-top-color: rgba(9, 38, 30, 0.96);
}
.sentinel-pin-popup .maplibregl-popup-close-button {
    color: rgba(255,255,255,0.4);
    font-size: 16px;
    line-height: 1;
    top: 4px;
    right: 6px;
}

/* Touch devices need a fingertip-sized close target */
@media (pointer: coarse) {
    .sentinel-pin-popup .maplibregl-popup-close-button {
        font-size: 22px;
        padding: 6px 10px;
        top: 0;
        right: 0;
    }
}
.sentinel-pin-popup .maplibregl-popup-close-button:hover {
    color: #fff;
    background: none;
}
.pin-popup-index {
    font-size: 10px;
    font-weight: 700;
    color: rgba(52, 211, 153, 0.65);
    letter-spacing: 0.08em;
    margin-bottom: 2px;
    font-family: var(--font-family);
}
.pin-popup-value {
    font-size: 22px;
    font-weight: 700;
    color: #ffab00;
    line-height: 1;
    font-family: var(--font-family);
}
.pin-popup-label {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    margin-top: 4px;
    font-family: var(--font-family);
}

/* Soil/terrain inspection popup (reuses .sentinel-pin-popup container) */
.soil-pin { font-family: var(--font-family); min-width: 120px; }
.soil-pin-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.soil-pin-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.4);
}
.soil-pin-title {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.6);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.soil-pin-value {
    font-size: 16px;
    font-weight: 700;
    color: #e2e8f0;
    line-height: 1.15;
}
.soil-pin-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    margin-top: 2px;
}

/* ============================================================
   INDEX DATE CHIP — satellite acquisition date in index bar
   ============================================================ */
.index-date-chip {
    flex-shrink: 0;
    align-self: center;
    /* Now the last item in the pill row (moved there per Simon's request —
       previously this used position:sticky + margin-left:auto to visually
       pin it to the right edge while sitting mid-row, but with an overflowing
       row that combination clamps the chip's sticky position over the still
       -visible pill before it rather than scrolling with the rest of the row,
       hiding that pill under the chip. As a genuine trailing item, plain flow
       already puts it "at the end", so it just scrolls normally like the pills
       before it — no sticky/auto-margin needed. */
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: rgba(15, 33, 55, 0.95);
    border: 1px solid rgba(96, 165, 250, 0.22);
    color: rgba(96, 165, 250, 0.85);
    font-size: 10px;
    font-family: var(--font-family);
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.index-date-chip .date-chip-label {
    color: rgba(255, 255, 255, 0.45);
    font-weight: 400;
    margin-right: 6px;
}

.index-date-chip .date-chip-date {
    font-weight: 600;
}

/* ============================================================
   FIELD CARD SPARKLINE — Mini trend inside each sidebar card
   ============================================================ */
.field-history-zone {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 6px;
    width: 100%;
}

.field-sparkline {
    width: 100%;
    height: 52px;
    display: block;
    overflow: visible;
}

/* ============================================================
   RTL (Arabic) — baseline. dir="rtl" on <html> already flips text
   alignment and flex row direction; these are minimal, safe additions.
   Expand per-screen as more UI is translated (see handover i18n plan).
   ============================================================ */
[lang="ar"],
[dir="rtl"] {
    font-family: "Cairo", "Segoe UI", Tahoma, "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", sans-serif;
}

[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea {
    text-align: right;
}

/* ---- RTL polish (v0.25.0 i18n) ----
   dir="rtl" flips flex row order + base text; these target the spots that
   need explicit start/end handling. Keep LTR untouched. */

/* General: cards, panels and list items read right-aligned */
[dir="rtl"] .stat-row,
[dir="rtl"] .field-meta,
[dir="rtl"] .field-card,
[dir="rtl"] .settings-card,
[dir="rtl"] .index-description,
[dir="rtl"] .advisory-card,
[dir="rtl"] .crop-card,
[dir="rtl"] .modal-body,
[dir="rtl"] .form-group {
    text-align: right;
}

/* Forms: labels and hints align to the start (right in RTL) */
[dir="rtl"] .form-label,
[dir="rtl"] .settings-label,
[dir="rtl"] .settings-hint,
[dir="rtl"] .settings-value {
    text-align: right;
}

/* Modal footer buttons sit at the start edge */
[dir="rtl"] .modal-footer {
    flex-direction: row-reverse;
}

/* Bottom nav: keep the natural visual order (icons + labels centred already) */
[dir="rtl"] .bottom-nav {
    direction: rtl;
}

/* Sidebar header controls flip cleanly */
[dir="rtl"] .sidebar-header,
[dir="rtl"] .map-controls,
[dir="rtl"] .sidebar-sort {
    direction: rtl;
}

/* Chevrons / directional arrows point the right way in RTL */
[dir="rtl"] .sidebar-ctrl-btn svg,
[dir="rtl"] .crop-trigger-btn > svg:last-child,
[dir="rtl"] .crop-picker-back svg {
    transform: scaleX(-1);
}

/* Toggle groups + index switcher pills follow reading direction */
[dir="rtl"] .toggle-group,
[dir="rtl"] .index-switcher {
    direction: rtl;
}

/* Crop list rows: name on the right, meta on the left */
[dir="rtl"] .crop-list-item,
[dir="rtl"] .crop-cat-header {
    text-align: right;
}

/* Pixel inspector + history caption read RTL */
[dir="rtl"] .pixel-inspector,
[dir="rtl"] .map-history-caption,
[dir="rtl"] .map-history-header {
    direction: rtl;
}

/* Forecast / gauge labels stay centred (numeric); no flip needed.
   Date chip flips to keep the icon leading. */
[dir="rtl"] .index-date-chip {
    direction: rtl;
}

/* Danger note + privacy link align right */
[dir="rtl"] .danger-note,
[dir="rtl"] .privacy-link {
    text-align: right;
}

/* ============================================================
   SPOTLIGHT TOUR
   ============================================================ */

/* SVG overlay — dims everything except the hole cutout */
.sp-svg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sp-svg.sp-active { opacity: 1; }
.sp-dim { fill: rgba(0, 0, 0, 0.72); }

/* Tooltip bubble */
.sp-tooltip {
    position: fixed;
    z-index: 10000;
    background: var(--color-bg-card, #1e293b);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 16px 18px 14px;
    width: 260px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sp-tooltip.sp-active {
    opacity: 1;
    pointer-events: auto;
}

.sp-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-primary, #f1f5f9);
    margin: 0 0 6px;
    line-height: 1.3;
}
.sp-body {
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-text-secondary, #94a3b8);
    margin: 0 0 14px;
}
.sp-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sp-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sp-progress {
    font-size: 12px;
    color: var(--color-text-secondary, #94a3b8);
}
.sp-skip {
    background: none;
    border: none;
    color: var(--color-text-secondary, #94a3b8);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.15s;
}
.sp-skip:hover { color: var(--color-text-primary, #f1f5f9); }
.sp-next {
    background: var(--color-primary, #ffab00);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.sp-next:hover { opacity: 0.85; }

/* Arrow pointing toward the highlighted element */
.sp-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}
.sp-arrow--up {
    bottom: 100%;
    border-bottom-color: var(--color-bg-card, #1e293b);
    border-top: none;
}
.sp-arrow--down {
    top: 100%;
    border-top-color: var(--color-bg-card, #1e293b);
    border-bottom: none;
}
.sp-arrow--left {
    right: 100%;
    border-right-color: var(--color-bg-card, #1e293b);
    border-left: none;
}
.sp-arrow--right {
    left: 100%;
    border-left-color: var(--color-bg-card, #1e293b);
    border-right: none;
}

/* Emerald ring on the spotlit element */
.sp-target-highlight {
    outline: 2px solid var(--color-primary, #ffab00) !important;
    outline-offset: 3px !important;
    position: relative;
    z-index: 9999 !important;
}

/* ── Soil Analysis layer toggle buttons ──────────────────────────────────── */
/* Center the soil layer pills; wrap on narrow screens instead of horizontal scroll */
#soil-layer-list {
    justify-content: center;
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 2px 0 4px !important;
}

/* soil-layer-btn: inherits .index-pill base styling; only active + disabled states needed */
.soil-layer-btn.active {
    background: var(--color-brand-cyan);
    border-color: var(--color-brand-cyan);
    color: #000;
    box-shadow: 0 0 12px rgba(255, 171, 0, 0.3);
}
.soil-layer-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Soil Analysis panel — sits below the map layout like .map-history-panel */
.soil-analysis-panel {
    padding: 8px 16px 10px;
    background: rgba(20, 28, 48, 0.72);
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.soil-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.soil-panel-title {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    flex-shrink: 0;
}
.soil-panel-metrics {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.soil-panel-ssi {
    display: flex;
    gap: 6px;
    align-items: center;
}
.soil-metric {
    display: flex;
    gap: 3px;
    align-items: baseline;
}
.soil-metric-label {
    font-size: 9px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.soil-metric-value {
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
}
.soil-panel-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.soil-run-btn {
    font-size: 10px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-full);
    color: #94a3b8;
    cursor: pointer;
    font-family: var(--font-family);
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.soil-run-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
    color: #e2e8f0;
}
.soil-run-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============================================================
   FIELD SCOUT OVERLAY
   ============================================================ */

/* Entry button in dashboard */
.scout-entry-row {
    padding: 0 var(--space-md) var(--space-sm);
}

@media (min-width: 768px) {
    .scout-entry-row { display: none; }
}

.scout-entry-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 171, 0, 0.07);
    border: 1px solid rgba(255, 171, 0, 0.25);
    border-radius: var(--radius-md);
    color: var(--color-brand-cyan);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.scout-entry-btn:hover {
    background: rgba(255, 171, 0, 0.13);
    border-color: rgba(255, 171, 0, 0.45);
}

/* --- Full-screen overlay shell --- */

.scout-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    overflow: hidden;
    background: #000;
}

.scout-camera {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scout--no-camera .scout-camera { display: none; }

.scout-no-camera-bg {
    display: none;
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, #0a0a1a 0%, #000 70%);
}

.scout--no-camera .scout-no-camera-bg { display: block; }

/* --- HUD layer (absolute children, not flex) --- */

.scout-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Top bar */
.scout-top-bar {
    position: absolute;
    top: calc(76px + env(safe-area-inset-top, 0px));
    left: 16px;
    right: 72px;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 12px;
}

.scout-field-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scout-field-meta {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 2px;
}

/* Compass strip */
.scout-compass {
    position: absolute;
    top: calc(140px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    padding: 5px 14px;
    white-space: nowrap;
}

.scout-compass-dir {
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-tech);
    color: #ffab00;
    min-width: 24px;
    text-align: center;
}

.scout-compass-sep {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
}

.scout-compass-deg {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.55);
    min-width: 32px;
}

/* Mid row: NDVI panel · pulse · VSM panel */
.scout-mid-row {
    position: absolute;
    top: 50%;
    left: 16px;
    right: 16px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Glass data panels */
.scout-panel {
    width: 88px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    transition: border-color var(--transition-base);
}

.scout-panel-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-tech);
    color: #fff;
    line-height: 1;
    transition: color var(--transition-base);
}

.scout-panel-label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.38);
    margin-top: 5px;
}

.scout-panel-sub {
    display: block;
    font-size: 10px;
    font-weight: 500;
    margin-top: 3px;
    transition: color var(--transition-base);
}

/* Center pulse */
.scout-center-pulse {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.scout-pulse-ring {
    position: absolute;
    inset: 0;
    border: 1.5px solid rgba(255, 171, 0, 0.55);
    border-radius: 50%;
    animation: scout-pulse 2.4s ease-out infinite;
}

.scout-pulse-ring--delay { animation-delay: 1.2s; }

@keyframes scout-pulse {
    0%   { transform: scale(0.6); opacity: 0.8; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* No-camera fallback message */
.scout-no-camera-msg {
    display: none;
    position: absolute;
    top: calc(50% + 52px);
    left: 0;
    right: 0;
    text-align: center;
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.4);
    padding: 0 var(--space-xl);
    margin: 0;
}

.scout--no-camera .scout-no-camera-msg { display: block; }

/* Bottom advisory bar */
.scout-advisory-bar {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: border-color var(--transition-base);
}

.scout-adv-action {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.55);
    transition: color var(--transition-base);
}

.scout-adv-detail {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

/* Advisory state colours */
.scout-adv--irrigate { border-color: rgba(255, 23, 68, 0.4); }
.scout-adv--irrigate .scout-adv-action { color: #ff1744; }
.scout-adv--monitor  { border-color: rgba(255, 171, 0, 0.4); }
.scout-adv--monitor  .scout-adv-action { color: #ffab00; }
.scout-adv--ok       { border-color: rgba(52, 211, 153, 0.4); }
.scout-adv--ok       .scout-adv-action { color: #34d399; }

/* Close button */
.scout-close-btn {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    color: #fff;
    cursor: pointer;
    transition: background var(--transition-fast);
    z-index: 1;
}

.scout-close-btn:hover { background: rgba(0, 0, 0, 0.72); }

/* ============================================================
   MAP ADD DROPDOWN / MENU
   ============================================================ */
.map-add-dropdown {
    position: relative;
    display: flex;
    align-items: stretch;
    border-radius: var(--radius-sm);
    overflow: visible;
}

.map-add-dropdown .map-add-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    flex-grow: 1;
}

.map-add-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-xs);
    background: rgba(255, 171, 0, 0.1);
    border: 1px solid rgba(255, 171, 0, 0.35);
    border-left: 1px solid rgba(255, 171, 0, 0.2);
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    color: var(--color-brand-cyan);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.map-add-toggle:hover {
    background: rgba(255, 171, 0, 0.18);
}

.map-add-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    margin-top: 4px;
    display: none;
    flex-direction: column;
}

.map-add-menu.active {
    display: flex;
}

.map-add-menu-item {
    background: none;
    border: none;
    padding: 8px 12px;
    color: var(--color-text-light);
    font-size: var(--font-size-xs);
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.map-add-menu-item:hover {
    background: rgba(255, 171, 0, 0.1);
    color: var(--color-brand-cyan);
}

.map-add-menu-item:first-child {
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
}

.map-add-menu-item:last-child {
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

@keyframes slideInDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================================
   BOUNDARY EDIT PANEL
   ============================================================ */
.boundary-edit-panel {
    position: absolute;
    top: 70px;
    left: 20px;
    z-index: 100;
    width: 280px;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 171, 0, 0.35);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    color: var(--color-text-light);
    animation: slideInDown 0.3s ease-out;
}

.boundary-edit-panel.hidden {
    display: none !important;
}

.be-panel-title {
    font-family: var(--font-tech);
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-amber);
}

.be-panel-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.4;
    margin: 0;
}

.be-panel-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.btn-be {
    flex: 1;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-family: var(--font-tech);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.btn-be--cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--color-text-light);
}

.btn-be--cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-be--save {
    background: var(--color-amber);
    border: 1px solid var(--color-amber);
    color: #121212;
}

.btn-be--save:hover {
    background: #ffb300;
    box-shadow: 0 0 10px rgba(255, 171, 0, 0.35);
}

/* ============================================================
   GUIDED SELECT PANEL
   ============================================================ */
.guided-select-panel {
    position: absolute;
    top: 70px;
    left: 20px;
    z-index: 100;
    width: 280px;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    color: var(--color-text-light);
    animation: slideInDown 0.3s ease-out;
}

.guided-select-panel.hidden {
    display: none !important;
}

.gs-panel-title {
    font-family: var(--font-tech);
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-brand-cyan);
}

.gs-panel-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.4;
    margin: 0;
}

.gs-counter {
    font-family: var(--font-tech);
    font-size: var(--font-size-xs);
    font-weight: bold;
    color: var(--color-amber);
    background: rgba(255, 171, 0, 0.1);
    border: 1px solid rgba(255, 171, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    text-align: center;
    margin: var(--space-xs) 0;
}

.gs-shape-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.gs-option-title {
    font-family: var(--font-tech);
    font-size: var(--font-size-xs);
    font-weight: bold;
    color: var(--color-text-light);
}

.gs-radio-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.gs-radio-label:hover {
    color: var(--color-text-light);
}

.gs-radio-label input[type="radio"] {
    margin: 0;
    accent-color: var(--color-brand-cyan);
}

.gs-panel-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.btn-gs {
    flex: 1;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-family: var(--font-tech);
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.btn-gs--cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--color-text-light);
}

.btn-gs--cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-gs--generate {
    background: var(--color-brand-cyan);
    border: 1px solid var(--color-brand-cyan);
    color: #121212;
}

.btn-gs--generate:hover:not(:disabled) {
    background: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

.btn-gs--generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
}


