:root {
    /* Cores da Empresa (Tons de Verde) */
    --company-primary: #2E7D32; /* Verde Escuro Principal */
    --company-secondary: #4CAF50; /* Verde Médio Secundário */
    --company-accent: #81C784; /* Verde Claro Acento */
    --company-light: #C8E6C9; /* Verde Muito Claro / Fundo */

    /* Cores Neutras e de UI */
    --text-dark: #333333;
    --text-light: #FFFFFF;
    --text-muted: #6c757d;
    --bg-light: #f4f6f8; 
    --bg-card: #FFFFFF;
    --border-color: #e0e0e0;

    /* Fontes */
    --font-primary: 'Poppins', sans-serif;

    /* Sombras e Bordas */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --box-shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
    --box-shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.12);
    --box-shadow-lifted: 0 8px 25px rgba(46, 125, 50, 0.15); 
}

body, html {
    margin: 0;
    padding: 0;
    min-height: 100vh; /* Garante que o body ocupe pelo menos a altura da viewport */
    font-family: var(--font-primary);
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 15px; 
    display: flex; 
    flex-direction: column; 
}

/* --- Header --- */
.site-header {
    background: linear-gradient(90deg, var(--company-primary) 0%, var(--company-secondary) 100%);
    color: var(--text-light);
    padding: 1rem 2rem; 
    box-shadow: var(--box-shadow-medium);
    flex-shrink: 0; /* Header não encolhe */
    position: sticky; /* Header fixo no topo ao rolar */
    top: 0;
    z-index: 1000; 
}
.header-content {
    display: flex;
    align-items: center;
    justify-content: center; 
    max-width: 1400px; 
    margin: 0 auto; 
}
.header-icon {
    font-size: 2.2em; 
    margin-right: 15px;
    opacity: 0.9;
}
.site-header h1 {
    margin: 0;
    font-size: 1.8em; 
    font-weight: 600; 
    letter-spacing: 0.5px;
}

/* --- Layout Principal --- */
.container {
    display: flex;
    flex-grow: 1; /* Permite que o container ocupe o espaço vertical restante */
    padding: 25px; 
    gap: 25px; 
    /* overflow: hidden; Comentado para permitir scroll da página se necessário */
}

.sidebar {
    width: 380px; 
    flex-shrink: 0; 
    overflow-y: auto; /* Sidebar rola internamente se seu conteúdo for grande */
    display: flex;
    flex-direction: column;
    gap: 25px;
    /* Se o header for sticky, pode precisar de um max-height aqui:
       max-height: calc(100vh - HEADER_HEIGHT - CONTAINER_PADDING_TOP_BOTTOM - FOOTER_HEIGHT); 
       Exemplo: max-height: calc(100vh - 74px - 50px - 68px); */
}

.main-content {
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 0; 
    /* overflow: hidden; Comentado para permitir scroll da página se necessário */
}

/* --- Cards --- */
.card {
    background-color: var(--bg-card);
    padding: 22px; 
    border-radius: var(--border-radius-md);
    box-shadow: var(--box-shadow-light);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-lifted);
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animated-card {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0; 
}
.animated-card:nth-child(1) { animation-delay: 0.1s; }
.animated-card:nth-child(2) { animation-delay: 0.2s; }
.animated-card:nth-child(3) { animation-delay: 0.3s; }
.animated-card-map { 
    animation: fadeInUp 0.4s ease-out forwards;
    opacity: 0;
}

.sidebar h2 {
    margin-top: 0;
    color: var(--company-primary);
    border-bottom: 2px solid var(--company-accent);
    padding-bottom: 12px;
    margin-bottom: 20px;
    font-size: 1.25em; 
    font-weight: 600;
}
.sidebar h2 i {
    margin-right: 10px;
    color: var(--company-secondary);
}

/* --- Formulários e Botões --- */
.input-group {
    margin-bottom: 18px;
}
.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500; 
    color: var(--text-muted);
    font-size: 0.9em;
}
.input-group input[type="text"],
.input-group input[type="number"] {
    width: calc(100% - 24px); 
    padding: 11px 12px; 
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    background-color: #fdfdfd;
}
.input-group input[type="text"]:focus,
.input-group input[type="number"]:focus {
    border-color: var(--company-secondary);
    box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25); 
    outline: none;
}

.button-primary, .button-alt { 
    color: var(--text-light);
    border: none;
    padding: 11px 18px; 
    text-align: center;
    text-decoration: none;
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    font-size: 0.95rem; 
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-transform: uppercase; 
    letter-spacing: 0.5px;
}
.button-primary i, .button-alt i {
    margin-right: 10px; 
    font-size: 1.1em; 
}

.button-primary { 
    background-color: var(--company-secondary);
}
.button-primary:hover {
    background-color: var(--company-primary); 
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(46, 125, 50, 0.2);
}
.button-primary:disabled {
    background-color: var(--company-light);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button-alt { 
    background-color: var(--text-muted);
}
.button-alt:hover {
    background-color: var(--text-dark); 
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.button-alt:disabled {
    background-color: #d1d5db; 
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Painel de Estatísticas --- */
.city-title {
    font-size: 1.15em; 
    font-weight: 600; 
    color: var(--company-primary);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--company-light);
}
.stats-panel p {
    margin: 12px 0;
    font-size: 0.9rem; 
    display: flex;
    flex-direction: column; 
    align-items: center; 
    text-align: center; 
    padding: 8px 0;
    border-bottom: 1px dotted #eee; 
}
.stats-panel p:last-child {
    border-bottom: none; 
}
.stats-panel strong {
    color: var(--text-dark);
    font-weight: 500;
    margin-bottom: 4px; 
    display: block; 
    width: 100%; 
}
.stats-panel span {
    font-weight: 700; 
    font-size: 1.2em; 
    color: var(--company-secondary);
    display: block; 
    width: 100%; 
}
.stats-panel span:after { 
    content: attr(data-unit); 
    font-size: 0.7em;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 5px; 
    display: block; 
}


/* --- Painel de Análise de Trecho --- */
.instructions { /* ... estilos existentes ... */ }
.instructions i { /* ... estilos existentes ... */ }
.segment-points-details { /* ... estilos existentes ... */ }
.segment-points-details p { /* ... estilos existentes ... */ }
.segment-points-details i { /* ... estilos existentes ... */ }
.start-icon { /* ... estilos existentes ... */ }
.end-icon { /* ... estilos existentes ... */ }


/* --- Mapa --- */
#map {
    flex-basis: 60%; /* Tenta ocupar 60% do espaço vertical do main-content */
    flex-grow: 0;   /* Não cresce além da base */
    flex-shrink: 0; /* Não encolhe se não houver espaço */
    border: 1px solid var(--border-color);
    position: relative; 
    border-radius: var(--border-radius-md); 
    min-height: 350px; 
}

/* --- Gráficos --- */
.charts-container {
    display: flex;
    gap: 25px;
    overflow-x: auto; 
    /* flex: 1; Removido para que a altura seja determinada pelo conteúdo */
    padding-bottom: 10px; /* Espaço para scrollbar não cobrir conteúdo */
}
.chart-card {
    flex: 1 1 330px; /* Base de 330px, pode crescer/encolher */
    display: flex;
    flex-direction: column; 
    padding: 0; 
    min-height: 360px; /* Altura mínima aumentada para os cards de gráfico */
}
.chart-header {
    padding: 18px 22px; 
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; 
}
.chart-card h3 {
    text-align: left; 
    margin: 0; 
    font-size: 1.05em; 
    font-weight: 600;
    color: var(--text-dark);
}
.chart-card h3 i {
    margin-right: 10px;
    color: var(--company-secondary);
    font-size: 1.2em; 
}
.chart-content {
    flex-grow: 1; 
    padding: 20px; 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden; 
    /* min-height: 220px; Removido, o card já tem min-height */
}
.chart-card canvas {
    max-width: 100%;
    max-height: 100%; 
}

/* --- Footer --- */
.site-footer { 
    background-color: var(--text-dark); 
    color: var(--company-light); 
    text-align: center;
    padding: 18px 0; 
    font-size: 0.85rem;
    width: 100%; 
    margin-top: auto; /* Empurra para o final do fluxo da página */
    flex-shrink: 0; /* Impede que o footer encolha */
    border-top: 3px solid var(--company-primary); 
}
.site-footer a {
    color: var(--company-accent); 
    text-decoration: none;
    font-weight: 500;
}
.site-footer a:hover {
    text-decoration: underline;
    color: var(--text-light);
}

/* --- Indicador de Loading --- */
.loading { /* ... estilos existentes ... */ }
.spinner { /* ... estilos existentes ... */ }
.status-message { /* ... estilos existentes ... */ }

/* --- Leaflet Draw Customizations --- */
.leaflet-draw-toolbar { /* ... estilos existentes ... */ }
.leaflet-draw-toolbar a { /* ... estilos existentes ... */ }
.leaflet-draw-toolbar a:last-child { /* ... estilos existentes ... */ }
.leaflet-draw-toolbar a:first-child { /* ... estilos existentes ... */ }
.leaflet-draw-toolbar a:hover { /* ... estilos existentes ... */ }
.leaflet-draw-toolbar a .sr-only { /* ... estilos existentes ... */ }
.leaflet-draw-toolbar a:before { /* ... estilos existentes ... */ }
.leaflet-draw-draw-polyline:before { /* ... estilos existentes ... */ }
.leaflet-draw-edit-edit:before { /* ... estilos existentes ... */ }
.leaflet-draw-edit-remove:before { /* ... estilos existentes ... */ }
.leaflet-draw-actions a { /* ... estilos existentes ... */ }
.leaflet-draw-actions a:hover { /* ... estilos existentes ... */ }
.leaflet-draw-actions li:last-child a { /* ... estilos existentes ... */ }
.leaflet-draw-actions li:last-child a:hover { /* ... estilos existentes ... */ }

/* Marcadores de Vértice Numerados */
.vertex-marker-icon { /* ... estilos existentes ... */ }
.vertex-marker-icon:hover { /* ... estilos existentes ... */ }
.vertex-marker-icon.start-node { /* ... estilos existentes ... */ }
.vertex-marker-icon.end-node { /* ... estilos existentes ... */ }

/* Ícones de edição padrão do Leaflet (quadradinhos) */
.leaflet-editing-icon, .leaflet-vertex-icon { /* ... estilos existentes ... */ }

/* --- Media Queries para Responsividade --- */
@media (max-width: 1300px) { 
    .container { padding: 20px; gap: 20px; }
    .sidebar { width: 350px; }
    .charts-container { gap: 20px; }
    .chart-card { flex-basis: 300px; min-height: 340px; } 
}

@media (max-width: 1024px) { 
    .container { flex-direction: column; overflow-y: auto; }
    .sidebar { width: 100%; margin-bottom: 20px; max-height: none; overflow-y: visible; }
    .main-content { width: 100%; overflow: visible; }
    #map { flex-basis: 50vh; min-height: 300px; } 
    .charts-container {
        flex-direction: column; 
        min-height: auto; 
        overflow-y: visible;
        flex: none; 
    }
    .chart-card {
        min-height: 360px; 
        margin-bottom: 20px;
        flex-basis: auto; 
    }
     .chart-card:last-child { margin-bottom: 0; }
}

@media (max-width: 768px) { 
    body, html { font-size: 14px; }
    .site-header { padding: 0.8rem 1rem; position: static; } 
    .site-header h1 { font-size: 1.3em; }
    .header-icon { font-size: 1.8em; }
    .container { padding: 15px; gap: 15px; }
    #map { flex-basis: 40vh; min-height: 280px; } 
    .chart-card { min-height: 330px; } 
    .sidebar h2 { font-size: 1.15em; }
    .button-primary, .button-alt { font-size: 0.9rem; padding: 10px 15px; }
    .stats-panel p { flex-direction: row; align-items: baseline; text-align: left; }
    .stats-panel strong { width: auto; min-width: 100px; margin-bottom: 0; margin-right: 8px; }
    .stats-panel span { width: auto; font-size: 1em; }
    .stats-panel span:after { display: inline; margin-left: 3px; }
}

/* --- Scrollbar Customizada --- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #e9e9e9; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: var(--company-accent); border-radius: 10px; border: 2px solid #e9e9e9; }
::-webkit-scrollbar-thumb:hover { background: var(--company-secondary); }