/* ==========================================================================
   TELA DE CARREGAMENTO
   ========================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2E7D32;
    /* Cor primária do sistema */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* Fica acima de tudo */
    transition: opacity 0.5s ease, visibility 0.5s;
}

.loader-content {
    text-align: center;
    color: white;
    font-family: 'Segoe UI', sans-serif;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

/* ==========================================================================
   1. VARIÁVEIS & TEMAS
   ========================================================================== */
:root {
    /* --- TEMA CLARO (Padrão) --- */
    --primary-color: #2E7D32;
    --secondary-color: #1B5E20;
    --accent-color: #F9A825;
    --error-color: #D32F2F;

    --background-color: #F4F7F6;
    --card-background: #ffffff;

    --text-color: #333333;
    --light-text-color: #666666;

    --border-color: #e0e0e0;
    --input-bg: #fafafa;

    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --modal-overlay: rgba(0, 0, 0, 0.5);

    /* Cores específicas para tabelas e sidebar */
    --sidebar-text: #ffffff;
    --table-header-text: #ffffff;
    --table-hover: #f9f9f9;
}

/* ==========================================================================
   2. RESET & ESTRUTURA BÁSICA
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    /* Fonte nítida */
    -webkit-tap-highlight-color: transparent;
    /* Remove highlight azul no iOS */
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    display: flex;
    flex-grow: 1;
    width: 100%;
    height: 100vh;
    /* 🔑 altura fixa da viewport */
}

.hidden {
    display: none !important;
}

.undo-bar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--card-background, #ffffff);
    color: var(--text-color);
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 3200;
    overflow: hidden;
    transition: opacity 200ms ease, transform 200ms ease;
}

.undo-bar .btn {
    padding: 6px 12px;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
}

.undo-bar .undo-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    width: 100%;
    background: var(--primary-color);
    opacity: 0.9;
}

.undo-bar.is-hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
}

@media (max-width: 640px) {
    .undo-bar {
        width: calc(100% - 32px);
        justify-content: space-between;
        border-radius: 12px;
    }
}

/* ==========================================================================
   3. BARRA LATERAL (SIDEBAR)
   ========================================================================== */
.sidebar {
    width: 250px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    z-index: 100;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar-top {
    flex-grow: 1;
}

.logo {
    font-size: 1.4em;
    font-weight: 700;
    text-align: center;
    padding: 25px 20px;
    padding-top: 50px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.subtitulo {
    font-size: 10px;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.8);
}

/* --- MENU DE NAVEGAÇÃO --- */
.nav-menu ul,
.nav-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu li a,
.nav-menu-list li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    text-decoration: none;
    color: var(--sidebar-text) !important;
    transition: all 0.2s ease;
    font-size: 0.95em;
    border-left: 4px solid transparent;
}

.nav-menu li.active a {
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: var(--accent-color);
    font-weight: 600;
}

.nav-menu li a:hover,
.nav-menu-list li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    padding-left: 30px;
}

.nav-menu li a i,
.nav-menu-list li a i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
}

/* --- RODAPÉ DA SIDEBAR --- */
.sidebar-footer {
    background-color: rgba(0, 0, 0, 0.1);
    height: min-content;
    margin-bottom: auto;
}

.user-info {
    padding: 20px;
    display: flex;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #fff;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    margin-right: 12px;
    cursor: pointer;
    position: relative;
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.2s;
}

.user-avatar:hover {
    transform: scale(1.1);
    border-color: #fff;
}

.user-avatar::after {
    content: '\f030';
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.user-avatar:hover::after {
    opacity: 1;
}

.user-details {
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75em;
    opacity: 0.8;
}

.menu-toggle {
    display: none;
    /* Padrão desktop */
}

/* ==========================================================================
   4. CONTEÚDO PRINCIPAL (MAIN)
   ========================================================================== */
.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
    transition: background-color 0.3s ease;
}

/* --- CABEÇALHO DA TELA --- */
.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.screen-header h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.8em;
    font-weight: 700;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filtros-header-controls {
    flex-wrap: wrap;
}

.filtros-header-controls .btn-toggle-filtros {
    flex-basis: 100%;
}

.filtros-data-range {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filtros-data-range .custom-input {
    min-width: 150px;
}

.filtros-expansiveis-card .custom-select {
    width: 100%;
    min-width: 0;
}

.painel-filtro-wrap {
    min-width: 240px;
}

.painel-header-dashboard {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.painel-title-dashboard {
    order: 0;
    text-align: left;
}

.painel-filtro-wrap {
    margin-left: auto;
}

.header-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-field label {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-color);
}


/* --- BOTÕES --- */

/* Card de Informações - Layout para PC */
.info-personal-card {
    width: 100%;
    /* Limita a largura para não esticar demais no PC */

    border: 1px solid var(--border-color) !important;
}

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

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
}

.header-title h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 700;
}

/* Container de conteúdo */
.info-content-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Grid de informações mais organizada */
.info-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Mantém duas colunas bem definidas */
    gap: 25px 40px;
}

.info-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-field label {
    font-size: 0.75em;
    font-weight: 800;
    color: var(--primary-color);
    /* Usando a cor primária para os rótulos */
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.9;
}

.info-field span {
    font-size: 1.05em;
    font-weight: 500;
    color: var(--text-color);
    padding-left: 22px;
    /* Alinha o texto com o início do rótulo após o ícone */
}

/* Rodapé do Card para o Botão */
.info-footer-actions {
    display: flex;
    flex-direction: column;
    /* Alinha os itens um embaixo do outro */
    align-items: center;
    /* Centraliza os botões horizontalmente */
    gap: 15px;
    /* Cria o espaço entre os botões */
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    /* Linha sutil de separação */
}

.btn-icon-edit {
    background-color: var(--primary-color);
    /* Fica vermelho no hover */
    color: #fff;
    border: 1px solid var(--primary-color);
    padding: 12px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-edit:hover {
    border-color: var(--error-color);
    transform: translateY(-2px);
}

.btn-logout-rounded {
    background-color: var(--error-color);
    /* Fica vermelho no hover */
    color: #fff;
    border: 1px solid var(--error-color);
    padding: 12px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout-rounded:hover {
    border-color: var(--error-color);
    transform: translateY(-2px);
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .info-details-grid {
        grid-template-columns: 1fr;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    text-transform: uppercase;
}

.btn i {
    margin-right: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-success {
    background-color: #43A047;
}

.btn-danger {
    background-color: var(--error-color);
}

.btn-secondary {
    background-color: #757575;
}

.btn-nova-colheita {
    transition: all 0.3s ease;
}

.btn-nova-colheita:hover {
    background-color: #2e7d32;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--light-text-color);
    font-size: 1.2em;
    transition: color 0.2s;
    margin-left: 10px;
}

.action-btn:hover {
    color: var(--primary-color);
}

.link-ver-todas {
    transition: color 0.3s ease, text-decoration 0.3s ease;
}

.link-ver-todas:hover {
    color: #1b5e20;
    text-decoration: underline;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.05);
}

/* --- CARDS DE MÉTRICAS --- */
.metrics-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.card {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.card-caixa {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 2px solid var(--primary-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.metric-card {
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-3px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: var(--light-text-color);
}

.card-header h3 {
    font-size: 1em;
    font-weight: 600;
    margin: 0;
}

.metric-value {
    font-size: 2.2em;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 5px;
}

.metric-description {
    font-size: 0.85em;
    color: var(--light-text-color);
}

/* ==========================================================================
   5. TABELAS
   ========================================================================== */
.data-table-container {
    padding: 0;
    border-radius: 8px;
    overflow: visible;
    box-shadow: var(--shadow);
    border: none;
    margin-top: 20px;
}


.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    margin-top: 15px;
}

.data-table th,
.data-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.saldo-colheita {
    margin-top: 4px;
    font-size: 0.82em;
    color: var(--light-text-color);
}

.data-table th {
    background-color: var(--primary-color);
    color: var(--table-header-text);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

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

.data-table tr:hover {
    background-color: var(--table-hover);
}

.no-data td {
    text-align: center;
    padding: 40px;
    color: var(--light-text-color);
    font-style: italic;
    display: table-cell;
}

/* ==========================================================================
   6. FORMULÁRIOS & INPUTS
   ========================================================================== */
.climate-form {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group-caixa {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 1.4rem;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--text-color);
}

input,
select,
textarea {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.2s, background-color 0.2s;
    width: 100%;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'><path d='M1 1l6 6 6-6' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 8px;
    padding-right: 30px;
    width: auto;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

input:disabled {
    opacity: 0.6;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
    cursor: not-allowed;
    border-color: transparent;
}

/* Remove setas do input number */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Selects Customizados no Header */
.custom-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #fff;
    min-width: 180px;
    width: auto;
    min-height: 40px;
    height: auto;
    line-height: 1.2;
    padding-right: 30px;
}

.custom-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #fff;
    min-width: 160px;
    width: auto;
    min-height: 40px;
}

.form-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid .form-group {
    margin-bottom: 0;
}

.form-grid--pessoas {
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.form-grid--pessoas .form-group {
    grid-column: span 3;
}

.form-span-4 {
    grid-column: span 4;
}

.form-span-2 {
    grid-column: span 2;
}

.form-span-6 {
    grid-column: span 6;
}

.form-span-8 {
    grid-column: span 8;
}

.form-span-12 {
    grid-column: span 12;
}

.pessoa-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pessoa-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    align-items: center;
}

.pessoa-row-2 {
    grid-template-columns: 140px 1fr 120px 1fr;
}

.pessoa-row label {
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.pessoa-row input,
.pessoa-row select {
    width: 100%;
}

.pessoa-picker {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pessoa-picker input {
    flex: 1;
}

.pessoa-picker .btn {
    padding: 6px 10px;
}

#modal-insumo .pessoa-insumo-group {
    margin-bottom: 28px;
}

#modal-receita .pessoa-receita-group {
    margin-bottom: 28px;
}

#modal-receita .modal-content {
    width: min(92vw, 620px);
}

#modal-receita #bloco-parcelamento-receita {
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-background);
    color: var(--text-color);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

#modal-receita #bloco-parcelamento-receita .climate-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

#modal-receita #bloco-parcelamento-receita .form-group {
    flex: 1 1 170px;
    min-width: 160px;
}

#modal-despesa .pessoa-despesa-group {
    margin-bottom: 28px;
}

#modal-despesa .modal-content {
    width: min(92vw, 620px);
}

#modal-despesa #bloco-parcelamento-despesa {
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #e7edf5;
    border-radius: 10px;
    background: var(--card-background);
}

#modal-despesa #bloco-parcelamento-despesa .climate-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

#modal-despesa #bloco-parcelamento-despesa .form-group {
    flex: 1 1 170px;
    min-width: 160px;
}

#modal-despesa #insumo-despesa-wrapper {
    margin-bottom: 28px;
}

#modal-despesa #insumo-despesa-wrapper label {
    display: block;
    margin-bottom: 8px;
}

#modal-despesa #maquina-despesa-wrapper {
    margin-bottom: 28px;
}

#modal-despesa #maquina-despesa-wrapper label {
    display: block;
    margin-bottom: 8px;
}


@media (max-width: 768px) {

    .pessoa-row,
    .pessoa-row-2 {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .pessoa-row-2 label {
        margin-top: 6px;
    }
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

select::-ms-expand {
    display: none;
}

.custom-btn {
    white-space: nowrap;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 20px;
    height: 40px;
}

.classificacao-resumo {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.classificacao-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.classificacao-bar-fill {
    height: 100%;
    width: 0;
    background: var(--primary-color);
    transition: width 0.2s ease;
}

.classificacao-actions {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0;
}

.classificacao-table-wrapper {
    max-height: 220px;
    overflow-y: auto;
}

.classificacao-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.classificacao-table th,
.classificacao-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.classificacao-erro {
    color: var(--error-color);
    font-size: 0.85em;
    margin: 6px 0 10px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    overflow: hidden;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
    overflow: hidden;
}

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

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

input:checked+.slider:before {
    left: 27px;
}

/* Combo Box / Dropdown */
.combo-box {
    position: relative;
}

.combo-input-wrapper {
    position: relative;
}

.combo-input-wrapper input {
    width: 100%;
    padding-right: 34px;
    cursor: text;
}

.combo-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #4caf50;
    font-size: 0.9rem;
}

.combo-list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 20;
    padding: 4px 0;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.combo-list li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.combo-list li:hover {
    background-color: #e8f5e9;
}

.combo-list li.active {
    background-color: #c8e6c9;
}

/* ==========================================================================
   7. MODAIS
   ========================================================================== */
.modal-overlay {
    display: none !important;
    /* O SEGREDO: Força ficar oculto inicialmente */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
    backdrop-filter: blur(2px);
    overflow-y: auto;
    padding: 20px;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-content,
.modal-box {
    background: var(--card-background);
    color: var(--text-color);
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
    border: 1px solid var(--border-color);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

#modal-produto-lookup .data-table-container {
    margin-top: 8px;
}

#modal-produto-lookup .data-table {
    margin-top: 8px;
}

#modal-produto-lookup .modal-content,
#modal-produto-lookup .produto-lookup-scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#modal-produto-lookup .modal-content::-webkit-scrollbar,
#modal-produto-lookup .produto-lookup-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.modal-box-lg {
    max-width: 960px;
}

.leiteria-modal-content {
    max-width: 640px;
    overflow: visible;
    max-height: none;
}

.leiteria-modal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leiteria-modal-form .form-group {
    min-width: 0 !important;
    width: 100%;
}

.venda-leite-modal {
    max-width: 1100px;
}

.venda-leite-row {
    margin: 0;
}

.produto-lookup-modal {
    border-radius: 14px;
}

.produto-lookup-search-wrap input {
    background: linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
    border: 1px solid #d8e4dd;
}

.produto-lookup-results {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    max-height: 360px;
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
}

.produto-lookup-table {
    margin: 0;
}

.produto-lookup-table tbody tr {
    background: transparent;
    transition: background-color 0.2s ease;
}

.produto-lookup-table tbody tr:hover {
    background: #eef7f0;
}

.produto-lookup-select-btn {
    text-transform: none;
    letter-spacing: 0;
    padding: 8px 12px;
}

.venda-leite-row-top {
    align-items: flex-end;
}

.venda-leite-col-data {
    max-width: 220px;
}

.venda-leite-col-numero {
    max-width: 170px;
}

.venda-leite-actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 2px 0 8px;
}

.venda-leite-section-title {
    font-weight: 700;
    font-size: 0.92em;
    margin: 8px 0 6px;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.venda-leite-card {
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;

    flex-wrap: wrap;
}

#venda-leite-form input[type="number"] {
    text-align: right;
}

#venda-leite-saldo-controle {
    background: #f3f6fb;
    font-weight: 600;
}

#venda-leite-valor-total {
    font-weight: 700;
}

#venda-leite-qtde.input-error {
    border-color: var(--error-color);
    box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.15);
}

.venda-leite-alerta {
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgb(255, 255, 255);
    border: 1px solid rgba(229, 57, 53);
    color: #b3201f;
    font-size: 0.85em;
    font-weight: 600;
}

.venda-leite-modal-actions {
    margin-top: 14px;
}

@media (max-width: 980px) {

    .venda-leite-col-data,
    .venda-leite-col-numero {
        max-width: none;
    }
}

.modal-header {
    margin-bottom: 20px;
    text-align: center;
    color: var(--primary-color);
}

.modal-header i {
    font-size: 2rem;
    margin-top: 10px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 25px;
}

.modal-actions button,
.modal-actions .btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
}

.btn-cancel {
    background: #eee;
    color: #555;
}

.btn-confirm {
    background: var(--error-color);
    color: white;
}

/* Configurações (Modal Interno) */
.settings-section {
    margin-bottom: 15px;
    text-align: left;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-info h4 {
    margin: 0 0 5px 0;
    font-size: 1em;
    color: var(--text-color);
}

.settings-info p {
    margin: 0;
    font-size: 0.85em;
    color: var(--light-text-color);
}

.config-modules-grid {
    display: grid;
    gap: 12px;
    padding: 8px 0;
    grid-template-columns: 1fr;
}

.config-module-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    background: var(--card-background);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-module-card-wide {
    grid-column: 1 / -1;
}

.config-module-head h4 {
    margin: 0 0 3px 0;
    font-size: 0.95rem;
}

.config-module-head p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--light-text-color);
}

.config-inline-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.config-inline-control:last-child {
    border-bottom: none;
}

.config-inline-title {
    font-weight: 600;
    display: block;
    font-size: 0.9rem;
}

.config-inline-help {
    font-size: 0.78rem;
    color: var(--light-text-color);
}

.config-select-compact {
    min-width: 130px;
    max-width: 150px;
}

.config-logo-box {
    margin-top: 4px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-logo-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-btn-mini {
    font-size: 0.78em;
    padding: 4px 8px;
}

.config-alert-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}

.config-alert-grid .form-group {
    margin: 0;
}

.config-alert-grid label {
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.config-alert-grid input {
    height: 34px;
    padding: 6px 8px;
}

.config-collapsible {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
}

.config-collapsible+.config-collapsible {
    margin-top: 8px;
}

.config-collapsible summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
}

.config-collapsible-help {
    margin: 6px 0 8px;
    font-size: 0.78rem;
    color: var(--light-text-color);
}

.config-order-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-nav-group {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.01);
}

.mobile-nav-group+.mobile-nav-group {
    margin-top: 6px;
}

.mobile-nav-group-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--light-text-color);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-nav-group-title::-webkit-details-marker {
    display: none;
}

.mobile-nav-group-title::after {
    content: "▾";
    font-size: 0.8rem;
    transform: rotate(-90deg);
    transition: transform 0.2s ease;
}

.mobile-nav-group[open] .mobile-nav-group-title::after {
    transform: rotate(0deg);
}

.mobile-nav-group-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

@media (min-width: 760px) {
    .config-modules-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
    }

    to {
        transform: translateY(0);
    }
}

/* ==========================================================================
   8. MAPA (LEAFLET & CONTROLES)
   ========================================================================== */
.map-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: #fff;
    transition: all 0.3s ease-in-out;
    border: 1px solid #e0e0e0;
}

.map-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 2500;
    border-radius: 0;
    border: none;
    margin: 0;
    background: #fff;
}

#filtro-mapa-propriedade {
    min-width: 100px !important;
    /* Sobrescreve o inline style */
    font-size: 0.85em;
}

/* Reduz a largura mínima do Select para caber junto com a busca */
#filtro-mapa-propriedade {
    min-width: 100px !important;
    /* Sobrescreve o inline style */
    font-size: 0.85em;
}

/* Ajusta a barra de busca */
#busca-roca-mapa {
    font-size: 0.85em;
}

/* Garante que o botão de expandir não seja esmagado */
.btn-map-expand {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.map-controls-overlay {
    width: 96% !important;
    /* Usa quase toda a largura */
    top: 10px;
    flex-wrap: wrap;
    /* Permite quebrar linha para não cortar */
    padding: 8px 5px !important;
    gap: 5px !important;
}

.map-wrapper.fullscreen .map-legend {
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 2501;
}

.map-wrapper.fullscreen .leaflet-top {
    top: calc(80px + env(safe-area-inset-top));
}

.map-wrapper.fullscreen .btn-map-expand {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    flex: 0 0 40px;
}

#map {
    width: 100%;
    height: 100%;
    /* Herda do wrapper */
    margin-top: 0;
    border-radius: 0;
}

/* Barra de Controles Flutuante no Mapa */
.map-controls-overlay {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    z-index: 2000;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

.btn-map-expand {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    flex: 0 0 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-map-expand:focus {
    outline: none;
}

.btn-map-expand:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9),
        0 0 0 4px var(--secondary-color),
        0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-map-expand:hover {
    background: var(--secondary-color);
}

.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 160px;
    opacity: 0.95;
    font-size: 0.85em;
    pointer-events: auto;
}

/* Garante espaço para controles do Leaflet */
.map-wrapper .leaflet-top {
    top: 70px;
    transition: top 0.3s ease;
}

.map-wrapper .leaflet-left {
    left: 10px;
}

/* ==========================================================================
   9. FOOTER
   ========================================================================== */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    box-sizing: border-box;
    background: linear-gradient(90deg, #1f6c2f 0%, #2e7d32 50%, #388e3c 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.12);
}

.app-footer .footer-left p {
    margin: 0;
    color: #f3fff5;
    font-size: 0.92rem;
}

.app-footer strong {
    color: #ffffff;
}

.app-footer .footer-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-footer a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.app-footer a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* ==========================================================================
   10. MOBILE & RESPONSIVIDADE (Consolidado)
   ========================================================================== */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {

    /* --- ESTRUTURA GLOBAL --- */
    html,
    body,
    .container,
    .main-content,
    .form-container,
    .form-group {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .form-group-caixa {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        font-size: 1.2rem;
    }

    /* --- SIDEBAR & MENU --- */
    .menu-toggle {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 2000;
        background: var(--primary-color);
        color: #fff;
        border: none;
        padding: 10px 14px;
        border-radius: 6px;
        font-size: 1.2em;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

    .painel-header-dashboard {
        flex-direction: column;
        align-items: flex-start;
    }

    .painel-title-dashboard {
        order: 0;
        width: 100%;
    }

    .painel-header-dashboard .header-controls {
        order: 1;
        width: 100%;
        margin-left: 0 !important;
    }

    .painel-filtro-wrap {
        width: 100%;
        min-width: 0;
        margin-left: 0;
    }

    .mobile-header {
        display: none !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        max-width: 280px;
        height: 100vh;
        background-color: rgba(46, 125, 50, 0.95);
        backdrop-filter: blur(5px);
        z-index: 2005;
        transition: left 0.3s ease;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
        padding-top: 0;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar .logo {
        display: block !important;
    }

    .sidebar.open~.overlay,
    .overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 2004;
    }

    .sidebar.open~.overlay {
        display: block;
    }

    .sidebar-top {
        flex: 1;
        overflow-y: auto;
    }

    .sidebar-footer {
        width: 100%;
        padding: 25px 0;
        /* Espaçamento interno em cima e embaixo */
        display: flex;
        /* Define o layout como Flexbox */
        flex-direction: column;
        /* Organiza os itens em coluna (um abaixo do outro) */
        justify-content: center;
        /* Centraliza verticalmente no container */
        align-items: center;
        /* Centraliza horizontalmente no container */
        background-color: rgba(0, 0, 0, 0.1);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* --- CONTEÚDO PRINCIPAL --- */
    .main-content {
        margin-left: 0 !important;
        padding: 20px;
        padding-top: 70px !important;
        padding-bottom: 90px !important;
    }

    .screen-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        margin-bottom: 25px !important;
    }

    .screen-header h2 {
        text-align: center;
        font-size: 1.5em;
    }

    .screen-header .btn {
        width: 100%;
        padding: 15px;
        min-height: 44px;
    }

    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .mobile-order-1 {
        order: 1;
    }

    .mobile-order-2 {
        order: 2;
    }

    .mobile-order-3 {
        order: 3;
    }

    .custom-select,
    .custom-btn,
    .custom-input {
        width: 100% !important;
    }

    .filtros-data-range {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .filtros-data-range .custom-input {
        width: 100% !important;
        min-width: 0;
    }

    .main-content .card.data-table-container {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .main-content .card.data-table-container .data-table {
        margin-top: 0;
    }

    /* --- FORMULÁRIOS --- */
    .climate-form {
        flex-direction: column;
        gap: 15px;
    }

    .form-group {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* iOS Input Fixes */
    input[type="date"] {
        width: 100%;
        padding-right: 12px;
        appearance: none;
        -webkit-appearance: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        /* Evita zoom iOS */
        max-width: 100%;
        width: 100%;
        min-width: 0;
    }

    select {
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 10px center;
        background-size: 16px;
        padding-right: 40px;
    }

    .btn,
    .action-btn {
        min-height: 44px;
        touch-action: manipulation;
    }

    /* --- TABELAS PARA CARDS --- */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table {
        border: none;
        background: transparent;
    }

    .data-table thead {
        position: absolute;
        left: -9999px;
        top: -9999px;
    }

    .data-table tbody tr {
        background: #fff;
        border: 1px solid #d1d1d1;
        border-radius: 10px;
        padding: 15px;
        margin-top: 3%;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: none;
        text-align: right;
        font-size: 0.95em;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #555;
        margin-right: 10px;
        text-align: left;
    }

    .data-table tr.no-data td {
        display: block;
        text-align: center;
    }

    .data-table tr.no-data td::before {
        display: none;
    }

    /* Lista Propriedades Mobile */
    #lista-propriedades {
        max-height: none;
        overflow: visible;
        background: transparent;
    }

    #lista-propriedades tr {
        display: flex;
        flex-direction: column;
        padding: 15px;
        margin-bottom: 15px;
        background: white;
        border-radius: 10px;
        border: 1px solid #d1d1d1;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    #lista-propriedades tr:last-child {
        margin-bottom: 0;
    }

    .propriedades-tabela-container,
    .insumos-tabela-container {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .propriedades-tabela-container .data-table,
    .insumos-tabela-container .data-table {
        margin-top: 0;
    }

    #lista-propriedades td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: none;
        text-align: right;
    }

    #lista-propriedades td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #555;
        margin-right: 10px;
        text-align: left;
        min-width: 100px;
    }

    #lista-propriedades span[style*="background: var(--primary-color)"] {
        padding: 3px 6px;
        font-size: 0.7em;
        border-radius: 10px;
    }

    /* --- MAPA MOBILE --- */
    .map-controls-overlay {
        width: 95%;
        top: 10px;
        flex-direction: row;
    }

    .map-wrapper {
        height: 350px;
    }

    /* --- MODAIS & INTERFACE --- */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0px;
        padding: 20px;
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #modal-pessoa-lookup .modal-content,
    #modal-produto-lookup .modal-content,
    #modal-animal-lookup .modal-content {
        height: 85vh;
        max-height: 85vh;
    }

    #modal-produto-lookup .modal-content {
        padding: 16px;
    }

    #modal-produto-lookup .form-group label {
        margin-bottom: 6px;
    }

    #modal-produto-lookup .data-table-container {
        margin-top: 6px;
    }

    #modal-produto-lookup .data-table {
        margin-top: 6px;
    }

    #modal-produto-lookup .data-table tbody tr {
        margin-top: 8px;
        padding: 10px 12px;
    }

    #modal-produto-lookup .data-table td {
        padding: 8px 0;
    }

    #modal-produto-lookup .data-table td::before {
        min-width: 74px;
    }

    #modal-colheita .modal-actions,
    #modal-insumo .modal-actions {
        flex-wrap: wrap;
    }

    #modal-colheita .modal-actions .btn,
    #modal-insumo .modal-actions .btn {
        flex: 1 1 100%;
    }

    /* Enderecos adicionais (Pessoa) - compactar campos no mobile */
    #modal-pessoa-enderecos .modal-content {
        padding: 14px;
    }

    #modal-pessoa-enderecos .climate-form {
        flex-direction: column;
        flex-wrap: nowrap !important;
        align-items: stretch;
        gap: 8px !important;
        margin: 0 0 6px 0 !important;
    }

    #modal-pessoa-enderecos .form-group {
        flex: 0 0 auto !important;
        min-width: 0 !important;
        margin: 0;
    }

    #modal-pessoa-enderecos input,
    #modal-pessoa-enderecos select {
        padding: 10px;
    }

    .action-btn {
        display: flex;
        align-items: center;
        padding: 8px 12px;
        border-radius: 6px;
        background: #f5f5f5;
        border: 1px solid #ddd;
    }

    .btn-close-modal {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: #f5f5f5 !important;
    }

    /* Perfil */
    .perfil-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .profile-actions {
        display: flex;
        gap: 10px;
        width: 100%;
        justify-content: space-between;
    }

    .profile-actions .btn {
        flex: 1;
        padding: 12px 8px;
        font-size: 0.85em;
    }

    /* Compartilhamento de propriedade (mobile) */
    .modal-compartilhamento-propriedade {
        width: calc(100vw - 12px) !important;
        max-width: calc(100vw - 12px) !important;
        padding: 14px !important;
        border-radius: 10px;
    }

    .modal-compartilhamento-propriedade h3 {
        font-size: 1.05rem;
    }

    .modal-compartilhamento-propriedade .climate-form {
        gap: 10px;
    }

    .modal-compartilhamento-propriedade .form-group {
        margin-bottom: 0;
    }

    .modal-compartilhamento-propriedade .form-group .btn {
        width: 100%;
    }

    .modal-compartilhamento-propriedade .data-table tbody tr {
        margin-top: 10px;
        padding: 12px;
    }

    .modal-compartilhamento-propriedade .data-table td {
        gap: 8px;
        align-items: flex-start;
    }

    .modal-compartilhamento-propriedade .data-table td:last-child {
        justify-content: flex-end;
    }

    .modal-compartilhamento-propriedade .modal-actions .btn {
        width: 100%;
    }

    /* --- NAV BAR INFERIOR --- */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background: #fff;
        border-top: 1px solid #eee;
        justify-content: space-around;
        align-items: center;
        z-index: 2100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .mobile-bottom-nav a {
        text-decoration: none;
        color: #888;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 0.75em;
    }

    .mobile-bottom-nav a i {
        font-size: 1.4em;
        margin-bottom: 4px;
    }

    .mobile-bottom-nav a.active {
        color: var(--primary-color);
        font-weight: 700;
    }

    .sidebar.open~.mobile-bottom-nav {
        display: none !important;
    }

    .app-footer {
        display: none !important;
    }
}

/* --- CONFIG ORDEM MENU MOBILE --- */
.mobile-nav-order-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-background);
}

.mobile-nav-order-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.mobile-nav-order-text {
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-nav-order-actions {
    display: flex;
    gap: 4px;
}

.mobile-nav-order-btn {
    padding: 4px 7px;
    font-size: 0.72em;
    min-width: 52px;
}

.mobile-nav-order-toggle {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: #fff;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.mobile-nav-order-toggle:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.mobile-nav-order-toggle:checked::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: #fff;
}

.mobile-nav-order-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.25);
}

@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        body {
            overflow-x: clip;
        }
    }
}

/* ==========================================================================
   11. TEMA ESCURO (DARK MODE)
   ========================================================================== */
body.dark-mode {
    --primary-color: #4CAF50;
    --secondary-color: #81C784;
    --background-color: #121212;
    --card-background: #1E1E1E;

    --text-color: #E0E0E0;
    --light-text-color: #B0B0B0;
    --border-color: #333333;

    --input-bg: #2C2C2C;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);

    --table-hover: #2C2C2C;
    --table-header-text: #ffffff;
    --sidebar-text: #ffffff;
}

/* Sidebar & Layout */
body.dark-mode .sidebar {
    background-color: #1a1a1a;
    border-right: 1px solid #333;
}

body.dark-mode .modal-content {
    background-color: #1E1E1E;
    border: 1px solid #444;
}

body.dark-mode .mobile-nav-order-toggle {
    background: var(--input-bg);
}

body.dark-mode .produto-lookup-modal {
    background: linear-gradient(180deg, #1d1f1f 0%, #171919 100%);
    border: 1px solid #3b4740;
}

body.dark-mode .produto-lookup-search-wrap input {
    background: linear-gradient(180deg, #252b28 0%, #1f2522 100%) !important;
    border-color: #3f4f46 !important;
}

body.dark-mode .produto-lookup-results {
    border-color: #3f4f46;
    background: linear-gradient(180deg, #212624 0%, #1a1f1d 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.dark-mode .produto-lookup-table thead th {
    background: #2b332f !important;
    border-bottom: 1px solid #3f4f46 !important;
}

body.dark-mode .produto-lookup-table tbody tr {
    background: #202624 !important;
    border-bottom: 1px solid #323c37 !important;
}

body.dark-mode .produto-lookup-table tbody tr:hover {
    background: #2a3530 !important;
}

body.dark-mode .produto-lookup-select-btn {
    background-color: #37423d !important;
    border: 1px solid #4c5c53 !important;
}

body.dark-mode .produto-lookup-select-btn:hover {
    background-color: #425249 !important;
}

@media (max-width: 920px) {
    .config-alert-grid {
        grid-template-columns: 1fr;
    }
}

/* Inputs & Forms */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .custom-select,
body.dark-mode .input-field {
    background-color: #2C2C2C !important;
    color: #ffffff !important;
    border: 1px solid #555 !important;
}

body.dark-mode ::placeholder {
    color: #bbbbbb !important;
    opacity: 1;
}

body.dark-mode input[type="date"] {
    color-scheme: dark;
}

/* Setinha do Select */
body.dark-mode select {
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'><path d='M1 1l6 6 6-6' fill='none' stroke='%23bbb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
}

/* Tabelas */
body.dark-mode .data-table th,
body.dark-mode table th {
    background-color: #2e2e2e !important;
    color: #fff !important;
    border-bottom: 1px solid #444 !important;
}

body.dark-mode table thead {
    background-color: #2C2C2C !important;
}

body.dark-mode table tbody tr {
    background-color: var(--card-background) !important;
    border-bottom: 1px solid #333 !important;
}

body.dark-mode table td {
    color: #e0e0e0 !important;
}

/* Botões & Links */
body.dark-mode .action-btn {
    background-color: transparent;
    border-color: transparent;
    color: #ccc;
}

body.dark-mode .action-btn:hover {
    color: var(--primary-color);
    text-shadow: 0 0 6px rgba(76, 175, 80, 0.35);
}

body.dark-mode .btn-secondary {
    background-color: #444 !important;
    min-height: 44px !important;
    color: #fff !important;
    border: 1px solid #555;
}

body.dark-mode a {
    color: var(--primary-color);
}

body.dark-mode .user-avatar {
    background-color: var(--card-background) !important;
    border-color: #555 !important;
    color: var(--primary-color) !important;
}

body.dark-mode .user-avatar:hover {
    border-color: var(--primary-color) !important;
}

/* Cards */
body.dark-mode .metric-card {
    background-color: var(--card-background);
    border-top: 1px solid #333;
    border-right: 1px solid #333;
    border-bottom: 1px solid #333;
}

body.dark-mode .metric-description {
    color: #B0B0B0 !important;
}

/* Mapa (Leaflet) */
body.dark-mode .map-controls-overlay {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #444;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

body.dark-mode .map-legend {
    background: rgba(30, 30, 30, 0.95);
    color: #e0e0e0;
    border: 1px solid #444;
}

body.dark-mode .map-legend h4 {
    border-bottom-color: #555 !important;
    color: #fff !important;
}

body.dark-mode .leaflet-bar {
    border: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .leaflet-bar a {
    background-color: #2C2C2C !important;
    color: #ffffff !important;
    border-bottom: 1px solid #444 !important;
}

body.dark-mode .leaflet-bar a:hover {
    background-color: #444 !important;
    color: var(--primary-color) !important;
}

body.dark-mode .leaflet-popup-content-wrapper,
body.dark-mode .leaflet-popup-tip {
    background: #1E1E1E;
    color: #e0e0e0;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.6);
}

body.dark-mode .leaflet-popup-content h4 {
    color: var(--primary-color) !important;
}

body.dark-mode .leaflet-popup-content hr {
    border-top-color: #444 !important;
}

body.dark-mode .leaflet-tooltip {
    background-color: #333;
    border: 1px solid #555;
    color: #fff;
    box-shadow: none;
}

body.dark-mode .leaflet-tooltip::before {
    border-top-color: #333;
}

/* Nav Mobile Dark Mode */
body.dark-mode .mobile-bottom-nav {
    background-color: #1E1E1E !important;
    border-top: 1px solid #333 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .mobile-bottom-nav a {
    color: #888 !important;
}

body.dark-mode .mobile-bottom-nav a.active {
    color: var(--primary-color) !important;
}

/* Footer Dark Mode */
body.dark-mode .app-footer {
    background: linear-gradient(90deg, #151a18 0%, #1b2320 50%, #1f2b26 100%);
    border-top: 1px solid #2f3a35;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
}

body.dark-mode .app-footer .footer-left p {
    color: #cfd8d3;
}

body.dark-mode .app-footer strong {
    color: #ffffff;
}

body.dark-mode .app-footer a {
    color: #d9efe0;
    border-color: #3b4a43;
    background: rgba(76, 175, 80, 0.12);
}

body.dark-mode .app-footer a:hover {
    background: rgba(76, 175, 80, 0.24);
    color: #ffffff;
}

/* Fix Legibilidade Tabelas Mobile Dark */
@media (max-width: 768px) {

    body.dark-mode .data-table td::before,
    body.dark-mode #lista-propriedades td::before {
        color: #b0b0b0 !important;
        font-weight: 700;
    }

    body.dark-mode .data-table td,
    body.dark-mode #lista-propriedades td {
        color: #ffffff !important;
        border-bottom-color: #333 !important;
    }

    body.dark-mode .data-table tbody tr,
    body.dark-mode #lista-propriedades tr {
        background-color: #1E1E1E !important;
        border: 1px solid #333 !important;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
    }
}

/* ==========================================================================
   ESTILOS DOS CHECKBOXES DE RELATÓRIO
   ========================================================================== */

/* Estilo Padrão (Modo Claro) */
.report-col-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background-color: #f5f5f5;
    /* Cinza claro */
    padding: 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
    color: #333;
}

.report-col-option:hover {
    background-color: #e0e0e0;
}

/* Checkbox marcado (Destaque opcional) */
.report-col-option:has(input:checked) {
    border-color: var(--primary-color);
    background-color: #e8f5e9;
    /* Levemente verde no modo claro */
}

/* --- MODO ESCURO --- */
body.dark-mode .report-col-option {
    background-color: #2C2C2C;
    /* Fundo Escuro */
    color: #ffffff;
    /* Texto Branco */
    border: 1px solid #444;
}

body.dark-mode .report-col-option:hover {
    background-color: #383838;
}

body.dark-mode .report-col-option:has(input:checked) {
    background-color: #1b3a1e;
    /* Verde bem escuro quando marcado */
    border-color: var(--primary-color);
}

/* ==========================================================================
   BOTÕES DE ÍCONE (Relatórios e Ações Rápidas)
   ========================================================================== */
.btn-icon {
    width: 42px;
    /* Largura fixa */
    height: 42px;
    /* Altura fixa para ficar quadrado */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-icon i {
    margin: 0 !important;
    /* Remove margem padrão dos ícones */
    font-size: 1.1em;
}

/* Efeito Hover (Mouse em cima) */
.btn-icon:hover {
    transform: translateY(-3px);
    /* Sobe um pouquinho */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    /* Sombra mais forte */
    filter: brightness(1.1);
    /* Fica levemente mais claro */
}

/* Ajuste específico para o modo escuro */
body.dark-mode .btn-icon {
    border: 1px solid #444;
}

/* Força todos os campos de formulário a usarem a mesma fonte do sistema */
input,
select,
textarea,
button {
    font-family: inherit;
}

/* Garante especificamente para o campo de data, que alguns navegadores teimam em mudar */
input[type="date"] {
    font-family: inherit;
    /* Opcional: Ajusta a altura/alinhamento se estiver diferente dos inputs de texto */
    line-height: normal;
}

/* Estilização da Seção de Informações do Perfil */
.info-personal-card {
    padding: 25px !important;
}

.pagamento-card {
    padding: 22px 25px;
    margin-bottom: 30px;
}

.pagamento-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 8px;
}

.pagamento-card-header h3 {
    margin: 0;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagamento-valor {
    font-weight: 800;
    font-size: 1.15em;
    color: var(--primary-color);
}

.pagamento-descricao {
    margin: 0 0 14px 0;
    color: var(--light-text-color);
    font-size: 0.95em;
}

.pagamento-lista {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.pagamento-lista li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-size: 0.95em;
}

.pagamento-lista li i {
    color: #2e7d32;
    font-size: 0.95em;
}

.pagamento-acoes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.pagamento-acoes .btn {
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.btn-whatsapp {
    background-color: #25d366;
    color: #fff;
    border: none;
    box-shadow: 0 6px 14px rgba(37, 211, 102, 0.35);
}

.btn-whatsapp:hover {
    background-color: #22c55e;
    filter: none;
}

.btn-whatsapp i {
    margin-right: 0;
    font-size: 1.6em;
    font-weight: 700;
    color: #fff;
}

.btn-whatsapp-icon {
    width: 46px;
    height: 46px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

.card-header-flex h3 {
    margin: 0;
    font-size: 1.15em;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}


.info-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Duas colunas em telas maiores */
    gap: 20px;
}

.info-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-field label {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--light-text-color);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-field label i {
    width: 14px;
    color: var(--primary-color);
    opacity: 0.7;
}

.info-field span {
    font-size: 1em;
    font-weight: 500;
    color: var(--text-color);
    word-break: break-all;
}

/* Ajuste para Mobile */
@media (max-width: 600px) {
    .info-details-grid {
        grid-template-columns: 1fr;
        /* Uma coluna no celular */
        gap: 15px;
    }
}

/* Layout do Painel Principal */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Padrão mobile: uma coluna empilhada */
    gap: 20px;
    align-items: start;
    /* Alinha os itens ao topo */
}

.leiteria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.leiteria-module-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    min-height: 170px;
    min-width: 0;
}

.leiteria-module-card h3 {
    color: var(--primary-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.leiteria-module-card p {
    color: var(--light-text-color);
    margin: 0;
}

.leiteria-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.leiteria-chart-week {
    height: 230px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    align-items: stretch;
    gap: clamp(4px, 0.8vw, 10px);
    padding: 10px 4px 4px;
    min-width: 0;
}

.leiteria-chart-col {
    display: grid;
    grid-template-rows: 1fr auto;
    align-items: center;
    gap: 6px;
    min-height: 0;
}

.leiteria-chart-bar-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 0;
}

.leiteria-chart-col span {
    font-size: clamp(0.62rem, 0.7vw, 0.75rem);
    color: var(--light-text-color);
    line-height: 1;
    white-space: nowrap;
}

.leiteria-chart-bar {
    width: 100%;
    max-width: 30px;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #66bb6a 0%, var(--primary-color) 100%);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.leiteria-chart-bar:hover {
    transform: translateY(-2px);
}

.leiteria-module-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.leiteria-module-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    display: grid;
    gap: 10px;
    background: var(--background-color);
}

.leiteria-module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.leiteria-module-head h4 {
    margin: 0;
    color: var(--text-color);
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.leiteria-module-head span {
    font-weight: 700;
    color: var(--primary-color);
}

.leiteria-module-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(46, 125, 50, 0.15);
    overflow: hidden;
}

.leiteria-module-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary-color);
}

@media (max-width: 640px) {
    .leiteria-grid {
        grid-template-columns: 1fr;
    }

    .leiteria-chart-week {
        height: 190px;
        gap: 8px;
        padding: 8px 2px 2px;
    }

    .leiteria-chart-col span {
        font-size: 0.7em;
    }
}

/* Cards que devem preencher a altura */
.full-height-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.full-height-card .card-content-grow {
    flex-grow: 1;
    /* Faz a tabela ou conteúdo esticar */
}

/* Responsividade para Tablet/Desktop */
@media (min-width: 768px) {
    .dashboard-grid {
        /* Duas colunas: a da esquerda um pouco mais estreita (1fr), a da direita mais larga (1.5fr) para a tabela */
        grid-template-columns: 1fr 1.5fr;
    }

    /* A coluna da direita deve esticar para ficar da mesma altura da esquerda */
    .dashboard-column-right {
        height: 100%;
    }
}

.action-btn i.fa-robot:hover {
    animation: pulse-purple 1.5s infinite;
    color: var(--primary-color);
}

@keyframes pulse-purple {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}


.ai-response-content {
    color: var(--text-color) !important;
    line-height: 1.6;
    font-size: 0.95em;
}

/* Container do texto da IA 
.ai-response-content {
    background: var(--text-color);
    border-left: 4px solid #673AB7;
    padding: 15px;
    border-radius: 4px;
    line-height: 1.6;
    color:var(--text-color) !important; 
    font-size: 0.95em;
}
*/

/* Formata parágrafos dentro do Markdown */
.ai-response-content p {
    margin-bottom: 12px;
}


.ai-response-content strong {
    font-weight: 800;
    color: var(--text-color);
}

/* Garante que o negrito do Markdown apareça forte 
.ai-response-content strong {
    font-weight: 800;
    color: var(--text-color);
    
}
*/

/* Se a IA mandar listas, elas aparecerão assim: */
.ai-response-content ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

/* Painel Lateral Deslizante */
.painel-lateral {
    position: fixed;
    top: 0;
    right: -450px;
    width: 400px;
    height: 100vh;
    background: var(--card-background);
    /* ou white */
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);

    /* 🔴 AQUI ESTÁ A CORREÇÃO: Mude de 2100 para 3500 */
    /* O mapa em tela cheia usa 2500, então precisamos de mais que isso */
    z-index: 3500;

    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

/* Classe que ativa o painel */
.painel-lateral.aberto {
    right: 0;
}

.painel-header {
    padding: 20px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-fechar-painel {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.painel-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Estilo da Timeline */
.timeline {
    border-left: 2px solid #e0e0e0;
    margin-left: 10px;
    padding-left: 25px;
    margin-top: 20px;
}

.timeline-item {
    position: relative;
    margin-bottom: 25px;
}

.timeline-icon {
    position: absolute;
    left: -36px;
    background: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    border: 2px solid var(--primary-color);
    font-size: 0.8em;
}

.timeline-date {
    font-size: 0.75em;
    color: #888;
    margin-bottom: 4px;
    display: block;
}

.timeline-title {
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.timeline-desc {
    font-size: 0.9em;
    color: #666;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .painel-lateral {
        width: 100%;
        right: -100%;
    }
}

/* Card Inline (Abaixo do Mapa) */
#roca-detalhes-inline {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

#roca-detalhes-inline.hidden {
    display: none;
    opacity: 0;
}

/* Ajustes da Grid Resumo (para ficar bonito no card) */
.grid-resumo .card-info {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.grid-resumo .card-info i {
    font-size: 1.4em;
    color: var(--primary-color);
    margin-bottom: 5px;
}

/* Animação suave ao aparecer */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* =========================================
   MODO ESCURO - MAPA E PAINEL LATERAL
   ========================================= */

/* Fundo padrão do painel lateral */
.painel-lateral {
    background: #fff;
    color: #333;
    border-left: 1px solid #ddd;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

/* Box do estágio (Verde Claro no modo claro) */
.box-estagio {
    border: 1px solid #4CAF50;
    background: #f1f8e9;
    padding: 5px;
}

.select-estagio-padrao {
    background-color: #ffffff;
    border: 1px solid #4CAF50;
    border-radius: 6px;
    padding: 6px 28px 6px 10px;
    font-size: 0.95em;
    color: #2e7d32;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.select-estagio-padrao:focus {
    border-color: #2e7d32;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
}

/* --- REGRAS DARK MODE --- */
body.dark-mode .painel-lateral {
    background-color: #1e1e1e;
    /* Cinza escuro */
    color: #e0e0e0;
    border-left: 1px solid #333;
}

body.dark-mode .painel-header {
    border-bottom: 1px solid #333;
}

body.dark-mode .painel-titulo-roca {
    color: #fff;
}

/* Cards de Informação dentro do Painel */
body.dark-mode .card-info {
    background-color: #2d2d2d;
    border: 1px solid #444;
}

body.dark-mode .card-info strong {
    color: #fff;
    /* Texto em destaque fica branco */
}

body.dark-mode .card-info .label {
    color: #aaa;
    /* Texto secundário fica cinza claro */
}

/* Ajuste específico para o Box de Estágio no escuro */
body.dark-mode .box-estagio {
    background-color: rgba(76, 175, 80, 0.15);
    /* Verde bem transparente */
    border-color: #4CAF50;
}

body.dark-mode .select-estagio-padrao {
    background-color: #2b2b2b;
    border-color: #4CAF50;
    color: #dff3e3;
}

body.dark-mode .select-estagio-padrao:focus {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

body.dark-mode .classificacao-bar {
    background: #333;
}

body.dark-mode .classificacao-table th,
body.dark-mode .classificacao-table td {
    border-bottom-color: #444;
}

/* Linha do Tempo (Timeline) */
body.dark-mode .timeline-item {
    border-left-color: #444;
}

body.dark-mode .timeline-title {
    color: #f5f5f5;
}

body.dark-mode .timeline-desc {
    color: #bbb;
}

body.dark-mode .timeline-date {
    color: #888;
}

/* Card Flutuante (Inline) abaixo do mapa */
body.dark-mode #roca-detalhes-inline {
    background-color: #1e1e1e;
    color: #fff;
    border-color: #333;
}

body.dark-mode #inline-subtitulo {
    color: #aaa !important;
}

/* Botão de fechar painel */
body.dark-mode .btn-fechar-painel {
    color: #fff;
}

body.dark-mode .btn-fechar-painel:hover {
    background-color: #333;
}

/* =========================================
   ESTILO MODERNO DO PAINEL LATERAL (SIDEBAR)
   ========================================= */

/* Fundo escuro semitransparente que cobre o mapa quando o painel abre (opcional, dá foco) */
.sidebar-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 1999;
    /* Fica logo abaixo do painel */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.map-wrapper.fullscreen.painel-aberto .sidebar-backdrop {
    opacity: 1;
    pointer-events: all;
}

/* O Painel em si */
#painel-roca {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: 380px;
    /* Largura confortável */
    max-width: 90%;
    /* Para telas pequenas */
    background: #ffffff;
    z-index: 2000;
    border-radius: 16px;
    /* Cantos bem arredondados */
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    /* Sombra suave e difusa */
    transform: translateX(110%);
    /* Começa escondido na direita */
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* Animação elástica suave */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Garante que nada vaze das bordas arredondadas */
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Quando ativo */
#painel-roca.aberto {
    transform: translateX(0);
}

/* Cabeçalho do Painel */
.painel-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #43a047 100%);
    /* Degradê moderno */
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    /* Sombra interna sutil */
    z-index: 2;
    /* Fica acima do conteúdo scrollável */
}

.painel-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-fechar-painel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-fechar-painel:hover {
    background: white;
    color: var(--primary-color);
    transform: rotate(90deg);
    /* Efeito legal ao passar o mouse */
}

/* Corpo do Painel (Onde fica o conteúdo) */
.painel-body {
    flex: 1;
    overflow-y: auto;
    /* Scroll suave */
    padding: 20px;
    background: #f8f9fa;
    /* Fundo levemente cinza para destacar os cards brancos */
}

/* Scrollbar personalizada e bonita */
.painel-body::-webkit-scrollbar {
    width: 6px;
}

.painel-body::-webkit-scrollbar-track {
    background: transparent;
}

.painel-body::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 10px;
}

/* Ajustes nos Cards internos (que são gerados pelo JS) */
#painel-roca .card-info {
    background: white;
    border: none;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0 !important;
    /* Remove margem padrão se houver */
}

#painel-roca .card-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

#painel-roca .grid-resumo {
    gap: 12px !important;
}

/* Estilo da Linha do Tempo dentro do Painel */
#painel-roca .timeline {
    padding-left: 10px;
    margin-top: 15px;
}

#painel-roca .timeline-item {
    padding-bottom: 20px;
    position: relative;
    border-left: 2px solid #e0e0e0;
    padding-left: 20px;
}

#painel-roca .timeline-icon {
    width: 14px;
    height: 14px;
    position: absolute;
    left: -8px;
    top: 0;
    background: white;
    border-width: 3px;
    border-style: solid;
    border-radius: 50%;
}

/* Modo Escuro (Se o usuário ativar) */
body.dark-mode #painel-roca {
    background: #1e1e1e;
    border-color: #333;
}

body.dark-mode .painel-body {
    background: #121212;
}

body.dark-mode #painel-roca .card-info {
    background: #2d2d2d;
    color: #e0e0e0;
}

/* =========================================
   CORREÇÕES GERAIS PARA MODO ESCURO
   ========================================= */

body.dark-mode .modal-content {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    border: 1px solid #333;
}

body.dark-mode .modal-header h3 {
    color: #e0e0e0 !important;
}

body.dark-mode p {
    color: #b0b0b0 !important;
}

/* --- Botões do Modal de Confirmação --- */

/* Botão Cancelar (que era cinza claro) */
body.dark-mode #modal-confirmacao button:first-child,
/* Pega pelo primeiro botão */
body.dark-mode .btn-secondary,
body.dark-mode .btn-cancel {
    background-color: #333 !important;
    color: #e0e0e0 !important;
    border: 1px solid #444 !important;
}

body.dark-mode #modal-confirmacao button:first-child:hover,
body.dark-mode .btn-secondary:hover,
body.dark-mode .btn-cancel:hover {
    background-color: #444 !important;
}

/* Botão Confirmar/Sim (Mantém vermelho, mas ajusta borda/sombra) */
body.dark-mode #btn-modal-confirmacao-sim,
body.dark-mode .btn-danger,
body.dark-mode .btn-confirm {
    box-shadow: none !important;
    border: 1px solid #b71c1c !important;
    /* Vermelho mais escuro na borda */
}

/* --- Botões de Seleção de Manejo (Cards Grandes) --- */
body.dark-mode .btn-manejo-opcao {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
}

body.dark-mode .btn-manejo-opcao:hover {
    background-color: #383838 !important;
    border-color: var(--primary-color) !important;
}

/* Ajuste de ícones dentro dos botões de manejo para ficarem visíveis */
body.dark-mode .btn-manejo-opcao i {
    filter: brightness(1.2);
    /* Deixa os ícones coloridos um pouco mais brilhantes */
}

/* --- Botões de Relatórios (Cards) --- */
body.dark-mode .btn-relatorio {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
}

body.dark-mode .btn-relatorio:hover {
    background-color: #383838 !important;
}

/* --- Inputs e Selects dentro de Modais --- */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #2d2d2d !important;
    color: #fff !important;
    border: 1px solid #444 !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #777 !important;
}

/* =========================================
   ESTILO DO MODAL DE MANEJO (PADRÃO DO SISTEMA)
   ========================================= */

/* Grid para os botões */
.manejo-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 2 colunas */
    gap: 15px;
    margin-bottom: 10px;
}

/* O Botão "Card" */
.btn-manejo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-card);
    /* Usa a cor do seu tema */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-manejo-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Ícones coloridos (mas sutis) */
.icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 10px;
    background-color: rgba(128, 128, 128, 0.1);
    /* Fundo neutro padrão */
}

/* Cores específicas apenas para os ícones */
.icon-wrapper.defensivo {
    color: #ef5350;
    background-color: rgba(239, 83, 80, 0.1);
}

.icon-wrapper.adubo {
    color: #66bb6a;
    background-color: rgba(102, 187, 106, 0.1);
}

.icon-wrapper.colheita {
    color: #ffa726;
    background-color: rgba(255, 167, 38, 0.1);
}

/* Botão de Colheita ocupa 2 colunas (destaque) */
.btn-manejo-card.destaque {
    grid-column: span 2;
    background-color: var(--bg-highlight, rgba(var(--primary-rgb), 0.05));
    /* Leve destaque se houver */
    font-weight: 600;
}

/* =========================================
   FORÇAR MAIÚSCULAS (PADRÃO DO SISTEMA)
   ========================================= */
input[type="text"],
textarea,
.form-control {
    text-transform: uppercase !important;
}

/* Exceção: Senhas e E-mails devem permanecer normais */
input[type="password"],
input[type="email"] {
    text-transform: none !important;
}

/* --- MENU LATERAL (LAYOUT COMPACTO) --- */

.nav-link {
    display: flex;
    align-items: center;
    /* Centraliza verticalmente */
    justify-content: flex-start;
    /* Alinha tudo à esquerda (junto) */
    gap: 12px;
    /* Espaço igual entre Ícone, Texto e Seta */
    padding: 14px 25px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    cursor: pointer;
    font-size: 0.95em;
}

/* Ícone Principal (Casa, Trator, etc) */
.nav-link>i:first-child {
    width: 20px;
    text-align: center;
    font-size: 1.1em;
}

/* Texto do Menu */
.nav-link span {
    flex-grow: 0;
    /* Impede que o texto empurre a seta para longe */
    font-weight: 500;
}

/* Seta do Dropdown */
.arrow-icon {
    font-size: 0.8em;
    opacity: 0.6;
    transition: transform 0.3s ease;
    margin-top: 2px;
    /* Pequeno ajuste ótico */
}

/* Hover no link */
.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding-left: 28px;
    /* Movimento sutil para direita */
}

/* --- ESTADOS ATIVOS E ABERTOS --- */

/* Item Pai Ativo ou Aberto */
.nav-item.active>.nav-link,
.nav-item.open>.nav-link {
    background-color: rgba(0, 0, 0, 0.15);
    color: #fff;
    border-left-color: var(--accent-color);
    /* Amarelo/Laranja destaque */
}

/* Rotação da Seta quando aberto */
.nav-item.open .arrow-icon {
    transform: rotate(90deg);
    opacity: 1;
    color: var(--accent-color);
}

/* --- SUBMENU --- */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.2);
    /* Fundo mais escuro */
    transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Quando aberto, dá altura suficiente */
.nav-item.open .nav-submenu {
    max-height: 500px;
}

/* Links do Submenu */
.nav-submenu li a {
    padding: 10px 20px 10px 58px;
    /* Recuo maior para indicar hierarquia */
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid transparent;
    /* Mantém alinhamento */
}

.nav-submenu li a:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

/* Item filho ativo */
.nav-submenu li.active a {
    color: var(--accent-color);
    font-weight: 600;
    background-color: rgba(0, 0, 0, 0.2);
}
