body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f7f9;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 20px;
}

#filters-container {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

#filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-start;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 160px;
    flex-grow: 1;
    flex-basis: 180px;
}

 .filter-group.date-filter {
    flex-basis: 150px;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
    color: #555;
}

input[type="text"],
input[type="date"],
select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95em;
    box-sizing: border-box;
    width: 100%;
}

select[multiple] {
    min-height: 70px;
    font-size: 0.9em;
}

#filter-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: flex-start;
    width: 100%;
    flex-wrap: wrap;
}

button {
    padding: 9px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background-color 0.3s ease;
    flex-grow: 0;
}
 button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

#apply-filters { background-color: #3498db; color: white; }
#apply-filters:hover:not(:disabled) { background-color: #2980b9; }
#clear-filters { background-color: #e74c3c; color: white; }
#clear-filters:hover:not(:disabled) { background-color: #c0392b; }

#loading, #error {
    text-align: center; padding: 15px; font-size: 1.1em; display: none;
    border-radius: 4px; margin: 15px 0;
}
#error { color: #e74c3c; background-color: #fdd; border: 1px solid #e74c3c; }
#loading { color: #3498db; }

#results-container {
    flex-grow: 1; background-color: #ffffff; padding: 20px;
    border-radius: 8px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex; flex-direction: column;
    min-height: 300px; /* Garante altura mínima */
}

#table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}
#table-controls label { margin-bottom: 0; margin-right: 5px;}
#rows-per-page-select { padding: 5px; font-size: 0.9em; }

#pagination-controls {
     display: flex;
     align-items: center;
     gap: 5px;
}
 #pagination-controls button { padding: 5px 10px; font-size: 0.9em;}
 #page-info { font-size: 0.9em; margin: 0 10px;}

#table-wrapper {
     overflow-x: auto; /* Scroll horizontal para a tabela */
     width: 100%;
     flex-grow: 1; /* Permite que a tabela ocupe espaço */
     min-height: 150px; /* Altura mínima para área da tabela */
}

table {
    width: 100%; border-collapse: collapse; margin-top: 0;
    white-space: nowrap;
}

th, td {
    border: 1px solid #ddd; padding: 9px 11px;
    text-align: left; font-size: 0.88em;
    vertical-align: middle;
}

th {
    background-color: #ecf0f1; color: #34495e; font-weight: bold;
    position: sticky; top: 0; z-index: 1; cursor: pointer;
    user-select: none;
}
th .sort-arrow {
    margin-left: 5px; opacity: 0.5; display: inline-block;
    transition: transform 0.2s ease-in-out; /* Animação suave da seta */
}
 th .sort-arrow.asc { opacity: 1; transform: rotate(180deg); }
 th .sort-arrow.desc { opacity: 1; transform: rotate(0deg); } /* Garante estado inicial */


tbody tr:nth-child(even) { background-color: #f9f9f9; }
tbody tr:hover { background-color: #e8f4fd; }
#no-results { text-align: center; padding: 20px; display: none; color: #777; }


/* --- ESTILOS PARA O GRÁFICO --- */
#chart-container {
    margin-top: 30px;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: 400px; /* Altura fixa */
    position: relative;
    box-sizing: border-box;
}
 #chart-container h2 { margin-bottom: 15px;}
 #chart-container canvas {
     max-width: 100%;
     max-height: 100%;
 }
 /* --- FIM ESTILOS GRÁFICO --- */


/* Responsividade */
@media (max-width: 768px) {
     #filters { flex-direction: column; align-items: stretch; }
    .filter-group { min-width: 100%; flex-basis: auto; }
    #table-controls { flex-direction: column; align-items: flex-start;}
    #pagination-controls { margin-top: 10px;}
     th, td { font-size: 0.8em; padding: 7px 9px;}
     #chart-container { height: 300px; } /* Altura menor em telas pequenas */
}