:root {
    --mineco-navy: #192854;
    --rpsc-primary: #007A96;
    --rpsc-secondary: #009EDE;
    --white: #FFFFFF;
    --gray-100: #F8FAFC;
    --gray-200: #E2E8F0;
    --gray-500: #64748B;
    --gray-700: #334155;
}

.container.estadisticas {
    padding: 2rem;
    border-radius: 20px;
}

.titulo {
    color: var(--color-primary);
    font-weight: 700;
    display: block !important;
    padding-left: 0 !important;
    text-align: center !important;
    margin: 0 auto 2.5rem auto;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.tarjeta.total {
    background: linear-gradient(135deg, var(--primary-blue), #1e40af);
    color: white;
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(30, 58, 138, 0.2);
    margin-bottom: 3rem;
}

.tarjeta.total h2 {
    font-size: 1.1rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.tarjeta.total .numero {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.graficos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.grafico {
    background: #ffffff;
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.grafico h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 1.5rem;
    padding-left: 0.5rem;
    border-left: 4px solid var(--accent-blue);
}

.grafico-container {
    position: relative;
    width: 100%;
    height: 320px;
}

.grafico-full {
    grid-column: 1 / -1;
}

#mapaCapacitaciones {
    width: 100%;
    height: 480px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    z-index: 1;
}

.leaflet-tooltip {
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.distribucion-grid {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: 1.5rem;
}

/* ===== Tabla compacta dashboard ===== */
.tabla-regiones {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.tabla-regiones thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 6px 8px;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid #e5e7eb;
}

.tabla-regiones tbody tr {
    transition: background .15s ease;
}

.tabla-regiones tbody tr:hover {
    background: #f1f5f9;
}

.tabla-regiones td {
    padding: 6px 8px;
    vertical-align: top;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

/* Región + color */
.region-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    white-space: nowrap;
}

.region-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Departamentos más compactos */
.deps {
    color: #64748b;
    font-size: 10px;
    line-height: 1.35;
}

/* Totales */
.total {
    text-align: right;
    font-weight: 800;
    color: #0f172a;
}

/* Porcentaje con barra */
.porcentaje {
    text-align: right;
    font-weight: 700;
    color: #475569;
    width: 60px;
}

.barra {
    height: 4px;
    background: #e5e7eb;
    border-radius: 4px;
    margin-top: 4px;
    overflow: hidden;
}

.barra span {
    display: block;
    height: 100%;
    border-radius: 4px;
}

/* ===== KPI ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.kpi-main {
    background: linear-gradient(135deg, var(--color-primary), #1e40af);
    color: #fff;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(30, 58, 138, .25);
}

.kpi-label {
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .85;
}

.kpi-value {
    display: block;
    font-size: 3rem;
    font-weight: 800;
    margin: .5rem 0;
}

.kpi-sub {
    font-size: .9rem;
    opacity: .9;
}

.kpi-card {
    background: #fff;
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-mini-label {
    font-size: .75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.kpi-mini-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f172a;
}

.kpi-card.positive .kpi-mini-value {
    color: #16a34a;
}

.kpi-subtitle.muted {
    font-size: 0.75rem;
    color: #9ca3af;
    /* gris suave */
    letter-spacing: 0.02em;
}

.kpi-card.neutral {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.kpi-secondary {
    font-size: 0.9rem;
    color: #1e293b;
}

.grafico-dona-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
}

.tabla-wrapper {
    overflow-x: auto;
}

.chart-container {
    position: relative;
    height: 300px; /* Altura fija para que Chart.js sepa cuánto medir */
    width: 100%;
}

@media (max-width: 768px) {
    .grafico-dona-wrapper {
        height: 260px;
    }

    .tabla-regiones {
        font-size: 10px;
    }
}

@media (max-width: 992px) {
    .distribucion-grid {
        display: block !important;
    }

    .grafico-dona-wrapper {
        height: 300px;
        margin-bottom: 2rem;
    }

    .graficos {
        grid-template-columns: 1fr;
    }
}

/* === FORZAR REFLUJO CORRECTO DE CANVAS === */
canvas {
    max-width: 100%;
    height: 100% !important;
    display: block;
}

/* Evita colapsos al cambiar breakpoint */
.grafico-container,
.grafico-dona-wrapper,
.chart-container {
    min-height: 260px;
}

/* KPI GRID responsive SIN CAMBIAR DISEÑO */
@media (max-width: 992px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* Asegura que Leaflet refluya */
#mapaCapacitaciones {
    min-height: 360px;
}

/* Evita scroll horizontal fantasma */
.container.estadisticas {
    overflow-x: hidden;
}