/* ====== Dasar & warna tema (--brand diatur dari menu Pengaturan) ====== */
:root {
    --brand-dark: color-mix(in srgb, var(--brand) 70%, #000);
    --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
    --bg: #f3f5f7;
    --line: #e5e8ec;
    --sidebar-w: 256px;
    --bs-body-font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    --bs-body-color: #1f2933;
}

body { background: var(--bg); font-size: .925rem; }
a { color: var(--brand); }

.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-dark);
}
.text-bg-primary { background: var(--brand) !important; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.page-link { color: var(--brand); }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 18%, transparent);
}
.form-label { font-weight: 500; font-size: .85rem; }

/* ====== Layout ====== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--sidebar-w); display: flex; flex-direction: column;
    background: var(--brand-dark); color: #fff;
    transition: transform .2s;
}
.brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none;
}
.brand img { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand strong { display: block; font-size: 1.1rem; letter-spacing: .02em; }
.brand small { display: block; font-size: .72rem; opacity: .7; line-height: 1.3; }

.menu { flex: 1; overflow-y: auto; padding: .5rem .75rem; }
.menu-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; margin: 1rem .75rem .4rem; }
.menu a {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; margin-bottom: 2px; border-radius: 8px;
    color: rgba(255, 255, 255, .78); text-decoration: none; font-weight: 500;
}
.menu a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.menu a.active { background: #fff; color: var(--brand-dark); }
.sidebar-foot { padding: 1rem 1.25rem; font-size: .72rem; opacity: .55; border-top: 1px solid rgba(255, 255, 255, .1); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .2s; }
.menu-toggle { width: 38px; height: 38px; padding: 0; font-size: 1.2rem; }
.sidebar-backdrop { display: none; }

/* Sidebar disembunyikan (desktop) — pilihan disimpan di localStorage */
@media (min-width: 992px) {
    .sidebar-hidden .sidebar { transform: translateX(-100%); }
    .sidebar-hidden .main { margin-left: 0; }
}

.topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.75rem; background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.user-btn { display: flex; align-items: center; gap: .6rem; border: 0; background: none; padding: .25rem; }
.user-btn strong { display: block; font-size: .85rem; line-height: 1.2; }
.user-btn small { display: block; font-size: .72rem; color: #6b7280; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand); font-weight: 700;
}

.content { flex: 1; padding: 1.5rem 1.75rem; }
.footer { padding: 1rem 1.75rem; font-size: .78rem; color: #8a94a0; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(0, 0, 0, .35); }
    .main { margin-left: 0; }
    .topbar, .content { padding-inline: 1rem; }
}

/* ====== Kartu ====== */
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header {
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem;
    background: none; border-bottom: 1px solid var(--line); padding: .9rem 1.25rem;
}
.card-header h2 { font-size: .95rem; font-weight: 700; margin: 0; }
.card-header h2 small { font-weight: 400; color: #8a94a0; font-size: .78rem; }
.card-header > small { color: #8a94a0; }
.card-footer { background: none; border-top: 1px solid var(--line); }
.table > :not(caption) > * > * { padding: .7rem 1rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; background: #fafbfc; }
.row-link { cursor: pointer; }
.col-no { width: 1%; text-align: center; white-space: nowrap; color: #6b7280; }

.stat { padding: 1.1rem 1.25rem; position: relative; overflow: hidden; }
.stat > i {
    position: absolute; right: 1rem; top: 1rem; font-size: 1.25rem;
    width: 42px; height: 42px; display: grid; place-items: center;
    border-radius: 10px; background: var(--brand-soft); color: var(--brand);
}
.stat span { font-size: .8rem; color: #6b7280; font-weight: 500; }
.stat strong { display: block; font-size: 1.85rem; font-weight: 700; line-height: 1.3; }
.stat small { color: #8a94a0; font-size: .75rem; }

.stat-inline { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .5rem 1rem; }
.stat-inline span { display: block; font-size: .72rem; color: #6b7280; }
.stat-inline strong { font-size: 1.05rem; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .5rem; }
.bar { height: 6px; background: #eef1f4; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* Peta & ranking kecamatan */
.map { height: 430px; border-radius: 0 0 12px 12px; background: #eef2f3; }
.rank-list { max-height: 430px; overflow-y: auto; padding-block: .5rem; }
.rank { display: grid; grid-template-columns: 1fr auto; gap: .3rem; padding: .45rem 0; color: inherit; text-decoration: none; }
.rank:hover span { color: var(--brand); }
.rank .bar { grid-column: 1 / -1; }

/* Rekap laporan */
.rekap .bar-col { width: 32%; }
.rekap .bar-col .bar { display: inline-block; width: calc(100% - 48px); vertical-align: middle; }
.rekap .bar-col small { display: inline-block; width: 44px; text-align: right; color: #6b7280; }

/* Detail & unggahan */
.detail { display: grid; grid-template-columns: 130px 1fr; gap: .55rem 1rem; margin: 0; }
.detail dt { font-weight: 500; color: #6b7280; }
.detail dd { margin: 0; }
.preview { width: 100%; height: 640px; border: 0; border-radius: 0 0 12px 12px; }
.empty { text-align: center; padding: 4rem 1rem; color: #8a94a0; }
.empty i { font-size: 2.5rem; }
.upload-box {
    display: flex; flex-direction: column; align-items: center; gap: .2rem;
    padding: 1.5rem 1rem; border: 2px dashed var(--line); border-radius: 10px;
    cursor: pointer; text-align: center; transition: .15s;
}
.upload-box:hover { border-color: var(--brand); background: var(--brand-soft); }
.upload-box i { font-size: 2rem; color: var(--brand); }
.upload-box small { color: #8a94a0; }
.logo-preview { width: 120px; height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; padding: .5rem; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }

/* ====== Halaman masuk & error ====== */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(135deg, var(--brand-soft), var(--bg)); }
.auth-card { display: grid; grid-template-columns: 1fr 1fr; width: min(900px, 100%); background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 20px 50px rgba(16, 24, 40, .12); }
.auth-intro { background: var(--brand-dark); color: #fff; padding: 2.5rem; display: flex; flex-direction: column; }
.auth-logo { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 14px; padding: 4px; margin-bottom: 1.25rem; }
.auth-intro h1 { font-size: 1.75rem; font-weight: 700; margin: 0; }
.auth-intro p { opacity: .8; }
.auth-intro ul { list-style: none; padding: 0; margin: 1rem 0 2rem; }
.auth-intro li { padding: .4rem 0; opacity: .9; }
.auth-intro li i { margin-right: .6rem; }
.auth-intro > small { margin-top: auto; opacity: .6; }
.auth-form { padding: 2.5rem; align-self: center; }
.auth-form h2 { font-weight: 700; }
@media (max-width: 767.98px) {
    .auth-card { grid-template-columns: 1fr; }
    .auth-intro ul { display: none; }
}
.error-box { background: #fff; padding: 3rem; border-radius: 18px; box-shadow: 0 20px 50px rgba(16, 24, 40, .1); }
.error-code { font-size: 4.5rem; font-weight: 700; color: var(--brand); line-height: 1; margin-bottom: 1rem; }

/* ====== Cetak laporan ====== */
.print-page { background: #e9ecef; font-size: 11pt; }
.paper { width: 210mm; min-height: 297mm; margin: 1.5rem auto; padding: 15mm 18mm; background: #fff; box-shadow: 0 4px 20px rgba(0, 0, 0, .1); }
.kop { display: flex; align-items: center; gap: 1rem; padding-bottom: .75rem; border-bottom: 4px double #000; margin-bottom: 1.25rem; }
.kop img { width: 80px; height: 80px; object-fit: contain; }
.kop > div { flex: 1; text-align: center; }
.kop-pemda { font-size: 13pt; font-weight: 600; }
.kop-instansi { font-size: 15pt; font-weight: 700; }
.kop-alamat { font-size: 9pt; }
.report-title { font-size: 13pt; font-weight: 700; text-align: center; margin: 0; }
.report-sub { text-align: center; margin-bottom: 1rem; }
.paper h2 { font-size: 11pt; font-weight: 700; margin: 1rem 0 .4rem; }
.paper .table { font-size: 9pt; }
.paper .table > :not(caption) > * > * { padding: .3rem .45rem; }
.paper .table thead th { background: #f1f3f5; color: #000; }
.paper .detail-table { font-size: 7.5pt; }
.summary td { text-align: center; font-size: 8.5pt; }
.summary strong { display: block; font-size: 12pt; }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.paper .rekap .bar { display: none; }
.paper .rekap .bar-col { width: auto; text-align: right; }
.page-break { break-before: page; }
.ttd { width: 45%; margin: 2.5rem 0 0 auto; text-align: center; }
.ttd-nama { margin-top: 4.5rem; font-weight: 700; text-decoration: underline; }
.print-actions { position: fixed; right: 1.5rem; bottom: 1.5rem; display: flex; gap: .5rem; }
@media print {
    @page { size: A4; margin: 12mm; }
    .print-page { background: #fff; }
    .paper { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
    tr { break-inside: avoid; }
}

/* Beranda publik */
.public-page { background: #f5f7f8; }
.public-header { background: #fff; border-bottom: 1px solid #e6eaec; padding: .75rem 0; position: sticky; top: 0; z-index: 1000; }
.public-logo { width: 40px; height: 40px; object-fit: contain; }
.public-hero { margin-bottom: 1.25rem; }
.public-hero h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }
.public-hero p { color: #6c757d; margin: 0; }
.public-map { height: 480px; border-radius: var(--bs-border-radius-lg) var(--bs-border-radius-lg) 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .85rem; border-top: 1px solid #eef1f2; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: .25rem; }
.level { font-size: .75rem; font-weight: 600; padding: .15rem .6rem; border-radius: 99px; background: color-mix(in srgb, var(--level) 22%, #fff); color: color-mix(in srgb, var(--level) 70%, #000); }
.level::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--level); margin-right: .35rem; }
.public-footer { padding: 1.5rem 0; color: #6c757d; font-size: .85rem; border-top: 1px solid #e6eaec; background: #fff; margin-top: 1rem; }

/* ====== Responsif ====== */
.topbar h1 { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.stat-grid { flex: 1 1 640px; display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: .5rem; }
.report-actions { display: flex; gap: .5rem; margin-left: auto; }

@media (max-width: 575.98px) {
    body { font-size: .9rem; }
    .content { padding: 1rem .75rem; }
    .topbar { padding-block: .6rem; }
    .card-header { padding: .75rem 1rem; }
    .table > :not(caption) > * > * { padding: .6rem .65rem; }
    .stat { padding: .9rem 1rem; }
    .stat > i { width: 32px; height: 32px; font-size: 1rem; right: .75rem; top: .75rem; }
    .stat span { display: block; padding-right: 2.25rem; }
    .stat strong { font-size: 1.5rem; }
    .map, .rank-list { height: 320px; max-height: 320px; }
    .report-actions { width: 100%; }
    .report-actions .btn { flex: 1; padding-inline: .4rem; }
    .rekap .bar-col { width: auto; }
    .rekap .bar-col .bar { display: none; }
    .detail { grid-template-columns: 105px 1fr; }
    .preview { height: 70vh; }
    .auth-intro, .auth-form { padding: 1.75rem 1.5rem; }
    .public-hero h1 { font-size: 1.3rem; }
    .public-map { height: 360px; }
    .rank-list { height: auto; }
}

/* Versi cetak di layar HP: kertas mengikuti lebar layar (hasil print/PDF tidak berubah) */
@media screen and (max-width: 860px) {
    .print-page .paper { width: auto; min-height: 0; margin: 0; padding: 1.25rem 1rem 5rem; box-shadow: none; overflow-x: auto; }
    .print-page .print-grid { grid-template-columns: 1fr; }
    .print-page .kop img { width: 54px; height: 54px; }
    .print-page .kop-pemda { font-size: 10pt; }
    .print-page .kop-instansi { font-size: 11.5pt; }
    .print-page .ttd { width: 100%; }
    .print-page .print-actions { right: 1rem; bottom: 1rem; }
}
.public-header .lh-sm { min-width: 0; }
