body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
    display: flex; /* Mantém flex para o footer ir para baixo */
    flex-direction: column; /* Empilha os elementos principais verticalmente */
    min-height: 100vh; /* Garante que o body ocupe pelo menos a altura da viewport */
    background-image: url('despesas-veiculos.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    align-items: center; /* Centraliza os blocos de conteúdo principais */
    color: #333;
    line-height: 1.6;
}

/* Cabeçalho (Mantido) */
.header-compact {
    background-color: #5DADE2;
    color: white;
    text-align: center;
    padding: 10px 0;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* position: sticky; top: 0; z-index: 1000; Se quiser fixo no topo ao rolar */
}

.header-compact-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 15px;
    flex-wrap: wrap;
}

.header-logo {
    max-width: 70px; /* Ou o tamanho que você preferir */
    height: auto;
    border-radius: 5px;
}

.header-compact-text h1 {
    color: white;
    margin: 0;
    font-size: 1.6em;
}

.header-compact-text p {
    color: #FFEB3B;
    margin: 0;
    font-size: 0.9em;
}

/* Título específico da ferramenta */
.tool-title-container {
    width: 100%;
    text-align: center;
    padding: 15px 0 5px 0; /* Espaçamento acima e abaixo do título */
    background-color: rgba(255, 255, 255, 0.7); /* Fundo leve para destacar */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tool-title-container h2 {
    margin: 0;
    color: #0D47A1; /* Cor principal do CalculateAll */
    font-size: 1.5em;
}


/* Wrapper para Formulário e Histórico */
.content-wrapper {
    /* flex-grow: 1; Removido para não empurrar o footer indevidamente se o conteúdo for pouco */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    padding: 25px 15px;
    width: 100%;
    box-sizing: border-box;
    gap: 25px;
    max-width: 1280px;
}

/* Container Genérico (para Formulário e Histórico) */
.container {
    background-color: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #333;
    overflow: hidden;
}

.input-form-container {
    flex: 1 1 350px;
    min-width: 300px;
    max-width: 480px;
    order: 1; 
}

.history-container {
    flex: 1 1 450px;
    min-width: 320px;
    max-width: 750px;
    display: flex;
    flex-direction: column;
    order: 2;
}


.container h2 {
    color: #0D47A1;
    margin-top: 0;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: #333;
    font-size: 0.9em;
}

input[type="date"],
input[type="number"],
input[type="text"],
input[type="time"],
select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 0.95em;
    background-color: rgba(255, 255, 255, 0.95);
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}


.calculated-field span {
    display: inline-block;
    padding: 9px 12px;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 5px;
    color: #495057;
    font-weight: bold;
}

button {
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    margin-top: 10px;
    display: inline-block;
    width: auto;
}
button:hover { opacity: 0.85; }

.full-width-button { width: 100%; box-sizing: border-box; }

.fueling-form-section,
.expense-form-section {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.fueling-form-section h3,
.expense-form-section h3 {
    color: #0D47A1;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1em;
}

#add-fueling-btn { background-color: #4CAF50; }
#add-fueling-btn:hover { background-color: #388E3C; }
#add-expense-btn { background-color: #FF9800; }
#add-expense-btn:hover { background-color: #FB8C00; }

.history-container h3 {
    color: #0D47A1; margin-top: 20px; margin-bottom: 8px;
    font-size: 1.05em; border-bottom: 1px solid #eee; padding-bottom: 4px;
}

.filter-controls {
    margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 8px;
    align-items: center; justify-content: center;
}
.filter-controls button {
    padding: 7px 10px; font-size: 0.85em; margin-top: 0;
    background-color: #4CAF50; border: 1px solid #388E3C;
}
.filter-controls button:hover { background-color: #388E3C; }
.filter-controls button#filter-all { background-color: #7f8c8d; border-color: #607D8B; }
.filter-controls button#filter-all:hover { background-color: #607D8B; }

.history-list-wrapper {
    max-height: 280px; overflow-y: auto; margin-bottom: 15px;
    border: 1px solid #ccc; border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.85);
    flex-grow: 1;
}

#fueling-history-table,
#other-expense-history-table {
    width: 100%; border-collapse: collapse; font-size: 0.85em;
}

#fueling-history-table th, #fueling-history-table td,
#other-expense-history-table th, #other-expense-history-table td {
    border: 1px solid #ddd; padding: 7px; text-align: left; word-break: break-word;
}

#fueling-history-table th, #other-expense-history-table th {
    background-color: #f2f2f2; position: sticky; top: 0; z-index: 2;
    font-weight: 600;
}

.col-data { width: 70px; }
.col-hora { width: 45px; }
.col-km { width: 70px; text-align: right; }
.col-comb { width: 80px; }
.col-vol { width: 85px; text-align: right;}
.col-unit { width: 85px; text-align: right;}
.col-total { width: 75px; text-align: right;}
.col-efic { width: 85px; text-align: center;}
.col-acoes-fuel { width: 65px; text-align: center; }

.col-data-other { width: 80px; }
.col-categoria-other { width: auto; min-width: 200px; }
.col-valor-other { width: 90px; text-align: right; }
.col-acoes-other { width: 65px; text-align: center; }


#fueling-history-table tbody tr:nth-child(even),
#other-expense-history-table tbody tr:nth-child(even) { background-color: rgba(249, 249, 249, 0.7); }
#fueling-history-table tbody tr:hover,
#other-expense-history-table tbody tr:hover { background-color: rgba(240, 240, 240, 0.8); }

.actions-cell button,
.col-acoes-fuel button,
.col-acoes-other button {
    background: none; color: #555; border: none; padding: 4px; font-size: 1.1em;
    cursor: pointer; margin: 0 2px; transition: color 0.2s ease;
    display: inline-block; width: auto;
}
.actions-cell button:hover,
.col-acoes-fuel button:hover,
.col-acoes-other button:hover { color: #0D47A1; opacity: 1; }
.edit-btn { color: #2196F3 !important; }
.delete-btn { color: #F44336 !important; }
.edit-btn:hover { color: #1976D2 !important; }
.delete-btn:hover { color: #D32F2F !important; }

.export-import-buttons {
    display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap;
}
.export-import-buttons button,
.export-import-buttons .import-button-label {
    flex: 1 1 auto; min-width: 130px; font-size: 0.9em; padding: 10px 15px;
}
button.export-pdf, .export-import-buttons #export-pdf-btn { background-color: #E57373; }
button.export-pdf:hover, .export-import-buttons #export-pdf-btn:hover { background-color: #EF5350; }
button.export-csv, .export-import-buttons #export-csv-btn { background-color: #81C784; }
button.export-csv:hover, .export-import-buttons #export-csv-btn:hover { background-color: #66BB6A; }
.import-button-label.import-csv, .export-import-buttons .import-button-label { background-color: #64B5F6; }
.import-button-label.import-csv:hover, .export-import-buttons .import-button-label:hover { background-color: #42A5F5; opacity: 0.9; }

/* Seção de Resumo Rápido (NO FINAL) */
.summary-section-bottom {
    width: 100%;
    background-color: rgba(230, 240, 255, 0.6);
    padding: 25px 15px; /* Padding horizontal para não colar nas bordas */
    margin-top: 20px;
    text-align: center;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.08);
    box-sizing: border-box; /* Para que o padding não aumente a largura total */
}

.summary-section-bottom h2 {
    margin-top: 0;
    color: #0D47A1;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.summary-cards {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
    /* padding: 0 15px; Removido daqui, já está no parent */
}

.card {
    background-color: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    flex: 1 1 220px;
    min-width: 200px;
    max-width: 260px;
    text-align: left;
    border-left: 5px solid;
}

.daily-summary { border-left-color: #4CAF50; }
.current-month-summary { border-left-color: #2196F3; }
.current-year-summary { border-left-color: #FFC107; }
.previous-year-summary { border-left-color: #9C27B0; }


.card h3 {
    margin-top: 0;
    color: #333;
    font-size: 1.0em;
    margin-bottom: 8px;
}

.card p {
    margin: 3px 0;
    font-size: 0.80em;
    color: #555;
}

.card span {
    font-weight: bold;
    color: #0D47A1;
}


.adsense-space {
    width: 100%;
    max-width: 970px; /* Para centralizar o bloco de anúncio se ele for menor */
    margin: 20px auto; /* Centraliza e adiciona espaço */
    padding: 10px;
    box-sizing: border-box;
    text-align: center;
    min-height: 90px; /* Altura mínima para o AdSense */
    background-color: rgba(220, 220, 220, 0.2); /* Fundo sutil */
    border: 1px dashed #ccc; /* Borda para visualização do espaço */
}
.adsense-space p { /* Estilo para o texto "Espaço para propaganda" */
    color: #888;
    font-style: italic;
    margin: 0;
    padding: 30px 0; /* Centraliza o texto verticalmente se o anúncio não carregar */
    line-height: normal; /* Reseta line-height para o parágrafo */
}


.tool-footer {
    background-color: #424242;
    color: white;
    text-align: center;
    padding: 15px 0;
    width: 100%;
    /* margin-top: auto;  Removido, pois o body flex column já o empurra para baixo */
    box-sizing: border-box;
}
.tool-footer-links a {
    color: #B0BEC5;
    text-decoration: none;
    margin: 0 10px;
}
.tool-footer-links a:hover {
    text-decoration: underline;
}
.tool-footer div {
    margin-top: 5px;
    font-size: 0.9em;
    color: #E0E0E0;
}

/* Ajustes responsivos mantidos como antes, mas revisados para a nova ordem */
@media (max-width: 1200px) {
    .summary-cards { max-width: 980px; }
    .card { flex-basis: calc(50% - 10px); }
}

@media (max-width: 992px) {
    .content-wrapper {
        flex-direction: column;
        align-items: center;
    }
    .input-form-container, .history-container {
        flex-basis: auto;
        width: 95%;
        max-width: 700px;
        order: 0; /* Garante que a ordem natural do HTML seja seguida */
    }
     .history-container { margin-top: 25px; }

    .summary-cards { max-width: 700px; }
}
@media (max-width: 768px) {
    .header-compact-content { flex-direction: column; gap: 10px; }
    .tool-title-container h2 { font-size: 1.3em;}

    .summary-cards { flex-direction: column; gap: 10px; align-items: center; }
    .card { flex-basis: 95%; max-width: 350px; }

    .content-wrapper { padding: 20px 10px; }
    .input-form-container, .history-container { padding: 20px; width: calc(100% - 20px); }

    button, .export-import-buttons button, .export-import-buttons .import-button-label {
        padding: 10px 15px; font-size: 0.9em;
    }
    .actions-cell button, .col-acoes-fuel button, .col-acoes-other button {
        padding: 4px; font-size: 1em;
    }
    #fueling-history-table th, #fueling-history-table td,
    #other-expense-history-table th, #other-expense-history-table td {
        font-size: 0.8em; padding: 5px;
    }
    .col-categoria-other { min-width: 120px; }
    .export-import-buttons { flex-direction: column; align-items: stretch;}
}

@media (max-width: 480px) {
    .card { padding: 12px; }
    .card h3 { font-size: 1em; }
    .card p { font-size: 0.8em; }
    .input-form-container, .history-container { padding: 15px; }
    .filter-controls { gap: 5px; }
    .filter-controls button { padding: 6px 8px; font-size: 0.8em; }
}