﻿:root {
    --bg: #f5f9f7;
    --panel: #ffffff;
    --panel-2: #fafbfa;
    --text: #12324a;
    --muted: #55738d;
    --accent: #7FC29B;
    --accent-soft: #E8F5F0;
    --ok: #A8D9E6;
    --warn: #FFD4A3;
    --danger: #de5b5b;
    --border: #D9E8E4;
}




.app-fondo {
    padding: 16px;
    background: #f3f7fb;
}

.panel {
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: none;
    border-radius: 5px;
    padding: 16px;
    margin-top: 15px;
    box-shadow: 0 10px 20px rgba(17, 48, 77, 0.08);
}

    .sidebar h2, .panel h2 {
        margin-top: 0;
        font-family: "Montserrat", sans-serif;
        font-size: 1.02rem;
        font-weight: 700;
    }

.sidebar {
    position: sticky;
    top: 70px;
}

.brand-cplt {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0b2238;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.brand-cplt-mark {
    color: #ffffff;
    font-family: "Montserrat", sans-serif;
    font-weight: 800;
    font-size: 1.9rem;
    line-height: 1;
    letter-spacing: 0.2px;
}

.brand-cplt-text {
    color: #ffffff;
    font-family: "Montserrat", sans-serif;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.1;
    border-left: 1px solid rgba(255, 255, 255, 0.28);
    padding-left: 10px;
}

.filters-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

    .filters-head h2 {
        margin: 0;
        font-size: 0.84rem;
        text-transform: uppercase;
        letter-spacing: 0.2px;
    }

    .filters-head a {
        font-size: 0.78rem;
        color: var(--text);
        text-decoration: none;
    }

        .filters-head a:hover {
            text-decoration: underline;
        }

.filter-group {
    margin-bottom: 12px;
}

    .filter-group label {
        display: block;
        color: var(--muted);
        font-size: 12px;
        margin-bottom: 6px;
    }

.main-content {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 2px 0 6px;
    background: transparent;
}

.topbar-main h1 {
    margin: 0;
    font-family: "Montserrat", sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #0b2f4f;
}

.topbar-main p {
    margin: 6px 0 0;
    color: #496b88;
    font-size: 15px;
}

.topbar-badge {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid #c9def1;
    border-radius: 10px;
    padding: 10px 14px;
    color: #2d5578;
    font-size: 13px;
    white-space: nowrap;
}

#link-reset-table-mode{
    color: var( --muted);
    text-decoration: underline;
}

.kpi {
    background: #f3f9ff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

    .kpi .label {
        color: var(--muted);
        font-size: 12px;
    }

    .kpi .value {
        font-size: 24px;
        font-weight: 800;
        margin-top: 4px;
    }

    .kpi .subvalue {
        color: var(--muted);
        font-size: 12px;
        margin-top: 6px;
    }

.kpi-note {
    margin-top: auto;
    font-size: 11px;
    color: #55738d;
    padding-top: 8px;
    border-top: 1px dashed #c8d8e8;
}

.kpi-mini {
    padding: 10px;
}

    .kpi-mini .label {
        font-size: 11px;
    }

    .kpi-mini .value {
        font-size: 16px;
        margin-top: 2px;
    }

.kpi-grid .row.g-2 {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 0.75rem;
}

.kpi-mini-wrap {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .kpi-grid .kpi-mini-wrap:nth-child(n+4) {
        margin-top: 10px;
    }
}

@media (max-width: 767.98px) {
    .kpi-mini-wrap + .kpi-mini-wrap {
        margin-top: 10px;
    }
}

.kpi--dynamic {
    background: transparent;
    border-color: var(--border);
    box-shadow: none;
}

    .kpi--dynamic .label {
        color: #1c4f78;
        font-weight: 700;
    }

    .kpi--dynamic .value {
        color: #0b2f4f;
    }

    .kpi--dynamic .subvalue {
        color: #2d6a96;
    }

.section-title-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

    .section-title-wrap p {
        margin: 0;
        color: var(--muted);
        font-size: 13px;
    }

#sankey-chart {
    width: 100%;
    overflow: hidden;
}

    #sankey-chart svg {
        width: 100%;
        height: 460px;
        display: block;
    }

.charts-grid {
    margin: 0;
}

    .charts-grid h3 {
        margin: 0 0 8px;
        font-family: "Montserrat", sans-serif;
        font-size: 0.9rem;
        color: #1d4668;
        font-weight: 700;
    }

.chart-card[data-table-mode] {
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.kpi-transparency-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed #c8d8e8;
    color: #55738d;
    font-size: 11px;
    line-height: 1.45;
}

    .kpi-transparency-message strong {
        color: #1d4668;
        font-size: 12px;
    }

    .kpi-transparency-message p {
        margin: 4px 0 0;
    }

    .chart-card[data-table-mode] h3::after {
        content: "Ver detalle";
        margin-left: 6px;
        font-family: sans-serif;
        font-size: 0.62rem;
        font-weight: 600;
        color: var(--muted);
    }

    .chart-card[data-table-mode]:hover,
    .chart-card[data-table-mode]:focus-visible {
        box-shadow: 0 12px 26px rgba(17, 48, 77, 0.16);
        outline: none;
    }

    .chart-card[data-table-mode].is-active {
        z-index: 1;
        box-shadow: 0 0 0 2px var(--accent), 0 12px 26px rgba(17, 48, 77, 0.16);
    }

        .chart-card[data-table-mode].is-active::before {
            position: absolute;
            z-index: 1;
            bottom: -25px;
            left: 50%;
            width: 0;
            height: 0;
            content: "";
            border-top: 25px solid var(--accent);
            border-right: 25px solid transparent;
            border-left: 25px solid transparent;
            transform: translateX(-50%);
        }

    .chart-card[data-table-mode].is-active h3::after {
        content: "Mostrando detalle";
    }

.detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1rem;
}

.table-empty-state {
    margin: 0;
    padding: 28px 16px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: #f8fbff;
    color: var(--muted);
    text-align: center;
    font-size: 0.9rem;
}

    .detail-head h2 {
        margin: 0;
    }

    .detail-head a {
        color: var(--accent);
        font-size: 0.84rem;
        text-decoration: none;
    }

        .detail-head a:hover {
            text-decoration: underline;
        }

.chart-subtitle {
    margin: -4px 0 8px;
    font-size: 12px;
    color: #55738d;
}

.cards-tight {
    --bs-gutter-x: 0.45rem;
    --bs-gutter-y: 0.5rem;
}

    .cards-tight > [class*="col-"] {
        padding-left: 0.22rem;
        padding-right: 0.22rem;
        display: flex;
        align-items: stretch;
    }

        .cards-tight > [class*="col-"] > .panel {
            width: 100%;
            min-height: 300px;
        }

#monthlyChart,
#comprasChart,
#personalChart,
#bienesChart {
    display: block;
    width: 100%;
}

#cometidosMap {
    width: 100%;
    height: 260px;
    background-image: url("../img/chile-map.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-color: #f3f8fe;
    position: relative;
    overflow: hidden;
}

.cometidos-wrap {
    display: grid;
    grid-template-columns: 0.75fr 1.25fr;
    gap: 8px;
    align-items: start;
}

.cometidos-table-wrap {
    overflow: visible;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fbff;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}

    .mini-table th, .mini-table td {
        padding: 4px 6px;
        border-bottom: 1px solid var(--border);
        text-align: left;
    }

    .mini-table th {
        color: #1d4668;
        font-weight: 700;
    }

@media (max-width: 1200px) {
    .cometidos-wrap {
        grid-template-columns: 1fr;
    }
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 13px;
}

th {
    color: var(--muted);
    font-weight: 600;
}

@media (max-width: 980px) {
    .app-container {
        padding: 12px;
    }

    .sidebar {
        position: static;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-main h1 {
        font-size: 1.6rem;
    }
}
