:root {
    --primary-blue: #003366;
    --secondary-blue: #00509d;
    --accent-blue: #00a8e8;
    --light-bg: #f0f5f9;
    --white: #ffffff;
    --text-dark: #003366;
    --text-light: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.4);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

a {
    text-decoration: none;
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #e9eff5;
    color: #003366;
    line-height: 1.4;
    font-size: 12.8px;
    height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Strict 1-page fit */
}

.dashboard-header {
    background: #002b5c;
    color: var(--white);
    padding: 0.25rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 44px;
}

.header-left { display: flex; align-items: center; gap: 0.5rem; }
.logo img { height: 40px; background: white; padding: 2px; border-radius: 4px; }
.title h1 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.1;
}

.title p {
    font-size: 0.7rem;
    opacity: 0.8;
    line-height: 1.1;
}

.nav-tabs {
    display: flex;
    gap: 0.2rem;
    margin-top: 0.2rem;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.55rem;
    font-weight: 600;
    min-width: 80px;
    text-decoration: none;
}

.nav-tab i { 
    font-size: 0.9rem; 
    margin-bottom: 2px; 
}

.nav-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-tab.active { 
    background: #004d99; 
    color: white; 
    box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
}

.nav-tab.active i {
    color: #00a8e8;
}

.header-right { display: flex; align-items: center; gap: 1.5rem; }
.data-info { font-size: 0.65rem; display: flex; align-items: center; gap: 0.5rem; color: white; }

/* Main Content */
.main-content {
    padding: 0.25rem 0.6rem;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.section-container {
    margin-bottom: 0.15rem;
}

.section-title {
    color: #003366;
    font-size: 0.68rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
    display: block;
    width: 100%;
}

.grid-macro {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.4rem;
}

.macro-card {
    background: linear-gradient(135deg, #ffffff 0%, #dceeff 100%);
    padding: 0.3rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,51,102,0.1);
    border: 1px solid #cce3f5;
}

.macro-card .top-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.macro-card .icon-box {
    width: 28px;
    height: 28px;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

.macro-card .label { font-size: 0.6rem; color: #475569; font-weight: 700; text-transform: uppercase; line-height: 1.1; }
.macro-card .year { font-size: 0.55rem; color: #94a3b8; }
.macro-card .value { font-size: 1.3rem; font-weight: 800; color: #003366; margin: 0.2rem 0; line-height: 1; }
.macro-card .comparison { display: flex; justify-content: space-between; font-size: 0.55rem; color: #64748b; border-top: 1px solid rgba(0,0,0,0.05); padding-top: 3px; }

/* Layout Rows */
.row {
    display: flex;
    gap: 0.25rem;
    flex: 1;
    overflow: hidden;
}

.card {
    background: linear-gradient(180deg, #ffffff 0%, #e8f4ff 100%);
    border-radius: 4px;
    padding: 0.35rem;
    box-shadow: 0 1px 4px rgba(0, 43, 92, 0.1);
    border: 1px solid #b3d7ff;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 0.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 0.2rem;
}

/* Tables */
table { width: 100%; border-collapse: collapse; }
.table-blue thead th { background: #003366; color: white; text-align: left; padding: 3px; font-size: 0.55rem; }
.table-blue td { padding: 1px 4px; font-size: 0.55rem; border-bottom: 1px solid #e2e8f0; }

.text-right { text-align: right; }
.status-up { color: #22c55e; }
.status-down { color: #ef4444; }

/* Profile Elements */
.stat-row { display: flex; justify-content: space-between; font-size: 0.65rem; margin-bottom: 3px; padding-bottom: 2px; border-bottom: 1px solid #f1f5f9; }
.top-sectors h5 { font-size: 0.6rem; color: #1e40af; margin-bottom: 0.3rem; text-transform: uppercase; }
.sector-row { display: flex; justify-content: space-between; font-size: 0.6rem; margin-bottom: 2px; }

/* Admin Modern Redesign */
.admin-sidebar {
    width: 180px;
    background: #002244;
    color: #f8fafc;
    padding: 1rem 0.5rem;
}

.sidebar-menu a {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    color: #94a3b8;
    border-radius: 6px;
    margin-bottom: 0.2rem;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background: #003366;
    color: #00a8e8;
}

.admin-header {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 0.75rem 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.admin-main {
    background: #f8fafc;
    overflow-y: auto;
}

.form-group label {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.form-group input, .form-group select, .form-group textarea {
    font-size: 0.85rem;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.btn-feedback, .btn-more {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

/* Charts adjustment */
.apexcharts-canvas { margin: 0 auto; }

/* ==========================================================================
   DYNAMIC MULTI-DEVICE RESPONSIVE LAYOUT (MOBILE & TABLET COMPATIBILITY)
   ========================================================================== */
@media (max-width: 1200px) {
    /* Global scrollable resets — satu scrollbar di body saja */
    html {
        height: auto !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
    
    body {
        height: auto !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        line-height: 1.5 !important;
    }

    /* Pastikan semua elemen tidak lebih lebar dari viewport */
    *, *::before, *::after {
        max-width: 100%;
        box-sizing: border-box;
    }
    /* Pengecualian: elemen yang memang boleh lebih lebar (tabel dengan hscroll) */
    table, .apbn-kl-table, .apbn-satker-table,
    .tkd-table-wrap table { max-width: none; }
    
    .main-content {
        overflow: visible !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 10px !important;
        gap: 15px !important;
        /* hapus flex: 1 agar tidak paksa full-height */
        flex: none !important;
    }
    
    /* Override hidden/fixed heights — hanya wrapper konten utama, bukan tabel/chart */
    .keuangan-container,
    .exec-summary-wrapper,
    .profil-pemda-container,
    .realisasi-apbd-container,
    .tkd-transfer-container,
    .data-wilayah-container,
    /* ── Konsolidasi wrappers ── */
    .cons-wrapper,
    .apbd-cons-wrapper,
    .tkd-cons-wrapper,
    .apbn-cons-wrapper,
    .apbn-grid-bottom,
    .apbn-right-stack,
    .apbn-card,
    .apbn-right-card,
    .apbn-chart-card,
    .apbn-satker-card,
    .apbn-chart-area,
    .tkd-grid-top,
    .tkd-grid-bottom,
    .tkd-card {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        flex: none !important;
        min-height: 0 !important;
    }
    
    /* Header layout optimization */
    .dashboard-header {
        height: auto !important;
        flex-direction: column !important;
        padding: 12px 15px !important;
        gap: 12px !important;
        align-items: center !important;
    }
    
    .header-left {
        flex-direction: column !important;
        text-align: center !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    .header-left .logo img {
        height: 48px !important;
    }
    
    .header-left .title h1 {
        font-size: 1.1rem !important;
    }
    
    .header-left .title p {
        font-size: 0.8rem !important;
    }
    
    /* Navigation tabs responsive wraps */
    .nav-tabs {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        height: 38px !important;
        max-height: 38px !important;
        overflow: hidden !important;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border-top: none !important;
        padding-top: 0 !important;
        margin: 5px 0 !important;
        background: rgba(0, 0, 0, 0.2) !important;
        border-radius: 8px !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
    }
    
    .nav-tabs::before {
        content: "☰   MENU NAVIGASI";
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 36px !important;
        width: 100% !important;
        color: #ffffff !important;
        font-size: 0.75rem !important;
        font-weight: 800 !important;
        letter-spacing: 1px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        cursor: pointer !important;
        transition: background 0.2s ease !important;
    }
    
    /* Hover/Focus/Tap to expand burger menu */
    .nav-tabs:hover,
    .nav-tabs:active,
    .nav-tabs:focus-within {
        max-height: 500px !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .nav-tabs:hover::before,
    .nav-tabs:active::before,
    .nav-tabs:focus-within::before {
        background: rgba(255, 255, 255, 0.15) !important;
        content: "✕   TUTUP MENU";
    }
    
    .nav-tab {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: calc(100% - 16px) !important;
        margin: 5px 8px !important;
        padding: 8px 12px !important;
        font-size: 0.7rem !important;
        background: rgba(255, 255, 255, 0.04) !important;
        border-radius: 6px !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
        gap: 10px !important;
        text-align: left !important;
    }
    
    .nav-tab i {
        font-size: 0.95rem !important;
        width: 20px !important;
        text-align: center !important;
        margin-bottom: 0 !important;
    }
    
    .header-right {
        width: 100% !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding-top: 10px !important;
        gap: 10px !important;
    }

    /* Core structural layout stack */
    .row {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
        gap: 15px !important;
    }
    
    .col-2-3, .col-1-3 {
        flex: none !important;
        width: 100% !important;
        height: auto !important;
    }
    
    .box-inner {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
        gap: 15px !important;
    }
    
    .card {
        height: auto !important;
        min-height: auto !important;
        margin-bottom: 5px !important;
        padding: 12px !important;
    }
    
    /* Component grids: Executive Summary */
    .exec-top-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .ex-banner-card {
        padding: 15px !important;
    }
    
    .ex-banner-card p {
        font-size: 0.8rem !important;
    }
    
    .kpi-cards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    
    .exec-content-row {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .exec-column-card {
        height: auto !important;
        min-height: auto !important;
    }
    
    /* Component grids: Keuangan / APBD / POSKAS */
    .keuangan-container {
        height: auto !important;
        overflow: visible !important;
        padding: 8px !important;
        gap: 12px !important;
    }
    
    /* Target inline grid rows dynamically */
    div[style*="grid-template-columns: repeat(5, 1fr)"],
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(6, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
        height: auto !important;
        gap: 10px !important;
    }
    
    div[style*="grid-template-columns: 320px 1fr 1fr"],
    div[style*="grid-template-columns: 1.6fr 1fr"],
    div[style*="grid-template-columns: 1fr 1.2fr 0.8fr"],
    div[style*="grid-template-columns: 1.5fr 0.75fr 0.75fr"] {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 15px !important;
    }
    
    /* Data Wilayah adjustments */
    div[style*="position: absolute; bottom: 12px; left: 12px; z-index: 1000"] {
        position: relative !important;
        bottom: 0 !important;
        left: 0 !important;
        grid-template-columns: 1fr !important;
        margin-top: 10px !important;
        width: 100% !important;
    }
    
    .grid-macro {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    
    /* === Realisasi APBD Tab Responsive Overrides === */
    .realisasi-container {
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        gap: 14px !important;
    }
    
    /* KPI cards: 2 columns on tablet */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    /* Dashboard rows (table+chart rows) stack vertically */
    .dashboard-row,
    .dashboard-row-fluid {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        gap: 14px !important;
        flex: none !important;
        width: 100% !important;
        overflow: visible !important;
    }
    
    /* All columns in realisasi tab become full-width */
    .col-5,
    .col-7,
    .dashboard-row > div[style*="flex: 1.25"],
    .dashboard-row > div[style*="flex: 0.9"],
    .dashboard-row > div[style*="flex: 1.15"] {
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
    }
    
    /* Ringkasan, Detail Belanja & OPD containers: allow scrolling */
    .ringkasan-apbd-container,
    .detail-belanja-container {
        overflow: auto !important;
        max-height: 320px !important;
        flex: none !important;
    }
    
    /* Chart area needs a defined height on mobile */
    #viz-chart-wrapper {
        position: relative !important;
        height: 260px !important;
        min-height: 260px !important;
        flex: none !important;
    }
    
    /* OPD table wrapper: scrollable on mobile */
    .dashboard-row > div[style*="flex: 1.15"] > .card > div[style*="overflow-y: auto"] {
        max-height: 280px !important;
        overflow-y: auto !important;
    }
    
    /* SKPD top/bottom panels: allow natural height */
    .dashboard-row-fluid .col-7 > .card > div[style*="display: flex; gap: 0.5rem"] {
        flex-direction: column !important;
        gap: 12px !important;
        height: auto !important;
    }
    
    .dashboard-row-fluid .col-7 > .card > div[style*="display: flex; gap: 0.5rem"] > div {
        height: auto !important;
        min-height: 200px !important;
        max-height: 280px !important;
        overflow-y: auto !important;
    }
    
    /* Analisis ringkas cards become column */
    div[style*="display: flex; gap: 0.4rem; margin-bottom: 0.4rem"] {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    /* === Ekonomi & Fiskal Tab Responsive Overrides === */
    div[style*="display: flex; gap: 0.4rem; flex: 1.25"],
    div[style*="display: flex; gap: 0.4rem; flex: 1.45"],
    div[style*="display: flex; gap: 0.4rem; flex: 1.25; min-height: 0; align-items: stretch;"],
    div[style*="display: flex; gap: 0.4rem; flex: 1.45; min-height: 0; align-items: stretch;"] {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        gap: 12px !important;
    }
    
    div[style*="flex: 1; display: flex; gap: 0.5rem; min-height: 0;"],
    div[style*="flex: 1; display: flex; gap: 0.5rem; min-height: 0"] {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        gap: 10px !important;
    }
    
    div[style*="flex: 1.25; position: relative"],
    div[style*="flex: 1.25; position: relative;"] {
        flex: none !important;
        width: 100% !important;
        height: 260px !important;
    }
    
    div[style*="flex: 0.75; background: #f0fdfa"],
    div[style*="flex: 0.75; background: #f0fdfa;"] {
        flex: none !important;
        width: 100% !important;
        height: auto !important;
    }
    
    div[style*="flex: 1; display: flex; gap: 0.2rem; min-height: 110px"] {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        gap: 12px !important;
    }
    
    div[style*="flex: 1; position: relative; height: 100%"] {
        flex: none !important;
        width: 100% !important;
        height: 200px !important;
    }
    
    div[style*="flex: 0.8; overflow-y: auto"] {
        flex: none !important;
        width: 100% !important;
        max-height: 150px !important;
    }

    /* === TKD & Transfer Tab Responsive Overrides === */
    .tkd-container {
        height: auto !important;
        flex: none !important;
        overflow: visible !important;
    }
    .tkd-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        height: auto !important;
        gap: 10px !important;
    }
    .tkd-main-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 15px !important;
        overflow: visible !important;
    }
    .tkd-column {
        flex: none !important;
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
    }
    .tkd-source-switcher {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        height: auto !important;
    }
    .tkd-source-buttons {
        flex-direction: column !important;
        width: 100% !important;
        gap: 5px !important;
        padding: 5px !important;
    }
    .tkd-source-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    .tkd-gauges-grid {
        flex: none !important;
        height: auto !important;
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .tkd-gauge-card {
        height: 125px !important;
        padding: 8px !important;
        justify-content: flex-start !important;
    }
    .tkd-gauge-card [id^="gauge-"] {
        height: 95px !important;
        width: 100% !important;
        margin-top: 0 !important;
    }
    .tkd-table-card {
        flex: none !important;
        height: auto !important;
    }
    .tkd-table-card table {
        width: 100% !important;
        table-layout: auto !important;
    }
    .tkd-table-card table th,
    .tkd-table-card table td {
        font-size: 0.72rem !important;
        padding: 6px 4px !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    .tkd-table-wrapper {
        max-height: 350px !important;
        overflow-y: auto !important;
        overflow-x: auto !important;
        width: 100% !important;
    }
    .tkd-chart-detail-card {
        flex: none !important;
        height: auto !important;
    }
    #chart-tkd-detail {
        height: 280px !important;
        min-height: 280px !important;
        width: 100% !important;
    }
    .tkd-analysis-card {
        flex: none !important;
        height: auto !important;
    }
    .tkd-analysis-wrapper {
        max-height: 200px !important;
        overflow-y: auto !important;
        font-size: 0.75rem !important;
        line-height: 1.6 !important;
    }
    .tkd-recom-card {
        flex: none !important;
        height: auto !important;
    }
    .tkd-recom-wrapper {
        max-height: 200px !important;
        overflow-y: auto !important;
        font-size: 0.75rem !important;
        line-height: 1.6 !important;
    }
    .tkd-chart-radial-card {
        flex: none !important;
        height: auto !important;
    }
    #chart-tkd-radial {
        height: 280px !important;
        min-height: 280px !important;
        width: 100% !important;
    }
    .tkd-rankings-card {
        flex: none !important;
        height: auto !important;
    }
    .tkd-rankings-wrapper {
        gap: 12px !important;
        margin-top: 8px !important;
    }

    /* === Data Wilayah Tab Responsive Overrides === */
    .wilayah-container {
        height: auto !important;
        flex: none !important;
        overflow: visible !important;
    }
    .wilayah-kpi-row {
        grid-template-columns: repeat(3, 1fr) !important;
        height: auto !important;
        gap: 8px !important;
    }
    .wilayah-admin-row {
        grid-template-columns: repeat(3, 1fr) !important;
        height: auto !important;
        gap: 8px !important;
    }
    .wilayah-main-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        gap: 15px !important;
        overflow: visible !important;
    }
    .wilayah-map-card {
        flex: none !important;
        height: auto !important;
        min-height: auto !important;
    }
    #map-wilayah {
        height: 400px !important;
        min-height: 400px !important;
        width: 100% !important;
    }
    .wilayah-summary-card {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        margin-top: 10px !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        background: #0f172a !important;
    }
    .wilayah-map-controls {
        position: relative !important;
        bottom: 0 !important;
        left: 0 !important;
        margin-top: 10px !important;
        width: 100% !important;
        grid-template-columns: repeat(3, 1fr) !important;
        z-index: 10 !important;
    }
    .btn-map-control {
        width: 100% !important;
    }
    .wilayah-table-card {
        flex: none !important;
        height: auto !important;
    }
    .wilayah-table-wrapper {
        max-height: 300px !important;
        overflow-y: auto !important;
    }
    .wilayah-charts-card {
        flex: none !important;
        height: auto !important;
    }
    .wilayah-livelihood-card {
        flex: none !important;
        height: auto !important;
        min-height: auto !important;
    }
    #chart-livelihood {
        height: 280px !important;
        min-height: 280px !important;
    }
    .wilayah-analysis-card {
        flex: none !important;
        height: auto !important;
    }
    .wilayah-analysis-wrapper {
        max-height: 200px !important;
        overflow-y: auto !important;
    }

    /* === Profil Pemda Tab Responsive Overrides === */
    .profil-container {
        height: auto !important;
        flex: none !important;
        overflow: visible !important;
    }
    .pp-kpi {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    .pp-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
        gap: 15px !important;
    }
    .pp-column {
        flex: none !important;
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
    }
    .pp-card {
        flex: none !important;
        height: auto !important;
    }
    .pj-list-wrapper {
        max-height: 320px !important;
        overflow-y: auto !important;
    }
    .opd-tbl-wrapper {
        max-height: 400px !important;
        overflow-y: auto !important;
    }
    .tkd-section-title {
        font-size: 0.78rem !important;
        margin-top: 6px !important;
        margin-bottom: 6px !important;
    }
}

@media (max-width: 767px) {
    /* Tablet & Phone specific fine-tuning */
    .wilayah-kpi-row,
    .wilayah-admin-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .kpi-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-macro {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    div[style*="grid-template-columns: repeat(5, 1fr)"],
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns: repeat(6, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    
    .daily-cash-grid {
        grid-template-columns: 1fr !important;
    }
    
    .header-right {
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    .header-right button, .header-right .data-info {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
    }
    
    /* Realisasi APBD: 1 column KPI on phone */
    .kpi-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Font size normalization for small screens */
    .kpi-title { font-size: 0.65rem !important; }
    .kpi-value { font-size: 1.1rem !important; }
    .kpi-subtext { font-size: 0.6rem !important; }
    
    /* Table text larger on mobile for readability */
    .table-premium th,
    .table-premium td {
        font-size: 0.7rem !important;
        padding: 4px 6px !important;
    }

    /* Profil Pemda: KPI adjustments on tablet */
    .pp-kpi {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Footer: tidak boleh punya scroll sendiri */
    footer {
        overflow: visible !important;
        height: auto !important;
        flex-shrink: 0 !important;
    }
}

@media (max-width: 480px) {
    /* Mobile specific optimizations */
    .kpi-cards-grid {
        grid-template-columns: 1fr !important;
    }
    
    .grid-macro {
        grid-template-columns: 1fr !important;
    }

    .wilayah-kpi-row,
    .wilayah-admin-row {
        grid-template-columns: 1fr !important;
    }

    /* TKD kpi row stacks on mobile */
    .tkd-kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* TKD mini gauges stack on extra small mobile */
    .tkd-gauges-grid {
        grid-template-columns: 1fr !important;
    }

    /* Profil Pemda: KPI adjustments on extra small mobile */
    .pp-kpi {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Final mobile override for ringkasan charts. Keep this after generic mobile resets. */
@media (max-width: 1200px) {
    .ringkasan-apbd-box,
    .ringkasan-tkd-box {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .ringkasan-apbd-side {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .ringkasan-chart-card {
        display: block !important;
        flex: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 12px !important;
        overflow: hidden !important;
        clear: both !important;
    }

    .ringkasan-chart-wrapper {
        display: block !important;
        position: relative !important;
        flex: none !important;
        width: 100% !important;
        height: 300px !important;
        min-height: 300px !important;
        overflow: hidden !important;
    }

    .ringkasan-chart {
        display: block !important;
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        height: 300px !important;
        min-height: 300px !important;
        overflow: hidden !important;
    }

    .ringkasan-chart .apexcharts-canvas,
    .ringkasan-chart svg {
        max-width: 100% !important;
    }
}

@media (max-width: 768px) {
    .ringkasan-chart-wrapper,
    .ringkasan-chart {
        height: 290px !important;
        min-height: 290px !important;
    }
}

@media (max-width: 480px) {
    .ringkasan-chart-wrapper,
    .ringkasan-chart {
        height: 280px !important;
        min-height: 280px !important;
    }
}
