/* === MODALS === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.9);
    position: relative;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--green);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.form-input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--green);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-primary {
    flex: 1;
    background: var(--green);
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-secondary {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.barrel-mgmt-btns {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.barrel-card:hover .barrel-mgmt-btns {
    opacity: 1;
}

.mgmt-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.mgmt-btn:hover {
    border-color: var(--green);
    color: var(--green);
    background: rgba(126, 200, 32, 0.1);
}

.mgmt-btn.delete:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(224, 82, 82, 0.1);
}

/* === FLOW ANIMATION === */
@keyframes flow-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 0px var(--blue));
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
        filter: drop-shadow(0 0 10px var(--blue));
    }

    100% {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 0 0px var(--blue));
    }
}

.flow-indicator {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    color: var(--blue);
    animation: flow-pulse 1s infinite alternate ease-in-out;
    pointer-events: none;
    z-index: 10;
}

@keyframes wave-move {
    0% {
        transform: translateX(-50%) translateY(0);
    }

    100% {
        transform: translateX(-40%) translateY(-2px);
    }
}

.liquid-wave {
    position: absolute;
    top: 0;
    left: 0;
    width: 250%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0) 100%);
    animation: wave-move 1.5s infinite linear;
}

.flowing-glow {
    box-shadow: 0 0 20px rgba(82, 168, 224, 0.3) !important;
    border-color: var(--blue) !important;
}

/* === GOLDEN FLOW EFFECT === */
.golden-active {
    background: linear-gradient(180deg, #1e2a0f 0%, #4a3c10 50%, #2a1f0a 100%) !important;
    transition: background 1s ease-in-out !important;
}

.bubble-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
    overflow: hidden;
}

.bubble {
    position: absolute;
    bottom: -50px;
    background: rgba(255, 215, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    backdrop-filter: blur(2px);
    animation: bubble-rise var(--duration) linear infinite;
    left: var(--left);
    width: var(--size);
    height: var(--size);
    opacity: 0;
}

@keyframes bubble-rise {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.4;
    }

    100% {
        transform: translateY(-120vh) scale(1.2);
        opacity: 0;
    }
}

.golden-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(247, 198, 0, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 1s ease;
}

.golden-active .golden-overlay {
    opacity: 1;
}

:root {
    --bg: #080d08;
    --bg-1: #0c130c;
    --bg-2: #111811;
    --bg-card: rgba(14, 22, 14, 0.92);
    --green: #7ec820;
    --green-dim: rgba(126, 200, 32, 0.15);
    --green-glow: rgba(126, 200, 32, 0.4);
    --gold: #d4b896;
    --red: #e05252;
    --blue: #52a8e0;
    --blue-glow: rgba(82, 168, 224, 0.4);
    --text: #e8f0e8;
    --muted: #7a8f7a;
    --border: rgba(126, 200, 32, 0.12);
    --border-bright: rgba(126, 200, 32, 0.35);
    --font: 'Inter', sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

.theme-monochrome {
    --bg: #0b0c10;
    --bg-1: #12141c;
    --bg-2: #191b24;
    --bg-card: rgba(18, 20, 28, 0.92);
    --green: #e5e9f0;
    --green-dim: rgba(229, 233, 240, 0.08);
    --green-glow: rgba(229, 233, 240, 0.25);
    --gold: #8892b0;
    --red: #4c566a;
    --blue: #8fbcbb;
    --blue-glow: rgba(143, 188, 187, 0.25);
    --text: #eceff4;
    --muted: #6272a4;
    --border: rgba(229, 233, 240, 0.08);
    --border-bright: rgba(229, 233, 240, 0.25);

    --orchard-radial-1: rgba(229, 233, 240, 0.95);
    --orchard-radial-2: rgba(46, 52, 64, 0.85);
    --orchard-shadow-ring: rgba(229, 233, 240, 0.15);

    --cellar-radial-1: rgba(143, 188, 187, 0.9);
    --cellar-radial-2: rgba(46, 52, 64, 0.8);
    --cellar-shadow-ring: rgba(143, 188, 187, 0.15);
}

.theme-monochrome .nav-emoji {
    display: none;
}

/* === TOGGLE SWITCH === */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-bright);
    transition: .3s ease;
    border-radius: 24px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--muted);
    transition: .3s ease;
    border-radius: 50%;
}

.switch-toggle input:checked + .slider-toggle {
    background-color: var(--green-dim);
    border-color: var(--green);
}

.switch-toggle input:checked + .slider-toggle:before {
    transform: translateX(24px);
    background-color: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
}

/* === LEAFLET MONOCHROME MAP TILES === */
/* CartoDB Dark Matter is used as-is — no filter needed. */


/* === SCANLINE CRT SCIFI EFFECTS === */
.theme-monochrome .hq-root {
    position: relative;
}

.theme-monochrome .hq-root::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%), 
                linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0.03));
    z-index: 100000;
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    opacity: 0.35;
}

/* === CUSTOM MARKER STYLING === */
.orchard-custom-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
}

.orchard-custom-icon .pulse-ring-1,
.orchard-custom-icon .pulse-ring-2 {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    animation: orchard-pulse 2.5s ease-out infinite;
    pointer-events: none;
}

.orchard-custom-icon .pulse-ring-2 {
    animation-delay: 0.8s;
}

.orchard-marker-orchard .pulse-ring-1,
.orchard-marker-orchard .pulse-ring-2 {
    border: 1px solid var(--green-glow);
}

.orchard-marker-cellar .pulse-ring-1,
.orchard-marker-cellar .pulse-ring-2 {
    border: 1px solid var(--blue-glow);
}

.orchard-custom-icon .marker-core {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.orchard-marker-orchard .marker-core {
    background: radial-gradient(circle at 35% 35%, var(--orchard-radial-1, rgba(126, 200, 32, 0.9)), var(--orchard-radial-2, rgba(60, 100, 10, 0.8)));
    border: 2px solid var(--green);
    box-shadow: 0 0 0 6px var(--orchard-shadow-ring, rgba(126, 200, 32, 0.15)), 0 0 30px var(--green-glow), 0 4px 20px rgba(0, 0, 0, 0.5);
}

.orchard-marker-cellar .marker-core {
    background: radial-gradient(circle at 35% 35%, var(--cellar-radial-1, rgba(82, 168, 224, 0.9)), var(--cellar-radial-2, rgba(30, 80, 130, 0.8)));
    border: 2px solid var(--blue);
    box-shadow: 0 0 0 6px var(--cellar-shadow-ring, rgba(82, 168, 224, 0.15)), 0 0 30px var(--blue-glow), 0 4px 20px rgba(0, 0, 0, 0.5);
}

.orchard-custom-icon .marker-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 16, 8, 0.92);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.25s, color 0.25s;
}

.orchard-marker-orchard .marker-label {
    border: 1px solid var(--green-dim);
    color: var(--green);
}

.orchard-marker-cellar .marker-label {
    border: 1px solid var(--blue-dim);
    color: var(--blue);
}


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

html,
body,
#root {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100vw;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 2px;
}

/* === LAYOUT === */
.hq-root {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    height: 100%;
    overflow: hidden;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* === TOPBAR === */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    width: 100%;
    min-width: 0;
    padding: 0 2rem;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 200;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 2rem;
    min-width: 0;
}

.topbar-logo {
    height: 36px;
    object-fit: contain;
}

.topbar-nav {
    display: flex;
    gap: 4px;
}

.topbar-nav-btn {
    padding: 0.45rem 1.2rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.topbar-nav-btn.active {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid var(--border-bright);
}

.topbar-nav-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.topbar-clock {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--green);
    letter-spacing: 2px;
}

.topbar-date {
    font-size: 0.78rem;
    color: var(--muted);
}

.burger-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    transition: color 0.2s;
}

.burger-btn:hover {
    color: var(--green);
}

.mobile-nav-overlay {
    display: none;
}

.live-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    background: rgba(126, 200, 32, 0.1);
    border: 1px solid var(--border-bright);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff3b30;
    animation: pulse-dot-red 2s infinite;
}

@keyframes pulse-dot-red {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5);
    }

    50% {
        box-shadow: 0 0 0 5px transparent;
    }
}

/* === CONTENT AREA === */
.content {
    flex: 1;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

.page {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: 0;
    display: flex;
    overflow: hidden;
}

/* === ORCHARD MAP PAGE === */
.map-page {
    flex-direction: row;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.map-container {
    flex: 1;
    width: 100%;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.map-container .leaflet-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    background: #0a0f0a !important;
}

/* Prevent 1px black subpixel grid lines / seams between tiles on iOS Safari / Retina when zooming */
.leaflet-container .leaflet-tile-container img,
.leaflet-container img.leaflet-tile {
    width: 256.5px !important;
    height: 256.5px !important;
    max-width: none !important;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    outline: 1px solid transparent;
    mix-blend-mode: normal !important;
}

/* Orchard popup */
.leaflet-popup-content-wrapper {
    background: rgba(8, 16, 8, 0.97) !important;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-bright) !important;
    border-radius: 18px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--border), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
    color: var(--text) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
}

.leaflet-popup-tip {
    background: rgba(8, 16, 8, 0.97) !important;
}

.leaflet-popup-close-button {
    color: var(--muted) !important;
    font-size: 1.2rem !important;
    top: 12px !important;
    right: 12px !important;
}

/* Orchard Marker */
.orchard-marker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orchard-marker {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(126, 200, 32, 0.9), rgba(60, 100, 10, 0.8));
    border: 2px solid var(--green);
    box-shadow: 0 0 0 6px rgba(126, 200, 32, 0.2), 0 0 30px rgba(126, 200, 32, 0.5), 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.orchard-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 10px rgba(126, 200, 32, 0.15), 0 0 50px rgba(126, 200, 32, 0.7), 0 4px 20px rgba(0, 0, 0, 0.5);
}

.orchard-marker.cellar {
    background: radial-gradient(circle at 35% 35%, rgba(82, 168, 224, 0.9), rgba(30, 80, 130, 0.8));
    border-color: var(--blue);
    box-shadow: 0 0 0 6px rgba(82, 168, 224, 0.2), 0 0 30px rgba(82, 168, 224, 0.5), 0 4px 20px rgba(0, 0, 0, 0.5);
}

.orchard-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 16, 8, 0.9);
    border: 1px solid var(--border-bright);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--green);
    white-space: nowrap;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.orchard-pulse {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 1px solid var(--green-glow);
    animation: orchard-pulse 2.5s ease-out infinite;
    pointer-events: none;
}

.orchard-pulse:nth-child(2) {
    animation-delay: 0.8s;
}

@keyframes orchard-pulse {
    0% {
        transform: scale(0.7);
        opacity: 0.8;
    }

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

/* Right sidebar for map page */
.map-sidebar {
    width: 400px;
    flex-shrink: 0;
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.sidebar-section {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section.orchards-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1rem;
}

/* Area cards in sidebar */
.area-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.area-card:last-child {
    margin-bottom: 0;
}

.area-card:hover {
    border-color: var(--border-bright);
    background: var(--green-dim);
}

.area-card.active {
    border-color: var(--green);
    background: rgba(126, 200, 32, 0.08);
}

.area-card-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.area-card-sub {
    font-size: 0.75rem;
    color: var(--muted);
}

.area-card-data {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
}

.area-data-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.area-data-val {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--green);
}

.area-data-lbl {
    font-size: 0.62rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Weather Widget */
.weather-widget {
    flex-shrink: 0;
    background: var(--bg-2);
}

.weather-days {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.weather-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.7rem 0.3rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    font-size: 0.7rem;
}

.weather-day.today {
    border-color: var(--border-bright);
    background: var(--green-dim);
}

.weather-day-name {
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.62rem;
}

.weather-day.today .weather-day-name {
    color: var(--green);
}

.weather-icon {
    font-size: 1.4rem;
}

.weather-temp-high {
    color: var(--text);
    font-weight: 700;
    font-size: 0.85rem;
}

.weather-temp-low {
    color: var(--muted);
    font-size: 0.72rem;
}

.weather-desc {
    color: var(--muted);
    font-size: 0.6rem;
    text-align: center;
    line-height: 1.2;
}

/* Popup Card */
.popup-card {
    padding: 1.2rem;
    min-width: 350px;
    height: 430px;
    /* Fixed height keeps all tabs the same size */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.popup-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.popup-badge {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--green);
    background: var(--green-dim);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-bright);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    margin-left: 0.5rem;
    margin-top: 2px;
}

.popup-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.popup-data-cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.75rem;
}

.popup-data-label {
    font-size: 0.62rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.popup-data-value {
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--green);
}

.popup-trees {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 0.75rem;
}

.popup-tree-tag {
    background: rgba(126, 200, 32, 0.08);
    border: 1px solid rgba(126, 200, 32, 0.2);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.72rem;
    color: #bbd;
    display: flex;
    align-items: center;
    gap: 5px;
}

.popup-tree-count {
    color: var(--green);
    font-weight: 700;
}

/* Wind Overlay Animation */
.wind-box {
    flex: 1;
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 8px;
    transition: background 0.2s, box-shadow 0.2s;
    border: 1px solid transparent;
}

.wind-box:hover {
    background: rgba(82, 168, 224, 0.1);
}

.wind-box.active {
    background: rgba(82, 168, 224, 0.15);
    border-color: rgba(82, 168, 224, 0.4);
    box-shadow: 0 0 15px rgba(82, 168, 224, 0.2);
}

.wind-particle {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(82, 168, 224, 0.8), transparent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 400;
    opacity: 0;
}

/* === PRODUCTION STATS PAGE === */
.stats-page {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 2rem;
    gap: 1.5rem;
    display: flex;
}

.stats-grid-top {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    flex-shrink: 0;
    min-height: 0;
}

.stat-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.4rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.5rem;
}

.stat-kpi-value {
    font-family: var(--mono);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
}

.stat-kpi-unit {
    font-size: 0.9rem;
    color: var(--muted);
}

.stat-kpi-sub {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.4rem;
}

.stat-kpi-glow {
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--green-dim), transparent);
}

.stats-middle {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    flex-shrink: 0;
    min-height: 320px;
}

.stats-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-card-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1rem;
}

.chart-area {
    flex: 1;
    position: relative;
    min-height: 0;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table td {
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text);
}

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

.data-table tr:hover td {
    background: rgba(126, 200, 32, 0.04);
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(126, 200, 32, 0.08);
    border: 1px solid rgba(126, 200, 32, 0.2);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #acca78;
    margin: 1px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-input,
.filter-select {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 0.5rem 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.filter-input:focus,
.filter-select:focus {
    border-color: var(--border-bright);
}

.filter-select {
    padding-right: 1.5rem;
    cursor: pointer;
}

.filter-input {
    flex: 1;
    min-width: 200px;
}

.filter-select option {
    background: #111b11;
}

/* Scrollable table container */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin-bottom: 2rem;
}

.table-scroll {
    overflow: visible;
}

/* Variety badge row */
.variety-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

/* Map overlay HUD */
.map-hud {
    position: absolute;
    bottom: 1.5rem;
    left: 1.5rem;
    background: rgba(8, 16, 8, 0.92);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.5rem;
    display: flex;
    gap: 2rem;
    align-items: center;
    backdrop-filter: blur(12px);
    z-index: 800;
}

.map-hud-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Info Tooltip */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 0.6rem;
    font-weight: 800;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-btn:hover {
    background: var(--green-dim);
    color: var(--green);
    border-color: var(--green-glow);
}

.info-tooltip-wrap {
    position: relative;
    display: inline-block;
}

.info-tooltip-content {
    position: absolute;
    bottom: calc(100% + 4px);
    /* Tighter gap */
    width: min(280px, 80vw);
    padding: 12px;
    background: #0c130c;
    border: 1px solid var(--border-bright);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    z-index: 11000;
    font-size: 0.72rem;
    color: var(--text);
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    /* Reduced movement for stability */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    white-space: pre-line;
    max-height: min(350px, 70vh);
    overflow-y: auto;
}

.info-tooltip-content.center {
    left: 50%;
    transform: translateX(-50%) translateY(10px);
}

.info-tooltip-content.left {
    left: 0;
    transform: translateY(10px);
}

.info-tooltip-content.right {
    right: 0;
    transform: translateY(10px);
}

.info-tooltip-wrap:hover .info-tooltip-content,
.info-tooltip-wrap.active .info-tooltip-content {
    opacity: 1;
    pointer-events: auto;
}

.info-tooltip-wrap:hover .info-tooltip-content.center,
.info-tooltip-wrap.active .info-tooltip-content.center {
    transform: translateX(-50%) translateY(0);
}

.info-tooltip-wrap:hover .info-tooltip-content.left,
.info-tooltip-wrap.active .info-tooltip-content.left,
.info-tooltip-wrap:hover .info-tooltip-content.right,
.info-tooltip-wrap.active .info-tooltip-content.right {
    transform: translateY(0);
}

/* Leaflet Overrides for Tooltips */
.leaflet-popup-content-wrapper,
.leaflet-popup-content {
    overflow: visible !important;
}

.info-tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--border-bright) transparent transparent transparent;
}

.info-tooltip-content.left::after {
    left: 10px;
    margin-left: 0;
}

.info-tooltip-content.right::after {
    left: auto;
    right: 10px;
    margin-left: 0;
}

.map-hud-val {
    font-family: var(--mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--green);
}

.map-hud-lbl {
    font-size: 0.6rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.map-scale-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 16, 8, 0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 1rem;
    font-size: 0.72rem;
    color: var(--muted);
    backdrop-filter: blur(8px);
    z-index: 800;
    pointer-events: none;
}

.leaflet-control-zoom {
    display: none !important;
}

/* Responsive Improvements */
@media (max-width: 1200px) {
    .stats-grid-top {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-middle {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chart-card {
        min-height: 240px;
    }

    .map-sidebar {
        width: 340px;
    }
}

/* Popup Tabs */
.popup-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 2px;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.popup-tab-btn {
    flex: 1;
    padding: 6px 4px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-tab-btn.active {
    background: var(--green-dim);
    color: var(--green);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* === KELTERN & SETTINGS GRIDS === */
.keltern-grid {
    grid-template-columns: 1fr 1.25fr;
}

.settings-grid {
    grid-template-columns: 1fr 1fr;
}

/* === FLOATING MAP SELECTOR & TREE CONTROLS === */
.map-orchard-selector-bar {
    position: absolute;
    top: 10px;
    left: 8px;
    right: 8px;
    z-index: 850;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 6px 6px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.map-orchard-selector-bar::-webkit-scrollbar {
    display: none;
}

.map-orchard-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 999px;
    background: rgba(8, 16, 8, 0.88);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-bright);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    transition: all 0.2s;
    flex-shrink: 0;
}

.map-orchard-pill:hover {
    border-color: var(--green);
}

.map-orchard-pill.active {
    background: var(--green);
    color: #050a05;
    border-color: var(--green);
    box-shadow: 0 0 18px var(--green-glow);
}

.pill-tree-count {
    background: rgba(126, 200, 32, 0.22);
    color: var(--green);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-family: var(--mono);
    font-weight: 800;
}

.map-orchard-pill.active .pill-tree-count {
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
}

.map-trees-quickbar {
    position: absolute;
    top: 54px;
    left: 12px;
    right: 64px;
    z-index: 845;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.map-trees-quickbar::-webkit-scrollbar {
    display: none;
}

.map-trees-quickbar-label {
    background: rgba(8, 16, 8, 0.9);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.map-tree-chip {
    background: rgba(14, 26, 14, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--green);
    color: var(--green);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.73rem;
    font-family: var(--mono);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.15s;
}

.map-tree-chip.active,
.map-tree-chip:hover {
    background: var(--green);
    color: #000;
}

.map-add-tree-banner {
    position: absolute;
    top: 96px;
    left: 12px;
    right: 12px;
    z-index: 860;
    background: rgba(18, 36, 10, 0.95);
    border: 1px solid var(--green);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--green);
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.map-add-tree-banner button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-bright);
    color: var(--text);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.72rem;
    cursor: pointer;
    flex-shrink: 0;
}

.map-floating-controls {
    position: absolute;
    right: 12px;
    top: 60px;
    z-index: 840;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-ctrl-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(8, 16, 8, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-bright);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    transition: all 0.15s;
}

.map-ctrl-btn.active {
    background: var(--green);
    color: #000;
    border-color: var(--green);
}

@media (hover: hover) {
    .map-ctrl-btn:not(.active):hover {
        border-color: var(--green);
        background: rgba(22, 42, 22, 0.95);
    }
}

.map-ctrl-btn.add-tree-ctrl:not(.active) {
    font-size: 0.78rem;
    color: var(--green);
}

.map-ctrl-btn.add-tree-ctrl.active {
    font-size: 0.78rem;
    color: #000;
}

.mobile-map-bottom-bar {
    display: none;
}

/* === COMPACT ORCHARD MARKER WHEN ZOOMED IN === */
.orchard-custom-icon.compact-zoomed {
    opacity: 0.65;
    transform: scale(0.68);
    transition: all 0.25s ease;
}

.orchard-custom-icon.compact-zoomed .pulse-ring-1,
.orchard-custom-icon.compact-zoomed .pulse-ring-2 {
    display: none;
}

.orchard-edge-badge-leaflet {
    background: transparent !important;
    border: none !important;
}

.orchard-edge-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(8, 16, 8, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-bright);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.15s ease;
}

.orchard-edge-badge.active,
.orchard-edge-badge:hover {
    border-color: var(--green);
    color: var(--green);
    box-shadow: 0 0 14px var(--green-glow);
}

.orchard-edge-badge-count {
    background: rgba(126, 200, 32, 0.2);
    color: var(--green);
    border-radius: 999px;
    padding: 0 6px;
    font-size: 0.64rem;
    font-family: var(--mono);
    font-weight: 800;
}

/* === INDIVIDUAL TREE PULSING DOT & HOVER CARD === */
.tree-dot-leaflet-icon {
    background: transparent !important;
    border: none !important;
}

.tree-dot-leaflet-icon:hover {
    z-index: 10000 !important;
}

.tree-dot-marker {
    position: relative;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tree-dot-pulse {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(126, 200, 32, 0.35);
    border: 1px solid var(--green);
    animation: tree-dot-pulse-anim 2.2s ease-out infinite;
    pointer-events: none;
}

@keyframes tree-dot-pulse-anim {
    0% {
        transform: scale(0.55);
        opacity: 0.9;
    }
    100% {
        transform: scale(1.9);
        opacity: 0;
    }
}

.tree-dot-core {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid #081208;
    box-shadow: 0 0 10px var(--green-glow), 0 2px 5px rgba(0, 0, 0, 0.8);
    transform: scale(calc(1 + var(--center-prox, 0) * 0.55));
    transition: background 0.15s ease, border-color 0.15s ease;
    z-index: 2;
}

.tree-dot-marker.has-data .tree-dot-core {
    border-color: var(--gold);
}

.tree-dot-marker:hover .tree-dot-core,
.tree-dot-marker.selected .tree-dot-core,
.tree-dot-marker.center-focused .tree-dot-core {
    background: #fff;
    border-color: var(--green);
    box-shadow: 0 0 16px var(--green);
}

.tree-dot-marker:hover .tree-dot-core,
.tree-dot-marker.selected .tree-dot-core {
    transform: scale(1.45);
}

.tree-dot-marker.draggable {
    cursor: grab;
}

.tree-dot-marker.draggable:active {
    cursor: grabbing;
}

.tree-dot-marker.moving .tree-dot-core {
    background: #fff;
    border-color: var(--gold);
    box-shadow: 0 0 20px var(--gold), 0 0 10px var(--green);
    transform: scale(1.6);
}

.tree-dot-marker.moving .tree-dot-pulse {
    background: rgba(212, 184, 150, 0.45);
    border-color: var(--gold);
    animation-duration: 1.1s;
}

.tree-hover-card {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) translateY(6px) scale(0.75);
    background: rgba(8, 16, 8, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-bright);
    border-radius: 12px;
    padding: 8px 11px;
    min-width: 158px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.85);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
    z-index: 9999;
}

.tree-hover-card::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: var(--border-bright) transparent transparent transparent;
}

/* Desktop hover & clicked/selected tree (works regardless of reticle mode) */
.tree-dot-marker:hover .tree-hover-card,
.tree-dot-marker.selected .tree-hover-card {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

/* Dynamic Center-Proximity Zoom Effect (Mobile & Panning) */
.tree-dot-marker.center-focused .tree-hover-card {
    opacity: var(--card-opacity, 1);
    visibility: visible;
    transform: translateX(-50%) translateY(var(--card-y, 0px)) scale(var(--card-scale, 1));
    transition: none;
    pointer-events: auto;
}

/* Subtle Center Target Reticle */
.map-center-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reticle-ring {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px dashed rgba(126, 200, 32, 0.28);
}

.reticle-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(126, 200, 32, 0.35);
}

.tree-hover-title {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--green);
    white-space: nowrap;
}

.tree-hover-sub {
    font-size: 0.66rem;
    color: var(--muted);
    margin-bottom: 6px;
    white-space: nowrap;
}

.tree-hover-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 5px;
}

.tree-hover-metric {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.tree-hover-metric-forecast {
    margin-top: 2px;
    padding-top: 4px;
    border-top: 1px dashed rgba(126, 200, 32, 0.28);
}

.tree-hover-metric-forecast .tree-hover-lbl {
    color: var(--green);
    font-weight: 700;
}

.tree-hover-metric-forecast .tree-hover-val {
    color: var(--green);
}

.tree-hover-lbl {
    font-size: 0.56rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.tree-hover-val {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.tree-hover-details-btn {
    margin-top: 7px;
    width: 100%;
    padding: 5px 8px;
    border-radius: 7px;
    background: rgba(126, 200, 32, 0.16);
    border: 1px solid var(--green);
    color: var(--green);
    font-family: var(--font);
    font-size: 0.68rem;
    font-weight: 800;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.15s ease;
    text-align: center;
}

.tree-hover-details-btn:hover,
.tree-hover-details-btn:active {
    background: var(--green);
    color: #050a05;
}

/* === TREE DETAIL MODAL / SHEET === */
.tree-modal-overlay {
    z-index: 12000;
}

.orchard-sheet-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.45);
}

.orchard-context-sheet {
    width: 100% !important;
    max-width: 540px !important;
    max-height: 82dvh !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 0.85rem 1.15rem 1.25rem 1.15rem !important;
    touch-action: none;
}

.tree-detail-sheet {
    max-width: 640px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow: hidden;
}

.sheet-drag-handle {
    display: none;
    width: 42px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin: 0 auto 0.75rem auto;
    flex-shrink: 0;
}

.tree-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tree-modal-badge {
    display: inline-flex;
    align-items: center;
    background: var(--green-dim);
    border: 1px solid var(--border-bright);
    color: var(--green);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tree-saved-pill {
    background: rgba(126, 200, 32, 0.2);
    border: 1px solid var(--green);
    color: var(--green);
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
}

.tree-modal-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    margin-top: 0.35rem;
    font-family: var(--mono);
}

.tree-modal-close {
    position: static !important;
    padding: 4px;
}

.tree-modal-body {
    flex: 1;
    overflow-y: auto;
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding-right: 4px;
}

.tree-section-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.1rem;
}

.tree-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.85rem;
}

.tree-age-control-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.tree-age-stepper {
    display: flex;
    flex-direction: column;
}

.age-step-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-2);
    border: 1px solid var(--border-bright);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.age-step-btn:hover {
    background: var(--green);
    color: #000;
}

.age-number-input {
    width: 82px !important;
    text-align: center;
    font-family: var(--mono) !important;
    font-size: 1.1rem !important;
    font-weight: 800;
    color: var(--green) !important;
    padding: 0.5rem !important;
}

.tree-form-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Photos Grid */
.tree-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.tree-photo-slot {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tree-photo-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tree-photo-delete-btn {
    background: rgba(224, 82, 82, 0.12);
    border: 1px solid rgba(224, 82, 82, 0.3);
    color: var(--red);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tree-photo-preview-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.tree-photo-img {
    width: 100%;
    height: 125px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-bright);
    cursor: zoom-in;
}

.tree-photo-replace-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    text-align: center;
}

.tree-photo-empty-drop {
    min-height: 140px;
    border: 1px dashed var(--border-bright);
    border-radius: 10px;
    background: rgba(126, 200, 32, 0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.tree-photo-empty-drop:hover {
    background: rgba(126, 200, 32, 0.08);
}

/* Harvest Form & List */
.tree-harvest-form {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.85rem;
}

.tree-harvest-inputs {
    display: grid;
    grid-template-columns: 90px 100px 100px 1fr;
    gap: 0.6rem;
}

.tree-pruning-inputs {
    display: grid;
    grid-template-columns: 95px 1fr 1fr;
    gap: 0.6rem;
}

.tree-harvest-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tree-harvest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.tree-harvest-year-badge {
    background: var(--green-dim);
    border: 1px solid var(--border-bright);
    color: var(--green);
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
}

/* Lightbox */
.photo-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 25000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.photo-lightbox-header {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.photo-lightbox-img {
    max-width: 95vw;
    max-height: 82vh;
    border-radius: 12px;
    border: 1px solid var(--border-bright);
    object-fit: contain;
}

/* === MOBILE VIEWPORT (<= 768px) === */
@media (max-width: 768px) {
    .hq-root {
        flex-direction: column;
        height: 100dvh;
    }

    /* --- TOPBAR --- */
    .topbar {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        height: 50px !important;
        padding: 0.4rem 0.9rem !important;
        position: relative !important;
        z-index: 10005 !important;
    }

    .topbar-left {
        display: flex !important;
        align-items: center !important;
    }

    .topbar-logo {
        height: 26px !important;
    }

    .topbar-nav {
        display: none !important;
    }

    .topbar-right {
        display: flex !important;
        align-items: center !important;
        gap: 0.65rem !important;
    }

    .topbar-date-wrap,
    .topbar-date,
    .live-pill {
        display: none !important;
    }

    .topbar-clock {
        font-size: 0.85rem !important;
        letter-spacing: 1px !important;
    }

    .burger-btn {
        display: flex !important;
    }

    .mobile-nav-overlay {
        display: flex !important;
        position: absolute;
        top: 50px;
        left: 0;
        right: 0;
        background: rgba(12, 19, 12, 0.97);
        backdrop-filter: blur(15px);
        border-bottom: 1px solid var(--border-bright);
        flex-direction: column;
        padding: 0.85rem;
        gap: 0.45rem;
        z-index: 20000 !important;
    }

    .mobile-nav-btn {
        width: 100%;
        padding: 0.75rem 1rem;
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid var(--border);
        border-radius: 10px;
        color: var(--text);
        font-family: var(--font);
        font-size: 0.88rem;
        font-weight: 600;
        cursor: pointer;
        text-align: left;
    }

    .mobile-nav-btn.active {
        background: var(--green-dim);
        border-color: var(--green);
        color: var(--green);
    }

    /* --- PAGE BASES --- */
    .page {
        padding: 0;
    }

    /* --- ORCHARDS (WIESEN) FULLSCREEN MOBILE MAP --- */
    .map-page {
        flex-direction: column;
        padding: 0 !important;
    }

    .map-container {
        width: 100%;
        height: 100% !important;
        flex: 1;
        min-height: 0;
    }

    /* Hide the bulky desktop right sidebar on mobile Wiesen page — map is full screen! */
    .map-sidebar {
        display: none !important;
    }

    .map-hud,
    .map-scale-hint {
        display: none !important;
    }

    .mobile-map-bottom-bar {
        display: block;
        position: absolute;
        left: 10px;
        right: 10px;
        bottom: 10px;
        z-index: 850;
    }

    .mobile-active-orchard-card {
        background: rgba(8, 16, 8, 0.94);
        backdrop-filter: blur(14px);
        border: 1px solid var(--border-bright);
        border-radius: 14px;
        padding: 0.7rem 0.9rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.65rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    }

    .mobile-orchard-info-btn {
        background: var(--green-dim);
        border: 1px solid var(--green);
        color: var(--green);
        border-radius: 9px;
        padding: 0.48rem 0.75rem;
        font-size: 0.74rem;
        font-weight: 800;
        cursor: pointer;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .mobile-orchard-close-btn {
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid var(--border);
        color: var(--muted);
        border-radius: 9px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    /* --- TREE DETAIL SHEET ON MOBILE --- */
    .tree-modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .tree-detail-sheet {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90dvh !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 0.85rem 1rem 1.25rem 1rem !important;
    }

    .sheet-drag-handle {
        display: block;
    }

    .tree-photos-grid {
        grid-template-columns: 1fr;
    }

    .tree-photo-img {
        height: 160px;
    }

    .tree-photo-empty-drop {
        min-height: 95px;
        flex-direction: row;
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        gap: 12px;
    }

    .tree-harvest-inputs {
        grid-template-columns: 1fr 1fr;
    }

    .tree-pruning-inputs {
        grid-template-columns: 1fr;
    }

    .tree-harvest-note-col {
        grid-column: span 2;
    }

    .tree-form-two-col {
        grid-template-columns: 1fr;
    }

    .popup-card {
        min-width: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-height: 75dvh;
        padding: 0.5rem 0.25rem !important;
    }

    /* --- STATS, CELLAR, KELTERN, SETTINGS PAGES ON MOBILE --- */
    .stats-page {
        overflow-y: auto;
        display: flex !important;
        flex-direction: column !important;
        padding: 0.85rem !important;
        padding-bottom: 1.5rem !important;
        gap: 0.85rem !important;
    }

    .stats-grid-top {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }

    .stat-kpi {
        padding: 1rem 1.1rem !important;
    }

    .stat-kpi-value {
        font-size: 1.65rem !important;
    }

    .stats-middle,
    .keltern-grid,
    .settings-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
        min-height: 0 !important;
    }

    .chart-card {
        min-height: 240px !important;
        padding: 1.1rem !important;
    }

    .filter-bar {
        padding: 0.8rem !important;
    }

    .table-card {
        flex: none;
        height: auto;
        padding: 0.85rem !important;
        margin-bottom: 1rem !important;
    }

    .table-scroll {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 560px !important;
    }

    /* --- CELLAR (KELLER) ON MOBILE --- */
    .barrel-mgmt-btns {
        opacity: 1 !important;
    }

    .cellar-kpi-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }

    .barrel-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .barrel-card {
        padding: 1rem !important;
    }

    /* --- MODALS --- */
    .modal-card {
        padding: 1.15rem !important;
        border-radius: 16px !important;
        max-height: 90dvh;
        overflow-y: auto;
    }

    .modal-actions {
        margin-top: 1.25rem !important;
        gap: 0.65rem !important;
    }
}

/* === CELLAR PAGE === */
.hahn-zone {
    border: 2px solid var(--green) !important;
    background: rgba(126, 200, 32, 0.07) !important;
    flex-shrink: 0;
}

.hahn-zone-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1rem;
}

.hahn-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 80px;
    align-items: flex-start;
}

.hahn-empty {
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 0.82rem;
    font-style: italic;
    gap: 0.5rem;
    min-height: 60px;
}

.barrel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
    flex-shrink: 0;
}

.barrel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem 1.25rem 1rem 1.25rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.barrel-card:hover {
    border-color: var(--border-bright);
}

.barrel-card.on-tap {
    border-color: var(--green);
    box-shadow: 0 0 20px rgba(126, 200, 32, 0.15);
}

.barrel-fill-bg {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 4px;
    top: 0;
    border-radius: 16px 0 0 16px;
    background: var(--border);
}

.barrel-fill-fg {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 4px;
    border-radius: 0 0 0 16px;
    transition: height 0.4s ease, background 0.4s ease;
}

.barrel-id {
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tap-badge {
    background: var(--blue);
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0;
}

.barrel-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.barrel-inhalt {
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.4;
    margin-bottom: 0.3rem;
}

.barrel-vol-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.barrel-vol {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
}

.barrel-vol-unit {
    font-size: 0.82rem;
    color: var(--muted);
}

.barrel-vol-max {
    font-size: 0.72rem;
    color: var(--muted);
    margin-left: auto;
}

.barrel-pct-bar-wrap {
    height: 4px;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
    margin: 0.2rem 0;
}

.barrel-pct-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease, background 0.4s ease;
}

.barrel-controls {
    display: flex;
    gap: 5px;
    margin-top: 0.6rem;
    align-items: center;
}

.barrel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg-1);
    color: var(--text);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--font);
    font-weight: 600;
    transition: all 0.15s;
    flex-shrink: 0;
}

.barrel-btn:hover {
    border-color: var(--border-bright);
    background: var(--green-dim);
    color: var(--green);
}

.barrel-btn.hahn-btn {
    margin-left: auto;
    color: var(--green);
    border-color: var(--border-bright);
}

.barrel-btn.hahn-btn.off {
    color: var(--muted);
    border-color: var(--border);
}

.barrel-step-label {
    font-size: 0.62rem;
    color: var(--muted);
    text-align: center;
    line-height: 1;
}

.cellar-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    flex-shrink: 0;
}

.cellar-export-row {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.cellar-kpi-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    flex-shrink: 0;
}

@media (max-width: 1100px) {
    .cellar-kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .cellar-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}
