* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #eef2f6;
    color: #18212b;
    font-family: "Segoe UI", Arial, sans-serif;
    overflow: hidden;
}

.topbar {
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
    border-bottom: 1px solid #d5dde7;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 80;
}

.eyebrow {
    color: #52616f;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 4px;
    text-transform: uppercase;
}

h1 {
    font-size: 22px;
    line-height: 1.2;
    margin: 0;
}

.primary-button {
    background: #176b87;
    border: 0;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    min-height: 40px;
    padding: 0 18px;
}

.secondary-button {
    background: #ffffff;
    border: 1px solid #9aa8b5;
    border-radius: 6px;
    color: #263238;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    min-height: 40px;
    padding: 0 18px;
}

.filters {
    background: #ffffff;
    border-bottom: 1px solid #dce3ec;
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(8, minmax(135px, 1fr));
    padding: 16px 24px;
    position: sticky;
    top: 73px;
    z-index: 70;
}

.filters label {
    color: #52616f;
    display: grid;
    font-size: 12px;
    font-weight: 700;
    gap: 6px;
    text-transform: uppercase;
}

.select {
    background: #ffffff;
    border: 1px solid #c8d1dc;
    border-radius: 6px;
    color: #1f2933;
    font-size: 14px;
    min-height: 38px;
    padding: 6px 8px;
    width: 100%;
}

.select:disabled {
    background: #edf1f5;
    color: #7b8794;
    cursor: not-allowed;
}

.select:focus {
    border-color: #176b87;
    box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.16);
    outline: none;
}

.summary {
    display: grid;
    gap: 1px;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    margin: 16px 24px 14px;
    overflow: hidden;
}

.summary div {
    background: #ffffff;
    border: 1px solid #d8dee6;
    border-radius: 6px;
    padding: 12px 14px;
}

.summary span {
    color: #66788a;
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
}

.summary strong {
    font-size: 16px;
}

.message {
    background: #fff5d6;
    border: 1px solid #e8c96a;
    border-radius: 6px;
    margin: 0 24px 18px;
    padding: 12px 14px;
}

.table-wrap {
    margin: 0 24px 24px;
    height: calc(100vh - 286px);
    max-height: calc(100vh - 286px);
    overflow: auto;
    border: 1px solid #cfd7e2;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(24, 33, 43, 0.06);
}

.loading-overlay {
    align-items: center;
    background: rgba(15, 23, 32, 0.48);
    display: none;
    inset: 0;
    justify-content: center;
    place-items: center;
    position: fixed;
    z-index: 5000;
}

.loading-box {
    background: #ffffff;
    border: 1px solid #c8d1dc;
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(15, 23, 32, 0.28);
    color: #263238;
    font-size: 16px;
    font-weight: 800;
    min-width: 220px;
    padding: 22px 28px;
    text-align: center;
}

.loading-box::before {
    animation: spin 0.8s linear infinite;
    border: 3px solid #dce3ec;
    border-top-color: #176b87;
    border-radius: 999px;
    content: "";
    display: block;
    height: 28px;
    margin: 0 auto 12px;
    width: 28px;
}

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

.report-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    min-width: 4700px;
    width: 100%;
}

.report-table th,
.report-table td {
    border-bottom: 1px solid #dde4ec;
    border-right: 1px solid #dde4ec;
    padding: 6px 8px;
    vertical-align: middle;
}

.report-table thead th {
    background: #263238;
    color: #ffffff;
    font-weight: 700;
    height: 36px;
    line-height: 1.15;
    position: sticky;
    text-align: center;
    top: 0 !important;
    z-index: 40;
}

.report-table thead .month-row th {
    top: 0 !important;
    z-index: 43;
}

.report-table thead .source-row th {
    top: 36px !important;
    z-index: 42;
}

.report-table thead .metric-row th {
    top: 72px !important;
    z-index: 41;
}

.month-head {
    background: #176b87 !important;
}

.source-head {
    background: #43515c !important;
}

.minsa-head {
    background: #176b87 !important;
}

.diresa-head {
    background: #8a6f2a !important;
}

.total-head {
    background: #5b6770 !important;
}

.sticky-col {
    left: 0;
    position: sticky;
    z-index: 3;
}

.report-table thead .sticky-col {
    z-index: 60;
}

.area {
    background: #f8fafc;
    min-width: 150px;
    width: 150px;
}

.indicator {
    background: #ffffff;
    left: 150px;
    min-width: 420px;
    width: 420px;
}

.code {
    color: #176b87;
    display: inline-block;
    font-weight: 800;
    margin-right: 6px;
}

.expand-button,
.expand-spacer {
    display: inline-grid;
    height: 22px;
    margin-right: 8px;
    place-items: center;
    vertical-align: middle;
    width: 22px;
}

.expand-button {
    background: #176b87;
    border: 0;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
}

.expand-button.small {
    height: 18px;
    font-size: 13px;
    width: 18px;
}

.detail-row {
    display: none;
}

.detail-row td {
    background: #f6f9fb;
}

.level-red td {
    background: #eef6f8;
}

.level-micro td {
    background: #f5f8fb;
}

.level-estab td {
    background: #ffffff;
}

.detail-area {
    color: #66788a;
    font-weight: 700;
}

.detail-indicator {
    color: #263238;
    font-weight: 700;
    padding-left: 38px !important;
}

.detail-indicator.micro {
    padding-left: 58px !important;
}

.detail-indicator.estab {
    color: #52616f;
    font-weight: 600;
    padding-left: 86px !important;
}

.detail-red {
    display: block;
}

.detail-meta {
    color: #66788a;
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
}

.num,
.pct {
    text-align: right;
    white-space: nowrap;
}

.pct {
    color: #0f5132;
    font-weight: 700;
}

.diresa {
    background: #fffaf0;
}

.pct.goal-ok {
    background: #dff5e8;
    color: #126c37;
}

.pct.goal-bad {
    background: #fde2e2;
    color: #b42318;
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
        position: static;
        padding: 14px 12px;
    }

    .filters,
    .summary {
        grid-template-columns: 1fr;
        position: static;
    }

    .filters {
        padding: 12px;
    }

    .summary {
        margin: 12px;
    }

    .table-wrap {
        height: calc(100vh - 260px);
        margin: 0 12px 16px;
        max-height: calc(100vh - 260px);
    }
}
