/**
 * AgriTopo • Estilos e Design Responsivo (style.css v2.5)
 * Brant Solutions | AgriNewBras • Prof. Dr. Santos H. B. Dias
 */

:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #dcfce7;
    --secondary: #0284c7;
    --secondary-dark: #0369a1;
    --dark: #0f172a;
    --slate: #334155;
    --light: #f8fafc;
    --border: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.15), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--dark);
    background: #0f172a;
}

#app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: relative;
}

/* ==============================================================================
   TOPO DA APLICAÇÃO (HEADER)
   ============================================================================== */
.top-header {
    height: 58px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    gap: 12px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.brand-icon {
    font-size: 26px;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--slate);
    font-weight: 500;
}

/* Crachá Oficial do TopoData INPE */
.source-badge {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

/* Barra de Pesquisa de Município */
.search-wrapper {
    display: flex;
    align-items: center;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    max-width: 260px;
    width: 100%;
    transition: all 0.2s;
}

.search-wrapper:focus-within {
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
    background: #ffffff;
}

.search-wrapper input {
    border: none;
    background: transparent;
    padding: 5px 8px;
    font-size: 12px;
    width: 100%;
    outline: none;
    color: var(--dark);
}

.search-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: var(--slate);
}

/* Ações Rápidas do Topo */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    color: var(--slate);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-header:hover {
    background: #e2e8f0;
    color: var(--dark);
}

.btn-header.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.btn-header-primary {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary-dark);
}

.btn-header-primary:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

.btn-header-accent {
    background: var(--secondary);
    color: #ffffff;
    border-color: var(--secondary-dark);
}

.btn-header-accent:hover {
    background: var(--secondary-dark);
    color: #ffffff;
}

/* ==============================================================================
   BARRA DE FERRAMENTAS DO WEBGIS (SEGUNDA LINHA / SUB-HEADER)
   ============================================================================== */
.sub-header-toolbar {
    min-height: 44px;
    height: 44px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
    z-index: 990;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    flex-shrink: 0;
}

.sub-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sub-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate);
    background: #ffffff;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-sub-toolbar:hover {
    background: #f1f5f9;
    color: var(--dark);
    border-color: #cbd5e1;
}

.btn-sub-toolbar.active {
    background: #15803d;
    color: #ffffff;
    border-color: #16a34a;
}

.btn-sub-accent {
    background: var(--secondary) !important;
    color: #ffffff !important;
    border-color: var(--secondary-dark) !important;
}

.btn-sub-accent:hover {
    background: var(--secondary-dark) !important;
    color: #ffffff !important;
}

.farm-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #bbf7d0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ==============================================================================
   ÁREA PRINCIPAL COM MAPA E PAINEL QGIS
   ============================================================================== */
.main-view {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* Renderização Nítida de Pixels TopoData (Visual R / QGIS) */
.pixelated-raster,
.leaflet-image-layer.pixelated-raster {
    image-rendering: pixelated !important;
    image-rendering: -moz-crisp-edges !important;
    image-rendering: crisp-edges !important;
}

/* ==============================================================================
   PAINEL DE GESTÃO DE TALHÕES ESTILO QGIS (LATERAL ESQUERDA)
   ============================================================================== */
.qgis-panel {
    width: 320px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.qgis-panel.panel-collapsed {
    display: none !important;
}

.qgis-panel-header {
    padding: 12px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-close-panel {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #64748b;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.btn-close-panel:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
}

.qgis-panel-title {
    font-size: 13px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.qgis-panel-hint {
    padding: 6px 12px;
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
    font-size: 11px;
    color: #1e40af;
    line-height: 1.3;
}

.btn-studio-mini {
    background: var(--primary);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-studio-mini:hover {
    background: var(--primary-dark);
}

.qgis-paddocks-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Linha da Tabela QGIS de Talhões */
.qgis-row {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all 0.15s ease;
}

.qgis-row:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.qgis-row.row-selected {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 0 0 1px #f59e0b;
}

.row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.paddock-info {
    flex: 1;
    min-width: 0;
}

.paddock-name-input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    font-size: 12px;
    font-weight: 700;
    color: var(--dark);
    padding: 2px 4px;
    border-radius: 3px;
    outline: none;
}

.paddock-name-input:focus {
    border-color: var(--secondary);
    background: #ffffff;
}

.paddock-meta {
    font-size: 11px;
    color: var(--slate);
    margin-top: 1px;
    padding-left: 4px;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-paddock-action {
    background: #f1f5f9;
    border: 1px solid var(--border);
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--slate);
    transition: all 0.15s;
}

.btn-paddock-action:hover {
    background: #e2e8f0;
    color: var(--dark);
}

.btn-paddock-del:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* ==============================================================================
   CONTROLE DE CAMADAS FLUTUANTE (TOP CENTER/RIGHT)
   ============================================================================== */
.floating-layers-bar {
    position: absolute;
    top: 15px;
    left: 335px; /* À direita do painel QGIS */
    z-index: 400;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    max-width: calc(100vw - 360px);
    transition: left 0.25s ease;
}

.qgis-panel.panel-collapsed + #map + .floating-layers-bar,
.panel-collapsed ~ .floating-layers-bar {
    left: 15px;
}

.layers-title {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--slate);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layer-buttons-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.layer-btn {
    background: #f1f5f9;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.layer-btn:hover {
    background: #e2e8f0;
}

.layer-btn.active {
    background: #16a34a !important; /* Verde Esmeralda de Destaque */
    color: #ffffff !important;      /* Texto Branco Garantido */
    border-color: #15803d !important;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.4) !important;
}

.layer-btn.active span {
    color: #ffffff !important;
}

.layer-btn-quick-contour {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}
.layer-btn-quick-contour.active {
    background: #f59e0b !important;
    border-color: #d97706 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4) !important;
}

/* Puxador e Botões de Ajustes Mobile */
.mobile-sheet-handle {
    display: none;
}

.btn-toggle-adjustments {
    background: #f1f5f9;
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}
.btn-toggle-adjustments:hover {
    background: #e2e8f0;
    color: var(--dark);
}
.btn-toggle-adjustments.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.layer-advanced-settings {
    display: block;
}

.btn-close-adjustments-mobile {
    display: none;
}

/* Botão Flutuante Redondo para Reabrir Camadas (FAB) */
.fab-reopen-layers {
    position: absolute;
    bottom: 25px;
    right: 25px;
    z-index: 450;
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 24px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
}
.fab-reopen-layers:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 18px rgba(22, 163, 74, 0.55);
}
.fab-reopen-layers:active {
    transform: scale(0.97);
}

/* Slider de Opacidade */
.opacity-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--slate);
}

.opacity-slider-wrapper input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ==============================================================================
   SELETOR DE MAPA DE FUNDO (BOTTOM LEFT)
   ============================================================================== */
.basemap-selector-box {
    position: absolute;
    bottom: 25px;
    left: 335px;
    z-index: 400;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: left 0.25s ease;
}

.panel-collapsed ~ .basemap-selector-box {
    left: 15px;
}

.basemap-selector-box select {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    outline: none;
}

/* ==============================================================================
   LEGENDA DINÂMICA FLUTUANTE (BOTTOM RIGHT)
   ============================================================================== */
.dynamic-legend-box {
    position: absolute;
    bottom: 25px;
    right: 360px;
    z-index: 400;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-width: 280px;
    font-size: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.dynamic-legend-box.legend-minimized .legend-content {
    display: none !important;
}

.legend-header {
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.dynamic-legend-box.legend-minimized .legend-header {
    border-bottom: none;
}

.legend-content {
    padding: 8px 12px;
    max-height: 220px;
    overflow-y: auto;
}

.legend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}

.legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.15);
}

.legend-text {
    flex: 1;
    font-size: 11px;
}

.legend-val {
    font-size: 11px;
    font-weight: 600;
    color: var(--slate);
    white-space: nowrap;
}

/* ==============================================================================
   PAINEL LATERAL DE ESTATÍSTICAS COMERCIAIS (RIGHT DRAWER)
   ============================================================================== */
.stats-drawer {
    width: 340px;
    background: #ffffff;
    border-left: 1px solid var(--border);
    z-index: 600;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
}

.stats-drawer.drawer-open {
    transform: translateX(0);
}

.drawer-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.drawer-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.kpi-main-card {
    background: linear-gradient(135deg, #15803d, #16a34a);
    color: white;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.kpi-main-val {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 4px;
}

.unit-selector-mini {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    font-size: 11px;
}

.unit-selector-mini label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.kpi-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.kpi-card-lbl {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--slate);
}

.kpi-card-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-top: 2px;
}

.kpi-card-sub {
    font-size: 10px;
    color: var(--slate);
    margin-top: 2px;
}

.drawer-section-title {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--slate);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.drawer-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-report-main {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-report-main:hover {
    background: var(--primary-dark);
}

/* ==============================================================================
   MODAL DE RELATÓRIO TÉCNICO
   ============================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content-wrapper {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--slate);
}

/* ==============================================================================
   MODAL DE PROGRESSO DO DEM
   ============================================================================== */
.progress-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    width: 380px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.progress-bar-track {
    background: #e2e8f0;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin: 15px 0 10px 0;
}

.progress-bar-fill {
    background: linear-gradient(90deg, #16a34a, #0284c7);
    height: 100%;
    width: 0%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* ==============================================================================
   TOAST NOTIFICATION
   ============================================================================== */
.toast-msg {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dark);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.toast-msg.toast-visible {
    transform: translateX(-50%) translateY(0);
}

.pulse-anim {
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

/* ==============================================================================
   BARRA DE NAVEGAÇÃO INFERIOR ESTILO APLICATIVO NATIVO (BOTTOM APP BAR)
   ============================================================================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);
    z-index: 1200;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item .nav-icon {
    font-size: 19px;
    line-height: 1;
}

.bottom-nav-item .nav-label {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active .nav-icon {
    transform: scale(1.1);
}

/* ==============================================================================
   DESIGN RESPONSIVO & EXPERIÊNCIA DE APLICATIVO (MOBILE APP OPTIMIZATION)
   ============================================================================== */
@media (max-width: 900px) {
    /* Ativar Barra de Navegação Inferior */
    .mobile-bottom-nav {
        display: flex;
    }

    /* Top Header Otimizado para Smartphones */
    .top-header {
        height: 52px;
        padding: 0 10px;
        gap: 6px;
    }

    .brand-icon {
        font-size: 22px;
    }

    .brand-title {
        font-size: 13px;
    }

    .brand-subtitle,
    .source-badge,
    .search-wrapper,
    .btn-label-text {
        display: none !important;
    }

    /* O botão de Instalar App mantém texto legível ou destaque total */
    .btn-header-install .btn-label-text {
        display: inline !important;
    }

    .header-actions {
        gap: 6px;
    }

    .btn-header {
        padding: 6px 10px;
        font-size: 12px;
        min-height: 36px;
    }

    /* Sub-Header no Smartphone com rolagem fluida */
    .sub-header-toolbar {
        min-height: 40px;
        height: 40px;
        padding: 0 10px;
        gap: 6px;
    }
    .btn-sub-toolbar {
        padding: 5px 10px;
        font-size: 11px;
    }

    /* Área do Mapa reserva espaço para a Bottom Bar */
    .main-view {
        padding-bottom: 60px;
        height: calc(100% - 94px);
    }

    #map {
        height: 100%;
        width: 100%;
    }

    /* Painel de Talhões QGIS em Modo Gaveta Mobile */
    .qgis-panel {
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: 94px;
        bottom: 60px;
        left: 0;
        right: 0;
        z-index: 1100;
        border-right: none;
        box-shadow: none;
        transform: translateY(0);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    }

    .qgis-panel.panel-collapsed {
        transform: translateY(105%);
        pointer-events: none;
        opacity: 0;
    }

    /* Resumo Executivo em Formato Bottom Sheet no Telefone */
    .stats-drawer {
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: auto;
        bottom: 60px;
        left: 0;
        right: 0;
        z-index: 1150;
        border-left: none;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
        background: var(--bg-card);
        transform: translateY(105%);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), height 0.25s ease, opacity 0.2s ease;
        opacity: 0;
        pointer-events: none;
        height: 72px; /* Padrão Peek */
        overflow: hidden;
    }

    .stats-drawer.drawer-open,
    .stats-drawer.drawer-half {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        height: 48vh;
        overflow-y: auto;
    }

    .stats-drawer.drawer-peek {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        height: 72px;
        overflow: hidden;
    }

    .stats-drawer.drawer-full {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        height: 82vh;
        overflow-y: auto;
    }

    /* Puxador táctil do Bottom Sheet */
    .stats-drawer .drawer-header {
        cursor: grab;
        padding-top: 10px;
        position: relative;
    }

    .stats-drawer .drawer-header::before {
        content: '';
        display: block;
        width: 40px;
        height: 5px;
        border-radius: 3px;
        background: #cbd5e1;
        margin: 0 auto 8px auto;
    }

    /* ==============================================================================
       SELETOR DE CAMADAS EM SMARTPHONE: DOCK INFERIOR ULTRA COMPACTO & ERGONÔMICO
       ============================================================================== */
    .floating-layers-bar {
        position: fixed !important;
        top: auto !important;
        bottom: 64px !important;
        left: 8px !important;
        right: 8px !important;
        max-width: none !important;
        z-index: 1050 !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(16px) !important;
        -webkit-backdrop-filter: blur(16px) !important;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        border-radius: 16px !important;
        padding: 4px 8px 8px 8px !important;
        border: 1px solid rgba(226, 232, 240, 0.85) !important;
        overflow: hidden !important;
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, max-height 0.3s ease !important;
    }

    .floating-layers-bar.dock-minimized {
        transform: translateY(120%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .mobile-sheet-handle {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 4px 0 2px 0 !important;
        cursor: pointer !important;
    }

    .mobile-sheet-handle .sheet-bar {
        width: 36px !important;
        height: 4px !important;
        background: #cbd5e1 !important;
        border-radius: 4px !important;
        transition: background 0.2s !important;
    }

    .mobile-sheet-handle:active .sheet-bar {
        background: var(--primary) !important;
    }

    .layers-title {
        margin-bottom: 4px !important;
        font-size: 11px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .layers-title .farm-badge {
        max-width: 120px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 10px !important;
        padding: 2px 6px !important;
    }

    .btn-toggle-adjustments {
        background: #f1f5f9 !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 12px !important;
        padding: 3px 8px !important;
        font-size: 10.5px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        color: #475569 !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 3px !important;
    }

    .btn-toggle-adjustments.active {
        background: #16a34a !important;
        color: #ffffff !important;
        border-color: #15803d !important;
    }

    /* Carrossel Horizontal de Chips Flutuantes (Pills Deslizantes) */
    .layer-buttons-grid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        gap: 6px !important;
        padding: 3px 2px !important;
        margin: 0 !important;
    }

    .layer-buttons-grid::-webkit-scrollbar {
        display: none !important;
    }

    .layer-btn {
        flex: 0 0 auto !important;
        padding: 6px 12px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        border-radius: 18px !important;
        min-height: 32px !important;
        border: 1px solid #e2e8f0 !important;
        white-space: nowrap !important;
        justify-content: center !important;
        background: #f1f5f9 !important;
        color: #334155 !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
        transition: all 0.15s ease !important;
    }

    .layer-btn.active {
        background: linear-gradient(135deg, #16a34a, #15803d) !important;
        color: #ffffff !important;
        border-color: #15803d !important;
        box-shadow: 0 2px 8px rgba(22, 163, 74, 0.45) !important;
    }

    /* Gaveta de Ajustes Avançados no Mobile (Bottom Sheet Retrátil) */
    .layer-advanced-settings {
        display: none;
    }

    .layer-advanced-settings.settings-open {
        display: block !important;
        max-height: 48vh !important;
        overflow-y: auto !important;
        margin-top: 8px !important;
        padding-top: 8px !important;
        border-top: 1px solid var(--border) !important;
        animation: slideUpSheet 0.22s ease-out !important;
    }

    @keyframes slideUpSheet {
        from { opacity: 0; transform: translateY(12px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .btn-close-adjustments-mobile {
        display: block !important;
        width: 100% !important;
        margin-top: 8px !important;
        padding: 8px 12px !important;
        background: #16a34a !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 8px !important;
        font-weight: 700 !important;
        font-size: 11.5px !important;
        cursor: pointer !important;
        text-align: center !important;
        box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3) !important;
    }

    .btn-close-adjustments-mobile:active {
        background: #15803d !important;
    }

    /* Botão Flutuante Redondo no Mapa Mobile (Quando Minimizado) */
    .fab-reopen-layers {
        position: fixed !important;
        bottom: 72px !important;
        right: 12px !important;
        z-index: 1040 !important;
        background: linear-gradient(135deg, #16a34a, #15803d) !important;
        color: #ffffff !important;
        border: 2px solid #ffffff !important;
        border-radius: 24px !important;
        padding: 7px 14px !important;
        font-size: 11.5px !important;
        font-weight: 700 !important;
        box-shadow: 0 4px 14px rgba(22, 163, 74, 0.45) !important;
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
        cursor: pointer !important;
    }

    /* Seletor de Mapa Base no Smartphone (Posicionado Acima do Dock de Camadas) */
    .basemap-selector-box {
        position: absolute !important;
        bottom: 126px !important;
        left: 8px !important;
        z-index: 400 !important;
        padding: 3px 6px !important;
        font-size: 10.5px !important;
        border-radius: 6px !important;
        background: rgba(255, 255, 255, 0.9) !important;
        backdrop-filter: blur(8px) !important;
        transition: bottom 0.25s ease !important;
    }

    .basemap-selector-box select {
        padding: 2px 4px !important;
        font-size: 10.5px !important;
        max-width: 130px !important;
    }

    /* Legenda Flutuante Adaptável no Smartphone (Posicionada Acima do Dock de Camadas) */
    .dynamic-legend-box {
        position: absolute !important;
        bottom: 126px !important;
        right: 8px !important;
        left: auto !important;
        max-width: 170px !important;
        z-index: 400 !important;
        border-radius: 8px !important;
        box-shadow: var(--shadow-md) !important;
        background: rgba(255, 255, 255, 0.9) !important;
        backdrop-filter: blur(8px) !important;
        transition: bottom 0.25s ease !important;
    }

    /* Quando a barra de camadas estiver oculta/minimizada, a legenda e mapa base descem para a borda inferior */
    body.dock-layers-hidden .basemap-selector-box,
    body.dock-layers-hidden .dynamic-legend-box {
        bottom: 72px !important;
    }

    .legend-header {
        padding: 5px 8px;
        font-size: 11px;
    }

    .legend-content {
        padding: 6px 8px;
        max-height: 140px;
    }

    .legend-row {
        gap: 4px;
        margin-bottom: 3px;
    }

    .legend-text {
        font-size: 10px;
    }

    .legend-val {
        font-size: 9px;
    }

    .dynamic-legend-box.legend-minimized .legend-content {
        display: none !important;
    }

    /* Modal do Laudo em Tela Cheia no Telefone */
    .modal-overlay {
        padding: 0;
    }

    .modal-content-wrapper {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-header,
    .modal-footer {
        padding: 12px 14px;
    }

    .modal-body {
        padding: 14px 10px;
    }

    /* Toasts posicionados acima da barra inferior */
    .toast-msg {
        bottom: 75px;
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* ==============================================================================
   BOTÃO DE INSTALAR APP (PWA)
   ============================================================================== */
.btn-header-install {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    border: 1px solid #059669 !important;
    font-weight: 700 !important;
    animation: pulseInstall 2.5s infinite;
}
@keyframes pulseInstall {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

/* ==============================================================================
   HISTÓRICO DE LAUDOS E AVALIAÇÕES
   ============================================================================== */
.history-list-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.history-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.history-title-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--dark);
}

.history-date {
    font-size: 11px;
    color: var(--slate);
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 12px;
}

.history-metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.history-metric-item {
    display: flex;
    flex-direction: column;
}

.history-metric-lbl {
    font-size: 10px;
    color: var(--slate);
    text-transform: uppercase;
    font-weight: 600;
}

.history-metric-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--dark);
}

.history-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.history-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--dark);
    cursor: pointer;
    transition: all 0.2s;
}

.history-btn:hover {
    background: #f1f5f9;
}

.history-btn-primary {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary-dark) !important;
}

.history-btn-primary:hover {
    background: var(--primary-dark) !important;
}

.history-btn-danger {
    color: #ef4444 !important;
    border-color: #fca5a5 !important;
}

.history-btn-danger:hover {
    background: #fee2e2 !important;
}

.history-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--slate);
}

.history-empty-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

/* ==============================================================================
   TEMA ESCURO (DARK MODE) COMPLETO
   ============================================================================== */
body.dark-theme {
    --dark: #f8fafc;
    --slate: #94a3b8;
    --light: #0b1120;
    --border: #334155;
    --card-bg: rgba(15, 23, 42, 0.95);
    background: #020617;
    color: #f8fafc;
}

body.dark-theme .top-header {
    background: #0f172a;
    border-bottom-color: #1e293b;
}

body.dark-theme .sub-header-toolbar {
    background: #0b1120;
    border-bottom-color: #1e293b;
}

body.dark-theme .btn-sub-toolbar {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

body.dark-theme .btn-sub-toolbar:hover {
    background: #334155;
    color: #ffffff;
    border-color: #475569;
}

body.dark-theme .btn-sub-toolbar.active {
    background: #16a34a;
    color: #ffffff;
    border-color: #22c55e;
}

body.dark-theme .brand-title {
    color: #f8fafc;
}

body.dark-theme .brand-subtitle {
    color: #94a3b8;
}

body.dark-theme .search-wrapper input {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}

body.dark-theme .btn-header {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

body.dark-theme .btn-header:hover {
    background: #334155;
    color: #ffffff;
}

body.dark-theme .btn-header.active {
    background: #15803d;
    color: #ffffff;
    border-color: #16a34a;
}

body.dark-theme .qgis-panel,
body.dark-theme .stats-drawer,
body.dark-theme .floating-layers-bar,
body.dark-theme .basemap-selector-box,
body.dark-theme .dynamic-legend-box,
body.dark-theme .modal-content-wrapper {
    background: rgba(15, 23, 42, 0.96);
    border-color: #334155;
    color: #f8fafc;
}

body.dark-theme .qgis-panel-header,
body.dark-theme .drawer-header,
body.dark-theme .modal-header,
body.dark-theme .modal-footer,
body.dark-theme .layers-title,
body.dark-theme .legend-header {
    border-color: #334155;
    background: #0f172a;
    color: #f8fafc;
}

body.dark-theme .drawer-content {
    background: #0f172a;
    color: #f8fafc;
}

body.dark-theme .qgis-panel-hint {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.dark-theme .paddock-card {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}

body.dark-theme .paddock-name-input {
    color: #f8fafc;
}

body.dark-theme .kpi-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-theme .kpi-card-lbl,
body.dark-theme .kpi-card-sub {
    color: #94a3b8;
}

body.dark-theme .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.98);
    border-top-color: #1e293b;
}

body.dark-theme .bottom-nav-item {
    color: #94a3b8;
}

body.dark-theme .bottom-nav-item.active {
    color: #4ade80;
}

body.dark-theme select {
    background: #1e293b;
    color: #f8fafc;
    border-color: #334155;
}

body.dark-theme .history-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-theme .history-title {
    color: #f8fafc;
}

body.dark-theme .history-date {
    background: rgba(255,255,255,0.08);
    color: #94a3b8;
}

body.dark-theme .history-metrics-row {
    background: #0f172a;
    border-color: #334155;
}

body.dark-theme .history-metric-val {
    color: #f8fafc;
}

body.dark-theme .history-metric-lbl {
    color: #94a3b8;
}

body.dark-theme .history-actions {
    border-top-color: #334155;
}

body.dark-theme .history-btn {
    background: #334155;
    color: #f8fafc;
    border-color: #475569;
}

body.dark-theme .history-btn:hover {
    background: #475569;
}

body.dark-theme .history-btn-danger {
    color: #f87171 !important;
    border-color: #7f1d1d !important;
}

body.dark-theme .history-btn-danger:hover {
    background: #450a0a !important;
}

/* ==============================================================================
   BOTÕES DE CABEÇALHO: ADMIN & USUÁRIO
   ============================================================================== */
.btn-header-admin {
    background: #4f46e5 !important;
    color: #ffffff !important;
    border: 1px solid #4338ca !important;
    font-weight: 700 !important;
}
.btn-header-admin:hover {
    background: #4338ca !important;
}

.btn-header-logged {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    font-weight: 600;
}

/* ==============================================================================
   MODAL DE AUTENTICAÇÃO (LOGIN / REGISTRO / CAPTCHA)
   ============================================================================== */
.auth-tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
body.dark-theme .auth-tabs-header {
    background: #0f172a;
    border-color: #334155;
}

.auth-tab-btn {
    flex: 1;
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--slate);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}
.auth-tab-btn:hover {
    color: var(--dark);
}
.auth-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #ffffff;
}
body.dark-theme .auth-tab-btn.active {
    background: #1e293b;
    color: #4ade80;
    border-bottom-color: #4ade80;
}

.auth-form-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-group-field label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--slate);
}
.form-group-field input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #ffffff;
    color: var(--dark);
    outline: none;
    transition: border-color 0.2s;
}
body.dark-theme .form-group-field input {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}
.form-group-field input:focus {
    border-color: var(--primary);
}

.btn-auth-submit {
    margin-top: 6px;
    padding: 11px 16px;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-auth-submit:hover {
    background: var(--primary-dark);
}

.auth-error-banner {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 12px;
    line-height: 1.4;
}
body.dark-theme .auth-error-banner {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

.auth-lockout-banner {
    background: #fef2f2;
    border: 2px solid #ef4444;
    color: #b91c1c;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 14px;
    line-height: 1.5;
}
body.dark-theme .auth-lockout-banner {
    background: #450a0a;
    border-color: #ef4444;
    color: #fecaca;
}

/* DESAFIO CAPTCHA */
.captcha-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 10px;
    margin-top: 4px;
}
body.dark-theme .captcha-box {
    background: #064e3b;
    border-color: #047857;
}
.captcha-label {
    font-size: 11px;
    color: var(--dark);
    margin-bottom: 6px;
    line-height: 1.4;
}
.captcha-box input {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: bold;
    border: 1px solid #86efac;
    border-radius: 4px;
}

/* ==============================================================================
   PAINEL DO ADMINISTRADOR (ADMIN DASHBOARD)
   ============================================================================== */
.admin-modal-wrapper {
    max-width: 960px !important;
    width: 95% !important;
}

.admin-tabs-nav {
    display: flex;
    overflow-x: auto;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 0 10px;
    gap: 4px;
}
.admin-tab-btn {
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.admin-tab-btn:hover {
    color: #f8fafc;
}
.admin-tab-btn.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

.admin-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.admin-kpi-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
}
body.dark-theme .admin-kpi-card {
    background: #1e293b;
    border-color: #334155;
}
.admin-kpi-lbl {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--slate);
}
.admin-kpi-val {
    font-size: 20px;
    font-weight: 800;
    margin: 4px 0;
}
.admin-kpi-sub {
    font-size: 11px;
    color: var(--slate);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}
.admin-table th {
    background: #f1f5f9;
    padding: 8px 10px;
    font-weight: 700;
    color: var(--slate);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
body.dark-theme .admin-table th {
    background: #0f172a;
    border-bottom-color: #334155;
    color: #94a3b8;
}
.admin-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--dark);
}
body.dark-theme .admin-table td {
    border-bottom-color: #334155;
    color: #f8fafc;
}
.admin-table tr:hover td {
    background: rgba(0,0,0,0.02);
}
body.dark-theme .admin-table tr:hover td {
    background: rgba(255,255,255,0.03);
}

.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}
.badge-primary {
    background: #ede9fe;
    color: #6d28d9;
}
.badge-success {
    background: #dcfce7;
    color: #15803d;
}
.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}
.badge-neutral {
    background: #f1f5f9;
    color: #475569;
}
body.dark-theme .badge-primary {
    background: #312e81;
    color: #c4b5fd;
}
body.dark-theme .badge-success {
    background: #064e3b;
    color: #86efac;
}
body.dark-theme .badge-danger {
    background: #450a0a;
    color: #fca5a5;
}
body.dark-theme .badge-neutral {
    background: #334155;
    color: #cbd5e1;
}




/* Botão Avaliar na Sub-Toolbar (Destaque Verde Vibrante com Pulso) */
.btn-sub-eval {
    background: #16a34a !important;
    color: #ffffff !important;
    border-color: #15803d !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 3px rgba(22, 163, 74, 0.35);
}

.btn-sub-eval:hover {
    background: #15803d !important;
    border-color: #166534 !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* Botão Como Usar na Sub-Toolbar */
.btn-sub-help {
    background: #f8fafc;
    color: #0284c7 !important;
    border-color: #bae6fd !important;
}

.btn-sub-help:hover {
    background: #f0f9ff !important;
    color: #0369a1 !important;
    border-color: #7dd3fc !important;
}

body.dark-theme .btn-sub-help {
    background: #0f172a;
    color: #38bdf8 !important;
    border-color: #0369a1 !important;
}

body.dark-theme .btn-sub-help:hover {
    background: #1e293b !important;
    color: #7dd3fc !important;
}

/* Ajustes para Tema Escuro no Seletor de Camadas e Legendas */
body.dark-theme .floating-layers-bar {
    background: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .layer-btn {
    background: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

body.dark-theme .layer-btn:hover {
    background: #334155 !important;
    color: #ffffff !important;
}

body.dark-theme .layer-btn.active {
    background: #16a34a !important;
    color: #ffffff !important;
    border-color: #15803d !important;
}

body.dark-theme .layer-btn.active span {
    color: #ffffff !important;
}

body.dark-theme .btn-toggle-adjustments {
    background: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

body.dark-theme .btn-toggle-adjustments.active {
    background: #16a34a !important;
    color: #ffffff !important;
}

body.dark-theme .mobile-sheet-handle .sheet-bar {
    background: #475569 !important;
}

body.dark-theme .layer-btn-quick-contour {
    background: #78350f !important;
    color: #fef3c7 !important;
    border-color: #92400e !important;
}

body.dark-theme .layer-btn-quick-contour.active {
    background: #f59e0b !important;
    color: #ffffff !important;
}

body.dark-theme .layers-title {
    color: #f8fafc !important;
    background: transparent !important;
}


/* ==============================================================================
   TEMA ESCURO NO LAUDO TÉCNICO & RELATÓRIO EXECUTIVO (REPORT MODAL)
   ============================================================================== */
body.dark-theme #reportModal .modal-content-wrapper {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

body.dark-theme #reportBodyContainer {
    background: #0f172a !important;
    color: #f8fafc !important;
}

body.dark-theme #reportBodyContainer * {
    /* Forçar cores de texto claras em títulos, parágrafos, spans e células */
    color: inherit;
}

body.dark-theme #reportBodyContainer h1,
body.dark-theme #reportBodyContainer h2,
body.dark-theme #reportBodyContainer h3,
body.dark-theme #reportBodyContainer h4,
body.dark-theme #reportBodyContainer strong {
    color: #f8fafc !important;
}

body.dark-theme #reportBodyContainer p,
body.dark-theme #reportBodyContainer td,
body.dark-theme #reportBodyContainer th,
body.dark-theme #reportBodyContainer div {
    color: #cbd5e1 !important;
}

body.dark-theme #reportBodyContainer table {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme #reportBodyContainer tr {
    border-bottom-color: #334155 !important;
}

body.dark-theme #reportBodyContainer thead tr {
    background: #0b1120 !important;
    border-bottom: 2px solid #475569 !important;
}

body.dark-theme #reportBodyContainer thead th {
    color: #f8fafc !important;
}

body.dark-theme #reportBodyContainer td strong {
    color: #ffffff !important;
}

/* Placas métricas e caixas de destaque no tema escuro */
body.dark-theme #reportBodyContainer div[style*="background:white"],
body.dark-theme #reportBodyContainer div[style*="background: white"],
body.dark-theme #reportBodyContainer div[style*="background:#f8fafc"],
body.dark-theme #reportBodyContainer div[style*="background: #f8fafc"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme #reportBodyContainer div[style*="background:#eff6ff"],
body.dark-theme #reportBodyContainer div[style*="background: #eff6ff"] {
    background: #172554 !important;
    border-color: #1e40af !important;
}

body.dark-theme #reportBodyContainer div[style*="background:#eff6ff"] h3,
body.dark-theme #reportBodyContainer div[style*="background: #eff6ff"] h3 {
    color: #60a5fa !important;
}

body.dark-theme #reportBodyContainer div[style*="background:#eff6ff"] div,
body.dark-theme #reportBodyContainer div[style*="background: #eff6ff"] div {
    color: #bfdbfe !important;
}

/* Caixa de Termo e Isenção de Responsabilidade Legal */
.report-disclaimer-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 6px;
    padding: 12px 14px;
    margin-top: 20px;
    margin-bottom: 20px;
    font-size: 12px;
    line-height: 1.5;
    color: #991b1b;
}

body.dark-theme .report-disclaimer-box {
    background: #450a0a !important;
    border-color: #7f1d1d !important;
    border-left-color: #ef4444 !important;
    color: #fca5a5 !important;
}

body.dark-theme .report-disclaimer-box * {
    color: #fca5a5 !important;
}


/* Ferramenta de Curvas de Nível e Barra de Download */
.contour-tool-wrapper {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.export-maps-wrapper {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.btn-download-layer {
    background: #f1f5f9;
    color: var(--slate);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-download-layer:hover {
    background: #e2e8f0;
    color: var(--dark);
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

body.dark-theme .btn-download-layer {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

body.dark-theme .btn-download-layer:hover {
    background: #334155;
    color: #ffffff;
}

body.dark-theme #btnOnlyContours {
    background: #78350f !important;
    border-color: #d97706 !important;
    color: #fef3c7 !important;
}

body.dark-theme #btnOnlyContours:hover {
    background: #92400e !important;
    color: #ffffff !important;
}

.report-section-selector-bar {
    transition: background 0.2s, border-color 0.2s;
}

body.dark-theme .report-section-selector-bar {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc;
}

body.dark-theme .report-section-selector-bar span {
    color: #cbd5e1;
}

body.dark-theme .report-section-selector-bar input[type="checkbox"] {
    accent-color: #22c55e;
}

/* ==============================================================================
   PAINEL DE TELEMETRIA AVANÇADO (POWER BI STYLE COM CHART.JS & HIERARQUIA)
   ============================================================================== */
.filter-bar {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}
body.dark-theme .filter-bar {
    background: #1e293b;
    border-color: #334155;
}
.filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.filter-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pill-btn {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
body.dark-theme .pill-btn {
    background: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}
.pill-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}
body.dark-theme .pill-btn:hover {
    background: #334155;
    color: #ffffff;
}
.pill-btn.active {
    background: #15803d !important;
    color: #ffffff !important;
    border-color: #15803d !important;
    box-shadow: 0 2px 6px rgba(21, 128, 61, 0.3);
}
.custom-date-box {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1.5px dashed #94a3b8;
}
body.dark-theme .custom-date-box {
    background: #0f172a;
    border-color: #475569;
}
.custom-date-box label {
    font-size: 11px;
    font-weight: 700;
    color: var(--slate);
}
.custom-date-box input[type="date"] {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--dark);
}
.btn-apply-custom {
    background: #15803d;
    color: #ffffff;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-apply-custom:hover {
    background: #166534;
}
.filter-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-badge-active {
    font-size: 11px;
    font-weight: 700;
    color: #15803d;
    background: #dcfce7;
    border: 1px solid #86efac;
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
body.dark-theme .filter-badge-active {
    background: #064e3b;
    border-color: #059669;
    color: #a7f3d0;
}

/* Grids e Layouts de Gráficos */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.kpi-card {
    background: #ffffff;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
body.dark-theme .kpi-card {
    background: #1e293b;
    border-color: #334155;
}
.kpi-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    margin-top: 2px;
}
.kpi-sub {
    font-size: 11px;
    color: var(--slate);
}

.analytics-grid-main {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 20px;
}
.analytics-grid-sub {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 18px;
    margin-bottom: 20px;
}
@media (max-width: 1024px) {
    .analytics-grid-main,
    .analytics-grid-sub {
        grid-template-columns: 1fr;
    }
}
.chart-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    position: relative;
}
body.dark-theme .chart-card {
    background: #1e293b;
    border-color: #334155;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.chart-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 6px;
}
body.dark-theme .chart-title {
    color: #f8fafc;
}
.chart-subtitle {
    font-size: 11px;
    color: var(--slate);
    margin-top: 2px;
}
.chart-container-rel {
    position: relative;
    width: 100%;
    height: 250px;
}

/* Hierarquia de Países e Estados */
.hierarquia-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 250px;
    padding-right: 4px;
}
.country-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}
body.dark-theme .country-card {
    background: #0f172a;
    border-color: #334155;
}
.country-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #ffffff;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
body.dark-theme .country-card-header {
    background: #1e293b;
}
.country-card-header:hover {
    background: #f1f5f9;
}
body.dark-theme .country-card-header:hover {
    background: #334155;
}
.country-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.country-flag {
    font-size: 16px;
}
.country-name {
    font-size: 12px;
    font-weight: 800;
    color: var(--dark);
}
body.dark-theme .country-name {
    color: #f8fafc;
}
.country-stats-badge {
    display: flex;
    align-items: center;
    gap: 6px;
}
.badge-country-total {
    background: #15803d;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
}
.country-states-list {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}
body.dark-theme .country-states-list {
    background: #0f172a;
    border-color: #334155;
}
.state-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--slate);
    border-radius: 4px;
}
.state-name {
    font-weight: 600;
}
.state-hits-badge {
    font-weight: 800;
    color: #0284c7;
}

/* Ranking de Cidades */
.ranking-cities-scroll {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: 250px;
    padding-right: 4px;
}
.city-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
}
body.dark-theme .city-row-item {
    background: #0f172a;
    border-color: #334155;
}
.city-left-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.city-pos-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.city-pos-top {
    background: #15803d;
    color: #ffffff;
}
.city-name-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--dark);
}
body.dark-theme .city-name-text {
    color: #f8fafc;
}
.city-state-text {
    font-size: 10px;
    color: var(--slate);
}
.city-badge-hits {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
}
body.dark-theme .city-badge-hits {
    background: #075985;
    color: #bae6fd;
}

/* ==============================================================================
   FASE 2: BOTÃO FLUTUANTE DE GPS DE CAMPO & USABILIDADE TÁTIL (48px TOUCH TARGETS)
   ============================================================================== */
.btn-floating-gps {
    position: absolute;
    top: 70px;
    right: 14px;
    z-index: 500;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #16a34a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    color: #15803d;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-floating-gps:hover {
    background: #f0fdf4;
    transform: scale(1.06);
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.35);
}

.btn-floating-gps:active {
    transform: scale(0.95);
    background: #dcfce7;
}

.btn-floating-gps.gps-searching {
    background: #fef08a;
    border-color: #ca8a04;
    animation: pulseGps 1.2s infinite;
}

.btn-floating-gps.gps-active {
    background: #15803d;
    border-color: #16a34a;
    color: #ffffff;
}

.btn-floating-gps .gps-icon {
    font-size: 18px;
    line-height: 1;
}

.btn-floating-gps .gps-text {
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    margin-top: 1px;
    letter-spacing: 0.5px;
}

@keyframes pulseGps {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(202, 138, 4, 0.6); }
    70% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(202, 138, 4, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(202, 138, 4, 0); }
}

@media (max-width: 900px) {
    .btn-floating-gps {
        top: 14px;
        right: 14px;
        width: 50px;
        height: 50px;
    }

    /* Garantir área de toque mínima de 48px para botões no celular */
    .btn-sub-toolbar,
    .bottom-nav-item,
    .layer-btn,
    .btn-draw-paddock,
    .btn-delete-paddock {
        min-height: 44px;
        min-width: 44px;
    }

    .leaflet-touch .leaflet-control-layers-toggle,
    .leaflet-touch .leaflet-bar a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
    }
}

/* ==============================================================================
   FASE 4: GERAÇÃO DE LAUDOS EM PDF VETORIAL A4 VIA @media print (ZERO CRASH NO MOBILE)
   ============================================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 12mm 14mm 12mm;
    }

    /* Ocultar todos os elementos da interface do WebGIS */
    header,
    .sub-header-toolbar,
    .qgis-panel,
    .floating-layers-bar,
    .dynamic-legend-box,
    .basemap-selector-box,
    .btn-floating-gps,
    .fab-reopen-layers,
    .mobile-bottom-nav,
    .modal-header,
    .modal-footer,
    .report-config-bar,
    #map {
        display: none !important;
    }

    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .modal-overlay {
        position: static !important;
        background: none !important;
        padding: 0 !important;
        display: block !important;
        overflow: visible !important;
    }

    .modal-content-wrapper {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .modal-body {
        padding: 0 !important;
        overflow: visible !important;
    }

    .laudo-container {
        padding: 0 !important;
        max-width: 100% !important;
        page-break-after: auto;
    }

    /* Evitar quebra de página no meio de tabelas e blocos principais */
    table,
    .kpi-main-card,
    .report-disclaimer-box,
    .drawer-section-title {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    h1, h2, h3 {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid !important;
    }
}




