/* ==========================================
   SylvaNexus Global SaaS - Main Stylesheet
   Migrated from: MyForestSaaS/css/style.css
   ========================================== */

/* === Base Reset & Global Styles === */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #1a1a1a;
    font-family: "Microsoft JhengHei", "Segoe UI", sans-serif;
    color: white;
    overflow: hidden;
}

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

/* === Sidebar Navigation === */
#sylva-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 60px;
    background: #1e272e;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
}

#sidebar-blocker {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2010;
    cursor: not-allowed;
}

.sylva-btn {
    position: relative;
    width: 100%;
    padding: 15px 0;
    text-align: center;
    color: #bdc3c7;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.2s ease;
}

.sylva-btn:hover,
.sylva-btn.active {
    color: #fff;
    background: #3498db;
}

.sylva-tooltip {
    position: absolute;
    left: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    z-index: 3000;
}

.sylva-btn:hover .sylva-tooltip {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.5s;
}

.sylva-divider {
    width: 26px;
    height: 1px;
    margin: 6px 0;
    background: rgba(255, 255, 255, 0.18);
}

#sylva-subnav {
    position: absolute;
    top: 12px;
    left: 68px;
    width: 0;
    max-height: calc(100vh - 24px);
    overflow: hidden;
    background: rgba(30, 39, 46, 0.96);
    border: 1px solid rgba(82, 179, 217, 0.18);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    z-index: 1999;
    opacity: 0;
    transition: width 0.22s ease, opacity 0.22s ease;
}

#sylva-subnav.open {
    width: 132px;
    opacity: 1;
}

.sidebar-subnav-header {
    padding: 12px 10px 8px;
    color: #9bd8ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-subnav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
}

.sidebar-subnav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 9px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: #cfd8dc;
    cursor: pointer;
    text-align: left;
    font-size: 12px;
    transition: all 0.2s ease;
}

.sidebar-subnav-btn i {
    width: 16px;
    text-align: center;
    font-size: 14px;
}

.sidebar-subnav-btn:hover,
.sidebar-subnav-btn.active {
    color: #ffffff;
    background: rgba(52, 152, 219, 0.18);
    border-color: rgba(52, 152, 219, 0.3);
}

.sidebar-subnav-btn-label {
    line-height: 1.3;
}

/* === Control Panel === */
#sylva-panel {
    position: absolute;
    top: 20px;
    left: 80px;
    width: 340px;
    background: rgba(30, 30, 30, 0.95);
    color: #eee;
    z-index: 2001;
    border-radius: 8px;
    border: 1px solid #444;
    display: none;
    flex-direction: column;
    max-height: 85vh;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

#sylva-panel-header {
    padding: 12px 15px;
    background: #2c3e50;
    font-weight: bold;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
    cursor: move;
    user-select: none;
}

.module-intro-card {
    display: none;
    margin: 15px 15px 0;
    padding: 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(46, 204, 113, 0.08));
    border: 1px solid rgba(82, 179, 217, 0.25);
}

.module-intro-group {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(52, 152, 219, 0.2);
    color: #9bd8ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.module-intro-description {
    color: #cfd8dc;
    font-size: 12px;
    line-height: 1.6;
}

#gis-lock-notice {
    display: none;
    margin: 12px 15px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(243, 156, 18, 0.14);
    border: 1px solid rgba(243, 156, 18, 0.35);
    color: #ffd27a;
    font-size: 12px;
    line-height: 1.5;
}

.sylva-close {
    cursor: pointer;
    color: #e74c3c;
    background: none;
    border: none;
    font-size: 18px;
    transition: transform 0.2s;
}

.sylva-close:hover {
    transform: scale(1.2);
}

/* === Form Elements === */
.sylva-input {
    width: 100%;
    box-sizing: border-box;
    background: #333;
    color: white;
    border: 1px solid #555;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
}

.sylva-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.sylva-action {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 10px;
    color: white;
    transition: all 0.3s;
}

.sylva-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

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

.sylva-action:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

body.gis-ui-locked #map,
body.gis-ui-locked #profile-container,
body.gis-ui-locked #sylva-panel-header,
body.gis-ui-locked #sylva-subnav,
body.gis-ui-locked .leaflet-control-container,
body.gis-ui-locked #view-logistics,
body.gis-ui-locked #view-profile,
body.gis-ui-locked #view-survey,
body.gis-ui-locked #view-sensors,
body.gis-ui-locked #view-edge,
body.gis-ui-locked #view-alerts,
body.gis-ui-locked #view-incidents,
body.gis-ui-locked #view-foxglove,
body.gis-ui-locked #view-biodiversity,
body.gis-ui-locked #view-carbon,
body.gis-ui-locked #view-esg {
    pointer-events: none;
    opacity: 0.42;
}

body.gis-ui-locked #view-volume,
body.gis-ui-locked #module-intro-card,
body.gis-ui-locked #gis-lock-notice {
    pointer-events: auto;
    opacity: 1;
}

.leaflet-top.leaflet-right .leaflet-control-layers {
    margin-top: 64px;
}

body.volume-draw-mode .leaflet-bottom.leaflet-right {
    z-index: 2105;
}

body.volume-draw-mode .leaflet-bottom.leaflet-right .leaflet-draw {
    margin-bottom: 24px;
}

body.volume-draw-mode .leaflet-draw-toolbar a {
    pointer-events: auto;
}

/* === Profile Chart Container === */
#profile-container {
    position: absolute;
    bottom: 20px;
    left: 80px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 15px;
    border-radius: 8px;
    z-index: 2000;
    display: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#loading-dem {
    color: #00e5ff;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    padding: 20px;
}

/* === Panel Views === */
.panel-view {
    display: none;
}

.scaffold-banner {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: rgba(52, 152, 219, 0.12);
    border: 1px solid rgba(52, 152, 219, 0.35);
    border-radius: 8px;
    color: #9bd8ff;
    font-size: 12px;
}

.scaffold-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.scaffold-stat-card,
.scaffold-card,
.scaffold-provider-group,
.scaffold-list-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.scaffold-stat-card {
    padding: 12px;
}

.scaffold-stat-card-wide {
    grid-column: span 1;
}

.scaffold-stat-card-full {
    grid-column: 1 / -1;
}

.scaffold-stat-label,
.scaffold-item-meta,
.scaffold-item-note,
.scaffold-empty,
.scaffold-card-title,
.scaffold-provider-title {
    color: #9aa4ad;
    font-size: 12px;
}

.scaffold-stat-value {
    margin-top: 6px;
    color: #ffffff;
    font-size: 24px;
    font-weight: 700;
}

.scaffold-stat-value-small {
    font-size: 14px;
    line-height: 1.4;
}

.scaffold-card,
.scaffold-provider-group {
    padding: 12px;
    margin-bottom: 14px;
}

.scaffold-card-title,
.scaffold-provider-title {
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.scaffold-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scaffold-list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
}

.scaffold-item-title {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.scaffold-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.scaffold-item-value,
.scaffold-item-text,
.scaffold-link {
    color: #dfe6e9;
    font-size: 12px;
}

.scaffold-item-text {
    margin-top: 6px;
    line-height: 1.5;
}

.scaffold-item-note {
    margin-top: 8px;
    line-height: 1.5;
}

.scaffold-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.scaffold-pill-online {
    background: rgba(46, 204, 113, 0.18);
    color: #6ef3a2;
}

.scaffold-pill-critical {
    background: rgba(231, 76, 60, 0.18);
    color: #ff8c82;
}

.scaffold-pill-warning,
.scaffold-pill-reserved {
    background: rgba(243, 156, 18, 0.18);
    color: #ffcf70;
}

.scaffold-alert-high {
    border-left: 4px solid #e74c3c;
}

.scaffold-alert-critical {
    border-left: 4px solid #ff5f57;
    box-shadow: inset 0 0 0 1px rgba(231, 76, 60, 0.15);
}

.scaffold-alert-medium {
    border-left: 4px solid #f39c12;
}

.scaffold-alert-low {
    border-left: 4px solid #3498db;
}

.leaflet-top.leaflet-right .leaflet-control-layers {
    margin-top: 64px;
}

.sylva-layer-switcher-control {
    margin-top: 64px;
    position: relative;
    z-index: 2100;
    pointer-events: auto;
}

.sylva-layer-switcher {
    width: 220px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.24);
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.sylva-layer-switcher * {
    pointer-events: auto;
}

.sylva-layer-switcher-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.sylva-layer-switcher-group {
    border: 0;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #35506b;
    background: #eef4f8;
    cursor: pointer;
}

.sylva-layer-switcher-group.is-active {
    background: #2d7d46;
    color: #ffffff;
}

.sylva-layer-switcher-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sylva-layer-switcher-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    color: #243447;
    background: rgba(241, 245, 249, 0.9);
    cursor: pointer;
}

.sylva-layer-switcher-item.is-active {
    background: rgba(45, 125, 70, 0.12);
}

.sylva-layer-switcher-input {
    margin: 0;
}

.sylva-layer-switcher-icon {
    font-size: 14px;
    line-height: 1;
}

.sylva-layer-switcher-color {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(36, 52, 71, 0.2);
    flex-shrink: 0;
}

.sylva-layer-switcher-label {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.layer-catalog-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.layer-catalog-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.layer-catalog-group-title {
    color: #9bd8ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.layer-catalog-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

.layer-catalog-item.is-active {
    border-color: rgba(82, 179, 217, 0.28);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.layer-catalog-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
}

.layer-catalog-summary::-webkit-details-marker {
    display: none;
}

.layer-catalog-summary-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.layer-catalog-icon {
    font-size: 16px;
    line-height: 1.4;
}

.layer-catalog-color,
.layer-catalog-grade-chip {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    margin-top: 4px;
}

.layer-catalog-text {
    flex: 1;
    min-width: 0;
}

.layer-catalog-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.layer-catalog-title {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}

.layer-catalog-state {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.layer-catalog-state.is-active {
    background: rgba(46, 204, 113, 0.15);
    color: #84f3b1;
}

.layer-catalog-state.is-inactive {
    background: rgba(149, 165, 166, 0.14);
    color: #c6d1d6;
}

.layer-catalog-description-preview,
.layer-catalog-body-text,
.layer-catalog-source-item,
.layer-catalog-grade-note {
    color: #b7c3cc;
    font-size: 12px;
    line-height: 1.6;
}

.layer-catalog-description-preview {
    margin-top: 4px;
}

.layer-catalog-chevron {
    color: #8fa7b5;
    font-size: 14px;
    line-height: 1;
    padding-top: 4px;
    transition: transform 0.2s ease;
}

.layer-catalog-item[open] .layer-catalog-chevron {
    transform: rotate(180deg);
}

.layer-catalog-body {
    padding: 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.layer-catalog-section {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.layer-catalog-section-label {
    color: #9bd8ff;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}

.layer-catalog-source-list,
.layer-catalog-grading-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-catalog-source-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 8px 10px;
}

.layer-catalog-grading-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 8px 10px;
}

.layer-catalog-grade-text {
    flex: 1;
    min-width: 0;
}

.layer-catalog-grade-label {
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

.scaffold-provider-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scaffold-empty {
    padding: 16px;
    text-align: center;
}

.scaffold-link {
    text-decoration: none;
    color: #63c5ff;
}

.scaffold-link:hover {
    color: #9bd8ff;
}

.incident-controls {
    margin-bottom: 14px;
}

.incident-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin-top: 10px;
}

.incident-meta-item {
    min-width: 0;
}

.incident-meta-item-full {
    grid-column: 1 / -1;
}

.incident-meta-label {
    color: #9aa4ad;
    font-size: 11px;
    margin-bottom: 4px;
}

.incident-meta-value {
    color: #ffffff;
    font-size: 12px;
    line-height: 1.45;
    word-break: break-word;
}

.incident-location {
    margin-top: 8px;
    color: #9bd8ff;
    font-size: 12px;
}

.incident-action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.incident-focus-btn {
    border: 1px solid rgba(52, 152, 219, 0.45);
    background: rgba(52, 152, 219, 0.14);
    color: #9bd8ff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.incident-focus-btn:hover {
    background: rgba(52, 152, 219, 0.22);
}

/* === Leaflet Custom Popup Styles === */
.custom-popup .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    padding: 0;
}

.custom-popup .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.98);
}

.custom-popup .leaflet-popup-content {
    resize: both !important;
    overflow: auto !important;
    min-width: 280px;
    margin: 15px;
    padding-right: 5px;
}

/* === Info Tables === */
.info-table {
    width: 100%;
    color: #222;
    font-size: 13px;
    border-collapse: collapse;
    margin-top: 5px;
}

.info-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

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

.info-table .label {
    color: #555;
    background: #f5f5f5;
    font-weight: bold;
    white-space: nowrap;
    width: 35%;
}

.info-table .val {
    font-weight: bold;
    text-align: right;
    color: #000;
    word-break: break-word;
}

/* === Details Section === */
.details-section {
    margin-top: 10px;
    border-top: 1px dashed #ccc;
    padding-top: 10px;
}

.details-title {
    font-size: 11px;
    color: #888;
    margin-bottom: 5px;
    text-align: center;
    cursor: pointer;
    transition: color 0.2s;
}

.details-title:hover {
    color: #2ecc71;
}

/* === Responsive Design === */

/* --- iPad / Tablet (portrait & landscape) --- */
@media (max-width: 1024px) {
    #sylva-sidebar {
        width: 50px;
        padding-top: 10px;
    }

    .sylva-btn {
        font-size: 18px;
        padding: 12px 0;
    }

    #map {
        left: 50px;
    }

    #sylva-panel {
        left: 65px;
        width: 320px;
        max-height: 80vh;
    }

    #profile-container {
        left: 65px;
        right: 15px;
    }
}

/* --- Mobile landscape (wider short screens) --- */
@media (max-width: 768px) and (orientation: landscape) {
    #sylva-sidebar {
        width: 44px;
        padding-top: 5px;
    }

    .sylva-btn {
        font-size: 16px;
        padding: 8px 0;
    }

    #map {
        left: 44px;
    }

    #sylva-panel {
        left: 50px;
        width: 280px;
        top: 5px;
        max-height: 95vh;
        font-size: 13px;
    }

    #profile-container {
        left: 50px;
        right: 10px;
        bottom: 5px;
        padding: 8px;
    }

    #profile-container canvas {
        height: 120px !important;
    }
}

/* --- Mobile portrait (phones) --- */
@media (max-width: 600px) {
    /* Sidebar becomes bottom bar */
    #sylva-sidebar {
        position: fixed;
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: 56px;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
        z-index: 2000;
    }

    .sylva-btn {
        font-size: 18px;
        padding: 8px 0;
        width: auto;
        flex: 1;
    }

    /* Hide tooltip on mobile - use touch */
    .sylva-tooltip {
        display: none;
    }

    #sidebar-blocker {
        flex-direction: row;
    }

    /* Map fills entire screen above bottom bar */
    #map {
        left: 0;
        top: 0;
        right: 0;
        bottom: 56px;
    }

    /* Panel becomes a compact right-side drawer on mobile */
    #sylva-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 56px;
        left: auto;
        width: 72vw;
        max-width: 320px;
        max-height: none;
        border-radius: 0;
        border: none;
        border-left: 2px solid #3498db;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.6);
        overflow-y: auto;
        transition: transform 0.25s ease;
        z-index: 1500;
    }

    /* Collapsed state - slide off screen */
    #sylva-panel.panel-collapsed {
        transform: translateX(calc(100% - 36px));
    }

    #sylva-panel-header {
        border-radius: 0;
        padding: 10px 12px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    /* Remove bottom-sheet drag handle, not needed for side drawer */
    #sylva-panel-header::before {
        display: none;
    }

    /* Profile chart repositioned: bottom of screen, above nav bar */
    #profile-container {
        left: 5px;
        right: 5px;
        bottom: 62px;
        padding: 10px;
        max-height: 35vh;
    }

    #profile-container canvas {
        height: 130px !important;
    }

    /* Larger touch targets */
    .sylva-action {
        padding: 14px;
        font-size: 15px;
        min-height: 48px;
    }

    .sylva-input {
        padding: 12px;
        font-size: 16px;  /* prevents iOS zoom */
        min-height: 44px;
    }

    .sylva-close {
        font-size: 22px;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Leaflet controls repositioning */
    .leaflet-top.leaflet-left {
        top: 10px;
        left: 10px;
    }

    .leaflet-control-zoom a {
        width: 36px !important;
        height: 36px !important;
        line-height: 36px !important;
        font-size: 18px !important;
    }

    /* Popup adjustments */
    .custom-popup .leaflet-popup-content {
        min-width: 200px;
        max-width: 85vw;
        margin: 10px;
        font-size: 13px;
    }

    .info-table {
        font-size: 12px;
    }

    .info-table .label {
        width: 40%;
    }
}

/* --- Small phones (SE, mini) --- */
@media (max-width: 375px) {
    #sylva-sidebar {
        height: 50px;
    }

    .sylva-btn {
        font-size: 16px;
        padding: 6px 0;
    }

    #map {
        bottom: 50px;
    }

    #sylva-panel {
        bottom: 50px;
        width: 80vw;
    }

    #profile-container {
        bottom: 56px;
    }

    #profile-container canvas {
        height: 120px !important;
    }
}

/* --- Safe area for notched phones (iPhone X+) --- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 600px) {
        #sylva-sidebar {
            padding-bottom: env(safe-area-inset-bottom);
            height: calc(56px + env(safe-area-inset-bottom));
        }

        #map {
            bottom: calc(56px + env(safe-area-inset-bottom));
        }

        #sylva-panel {
            bottom: calc(56px + env(safe-area-inset-bottom));
        }
    }
}

/* --- Mobile panel collapse toggle button --- */
.panel-collapse-btn {
    display: none;
}
@media (max-width: 600px) {
    .panel-collapse-btn {
        display: inline-block;
        background: none;
        border: none;
        color: #3498db;
        font-size: 20px;
        cursor: pointer;
        padding: 4px 8px;
        margin-right: 6px;
        vertical-align: middle;
    }

    /* --- Layer control: compact on mobile --- */
    .sylva-layer-switcher-control {
        margin-top: 8px;
    }

    .sylva-layer-switcher {
        width: 170px;
        padding: 8px;
        border-radius: 10px;
        font-size: 11px;
    }

    .sylva-layer-switcher-groups {
        gap: 4px;
        margin-bottom: 6px;
    }

    .sylva-layer-switcher-group {
        padding: 4px 8px;
        font-size: 10px;
    }

    .sylva-layer-switcher-list {
        gap: 4px;
    }

    .sylva-layer-switcher-item {
        gap: 5px;
        padding: 6px 8px;
        border-radius: 8px;
    }

    .sylva-layer-switcher-label {
        font-size: 11px;
    }

    .sylva-layer-switcher-icon {
        font-size: 12px;
    }

    /* --- Popup: more compact on mobile --- */
    .leaflet-popup-content {
        margin: 8px 10px !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
    }

    .leaflet-popup-content-wrapper {
        max-width: 280px !important;
    }

    .leaflet-popup-content table {
        font-size: 11px !important;
    }

    .leaflet-popup-content h4 {
        font-size: 13px !important;
        margin: 0 0 6px !important;
    }

    /* --- Panel content: better spacing on mobile --- */
    .panel-view {
        font-size: 13px;
    }

    .panel-view .scaffold-card {
        padding: 10px;
        margin-bottom: 8px;
    }

    .panel-view .scaffold-banner {
        font-size: 12px;
        padding: 8px;
        margin-bottom: 8px;
    }

    /* --- GEE panel: compact inputs --- */
    #view-gee .scaffold-card {
        padding: 8px;
    }

    #view-gee input[type="text"],
    #view-gee input[type="date"],
    #view-gee select {
        font-size: 13px;
        padding: 8px;
    }

    #view-gee label {
        font-size: 11px;
    }

    /* --- Buttons: slightly smaller on mobile --- */
    .panel-view .sylva-action {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 42px;
    }

    /* --- Volume/VWRR panels: compact grid --- */
    #view-volume .info-table,
    #view-vwrr .info-table {
        font-size: 11px;
    }

    /* --- Coordinate display: smaller --- */
    .leaflet-control-attribution,
    .coord-display {
        font-size: 10px !important;
    }
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #2c3e50;
}

::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* === Loading Animation === */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* === Utility Classes === */
.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.p-10 {
    padding: 10px;
}
