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

:root {
    --primary: #1a4f8a;
    --primary-dk: #0d3665;
    --accent: #e63946;
    --light-bg: #f4f6f9;
    --border: #dde1e7;
    --text: #1d2939;
    --text-muted: #667085;
    --white: #ffffff;
    --footer-top: #2d3748;
    --footer-bot: #1a202c;
    --shadow: 0 2px 12px rgba(0, 0, 0, .10);
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--light-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── NAVBAR ─────────────────────────────────── */
.navbar {
    background: var(--white);
    border-bottom: 3px solid var(--primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 1rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-flag {
    font-size: 1.6rem;
    line-height: 1;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -.5px;
}

.brand-name span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-size: .875rem;
    font-weight: 500;
    padding: .45rem .85rem;
    border-radius: 6px;
    transition: background .2s, color .2s;
}

.nav-links a:hover,
.nav-links a.active {
    background: var(--primary);
    color: var(--white);
}

.nav-filter {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.nav-filter label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-filter select {
    font-family: inherit;
    font-size: .85rem;
    padding: .35rem .75rem;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color .2s;
}

.nav-filter select:focus {
    border-color: var(--primary);
}

/* hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .3s;
}

/* ── MAIN ────────────────────────────────────── */
main {
    flex: 1;
}

/* hero strip */
.hero-strip {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dk) 100%);
    color: var(--white);
    padding: 1rem 1.5rem;
}

.hero-strip-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
}

.hero-strip h1 {
    font-size: 1.1rem;
    font-weight: 600;
    opacity: .95;
}

.hero-strip p {
    font-size: .8rem;
    opacity: .75;
    margin-top: .15rem;
}

.stat-chips {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}

.chip {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 20px;
    padding: .3rem .85rem;
    font-size: .78rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.chip span {
    color: #ffd166;
    margin-right: .3rem;
}

/* ── CONTENT AREA ───────────────────────────── */
.content-area {
    max-width: 1280px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    /* Kolom kiri (peta+chart) fleksibel, kolom kanan (sidebar) tetap 360px */
    grid-template-columns: 1fr 360px;
    gap: 1.25rem;
    align-items: start;
}

/* Kolom kiri: peta di atas, chart di bawah */
.main-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
    /* cegah overflow pada grid */
}

/* MAP CARD */
.map-card {
    background: var(--white);
    border-radius: 0px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.map-card-header {
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.map-card-header h2 {
    font-size: .95rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: .4rem;
}

.map-card-header h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

.map-hint {
    font-size: .76rem;
    color: var(--text-muted);
    background: var(--light-bg);
    padding: .2rem .6rem;
    border-radius: 4px;
}

#map {
    height: 520px;
    width: 100%;
}

/* SIDEBAR */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.info-card {
    background: var(--white);
    border-radius: 0px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.info-card-head {
    background: var(--primary);
    color: var(--white);
    padding: .75rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.info-card-body {
    padding: 1rem;
}

/* placeholder */
.placeholder-box {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.placeholder-box .ico {
    font-size: 2.5rem;
    margin-bottom: .5rem;
}

.placeholder-box p {
    font-size: .82rem;
    line-height: 1.5;
}

/* wilayah info */
.wilayah-info {
    display: none;
}

.wilayah-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: .15rem;
}

.wilayah-badge {
    display: inline-block;
    background: var(--light-bg);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 600;
    padding: .2rem .6rem;
    border-radius: 2px;
    margin-bottom: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* filter tahun inside sidebar */
.tahun-filter {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.tahun-btn {
    font-size: .75rem;
    font-weight: 600;
    padding: .25rem .6rem;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    background: var(--white);
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s;
}

.tahun-btn:hover,
.tahun-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.data-table th {
    background: var(--light-bg);
    padding: .45rem .6rem;
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--light-bg);
}

.data-table .nilai {
    font-weight: 600;
    color: var(--primary);
    text-align: right;
}

.data-table .variabel-name {
    font-weight: 500;
}

.data-table .variabel-desc {
    font-size: .72rem;
    color: var(--text-muted);
}

.loading-row {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: .82rem;
}

/* quick stats */
.quick-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
    margin-top: .75rem;
}

.stat-box {
    background: var(--light-bg);
    border-radius: 4px;
    padding: .6rem .75rem;
    text-align: center;
}

.stat-box .stat-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-box .stat-lbl {
    font-size: .68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-top: .1rem;
}

/* legend */
.legend-card .info-card-body {
    padding: .75rem 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .3rem;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── CHART CARD (sekarang di dalam .main-col, bukan section terpisah) ── */
.chart-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 0px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chart-card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dk) 100%);
    color: var(--white);
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .6rem;
}

.chart-card-header h3 {
    font-size: .95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.chart-header-controls {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.chart-type-btn {
    background: rgba(255, 255, 255, .15);
    border: 1.5px solid rgba(255, 255, 255, .4);
    color: var(--white);
    font-size: .75rem;
    font-weight: 600;
    padding: .28rem .75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
}

.chart-type-btn.active,
.chart-type-btn:hover {
    background: rgba(255, 255, 255, .3);
    border-color: var(--white);
}

.chart-select {
    background: rgba(255, 255, 255, .15);
    border: 1.5px solid rgba(255, 255, 255, .4);
    color: var(--white);
    font-size: .75rem;
    padding: .28rem .6rem;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.chart-select option {
    background: var(--primary-dk);
}

/* chart body = sidebar kiri + canvas kanan */
.chart-body {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 380px;
}

.chart-sidebar {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-panel {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.chart-panel:last-child {
    border-bottom: none;
    flex: 1;
}

.chart-panel-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: .6rem;
}

/* Variabel checklist */
.var-list {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    max-height: 180px;
    overflow-y: auto;
}

.var-item {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .8rem;
    padding: .2rem .3rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}

.var-item:hover {
    background: var(--light-bg);
}

.var-item input[type=checkbox] {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    cursor: pointer;
}

.var-item label {
    cursor: pointer;
    line-height: 1.3;
    color: var(--text);
}

/* Kategori group header di var-list */
.var-group-header {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .55px;
    color: var(--primary);
    background: #eef3fa;
    padding: .22rem .5rem;
    border-radius: 4px;
    margin-top: .45rem;
    margin-bottom: .1rem;
    opacity: .9;
}

.var-group-header:first-child {
    margin-top: 0;
}

/* Kategori group row di data-table */
.data-table tr.table-group-header td {
    background: linear-gradient(90deg, #eef3fa 0%, #f5f8fd 100%);
    color: var(--primary);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: .32rem .6rem;
    border-bottom: 1.5px solid #c8d8ed;
    border-top: 1px solid #dde6f1;
}

.data-table tr.table-group-header:first-child td {
    border-top: none;
}

/* Wilayah chips */
.wilayah-chips {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-height: 160px;
    overflow-y: auto;
}

.w-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .3rem .5rem;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 500;
    color: var(--white);
    gap: .4rem;
}

.w-chip-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.w-chip-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, .7);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .1rem;
    flex-shrink: 0;
    transition: color .15s;
}

.w-chip-remove:hover {
    color: var(--white);
}

.chart-hint {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .5rem;
    line-height: 1.4;
}

/* Chart canvas area */
.chart-area {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chart-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    gap: .6rem;
}

.chart-placeholder .chart-ico {
    font-size: 3rem;
}

.chart-placeholder p {
    font-size: .85rem;
    line-height: 1.6;
}

.chart-canvas-wrap {
    flex: 1;
    position: relative;
    min-height: 320px;
}

/* ── FOOTER ──────────────────────────────────── */
footer {
    margin-top: 2rem;
}

.footer-top {
    background: var(--footer-top);
    color: #e2e8f0;
    padding: 1rem 1.5rem;
}

.footer-top-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.footer-brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -.3px;
}

.footer-brand-name span {
    color: #ffd166;
}

.footer-top-links {
    display: flex;
    gap: .5rem 1.25rem;
    flex-wrap: wrap;
    list-style: none;
}

.footer-top-links a {
    text-decoration: none;
    color: #a0aec0;
    font-size: .8rem;
    transition: color .2s;
}

.footer-top-links a:hover {
    color: var(--white);
}

.footer-sep {
    color: #4a5568;
}

.footer-bot {
    background: var(--footer-bot);
    color: #718096;
    padding: 1.25rem 1.5rem;
}

.footer-bot-inner {
    max-width: 1280px;
    margin: 0 auto;
}

.footer-org {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #2d3748;
}

.footer-org-icon {
    background: var(--primary);
    color: var(--white);
    font-size: .75rem;
    font-weight: 800;
    padding: .4rem .5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.footer-org p {
    font-size: .8rem;
    line-height: 1.5;
}

.footer-org a {
    color: #63b3ed;
    text-decoration: none;
}

.footer-org a:hover {
    text-decoration: underline;
}

.footer-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .4rem .75rem;
    margin-bottom: .85rem;
}

.footer-links-grid a {
    color: #718096;
    font-size: .78rem;
    text-decoration: none;
    transition: color .2s;
}

.footer-links-grid a:hover {
    color: #a0aec0;
}

.footer-copy {
    font-size: .75rem;
    color: #4a5568;
    padding-top: .75rem;
    border-top: 1px solid #2d3748;
}

.footer-copy a {
    color: #63b3ed;
    text-decoration: none;
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 1024px) {
    .content-area {
        grid-template-columns: 1fr;
    }

    .main-col {
        width: 100%;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .info-card {
        flex: 1 1 300px;
    }

    #map {
        height: 420px;
    }

    .chart-body {
        grid-template-columns: 200px 1fr;
    }
}

@media (max-width: 900px) {
    .chart-body {
        grid-template-columns: 1fr;
    }

    .chart-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        flex-wrap: wrap;
    }

    .chart-panel {
        flex: 1 1 200px;
        border-bottom: none;
        border-right: 1px solid var(--border);
    }

    .chart-panel:last-child {
        border-right: none;
    }

    .chart-canvas-wrap {
        min-height: 280px;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        padding: .75rem;
        box-shadow: var(--shadow);
        border-top: 1px solid var(--border);
        z-index: 999;
    }

    .nav-links.open {
        display: flex;
    }

    .hamburger {
        display: flex;
    }

    .nav-filter {
        display: none;
    }

    .hero-strip-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .sidebar {
        flex-direction: column;
    }

    #map {
        height: 350px;
    }

    .footer-top-inner {
        flex-direction: column;
        align-items: flex-start;
    }

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

@media (max-width: 480px) {
    .navbar-inner {
        padding: 0 1rem;
    }

    .content-area {
        padding: 0 1rem;
    }

    #map {
        height: 280px;
    }
}