body { font-family: "Kanit", sans-serif; }

.stats-mt-6 { margin-top: 1.75rem !important; }
.stats-mt-8 { margin-top: 2.25rem !important; }
.stats-mt-10 { margin-top: 2.75rem !important; }
.stats-mb-6 { margin-bottom: 1.5rem !important; }
.stats-pb-8 { padding-bottom: 2rem !important; }
.stats-gap-6 { gap: 1.75rem !important; }
.stats-gap-05 { gap: 0.125rem !important; }
.stats-aspect-square { aspect-ratio: 1 / 1 !important; }

/* Make top summary cards less tall to match original proportions */
.stats-page .stats-summary-block {
    padding: 1.75rem !important;
}

.stats-page .stats-summary-block > .mt-5 {
    margin-top: 1.25rem !important;
}

.stats-page .stats-summary-block .p-5 {
    padding: 1.25rem 1.35rem !important;
}

.stats-page .stats-summary-block .fs-1 {
    line-height: 1;
}

@media (max-width: 767.98px) {
    .stats-mt-8 { margin-top: 1.75rem !important; }
    .stats-mt-10 {
        margin-top: 2.25rem !important;
    }
    .stats-pb-8 {
        padding-bottom: 2.25rem !important;
    }

    .stats-page .stats-summary-block {
        padding: 1.25rem !important;
    }

    .stats-page .stats-summary-block > .mt-5 {
        margin-top: 0.95rem !important;
    }

    .stats-page .stats-summary-block .p-5 {
        padding: 1rem !important;
    }
}

.stats-accent-text {
    color: #60256c !important;
}

.stats-filter-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .stats-filter-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .stats-filter-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.stats-filter-btn {
    min-height: 44px;
    min-width: 100px;
}

.stats-filter-btn-reset {
    transition: all 0.2s ease;
}

.stats-filter-btn-reset:hover {
    background: #f8fafc;
    border-color: #cbd5e1 !important;
    color: #1f2937 !important;
}

@media (max-width: 575.98px) {
    .stats-filter-actions {
        flex-direction: column;
        align-items: stretch !important;
    }

    .stats-filter-btn {
        width: 100%;
        min-width: 0;
    }
}

.budget-unit {
    color: #e2e8f0;
    text-shadow: none;
    -webkit-text-stroke: 0;
}
.area-unit {
    color: #e2e8f0;
    text-shadow: none;
    -webkit-text-stroke: 0;
}
        .text-stroke-white{
            text-shadow: 2px 0 #fff,-2px 0 #fff,0 2px #fff,0 -2px #fff,1px 1px #fff,-1px -1px #fff,1px -1px #fff,-1px 1px #fff;
            -webkit-text-stroke: 1px white;
        }
        .text-stroke-white-thin{
            text-shadow: 1px 1px 0 #fff,-1px -1px 0 #fff,1px -1px 0 #fff,-1px 1px 0 #fff;
            -webkit-text-stroke: .5px white;
        }
        .modern-card {
            background: #ffffff;
            border-radius: 1rem;
            border: 1px solid #e9edf5;
            box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
        }
        .stats-page .modern-card {
            padding: 2rem !important;
        }
        .stats-page .modern-card .position-relative.mb-4 {
            margin-bottom: 1.35rem !important;
            padding-top: 0.3rem;
            padding-inline: 0.35rem;
        }
        .stats-page .modern-card .position-relative.mb-3 {
            margin-bottom: 1rem !important;
            padding-top: 0.2rem;
            padding-inline: 0.35rem;
        }
        .stats-page .modern-card .chart-container {
            margin-top: 1rem !important;
            padding: 1rem 1.1rem 1.1rem 1.1rem;
            border-radius: 1rem;
        }
.stats-page .modern-card .stats-mt-8 {
    margin-top: 2rem !important;
}

/* Budget section: keep breathing room like original (less edge-tight) */
.stats-page .stats-budget-wrap .section-title {
    margin-bottom: 1.25rem !important;
}

.stats-page .stats-budget-wrap > .small {
    margin-bottom: 1.6rem !important;
    padding-inline: 0.35rem;
}

.stats-page .stats-budget-wrap > .d-grid {
    gap: 2rem !important;
}

.stats-page .stats-budget-wrap > .d-grid > .bg-white.rounded-4 {
    padding: 2rem !important;
}

.stats-page .stats-budget-wrap > .d-grid > .bg-white.rounded-4 > h3 {
    margin-bottom: 1.5rem !important;
}

.stats-page .stats-budget-wrap .stats-mb-6 {
    margin-bottom: 1.35rem !important;
}

.stats-page .stats-budget-wrap .d-grid.u_cols_1.u_rs_grid_cols_2 {
    gap: 1rem !important;
}
        .stat-purple-box {
            background: linear-gradient(135deg, #5b2a69 0%, #4a2358 100%);
            border: 1px solid rgba(255, 255, 255, 0.6);
            color: #ffffff;
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 10px 25px rgba(15, 23, 42, 0.12);
        }
        .stat-purple-box .text-slate-900 {
            color: #ffffff;
        }
        .stat-purple-box p.stats-accent-text {
            color: rgba(255, 255, 255, 0.9);
        }
        .op-legend {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px 24px;
            font-size: 0.78rem;
            color: #64748b;
            line-height: 1.35;
            max-width: 620px;
            margin: 0 auto;
        }
        .op-legend-item {
            display: flex;
            align-items: flex-start;
            gap: 8px;
            min-width: 0;
            justify-content: space-between;
        }
        .op-legend-item span:last-child {
            word-break: break-word;
        }
        .op-legend-value {
            color: #0f172a;
            font-weight: 700;
            white-space: nowrap;
            margin-left: 8px;
        }
        .policy-chart-layout {
            display: flex;
            align-items: flex-start;
            gap: 28px;
        }
        .op-donut-layout {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 28px;
            flex-wrap: wrap;
        }
        .op-chart-wrap {
            width: 320px;
            max-width: 100%;
            aspect-ratio: 1 / 1;
            position: relative;
        }
        .op-side-legend {
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-width: 140px;
            max-width: 220px;
            color: #0f172a;
            font-weight: 700;
            font-size: 0.95rem;
            line-height: 1.3;
        }
        .op-side-item {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .op-side-value {
            color: #0f172a;
            font-weight: 800;
        }
        .policy-side-legend {
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-width: 140px;
            max-width: 220px;
            align-items: flex-start;
            color: #0f172a;
            font-weight: 700;
            font-size: 0.95rem;
            line-height: 1.3;
        }
        .policy-side-legend-item {
            display: flex;
            align-items: center;
            gap: 10px;
            white-space: normal;
        }
        .policy-label-legend {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 6px 20px;
            font-size: 0.8rem;
            color: #475569;
            line-height: 1.3;
            justify-items: start;
        }
        .policy-label-item {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .policy-label-item span:last-child {
            word-break: break-word;
            white-space: normal;
            line-height: 1.25;
        }
@media (max-width: 640px) {
    .op-legend {
        grid-template-columns: 1fr;
        gap: 8px;
        font-size: 0.76rem;
    }
    .policy-label-legend {
        grid-template-columns: 1fr;
        gap: 6px;
        font-size: 0.76rem;
        justify-items: start;
    }
}
.op-legend-mobile {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 8px;
    justify-items: center;
    margin-top: 12px;
    color: #0f172a;
    font-weight: 700;
}
.op-legend-mobile-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.op-legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    display: inline-block;
}
.op-legend-value {
    font-size: 1.05rem;
}
.op-legend-unit {
    color: #64748b;
    font-weight: 600;
    font-size: 0.95rem;
}
        .digit-inline {
            display: flex;
            align-items: baseline;
            justify-content: center;
            gap: 0.5rem;
        }
        .digit-inline-number {
            font-size: 2.75rem;
            font-weight: 800;
            line-height: 1;
            color: #ffffff;
        }
        .digit-inline-label {
            font-size: 1rem;
            font-weight: 700;
            color: rgba(255, 255, 255, 0.85);
        }
        @media (min-width: 768px) {
            .digit-inline-number {
                font-size: 3.25rem;
            }
            .digit-inline-label {
                font-size: 1.1rem;
            }
        }
        .shadow-card {
            box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
        }
        .chart-container {
            position: relative;
            height: 300px;
            width: 100%;
            border-radius: 0.9rem;
            border: 1px solid #eef1f7;
            background: #fbfcff;
            padding: 10px;
            box-sizing: border-box;
        }
        .chart-container canvas {
            width: 100% !important;
            height: 100% !important;
            max-width: 100%;
            display: block;
        }
        .chart-container-tall {
            height: 400px;
        }
        .section-title {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            margin-bottom: 1rem;
            font-weight: 700;
            color: #0f172a;
            letter-spacing: -0.01em;
        }
        .section-title .dot {
            width: 8px;
            height: 8px;
            border-radius: 999px;
            background: #5b2a69;
            box-shadow: 0 0 0 6px rgba(91, 42, 105, 0.08);
        }
        .section-sub {
            color: #6b7280;
            font-size: 0.95rem;
            margin-top: 0.25rem;
        }
        .card-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            margin-top: 0.5rem;
        }
        .region-tag {
            display: inline-flex;
            align-items: center;
            padding: 0.25rem 0.6rem;
            border-radius: 999px;
            background: #f1f5f9;
            color: #0f172a;
            font-size: 0.85rem;
            font-weight: 600;
            border: 1px solid #e2e8f0;
        }
        .year-select {
            border: 1px solid #e2e8f0;
            background: #ffffff;
            color: #0f172a;
            border-radius: 0.5rem;
            padding: 0.35rem 0.6rem;
            font-size: 0.85rem;
        }
        .year-row {
            display: contents;
        }
        .is-hidden {
            display: none !important;
        }
        .stats-trend-table-wrap {
            margin-top: 1rem;
            overflow-x: auto;
        }
        .stats-trend-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.85rem;
            min-width: 640px;
        }
        .stats-trend-table th,
        .stats-trend-table td {
            border: 1px solid #e2e8f0;
            padding: 0.5rem 0.45rem;
            text-align: center;
        }
        .stats-trend-table th {
            background: #f8fafc;
            color: #334155;
            font-weight: 700;
        }
        .stats-trend-table td:first-child,
        .stats-trend-table th:first-child {
            text-align: left;
            white-space: nowrap;
        }
        .stats-trend-table tbody tr:nth-child(even) {
            background: #f9fafb;
        }
        @media (max-width: 768px) {
            .stats-page .modern-card {
                padding: 1.1rem !important;
            }
            .stats-page .modern-card .position-relative.mb-4,
            .stats-page .modern-card .position-relative.mb-3 {
                padding-inline: 0.1rem;
                padding-top: 0;
            }
            .stats-page .modern-card .chart-container {
                padding: 0.75rem;
            }
            .stats-trend-grid {
                grid-template-columns: 1fr !important;
            }
            .stats-trend-grid > * {
                min-width: 0;
            }
            .stats-trend-cards {
                display: grid;
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 10px;
            }
            .stats-trend-cards .js-year-card[data-year="total"] {
                grid-column: 1 / -1;
            }
            .chart-container.chart-container-tall {
                height: 280px;
            }
            .policy-chart-layout {
                flex-direction: column;
                align-items: stretch;
            }
            .policy-side-legend {
                flex-direction: row;
                flex-wrap: wrap;
                gap: 10px 18px;
                justify-content: center;
                min-width: 0;
            }
            .op-donut-layout {
                gap: 16px;
            }
            .op-side-legend {
                flex-direction: row;
                flex-wrap: wrap;
                justify-content: center;
                max-width: none;
                font-size: 0.9rem;
            }

            .stats-page .stats-budget-wrap > .small {
                margin-bottom: 1.1rem !important;
                padding-inline: 0;
            }
            .stats-page .stats-budget-wrap > .d-grid {
                gap: 1.25rem !important;
            }
            .stats-page .stats-budget-wrap > .d-grid > .bg-white.rounded-4 {
                padding: 1.1rem !important;
            }
            .stats-page .stats-budget-wrap > .d-grid > .bg-white.rounded-4 > h3 {
                margin-bottom: 1rem !important;
            }
            .stats-page .stats-budget-wrap .stats-mb-6 {
                margin-bottom: 1rem !important;
            }
        }
@media (max-width: 420px) {
            .stats-trend-cards {
                grid-template-columns: 1fr;
            }
            .stats-trend-cards .js-year-card[data-year="total"] {
                grid-column: auto;
            }
        }
