/* ==========================================================================
   WebGIS HidroMet - Arquitetura Profissional Estilo MapBiomas
   ========================================================================== */

:root {
    --primary: #1b4332;
    --primary-light: #2d6a4f;
    --primary-accent: #40916c;
    --secondary: #d8f3dc;
    --bg-card: rgba(255, 255, 255, 0.97);
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.22), 0 8px 10px -6px rgba(0, 0, 0, 0.18);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-dark);
    background-color: #0f172a;
}

#app-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ==========================================================================
   Topo Fixo da Aplicação (52px)
   ========================================================================== */
.top-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: linear-gradient(135deg, #1b4332 0%, #0d2818 100%);
    color: #fff;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 1100;
    gap: 10px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.brand-icon {
    font-size: 1.3rem;
}

.brand-title {
    font-size: 1.0rem;
    font-weight: 700;
    color: #fff;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: #a7f3d0;
    font-weight: 500;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barra de Busca de Localidade (Geocodificador Estilo MapBiomas) */
.search-box-wrapper {
    position: relative;
    flex: 1;
    max-width: 380px;
}

.search-input-group {
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 20px;
    padding: 4px 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}

.search-icon {
    font-size: 0.85rem;
    margin-right: 6px;
    color: #64748b;
}

.search-input-group input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.82rem;
    color: #1e293b;
}

.search-input-group input::placeholder {
    color: #94a3b8;
}

#btnClearSearch {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
}

#btnClearSearch:hover {
    color: #0f172a;
}

.search-results-dropdown {
    position: absolute;
    top: 38px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    max-height: 260px;
    overflow-y: auto;
    z-index: 1500;
}

.search-result-item {
    padding: 8px 12px;
    font-size: 0.82rem;
    color: #1e293b;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-result-item:hover {
    background: #f0fdf4;
    color: #166534;
}

/* Grupo de Coordenadas Lat/Lng */
.coords-box-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 18px;
    padding: 2px 4px 2px 10px;
    flex-shrink: 0;
}

.coords-box-group input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.78rem;
    width: 150px;
}

.coords-box-group input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.coords-box-group button {
    background: #40916c;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 700;
}

.btn-header-quick {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.80rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.btn-header-quick:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

/* ==========================================================================
   Barra de Navegação Principal Estilo Meso 7
   ========================================================================== */
.sub-nav-meso7 {
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    height: 44px;
    background: linear-gradient(180deg, rgba(8, 28, 21, 0.96) 0%, rgba(15, 30, 24, 0.94) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 1090;
    display: flex;
    align-items: center;
    padding: 0 16px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.sub-nav-meso7::-webkit-scrollbar {
    display: none;
}

.nav-container-meso7 {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-tab {
    padding: 6px 14px;
    border-radius: 8px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.nav-tab:active {
    transform: scale(0.97);
}

.nav-tab.active-tab {
    color: #ffffff !important;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
    border: 1px solid #34d399 !important;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
}

.nav-tab-icon {
    font-size: 1.0rem;
    line-height: 1;
}

.nav-tab-label {
    letter-spacing: -0.2px;
}

/* ==========================================================================
   Mapa Leaflet em Tela Cheia Fixo
   ========================================================================== */
#map {
    position: absolute;
    top: 96px;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #1e293b;
    z-index: 1;
}

/* ==========================================================================
   Botões Flutuantes (FABs)
   ========================================================================== */
.fab-container {
    position: absolute;
    top: 66px;
    left: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 900;
}

.fab-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s;
}

.fab-btn:hover {
    transform: scale(1.08);
    background: #f8fafc;
}

/* Toast */
#loadingIndicator {
    display: none;
    position: absolute;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 40, 24, 0.95);
    color: #fff;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    z-index: 1500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   Seletor Flutuante de Basemaps (Widget Estilo Google Maps)
   ========================================================================== */
.basemap-floating-widget {
    position: absolute;
    bottom: 20px;
    left: 14px;
    z-index: 920;
}

.basemap-toggle-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.basemap-toggle-btn:hover {
    background: #f1f5f9;
}

.basemap-options-card {
    position: absolute;
    bottom: 46px;
    left: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 170px;
}

.basemap-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    transition: background 0.15s;
}

.basemap-item:hover {
    background: #f1f5f9;
}

.basemap-item.active {
    background: #d8f3dc;
    color: #1b4332;
    border-left: 3px solid #1b4332;
}

.basemap-thumb {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.thumb-sat {
    background: linear-gradient(135deg, #1e3a1e 0%, #172554 100%);
}

.thumb-google {
    background: linear-gradient(135deg, #15803d 0%, #0284c7 100%);
}

.thumb-gray {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.thumb-osm {
    background: linear-gradient(135deg, #a7f3d0 0%, #bae6fd 100%);
}

.thumb-topo {
    background: linear-gradient(135deg, #d97706 0%, #15803d 100%);
}

.drawing-cursor {
    cursor: crosshair !important;
}

/* Alças de Vértice Interativas com Arrasto Suave (Nativo) */
.custom-vertex-handle {
    cursor: grab !important;
    background: transparent !important;
    border: none !important;
}

.custom-vertex-handle:active {
    cursor: grabbing !important;
}

.vertex-dot {
    width: 14px;
    height: 14px;
    background: #ffffff;
    border: 3px solid #f59e0b;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    transition: transform 0.15s ease, background 0.15s ease;
    box-sizing: border-box;
}

.custom-vertex-handle:hover .vertex-dot {
    transform: scale(1.4);
    background: #fef08a;
    border-color: #d97706;
}

/* Moldura do Mapa no Relatório Impresso */
.report-map-frame {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #1b4332;
    background: #0f172a;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.report-map-frame img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 380px;
    object-fit: contain;
}

.report-map-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.94);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #1e293b;
    border: 1px solid rgba(0,0,0,0.15);
    box-shadow: 0 2px 5px rgba(0,0,0,0.25);
}

/* ==========================================================================
   Barra Temporal de 12 Meses + Anual (Timeline)
   ========================================================================== */
.timeline-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 30px;
    padding: 4px 8px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 900;
    max-width: 94vw;
    overflow-x: auto;
    scrollbar-width: none;
    border: 1px solid var(--border-color);
}

.timeline-container::-webkit-scrollbar {
    display: none;
}

.timeline-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: #64748b;
    margin-right: 4px;
    padding-left: 4px;
}

.month-btn {
    background: transparent;
    border: none;
    padding: 6px 11px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.month-btn:hover {
    background: rgba(45, 106, 79, 0.12);
    color: var(--primary);
}

.month-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(27, 67, 50, 0.35);
}

/* ==========================================================================
   Toggle Switch e Sub-aba de 12 Meses Integrada na ETo
   ========================================================================== */
.module-header-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

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

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .2s;
    border-radius: 20px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}

input:checked + .slider-toggle {
    background-color: var(--primary);
}

input:checked + .slider-toggle:before {
    transform: translateX(18px);
}

.radio-card-wrapper {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    transition: all 0.15s;
    overflow: hidden;
}

.radio-card-wrapper.active {
    border-color: #40916c;
    background: #f0fdf4;
}

.radio-card-wrapper .radio-card {
    border: none;
    border-radius: 0;
    background: transparent;
}

.eto-months-subpanel {
    padding: 8px 10px 10px 10px;
    border-top: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.6);
}

.subpanel-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: #475569;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.months-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.month-pill {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 2px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.month-pill:hover {
    background: #d8f3dc;
    color: #1b4332;
    border-color: #40916c;
}

.month-pill.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 1px 4px rgba(27, 67, 50, 0.3);
}

.month-pill[data-mes="anual"] {
    grid-column: span 4;
    font-weight: 700;
    background: #f1f5f9;
}

.month-pill[data-mes="anual"].active {
    background: var(--primary);
    color: #fff;
}

/* Modo de Desenho Ativo (Desabilita captura de cliques nas camadas vetoriais) */
.drawing-active .leaflet-overlay-pane svg {
    pointer-events: none !important;
}

.drawing-active .leaflet-interactive {
    pointer-events: none !important;
}

.drawing-active,
.drawing-active #map,
.drawing-active .leaflet-container {
    cursor: crosshair !important;
}

.btn-farm-action {
    width: 100%;
    color: #fff;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: filter 0.15s;
}

.btn-farm-action:hover {
    filter: brightness(1.1);
}

/* Modal de Relatório e Impressão PDF */
.report-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: flex-start;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)) 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}
.report-modal[style*="display: flex"] {
    display: flex !important;
    flex-direction: column;
}

.report-modal-content {
    margin: auto 0;
    background: #ffffff;
    border-radius: 12px;
    width: 620px;
    max-width: 95vw;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #1b4332;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.report-brand h2 {
    font-size: 1.25rem;
    color: #1b4332;
    font-weight: 800;
}

.report-brand p {
    font-size: 0.78rem;
    color: #64748b;
}

.report-body {
    font-size: 0.88rem;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.report-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}

.report-section-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: #1b4332;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

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

.report-item {
    font-size: 0.82rem;
}

.report-item b {
    color: #475569;
}

.report-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
}

.btn-report-download-pdf {
    background: #15803d;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn-report-download-pdf:hover {
    background: #166534;
    transform: translateY(-1px);
}

.btn-report-print {
    background: #334155;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-report-print:hover {
    background: #1e293b;
}

.btn-report-secondary {
    background: #0284c7;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-report-secondary:hover {
    background: #0369a1;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }
    body * {
        visibility: hidden !important;
    }
    #reportModal, #reportModal *,
    .print-allowed, .print-allowed * {
        visibility: visible !important;
    }
    #reportModal,
    .print-allowed {
        position: absolute !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important; height: auto !important;
        background: #ffffff !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }
    .report-modal-content {
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }
    .report-footer, .close-btn {
        display: none !important;
    }
}

/* ==========================================================================
   Legenda Flutuante
   ========================================================================== */
.legend-card {
    position: absolute;
    bottom: 74px;
    right: 14px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(6px);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    box-shadow: var(--shadow-soft);
    z-index: 890;
    min-width: 170px;
    border: 1px solid var(--border-color);
}

.legend-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap;
}

.legend-title span:last-child {
    color: var(--primary);
}

.legend-color-bar {
    width: 100%;
    height: 12px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.2);
    margin-bottom: 4px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
}

/* ==========================================================================
   Sidebar Lateral Esquerda Estilo MapBiomas
   ========================================================================== */
.sidebar-mapbiomas {
    position: absolute;
    top: 96px;
    bottom: 0;
    left: 0;
    width: 340px;
    max-width: 90vw;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    z-index: 1050;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary);
}

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

.sidebar-module {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
}

.module-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
}

.radio-card-list, .checkbox-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-card, .checkbox-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
}

.radio-card:hover, .checkbox-card:hover {
    border-color: #40916c;
    background: #f0fdf4;
}

.radio-card input, .checkbox-card input {
    margin-top: 3px;
    accent-color: var(--primary);
}

.radio-card p {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 2px;
}

/* ==========================================================================
   Painéis Retráteis (Estilo e Minha Fazenda)
   ========================================================================== */
.side-panel {
    position: absolute;
    top: 104px;
    right: 14px;
    width: 330px;
    max-width: 90vw;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 16px;
    z-index: 1200;
    border: 1px solid var(--border-color);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.close-btn:hover,
.close-btn:active {
    background: rgba(0, 0, 0, 0.06);
    color: #0f172a;
}

.control-group {
    margin-bottom: 12px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.range-slider {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

.select-input {
    width: 100%;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.84rem;
    outline: none;
}

.drop-zone {
    border: 2px dashed #40916c;
    border-radius: 10px;
    padding: 18px 12px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.2s;
}

.drop-zone:hover {
    background: #d8f3dc;
}

.drop-zone-icon {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.btn-farm-draw {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-farm-draw:hover {
    background: var(--primary-light);
}

/* ==========================================================================
   Popups Customizados
   ========================================================================== */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    line-height: 1.4;
}

.custom-popup {
    padding: 12px 14px;
    min-width: 230px;
}

/* ==========================================================================
   Mobile-First & Responsividade de Alta Performance
   ========================================================================== */
@media (max-width: 768px) {
    /* 1. Topo compacto e adaptado para celular */
    .top-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: auto;
        min-height: 80px;
        padding: max(8px, env(safe-area-inset-top, 0px)) 10px 6px 10px;
        flex-wrap: wrap;
        align-content: center;
        z-index: 1100;
        box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    }

    .brand-section {
        max-width: 60%;
        gap: 6px;
    }

    .brand-icon {
        font-size: 1.15rem;
    }

    .brand-title {
        font-size: 0.90rem;
        line-height: 1.1;
    }

    .brand-subtitle {
        font-size: 0.68rem;
        max-width: 175px;
        line-height: 1.2;
    }

    .search-box-wrapper {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin-top: 5px;
    }

    .search-input-group {
        padding: 3px 10px;
        border-radius: 16px;
    }

    .search-input-group input {
        font-size: 0.80rem;
    }

    .coords-box-group {
        display: none;
    }

    .btn-header-quick {
        padding: 6px 10px;
        min-height: 36px;
        font-size: 0.78rem;
        border-radius: 14px;
        gap: 3px;
    }

    /* 2. Barra de Navegação no Topo (Abaixo do Cabeçalho) no Celular */
    .sub-nav-meso7 {
        position: absolute;
        top: calc(80px + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        height: 44px;
        z-index: 1090;
        background: linear-gradient(180deg, rgba(8, 28, 21, 0.96) 0%, rgba(15, 30, 24, 0.94) 100%);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
        display: flex;
        align-items: center;
        padding: 0 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sub-nav-meso7::-webkit-scrollbar {
        display: none;
    }

    .nav-container-meso7 {
        display: flex;
        align-items: center;
        gap: 6px;
        width: max-content;
        margin: 0;
    }

    .nav-tab {
        padding: 5px 11px;
        font-size: 0.75rem;
        gap: 5px;
        flex-shrink: 0;
        border-radius: 8px;
        white-space: nowrap;
    }

    .nav-tab-icon {
        font-size: 0.90rem;
    }

    /* 3. Mapa ocupando todo o espaço abaixo do menu superior */
    #map {
        position: absolute;
        top: calc(124px + env(safe-area-inset-top, 0px));
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
    }

    /* 4. Paineis Laterais / Gavetas no Celular (Abaixo do Menu) */
    .sidebar-mapbiomas,
    .side-panel {
        position: absolute;
        top: calc(124px + env(safe-area-inset-top, 0px));
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        background: #ffffff;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        border-top: none;
        border-right: none;
        border-left: none;
        z-index: 1080;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    }

    .sidebar-header,
    .panel-header {
        position: sticky;
        top: 0;
        background: #ffffff;
        z-index: 10;
        border-bottom: 1px solid #e2e8f0;
        padding: 10px 14px;
    }

    /* 5. Restauração Completa dos Widgets da Base no Celular (Elevados e Seguros) */
    /* Botãozinho de Fundo (Basemap) */
    .basemap-floating-widget {
        position: absolute;
        bottom: calc(52px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        z-index: 1000;
    }

    .basemap-toggle-btn {
        padding: 8px 14px;
        border-radius: 20px;
        border: 1.5px solid #2d6a4f;
        background: #ffffff;
        color: #1b4332;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
        font-size: 0.84rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Escala do Mapa (perfeitamente visível acima do botão Fundo) */
    .leaflet-bottom.leaflet-left {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        left: 12px !important;
        z-index: 950 !important;
    }

    .leaflet-control-scale {
        margin: 0 !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
    }

    /* Régua das Cores (Legenda da Evapotranspiração/Chuva/Temp) */
    .legend-card {
        position: absolute;
        bottom: calc(38px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        min-width: 160px;
        padding: 8px 12px;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.97);
        border: 1px solid var(--border-color);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.26);
        border-radius: var(--radius-md);
    }

    .legend-title {
        display: flex;
        justify-content: space-between;
        gap: 8px;
        white-space: nowrap;
        font-size: 0.76rem;
        font-weight: 700;
        color: #1e293b;
        margin-bottom: 5px;
    }

    /* 6. Modais no Celular */
    .report-modal-content {
        width: 95%;
        max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        margin: 10px auto;
        padding: 14px;
    }
}

/* ==========================================================================
   Modal / Gate de Inscrição no YouTube para Downloads Gratuitos
   ========================================================================== */
.yt-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 999999;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)) 16px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}
.yt-modal-overlay.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}
.yt-modal-box {
    margin: auto 0;
    background: #ffffff;
    padding: 26px 20px;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: ytPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Inter', -apple-system, sans-serif;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}
@keyframes ytPopIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.yt-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 6px;
    border: none;
    background: none;
    transition: color 0.2s;
}
.yt-modal-close:hover {
    color: #111827;
}
.modal-yt-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 14px auto;
    background: #ffebee;
    color: #e53935;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
}
.modal-yt-badge {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(229, 57, 53, 0.12);
    color: #e53935;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}
.yt-modal-box h3 {
    margin: 0 0 10px 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.4px;
}
.yt-modal-box p {
    font-size: 0.92rem;
    color: #4b5563;
    margin: 0 0 20px 0;
    line-height: 1.5;
}
.btn-subscribe-yt {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 18px rgba(229, 57, 53, 0.35);
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-subscribe-yt:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(229, 57, 53, 0.45);
}
.checking-box-yt {
    display: none;
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    color: #e65100;
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    margin-top: 12px;
    animation: pulseYt 1.5s infinite;
}
@keyframes pulseYt {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.countdown-box-yt {
    display: none;
    font-size: 0.92rem;
    color: #374151;
    margin-top: 12px;
    font-weight: 600;
    background: #f3f4f6;
    padding: 10px;
    border-radius: 8px;
}
.countdown-box-yt strong {
    color: #e53935;
    font-size: 1.15rem;
}
.btn-download-unlocked-yt {
    display: none;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 18px rgba(22, 163, 74, 0.35);
    margin-top: 12px;
    animation: popBtnYt 0.3s ease;
}
@keyframes popBtnYt {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.download-status-yt {
    display: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: #16a34a;
    margin-top: 12px;
}

/* =========================================================================
   TOUR INTERATIVO PASSO A PASSO ("QUADRINHOS DE COMO USAR")
   ========================================================================= */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px 30px;
    pointer-events: none;
    box-sizing: border-box;
}

.tour-backdrop {
    display: none !important;
}

.tour-card {
    position: relative;
    pointer-events: auto;
    z-index: 100000;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 440px;
    padding: 20px 22px;
    box-sizing: border-box;
    animation: tourCardIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tourCardIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tour-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tour-badge {
    font-size: 0.72rem;
    font-weight: 800;
    background: #dcfce7;
    color: #15803d;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.tour-close-btn {
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tour-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.tour-body {
    margin-bottom: 16px;
}

.tour-icon {
    font-size: 2.2rem;
    line-height: 1;
    margin-bottom: 8px;
}

.tour-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 10px;
    line-height: 1.3;
}

.tour-description {
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.55;
}

.tour-description b {
    color: #0f172a;
}

.tour-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.tour-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tour-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: all 0.25s ease;
}

.tour-dot:hover {
    background: #94a3b8;
}

.tour-dot.active {
    width: 22px;
    border-radius: 10px;
    background: #16a34a;
}

.tour-actions {
    display: flex;
    gap: 8px;
}

.btn-tour-secondary {
    background: #f1f5f9;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-tour-secondary:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-tour-primary {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
    font-size: 0.84rem;
    font-weight: 800;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
    transition: all 0.15s ease;
}

.btn-tour-primary:hover {
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.35);
    transform: translateY(-1px);
}

.btn-tour-portal {
    background: #0284c7;
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.82rem;
    text-decoration: none;
    transition: background 0.15s ease;
}

.btn-tour-portal:hover {
    background: #0369a1;
}

/* Responsividade Mobile para o Tour */
@media (max-width: 768px) {
    .tour-overlay {
        padding: 12px;
        align-items: flex-end;
        justify-content: center;
    }
    .tour-card {
        max-width: 100%;
        padding: 16px;
        border-radius: 14px;
    }
    .tour-title {
        font-size: 1.05rem;
    }
    .tour-description {
        font-size: 0.80rem;
    }
}
