.ag-watermark {
    display: none !important;
}

/* ==========================================================================
   1. General & Global Styles
   ========================================================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    margin: 0; /* Important: Remove default browser margin */
    display: flex;
    flex-direction: column;
    height: 100vh; /* Make the body take up the full window height */
}


h1, h2 {
    color: #0056b3;
}

hr {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0));
}

/* ==========================================================================
   2. Layout & Page Structure
   ========================================================================== */

#app-content {
    padding: 20px; /* Move padding from body to here */
    flex-grow: 1; /* THE KEY: This makes the container grow */
    display: flex; /* It also needs to be a flex container... */
    flex-direction: column; /* ...to manage its own children */
    overflow-y: auto; /* Add a scrollbar if content overflows */
}

/* Any page loaded inside app-content should also be a flex column */
.page {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow the page itself to grow */
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    /* This element will have a natural height, it should not grow */
    flex-shrink: 0; 
}

/* ==========================================================================
   3. Main Header & Navigation
   ========================================================================== */

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #004a99;
    color: white;
    margin-bottom: 0px;
    border-radius: 8px;
    position: relative;
    z-index: 200;
    margin-top: 20px;
    margin-left: 20px;
    margin-right: 20px;
}

.header-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 30px;
}

.logo {
    font-size: 1.5em;
    font-weight: bold;
}

.farm-selector {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 5px;
}

#farm-select {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    min-width: 150px;
    height: 30px;
    background-color: #f0f0f0;
}

/* --- Navigation Menu --- */

.main-nav > ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    color: #ffffff;
}

.main-nav li {
    position: relative;
}

.main-nav > ul > li > a {
    display: block;
    padding: 10px 15px;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Active and Hover States for Main Nav */
.main-nav > ul > li > a.active {
    background-color: #005dc0;
    color: #ffffff;
}

.main-nav > ul > li:hover > a,
.main-nav .has-dropdown.dropdown-is-active > a {
    background-color: #005dc0;
    color: #ffffff;
}

/* --- Dropdown Menus --- */

.dropdown {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    min-width: 180px;
    padding: 5px 0;
    transition: opacity 0.3s ease-in-out;
}

.has-dropdown.dropdown-is-active > .dropdown {
    visibility: visible;
    opacity: 1;
}

.dropdown a {
    color: #333;
    padding: 10px 15px;
    display: block;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
}

.dropdown a:hover {
    background-color: #e9ecef;
}

/* Dropdown Alignment */
.dropdown-align-right .dropdown {
    left: auto;
    right: 0;
}

.dropdown-align-center .dropdown {
    left: 50%;
    transform: translateX(-50%);
}

.main-nav a svg {
    width: 1.2em; /* Tamanho relativo à fonte do menu */
    height: 1.2em;
    vertical-align: middle; /* Alinha verticalmente com o texto dos outros itens */
    margin-bottom: 2px; /* Pequeno ajuste para um alinhamento visual perfeito */
}

/* ==========================================================================
   4. Buttons & Utility Classes
   ========================================================================== */

/* --- General Button Styles --- */

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    width: 30px;
    height: 30px;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f0f0f0;
    box-sizing: border-box;
    padding: 0;
}

.action-button:hover {
    background-color: #e0e0e0;
}

.button-primary {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.button-primary:hover {
    background-color: #0069d9;
}

.button-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.button-secondary:hover {
    background-color: #5a6268;
}

.remove-item-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2em;
}

/* --- State-specific Button Styles --- */

.btn-danger:hover {
    background-color: #c82333;
    border-color: #c82333;
    color: white;
}

/* --- Utility Classes --- */

.hidden {
    display: none !important;
}

.status-active {
    color: green;
    font-weight: bold;
}

.warning-text {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* ==========================================================================
   5. Forms & Inputs
   ========================================================================== */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

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

.form-group-full {
    grid-column: 1 / -1;
}

/* NOVO: Classe utilitária para um item do form ocupar 2 colunas */
.form-group-span-2 {
    grid-column: span 2;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

/* --- Sub-form (e.g., in Purchase Modal) --- */

.sub-form-section {
    grid-column: 1 / -1;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.sub-form-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
}

.sub-form-inputs {
    display: grid;
    grid-template-columns: 1.5fr 2.5fr 3fr 1.5fr 2fr;  
    gap: 10px; 
    align-items: center;
    margin-top: 10px;
}

.sub-form-inputs input {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
}

/* --- Style for the action buttons container --- */
.sub-form-actions {
    display: grid; /* This is the key to placing buttons side-by-side */
    grid-template-columns: 2fr 1fr;
    gap: 10px;     /* Creates space between the buttons */
    margin-top: 10px;
}


/* --- Dynamic List (for protocols) --- */

.dynamic-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
}

.dynamic-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.dynamic-list li:last-child {
    border-bottom: none;
}

/* --- NEW: Animal Search Results List --- */

.animal-search-results-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 10px;
}

.search-result-item {
    display: grid;
    grid-template-columns: auto 1fr; /* 1st column (radio) fits content, 2nd (label) takes all remaining space */
    gap: 15px; /* Creates space between the radio and the text */
     align-items: center;
     padding: 12px;
     border-bottom: 1px solid #eee;
     cursor: pointer;
     transition: background-color 0.2s ease-in-out;
 }


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

.search-result-item:hover {
    background-color: #f0f8ff; /* A light blue on hover */
}

.search-result-item input[type="radio"] {
    margin-right: 15px;
    flex-shrink: 0; /* Prevent the radio button from shrinking */
    flex-grow: 1; /* THE CRUCIAL FIX: Tells the label to take all available horizontal space */
    line-height: 1.4; /* Improves spacing between the lines of text */
}


.search-result-item label {
    font-weight: normal;
    color: #333;
    line-height: 1.4; /* Improves spacing between the lines of text */
}

/* Grid específico para a seção de dieta, para colocar os botões e inputs lado a lado */
.diet-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    /* align-items: end; foi removido para permitir o alinhamento dos labels no topo */
}

/* NOVO: Força o primeiro container a usar flexbox para alinhamento vertical interno */
.diet-section-grid > .form-group {
    display: flex;
    flex-direction: column;
}

/* NOVO: Empurra os botões de rádio para o fundo do seu container, alinhando com o input ao lado */
.diet-section-grid > .form-group > .radio-group {
    margin-top: auto;
}

/* Ajusta o espaçamento do grupo de botões de rádio para não ter margem inferior desnecessária */
.diet-section-grid .radio-group {
    margin-bottom: 0;
}

.last-value-hint {
    color: #888;
    font-size: 0.8em;
    font-weight: normal;
    margin-left: 8px;
}

/* ==========================================================================
   6. Modal Styles
   ========================================================================== */
   .search-result-details-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 equal-width columns */
    gap: 10px; /* Space between columns */
    width: 100%;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background-color: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    color: #333;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* NOVO: Garante que nada vaze para fora dos cantos arredondados do modal */
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    flex-shrink: 0; 
}

/* CORREÇÃO: O formulário agora é o container flex principal */
.modal-content form {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* O formulário ocupa todo o espaço restante */
    min-height: 0; /* Correção essencial para flexbox com overflow */
}

/* NOVO: Aplica a rolagem APENAS na grade de campos, não no formulário inteiro */
#add-purchase-modal .form-grid {
    overflow-y: auto; /* Apenas esta área vai rolar */
    flex-grow: 1; /* Faz esta área crescer, empurrando os botões para baixo */
    padding-right: 15px; /* Adiciona um espaço para a barra de rolagem */
    margin-right: -15px; /* Compensa o padding para manter o alinhamento */
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    flex-shrink: 0; /* Garante que os botões nunca encolham */
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* A CORREÇÃO: Aumento específico para o modal de compra de insumos */
#add-supply-purchase-modal .modal-content {
    max-width: 850px; /* Mais largo */
    min-height: 450px; /* Força uma altura mínima */
    max-height: 95vh; /* Ainda limita para não sair da tela */
}


/* --- Export Modal Specific Styles --- */
.export-farm-list-container {
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
}

.farm-checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 4px;
}

.farm-checkbox-item:hover {
    background-color: #f8f9fa;
}

.farm-checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

.farm-checkbox-item label {
    font-size: 1.1em;
    cursor: pointer;
}

/* Aumento específico para o modal de Adicionar Compra para acomodar mais campos */
#add-purchase-modal .modal-content {
    max-width: 1100px;
}

/* Força o grid do modal de compra a ter 4 colunas para otimizar o espaço */
#add-purchase-modal .form-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* A mágica acontece aqui: define um contêiner genérico para conteúdo rolável dentro de modais */
.modal-scrollable-content {
    overflow-y: auto;   /* Adiciona a barra de rolagem vertical quando necessário */
    flex-grow: 1;       /* Faz esta área crescer, preenchendo o espaço entre o título e os botões */
    padding: 10px;      /* Adiciona um espaçamento interno */
    margin: 0 -10px;    /* Compensa o padding para manter o alinhamento visual */
}

/* Estilos para a nova seção de pagamento para garantir consistência visual */
.payment-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
}
.installment-details {
    margin-top: 10px;
}



/* ==========================================================================
   7. Tables & AG-Grid
   ========================================================================== */

/* --- Standard HTML Table --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

thead {
    background-color: #007bff;
    color: white;
}

tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

tbody tr:hover {
    background-color: #e9ecef;
}


/* --- AG-Grid Customization --- */

.ag-header-cell-label {
    display: flex;
    justify-content: center;
}

/* --- History Page Grid (Using Flexbox) --- */
#purchase-history-grid {
    width: 100%;
    /* 
      THE KEY: Instead of a fixed height, we tell the grid
      to grow and fill all available vertical space within its
      flexbox parent (.page).
    */
    flex-grow: 1; 
}

/* This class will be used for any grid you want to fill the screen */
.full-height-grid {
    width: 100%;
    /* This tells the grid to grow and take up all available space
       left by the .page-header within its parent (.page) */
    flex-grow: 1;
}

.clickable-cell {
    cursor: pointer;
    color: #0056b3;
    font-weight: bold;
}

.clickable-cell:hover {
    text-decoration: underline;
}

/* ==========================================================================
   8. Page-Specific Styles
   ========================================================================== */

/* --- View Toggling --- */
.view-toggle-container {
    text-align: center;
    margin-bottom: 20px;
}

.inventory-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Essencial para que a grade dentro dela possa crescer */
}

   /* --- Dashboard / Summary --- */

#summary-kpis,
#location-summary-kpis {
    background-color: #ffffff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    /* This was missing from the old #location-summary-kpis style */
    display: flex;
    justify-content: space-around;
    text-align: center;
}
/* --- Settings Page --- */
.settings-container {
    background-color: #ffffff;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 600px; /* Give it a max width for better readability */
    margin: 20px auto; /* Center it on the page */
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

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

.setting-item label {
    font-weight: bold;
    color: #333;
}

.setting-item select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 200px; /* Ensure select is wide enough */
}

/* --- Active Stock Page --- */
/* This is the new rule that fixes the grid height issue */
#active-stock-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Make this container grow to fill its parent (.page) */
}

.pagination-controls {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

/* --- Dashboard / Summary --- */

#summary-kpis, #animal-list {
    background-color: #ffffff;
}

#animal-list {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* This is the key property that makes it grow */
    margin-bottom: 0; /* Remove bottom margin to fill the whole space */
}

/* ==========================================================================
   9. Notifications
   ========================================================================== */

#toast-notification {
    position: fixed; /* Keep it on screen even when scrolling */
    bottom: 30px; /* Position it at the bottom */
    left: 50%;
    transform: translateX(-50%); /* Center it horizontally */
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 1em;
    z-index: 9999; /* Ensure it's on top of everything */
    
    /* Animation setup */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s, bottom 0.5s;
}

/* State when the toast is visible */
#toast-notification.show {
    opacity: 1;
    visibility: visible;
    bottom: 50px; /* Animate it moving up slightly */
}

/* Style for success messages (green) */
#toast-notification.success {
    background-color: #28a745;
}

/* Style for error messages (red) */
#toast-notification.error {
    background-color: #dc3545;
}

/* ==========================================================================
   10. Locations Page Specific Styles
   ========================================================================== */

.locations-list-container {
    flex-grow: 1; /* Make the container fill available space */
    overflow-y: auto; /* Add a scrollbar if content overflows */
    padding: 5px;
}

.location-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.location-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f7f9fc;
    border-bottom: 1px solid #e0e0e0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.location-card-header h3 {
    margin: 0;
    color: #0056b3;
}

.location-card-body {
    padding: 20px;
}

.sublocation-list {
    list-style: none;
    padding: 0;
    margin: 0;
    
}

.sublocation-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;

}

.sublocation-list li:last-child {
    border-bottom: none;
}

.sublocation-list li span:first-child {
    font-weight: 500;
}

.sublocation-list li span:last-child {
    color: #555;
    font-size: 0.9em;
}

/* --- Styles for Occupied Sublocations --- */
.sublocation-list li.occupied {
    background-color: #e7f5ff; /* A light blue background */
    border-left: 4px solid #007bff; /* A prominent blue left border */
    font-weight: 600; /* Make the text bold */
}

.occupied-animal-count {
    color: #0056b3;
    margin-left: auto;
    font-size: 0.9em;
    padding-right: 20px;
    font-weight: bold;
    text-align: center;
}



.location-card-kpis {
    display: flex;
    justify-content: space-around;
    text-align: center;
    padding: 15px 10px;
    border-bottom: 1px solid #e0e0e0;
}

.location-card-actions {
    display: flex;
    gap: 10px; /* Adds space between the buttons */
    align-items: center;
}

.kpi-item {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.4em;
    font-weight: 600;
    color: #333;
}

.kpi-label {
    font-size: 0.8em;
    color: #6c757d;
    text-transform: uppercase;
}

#location-consult-view {
    display: flex; /* Makes this view a flex container */
    flex-direction: column; /* Stacks its children (header, kpis, grid) vertically */
    flex-grow: 1; /* Allows the view itself to fill the page space */
}

#location-summary-kpis {
    flex-shrink: 0; /* Prevents the KPI bar from shrinking */
}

.see-details-btn {
    flex-grow: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
}

/* ==========================================================================
   11. Lots Page Specific Styles
   ========================================================================== */

#lots-list-view, #lot-consult-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* This is the key: it allows this view to fill the parent page container */
}

#lot-summary-kpis {
    flex-shrink: 0; /* Prevents the KPI bar from shrinking when the grid loads */
    margin-bottom: 20px;
}

/* ==========================================================================
   12. Consult Animal Page Specific Styles
   ========================================================================== */

   .master-record-section {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 25px;
}

.master-record-section h3 {
    margin-top: 0;
    border-bottom: 2px solid #0056b3;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.details-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.details-panel {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px 20px;
}

.details-panel h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #495057;
}

.info-grid {
    display: grid;
    /* This is the key fix: creates 3 pairs of label/value columns */
    grid-template-columns: auto 1fr auto 1fr auto 1fr;
    gap: 12px 25px; /* vertical gap | horizontal gap */
    align-items: center;
}

.info-grid span { color: #6c757d; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.kpi-card {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    text-align: center;
    padding: 15px 10px;
    border-radius: 6px;
    flex-grow: 1;
}

.kpi-card-value {
    display: block;
    font-size: 1.6em;
    font-weight: 600;
    color: #007bff;
}

.kpi-card-label {
    font-size: 0.75em;
    color: #6c757d;
    text-transform: uppercase;
    font-weight: bold;
}

.status-grid {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    /* A simpler grid for the status line */
    grid-template-columns: auto 1fr auto 1fr auto 1fr;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    justify-self: start;
}

.status-badge.active { background-color: #28a745; }
.status-badge.sold { background-color: #007bff; }
.status-badge.dead { background-color: #dc3545; }

.exit-panel-sold { border-left: 4px solid #007bff; }
.exit-panel-dead { border-left: 4px solid #dc3545; }

.profit { color: #28a745; }
.loss { color: #dc3545; }

/* --- Chart and Grid Container --- */
.chart-and-grid-container {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    height: 400px;
}

.chart-container {
    position: relative;
    flex: 1;
    min-width: 300px;
}

.chart-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#animal-weight-history-grid {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 400px;
}


/* ==========================================================================
   13. Utility & Helper Styles
   ========================================================================== */
   .page-hint {
    text-align: center;

    color: #555;
    margin-top: 5px; /* Pull it a bit closer to the header */
    margin-bottom: 30px;
}


/* ==========================================================================
   14. Settings page styles
   ========================================================================== */

.setting-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.setting-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.setting-item-column {
    margin-bottom: 25px;
}

.setting-item-column h3 {
    margin-bottom: 5px;
}

.setting-description {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 0;
    margin-bottom: 15px;
    max-width: 90%;
}

/* ==========================================================================
   15. Farm Locations Map View
   ========================================================================== */

   #farm-locations-page .locations-content-container {
    display: flex;
    flex-grow: 1;
    min-height: 0; /* Important for flex children with overflow */
}

.locations-view {
    display: none; /* Hide views by default */
    width: 100%;
    height: 100%;
    flex-direction: column; /* Ensure children stack correctly */
}

.locations-view.active {
    display: flex; /* Show the active view */
}

.locations-view-toggle {
    margin-bottom: 15px;
    text-align: center;
}

.toggle-btn {
    padding: 8px 16px;
    border: 1px solid #007bff;
    background-color: transparent;
    color: #007bff;
    cursor: pointer;
    font-size: 1em;
}

.toggle-btn:first-child {
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}

.toggle-btn:last-child {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
    border-left: none;
}

.toggle-btn.active {
    background-color: #007bff;
    color: white;
}

/* Style for the InfoWindow content on the map */
.map-infowindow-content {
    line-height: 1.5;
    font-size: 1em;
}

.map-infowindow-content h4 {
    margin: 0 0 10px 0;
}

.map-infowindow-content p {
    margin: 4px 0;
}

.map-infowindow-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

#map-canvas {
    width: 100%;
    flex-grow: 1; /* This is the key: it tells the map to fill all available vertical space in its parent */
    min-height: 0; /* A flexbox best practice to prevent overflow issues */
}

#map-edit-box {
    position: absolute;
    top: 80px; /* Adjust to be below the "Map/Satellite" buttons */
    right: 10px;
    width: 280px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    padding: 15px 20px;
    z-index: 10; /* Ensures it's on top of the map canvas */
    border: 1px solid #ccc;
}

#map-edit-box h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1em;
    color: #333;
}

#map-edit-box p {
    margin: 0 0 15px 0;
    font-size: 0.9em;
    color: #666;
}

.sublocation-actions {
    display: flex;
    gap: 5px; /* Adds a small space between the buttons */
    align-items: center;
}

.map-location-label {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    /* This centers the div on its coordinate */
    transform: translate(-50%, -50%);
    /* This allows clicks to go "through" the label to the polygon below */
    pointer-events: none; /* --- ADD THIS LINE --- */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* ==========================================================================
   16. Custom Searchable Select Component
   ========================================================================== */

   .searchable-select-container {
    position: relative;
    width: 100%;
}

.searchable-select-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    cursor: pointer;
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001; /* Garante que fique sobre outros elementos do modal */
}

.searchable-select-item {
    padding: 10px;
    cursor: pointer;
}

.searchable-select-item:hover, .searchable-select-item.selected {
    background-color: #007bff;
    color: white;
}

.searchable-select-add-new {
    padding: 10px;
    cursor: pointer;
    background-color: #f0f0f0;
    color: #0056b3;
    font-weight: bold;
    border-top: 1px solid #ccc;
}

.searchable-select-add-new:hover {
    background-color: #e0e0e0;
}

/* ==========================================================================
   17. Tabbed Views (NOVA SEÇÃO)
   ========================================================================== */

   .page-content {
    display: flex; /* Permite que o conteúdo da aba ativa preencha o espaço */
    flex-grow: 1;  /* ESSENCIAL: Faz esta área crescer para preencher o espaço da página */
    min-height: 0; /* Boa prática para evitar problemas de overflow em contêineres flex */
}

.tab-content {
    display: none; /* Esconde todas as abas por padrão */
    flex-direction: column; /* Empilha o cabeçalho e a grade da aba verticalmente */
    width: 100%;
    flex-grow: 1; /* Permite que a aba ocupe o espaço dentro de .page-content */
}

.tab-content.active {
    display: flex; /* Mostra apenas a aba ativa */
}

/* Container para formulários dentro das abas para manter um estilo consistente */
.form-container {
    max-width: 900px;
    margin: 20px auto;
    background-color: #ffffff;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

/* Estilos para a Calculadora de Fornecimento */
.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.radio-group input[type="radio"] {
    display: none; /* Esconde o botão de rádio padrão */
}

.radio-group label {
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease-in-out;
}

.radio-group input[type="radio"]:checked + label {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
    font-weight: bold;
}

.calc-preview {
    background-color: #f8f9fa;
    border: 1px dashed #ced4da;
    border-radius: 6px;
    padding: 15px;
    margin-top: 20px;
}

.calc-preview p {
    margin: 5px 0;
    font-size: 1.1em;
}

.calc-preview .recommended-qty {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    font-size: 1.2em;
    color: #28a745;
}

.calc-preview .warning-text, .calc-preview .error-text {
    font-weight: bold;
    color: #dc3545;
}

/* ==========================================================================
   18. Componente de Lista de Checkbox (NOVO)
   ========================================================================== */

   .checkbox-list-container {
    max-height: 150px; /* Altura máxima antes de mostrar a barra de rolagem */
    overflow-y: auto; /* Adiciona a barra de rolagem vertical quando necessário */
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px; /* Espaço entre o checkbox e o texto */
    padding: 5px 0;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.checkbox-item label {
    font-weight: normal;
    cursor: pointer;
}

/* ==========================================================================
   18. Estilos para o Searchable Select de Animais (NOVO)
   ========================================================================== */

   .search-item-details-animal {
    display: grid;
    grid-template-columns: 1.5fr 1fr; /* Duas colunas */
    gap: 2px 15px; /* Espaçamento vertical e horizontal */
    align-items: center;
    width: 100%;
    font-size: 0.9em;
}

.search-item-details-animal .detail-main {
    grid-column: 1 / -1; /* O brinco ocupa a linha inteira */
    font-size: 1.2em;
    margin-bottom: 5px;
}

.search-item-details-animal .detail-secondary {
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quando o item está selecionado (hover/selected), melhora o contraste do texto secundário */
.searchable-select-item:hover .search-item-details-animal .detail-secondary,
.searchable-select-item.selected .search-item-details-animal .detail-secondary {
    color: #f0f0f0;
}

/* ==========================================================================
   19. Estilos do Manejo Unificado
   ========================================================================== */

   #management-status-bar {
    background-color: #ffc107; /* Amarelo alerta */
    color: #333;
    padding: 10px 20px;
    text-align: center;
    font-weight: bold;
    border-bottom: 2px solid #e0a800;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    position: sticky; /* Mantém a barra no topo durante a rolagem */
    top: 0;
    z-index: 150; /* Garante que fique acima do conteúdo, mas abaixo do header principal */
}

/* NOVO: Adiciona uma borda destacada na grade quando em modo de manejo */
.management-mode-active #animal-grid {
    border: 3px solid #ffc107;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

/* Classe para destacar a linha da grade que foi processada durante um manejo */
.row-processed-in-management {
    background-color: #d4edda !important; /* Verde claro, com !important para sobrescrever estilos da grade */
    font-weight: bold;
}

/* ==========================================================================
   20. Estilos da Barra Global de Manejo (NOVO)
   ========================================================================== */
   #active-management-bar {
    /* CORREÇÃO: Cor alterada para um amarelo mais vibrante e consistente. */
    background-color: #ffc107; 
    color: #333; /* Cor do texto alterada para ter melhor contraste com o amarelo */
    padding: 8px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-weight: bold; /* Aumentando o peso da fonte */
    position: sticky; 
    top: 0;
    z-index: 150; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    gap: 20px; 
    
    /* NOVO: Ajustes para corresponder ao header */
    margin-left: 20px;
    margin-right: 20px;
    margin-bottom: 20px; /* Adiciona espaço abaixo da barra */
    border-radius: 8px; /* Cantos arredondados como o header */
}

#active-management-bar.hidden {
    display: none;
}

#active-management-bar .actions button {
    padding: 5px 10px; 
    font-size: 0.9em;
}

#resume-management-banner {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    /* NOVO: Adiciona um gap para espaçar os botões */
    gap: 10px;
}

/* NOVO: Estilo para o container dos botões dentro do banner amarelo */
#resume-management-banner .actions {
    display: flex;
    gap: 10px;
}

/* ==========================================================================
   21. Estilos da Página de Detalhes do Manejo (NOVO)
   ========================================================================== */

   .operations-managements-container {
    display: flex;
    gap: 20px;
    flex-grow: 1; /* Faz o container preencher o espaço vertical */
    min-height: 0; /* Correção para flexbox em alguns navegadores */
}

.view-panel {
    display: flex;
    flex-direction: column;
    transition: flex 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.view-panel.hidden {
    display: none;
}

/* Estado padrão: Apenas a lista é visível */
#managements-list-view {
    flex-basis: 100%;
}

/* Estado quando um detalhe está ativo: A lista encolhe */
#managements-list-view.detail-active {
    flex-basis: 40%;
    flex-shrink: 0;
}

#management-detail-view {
    flex-basis: 60%;
    flex-grow: 1;
}

#management-summary-panel .kpi-card {
    background-color: #fff;
    padding: 15px;
}

/* Esta regra garante que o contêiner do grid cresça para preencher o espaço vertical disponível */
#management-animals-grid.full-height-grid {
    flex-grow: 1;
    min-height: 200px; /* Garante uma altura mínima para o grid ser visível mesmo com pouco espaço */
}

/* Adicione também uma estilização simples para a tabela de classificações */
.simple-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.simple-table th, .simple-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.simple-table thead {
    background-color: #007bff;
    color: white;
}

.simple-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Adicione estas classes para os selos de status (Estimado/Final) */
.status-label-estimated {
    font-size: 0.7em;
    font-weight: bold;
    color: #ffc107; /* Amarelo */
    margin-left: 8px;
    vertical-align: middle;
}

.status-label-final {
    font-size: 0.7em;
    font-weight: bold;
    color: #28a745; /* Verde */
    margin-left: 8px;
    vertical-align: middle;
}

/* Em: frontend/styles.css */

/* ==========================================================================
   22. ESTILOS DE IMPRESSÃO PARA PDF (VERSÃO FINAL E ROBUSTA)
   ========================================================================== */
   @media print {
    /* --- CONFIGURAÇÃO GERAL DA PÁGINA --- */
    @page {
        size: A4;
        margin: 2cm; /* Margens padrão de documento */
    }
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-family: 'Times New Roman', Times, serif; /* Fonte de documento clássica */
        font-size: 11pt;
    }

    /* --- ESCONDER ELEMENTOS DE UI --- */
    .main-header, #active-management-bar, .page > .page-header,
    #back-to-list-btn, #register-slaughter-btn, #generate-pdf-btn,
    .kpi-card /* Esconde os placeholders "A Implementar" */ {
        display: none !important;
    }

    /* --- LAYOUT GERAL DO DOCUMENTO --- */
    #app-content, .operations-managements-container, #management-detail-view, 
    #management-detail-content {
        display: block !important;
        padding: 0;
        overflow: visible;
        height: auto;
    }
    #managements-list-view { display: none !important; }

    /* --- ESTILO DO CABEÇALHO DO RELATÓRIO --- */
    #management-detail-title {
        font-size: 18pt;
        font-weight: bold;
        text-align: center;
        margin-bottom: 1.5cm;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }

    /* --- ESTILO DAS SEÇÕES DO RELATÓRIO --- */
    .report-section {
        margin-bottom: 1.5cm;
        page-break-inside: avoid; /* Tenta não quebrar seções */
        border: none;
        padding: 0;
    }
    .report-section h3 {
        margin-top: 0;
        margin-bottom: 0.5cm;
        font-size: 14pt;
        border-bottom: 1px solid #ccc;
        padding-bottom: 5px;
    }
    
    /* --- CORREÇÃO DO LAYOUT DOS DADOS (O MAIS IMPORTANTE) --- */
    /* Desfaz o grid da tela e cria um layout de lista simples */
    .info-grid.report-grid {
        display: block !important;
    }
    .info-grid.report-grid span, .info-grid.report-grid strong {
        display: inline-block; /* Faz com que fiquem na mesma linha */
        width: 49%; /* Divide o espaço em duas colunas virtuais */
        padding: 4px 0;
        font-size: 11pt;
    }
    .info-grid.report-grid strong {
        font-weight: normal; /* Remove o negrito extra, o valor já se destaca */
    }

    /* Estilos para tabelas (Classificações) */
    .details-panel { border: none; padding: 0; }
    .simple-table { width: 100%; border-collapse: collapse; margin-top: 0.5cm; }
    .simple-table th, .simple-table td { border: 1px solid #999; padding: 6px; }
    .simple-table thead { background-color: #e0e0e0 !important; color: #000 !important; }

    /* Estilo dos selos FINAL/ESTIMADO */
    .status-label-estimated, .status-label-final {
        font-size: 8pt; font-weight: bold; color: #000 !important;
        margin-left: 8px; vertical-align: middle;
    }

    /* --- CORREÇÃO FINAL PARA O AG-GRID --- */
    #management-animals-grid.ag-theme-quartz {
        height: auto !important; width: 100% !important;
        overflow: visible !important; flex-grow: 0 !important;
        page-break-before: always; /* Começa o grid em uma nova página */
    }
    .ag-root-wrapper, .ag-root, .ag-body-viewport, .ag-center-cols-clipper, .ag-center-cols-container {
        width: 100% !important; height: auto !important;
        overflow: visible !important;
    }
    .ag-header-cell-text {
        white-space: normal !important; text-overflow: clip !important;
        line-height: 1.2;
    }
    .ag-theme-quartz {
        --ag-borders: 1px solid; --ag-border-color: #999;
        --ag-header-height: 40px !important;
        --ag-font-family: 'Times New Roman', Times, serif;
        --ag-font-size: 10pt;
    }
}

/* Em: frontend/styles.css */

/* ==========================================================================
   23. NOVO ESTILO PARA RELATÓRIOS (TELA)
   ========================================================================== */

   .report-section {
    background-color: #ffffff;
    padding: 20px 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.report-section h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.2em;
    color: #495057;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.stats-container {
    display: grid;
    /* Layout responsivo: adapta o número de colunas ao espaço disponível */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    border: 1px solid #e9ecef;
    text-align: center;
}

.stat-label {
    font-size: 0.8em;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: 600;
    color: #343a40;
}

/* --- ATUALIZAÇÃO DO CSS DE IMPRESSÃO --- */
/* Remove as regras antigas para o .info-grid que não usamos mais na tela */
.info-grid.report-grid { display: none; }

@media print {
    /* --- CONFIGURAÇÃO GERAL DA PÁGINA --- */
    @page {
        size: A4;
        margin: 2cm; /* Margens padrão de documento */
    }

    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-family: 'Times New Roman', Times, serif; /* Fonte de documento clássica */
        font-size: 11pt;
        -webkit-print-color-adjust: exact; /* Força a impressão de cores de fundo no Chrome/Electron */
        print-color-adjust: exact;
    }

    /* --- ESCONDER ELEMENTOS DE UI --- */
    .main-header, 
    #active-management-bar, 
    .page > .page-header, /* Esconde o cabeçalho da PÁGINA, não do relatório */
    #managements-list-view, /* Esconde a lista da esquerda */
    #back-to-list-btn, 
    #register-slaughter-btn, 
    #generate-pdf-btn,
    #management-costs-section form { /* Esconde o formulário de adicionar custo */
        display: none !important;
    }

    /* --- LAYOUT GERAL DO DOCUMENTO --- */
    #app-content, 
    .operations-managements-container, 
    #management-detail-view, 
    #management-detail-content {
        display: block !important; /* Remove o layout flex/grid */
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important; /* Garante que nada seja cortado */
        height: auto !important;
        width: 100% !important;
        page-break-after: always;
    }

    /* --- ESTILO DO CABEÇALHO DO RELATÓRIO --- */
    #management-detail-title {
        font-size: 18pt;
        font-weight: bold;
        text-align: center;
        margin-bottom: 1.5cm;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }

    /* --- ESTILO DAS SEÇÕES E PAINÉIS --- */
    .report-section {
        margin-bottom: 1cm;
        page-break-inside: avoid; /* Tenta não quebrar seções no meio */
        border: 1px solid #ccc;
        box-shadow: none;
        padding: 15px;
    }
    .report-section h3 {
        font-size: 14pt;
        border-bottom: 1px solid #999;
        padding-bottom: 5px;
        margin-bottom: 0.7cm;
    }
    .details-panel {
        border: none;
        padding: 0;
    }
    
    /* Layout dos KPIs/Estatísticas */
    .stats-container {
        grid-template-columns: 1fr 1fr !important; /* Força 2 colunas no PDF */
        gap: 15px !important;
    }
    .stat-item {
        background-color: #f5f5f5 !important;
        border: 1px solid #ddd !important;
        padding: 10px;
    }
    .stat-label { font-size: 9pt; }
    .stat-value { font-size: 12pt; font-weight: bold; }

    /* Estilo para tabelas (Classificações, Custos) */
    .simple-table { 
        width: 100%; 
        border-collapse: collapse; 
        margin-top: 0.5cm; 
    }
    .simple-table th, .simple-table td { 
        border: 1px solid #999; 
        padding: 6px; 
    }
    .simple-table thead { 
        background-color: #e0e0e0 !important; 
        color: #000 !important;
        display: table-header-group; /* Garante que o cabeçalho se repita em novas páginas */
    }

    /* Estilo dos selos FINAL/ESTIMADO */
    .status-label-estimated, .status-label-final {
        font-size: 8pt; 
        font-weight: bold; 
        color: #000 !important;
        border: 1px solid #000;
        padding: 2px 4px;
        border-radius: 4px;
        display: inline-block;
        margin-left: 8px;
    }

    /* --- CORREÇÃO FINAL PARA O AG-GRID --- */
    /* O mais importante: força a grade a se expandir e mostrar todo o conteúdo */
    #management-animals-grid.ag-theme-quartz {
        width: 100%;
        height: auto !important;
        overflow: visible !important;
        page-break-before: always; /* Começa a grade em uma nova página para garantir espaço */
    }

    .ag-root-wrapper, .ag-root {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        border: none !important;
    }

    /* A MÁGICA ACONTECE AQUI: */
    /* Forçamos os contêineres internos a terem largura automática para se expandir com as colunas */
    .ag-body-viewport, 
    .ag-center-cols-clipper, 
    .ag-center-cols-container {
        width: auto !important; /* <<-- CORRIGE O CORTE LATERAL */
        height: auto !important;
        overflow: visible !important;
    }
    
    /* Adapta as cores da grade para um estilo de impressão limpo */
    .ag-theme-quartz {
        --ag-background-color: #ffffff;
        --ag-odd-row-background-color: white;
        --ag-borders: solid 1px;
        --ag-border-color: #999;
        --ag-header-background-color: #e0e0e0;
        --ag-header-foreground-color: #000;
        --ag-font-family: 'Times New Roman', Times, serif;
        --ag-font-size: 10pt;
    }

    /* Remove sombras e artefatos visuais da tela */
    .ag-pinned-left-header, .ag-pinned-left-cols-container {
        box-shadow: none !important;
    }
    .ag-horizontal-left-spacer {
        display: none !important;
    }
}

/* ==========================================================================
   24. CALCULATOR PAGE STYLES (CORREÇÃO FINAL E ROBUSTA)
   ========================================================================== */

.calculator-layout-grid {
    display: grid;
    /* Alterado para 4 frações iguais. Ajuste se preferir larguras diferentes. */
    grid-template-columns: 1.2fr 1fr 1.1fr 1.1fr;
    gap: 20px;
    align-items: start;
}

/* NOVO: Estilo para o contêiner que agrupa Recria e Engorda */
.form-column {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Espaçamento entre as seções Recria e Engorda */
}


#tools-calculator-page .calculator-layout-grid > .sub-form-section {
    grid-column: unset;
    margin-top: 0;
    border-top: none;
    padding-top: 15px; /* Adicionado para manter um espaçamento interno consistente */
}

/* Garante que as seções dentro da nova coluna não tenham margens ou bordas indesejadas */
.form-column > .sub-form-section {
    margin-top: 0;
    border-top: none;
}

.form-column > .sub-form-section #results-section { 
    padding: 25px; /* Define um preenchimento interno generoso em todos os lados */
    border: 1px solid #e9ecef; /* Adiciona uma borda sutil para melhor definição */
    border-radius: 8px; /* Cantos arredondados para um visual mais suave */
    background-color: #ffffff; /* Fundo branco padrão para todas as seções */
}

/* Esta regra anula a propriedade 'grid-column' que estava forçando as seções a ficarem uma embaixo da outra. */
#tools-opportunity-cost-page .calculator-layout-grid > .sub-form-section {
    grid-column: unset; /* Reseta a propriedade que força a largura total */
    margin-top: 0;
    border-top: none;
}

/* ==========================================================================
   25. DRE PAGE STYLES 
   ========================================================================== */
.dre-total {
    font-weight: bold;
    background-color: #e9ecef !important;
    border-top: 2px solid #343a40 !important;
}

.dre-subtotal {
    font-weight: bold;
    background-color: #f8f9fa !important;
}

.dre-cost-total {
    font-weight: 500;
}

/* ==========================================================================
25. ESTILOS PARA FILTROS E SELETORES (NOVO)
========================================================================== */
.filter-controls {
display: flex;
align-items: center;
gap: 15px;
}
.styled-select-container {
display: flex;
align-items: baseline; /* MUDANÇA: Alinha pela base do texto, corrigindo o desalinhamento vertical */
gap: 8px;
background-color: #ffffff;
padding: 8px 12px; /* AJUSTE: Simplificado para um padding mais equilibrado */
border-radius: 6px;
border: 1px solid #ccc;
box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
}
.styled-select-container label {
font-weight: bold;
color: #495057;
margin-bottom: 0;
}
select.styled-select {
border: none;
background-color: transparent;
font-size: 1em;
font-weight: 500;
color: #0056b3;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-image: url("data:image/svg+xml;charset=UTF8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2724%27%20height%3D%2724%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cpath%20d%3D%27M7%2010l5%205%205-5z%27%20fill%3D%27%23495057%27%2F%3E%3C%2Fsvg%3E");
background-repeat: no-repeat;
background-position: right 5px center;
background-size: 1.2em;
padding: 2px 25px 2px 8px; /* AJUSTE: Adiciona padding interno, o que reflete nas opções do dropdown */
}

/* ==========================================================================
   26. ESTILOS PARA O CARD DE DETALHAMENTO DE CUSTO (REVISADO)
   ========================================================================== */

/* Ajusta o card de detalhamento */
.stat-item.breakdown {
    text-align: left;
    align-items: flex-start; /* Alinha o título no topo */
}

/* Redefine o estilo do .stat-value dentro do card de detalhamento */
.stat-item.breakdown .stat-value {
    font-size: 1em; /* Tamanho da fonte normal, não gigante */
    font-weight: normal;
    margin-top: 8px;
    width: 100%;
}

/* Estiliza cada linha (div) do detalhamento */
.breakdown-item {
    display: flex;
    justify-content: space-between; /* Nome à esquerda, valor à direita */
    padding: 3px 5px; /* Um pouco mais de espaço vertical */
    font-size: 0.9em; /* Tamanho de fonte um pouco menor para caber mais info */
}

/* Adiciona uma linha sutil para separar os itens, exceto o último */
.breakdown-item:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

/* Estilo para a mensagem de 'nenhum custo' */
.breakdown-no-cost {
    font-size: 0.9em;
    color: #6c757d;
}

/* Estilos para a Barra de Progresso */
.progress-bar-container {
    width: 100%;
    background-color: #e0e0e0;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #007bff;
    border-radius: 4px;
    transition: width 0.4s ease;
    text-align: center;
    color: white;
    line-height: 20px;
}

/* Estilos para o container do logo */
.logo {
    display: flex; /* Habilita o alinhamento flexível */
    align-items: center; /* Alinha a imagem e o texto verticalmente no centro */
}

/* Estilos para o ícone do logo */
.logo-icon {
    height: 70px; /* Ajuste a altura conforme necessário */
    width: auto;  /* Mantém a proporção da imagem */
    margin-right: 10px; /* Adiciona um espaço entre o logo e o texto "BoiTrack" */
}

#offline-modal .modal-content {
    border-top: 5px solid #dc3545; /* Borda vermelha para indicar erro */
}

/* ==========================================================================
   27. MELHORIAS NO MODAL DE FORMULAÇÕES (NOVO)
   ========================================================================== */

/* Aumenta a altura do modal e prepara o layout interno */
#add-formula-modal .modal-content,
#edit-formula-modal .modal-content {
    max-width: 800px;  /* Largura que estava no HTML */
    max-height: 90vh;  /* Limite máximo de altura */
    min-height: 620px; /* Altura mínima garantida */
}

/* Transforma a seção de componentes em um container flexível */
#add-formula-modal .sub-form-section,
#edit-formula-modal .sub-form-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Faz esta seção crescer para preencher o espaço do modal */
    min-height: 0; /* Correção essencial para layout flex com conteúdo rolável */
}

/* Define que a lista de ingredientes deve crescer e ter rolagem */
#add-formula-modal .dynamic-list,
#edit-formula-modal .dynamic-list {
    flex-grow: 1; /* A lista ocupa todo o espaço vertical disponível */
    overflow-y: auto; /* Adiciona a barra de rolagem quando necessário */
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
}

/* Estiliza a barra de total para que fique sempre visível */
.formula-total-bar {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 1.1em;
    padding: 10px 5px;
    border-top: 2px solid #333;
    flex-shrink: 0; /* Impede que a barra de total encolha */
}

/* Transforma cada item da lista em um container flex para alinhar o conteúdo */
.component-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.component-name {
    flex-grow: 1; /* O nome do produto ocupa o espaço restante à esquerda */
}

/* Agrupa a porcentagem e o botão de remover */
.component-details {
    display: flex;
    align-items: center;
    gap: 15px; /* Espaço entre a porcentagem e o botão 'x' */
}

/* Alinha as porcentagens à direita com uma largura fixa */
.component-percentage {
    width: 90px;
    text-align: right;
    font-weight: bold;
}