:root {
    --azul-ons: #185FA5;
    --azul-escuro: #0C447C;
    --azul-claro: #B5D4F4;
    --cinza-fundo: #F5F6F8;
    --cinza-borda: #E2E4E8;
    --vermelho: #E24B4A;
    --amarelo: #BA7517;
    --verde: #3B6D11;
    --texto-primario: #1A1A1A;
    --texto-secundario: #5A6273;
    
    --bg-kpi: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--cinza-fundo);
    color: var(--texto-primario);
    line-height: 1.5;
    overflow-x: hidden;
}

.header {
    background-color: var(--azul-ons);
    color: white;
    padding: 0.5rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: fit-content;
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ao-vivo {
    background-color: var(--vermelho);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Filtros no Header */
.filtros-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-grow: 1;
}

.filtro-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filtro-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    white-space: nowrap;
}

select {
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    min-width: 100px;
}

select:hover, select:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: white;
}

select option {
    background-color: white;
    color: var(--texto-primario);
}

.btn {
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.75rem;
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.badge-filtros {
    background-color: white;
    color: var(--azul-ons);
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* KPIs Compactos */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.kpi-card {
    background-color: var(--bg-kpi);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--cinza-borda);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-card h3 {
    font-size: 0.7rem;
    color: var(--texto-secundario);
    margin-bottom: 0.25rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-valor {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--azul-ons);
    line-height: 1.2;
}

/* Grids */
.grid-principal {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 1.25rem;
}

.grid-graficos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* Sections */
.section-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--texto-secundario);
    text-transform: uppercase;
    letter-spacing: 0.075em;
}

.tabela-container, .mapa-container, .chart-container {
    background-color: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

/* Tabela */
.table-wrapper {
    overflow-x: auto;
    position: relative;
    min-height: 250px;
    flex-grow: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--cinza-borda);
}

th {
    font-weight: 700;
    color: var(--texto-secundario);
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.025em;
}

tbody tr:hover {
    background-color: #f8fafc;
    cursor: pointer;
}

.badge-tipo {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.7rem;
    display: inline-block;
    white-space: nowrap;
}

.tipo-forcado {
    background-color: #fee2e2;
    color: var(--vermelho);
}

.tipo-programado {
    background-color: #fef3c7;
    color: var(--amarelo);
}

.tipo-outros {
    background-color: #dcfce7;
    color: var(--verde);
}

.paginacao {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--cinza-borda);
    font-size: 0.75rem;
    font-weight: 500;
}

.btn-icon {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--cinza-borda);
    background-color: white;
    border-radius: 4px;
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon:not(:disabled):hover {
    background-color: var(--cinza-fundo);
    border-color: var(--azul-ons);
}

/* Mapa */
.mapa-wrapper {
    flex-grow: 1;
    min-height: 350px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Charts */
.chart-container {
    height: 400px; /* Increased height */
}

.canvas-wrapper {
    position: relative;
    flex-grow: 1;
    width: 100%;
    height: 100%;
    min-height: 0; /* Allow it to shrink if needed */
}

/* Utilities */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    display: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--cinza-borda);
    border-top-color: var(--azul-ons);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    color: transparent;
    border-radius: 4px;
    height: 1.5em;
    width: 80%;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsivo */
@media (max-width: 1400px) {
    .header {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0.75rem 1.5rem;
    }
    .logo {
        margin-right: 1.5rem;
    }
}

@media (max-width: 1100px) {
    .grid-principal {
        grid-template-columns: 1fr;
    }
    .kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .filtros-container {
        justify-content: flex-start;
        width: 100%;
    }
    .grid-graficos {
        grid-template-columns: 1fr;
    }
    .kpis {
        grid-template-columns: 1fr;
    }
    .chart-container {
        height: 350px;
    }
}
