:root {
    --hijau: #2e7d32;
    --kuning: #f9a825;
    --oranye: #ef6c00;
    --merah: #c62828;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f4f6f8;
    color: #1a1a1a;
}

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2e7d32, #66bb6a);
}
.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    width: 360px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-icon { font-size: 40px; }
.login-brand h1 { margin: 8px 0 4px; font-size: 22px; }
.login-brand p { margin: 0; color: #666; font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px;
}
#btnSubmit {
    width: 100%; padding: 12px; background: var(--hijau); color: #fff; border: none;
    border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
}
#btnSubmit:disabled { opacity: .6; cursor: not-allowed; }
.alert-error {
    background: #ffebee; color: var(--merah); padding: 10px; border-radius: 8px;
    font-size: 13px; margin-bottom: 14px;
}
.login-note { text-align: center; font-size: 12px; color: #999; margin-top: 16px; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); background: #1b3a1e; color: #fff;
    display: flex; flex-direction: column; padding: 20px 0; flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 20px; }
.sidebar-brand .brand-icon { font-size: 26px; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { color: #a5d6a7; font-size: 11px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px;
    color: #d7ecd8; text-decoration: none; font-size: 14px; position: relative;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.badge-count {
    margin-left: auto; background: var(--merah); color: #fff; font-size: 11px;
    padding: 2px 7px; border-radius: 10px;
}
.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { font-size: 12px; color: #c8e6c9; margin-bottom: 10px; }
.btn-logout {
    width: 100%; padding: 8px; background: transparent; color: #fff;
    border: 1px solid rgba(255,255,255,.3); border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,.1); }

.main-content { flex: 1; padding: 28px 32px; overflow-y: auto; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; }
.page-header p { margin: 0 0 20px; color: #666; font-size: 13px; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input[type=search], .filter-bar input[type=date], .filter-bar input[type=text] {
    padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; font-size: 13px; background: #fff;
}
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #444; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border-radius: 12px; padding: 18px; display: flex; align-items: center;
    gap: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: #777; }
.panel { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap th, .table-wrap td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; }
.muted { color: #999; font-size: 13px; }

/* ---------- Peta ---------- */
.peta-shell { height: calc(100vh - 56px); display: flex; flex-direction: column; }
.peta-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: #444; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.peta-body { position: relative; flex: 1; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
#map { width: 100%; height: 100%; }

.detail-panel {
    position: absolute; top: 0; right: 0; width: 340px; height: 100%; background: #fff;
    box-shadow: -4px 0 16px rgba(0,0,0,.1); padding: 20px; overflow-y: auto; transition: transform .2s;
    z-index: 1000;
}
.detail-panel.hidden { transform: translateX(100%); }
.btn-close { position: absolute; top: 14px; right: 14px; border: none; background: #f1f1f1; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.detail-row { display: flex; margin-bottom: 6px; font-size: 13px; }
.detail-row .label { width: 110px; color: #888; flex-shrink: 0; }
.status-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
}
.status-chip.hijau { background: #e8f5e9; color: var(--hijau); }
.status-chip.kuning { background: #fffde7; color: var(--kuning); }
.status-chip.oranye { background: #fff3e0; color: var(--oranye); }
.status-chip.merah { background: #ffebee; color: var(--merah); }
.status-chip.abu { background: #f5f5f5; color: #999; }

/* ---------- Notifikasi ---------- */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-card {
    background: #fff; border-radius: 10px; padding: 14px 16px; display: flex; gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); border-left: 4px solid #ccc; cursor: default;
}
.notif-card.emergency { border-left-color: var(--merah); }
.notif-card.alert { border-left-color: var(--oranye); }
.notif-card.unread { background: #fbfdf9; }
.notif-card .notif-body { flex: 1; }
.notif-card .notif-msg { font-size: 14px; margin-bottom: 6px; }
.notif-card .notif-meta { font-size: 12px; color: #999; display: flex; gap: 10px; align-items: center; }
.notif-tag { padding: 2px 8px; border-radius: 10px; background: #f0f0f0; font-size: 11px; }
.notif-card button { border: none; background: #f4f6f8; border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; width: 320px; }
.modal-box h3 { margin: 0 0 16px; font-size: 16px; }
.tindak-lanjut-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.tindak-lanjut-options button { padding: 10px; border-radius: 8px; border: 1px solid #ddd; background: #fff; cursor: pointer; font-size: 13px; }
.tindak-lanjut-options button:hover { background: #f4f6f8; }

@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 50; height: 100%; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { padding: 16px; }
    .detail-panel { width: 100%; }
}

/* Grafik populasi (halaman /grafik) */
.grafik-legend { flex-wrap: wrap; row-gap: 6px; margin-top: 10px; }
.grafik-legend i.line { border-radius: 2px; width: 16px; height: 4px; }

/* Marker balita dengan kasus gizi buruk (peta monitoring) -- efek berkedip/berdetak */
@keyframes marker-pulse-ring {
    0%   { transform: scale(0.8); opacity: 0.7; }
    70%  { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(2.2); opacity: 0; }
}
.marker-pulse-wrap { position: relative; width: 16px; height: 16px; }
.marker-pulse-ring {
    position: absolute; top: 0; left: 0; width: 16px; height: 16px;
    border-radius: 50%; background: #c62828;
    animation: marker-pulse-ring 1.4s ease-out infinite;
}
.marker-pulse-dot {
    position: absolute; top: 0; left: 0; width: 16px; height: 16px;
    border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 3px rgba(0,0,0,.5);
}

.kasus-list { margin: 10px 0 0; padding-left: 18px; }
.kasus-list li { font-size: 13px; color: #c62828; margin-bottom: 4px; }

/* =====================================================================
   Komponen bersama (halaman Kelola, Akun, Riwayat, Impor, Dashboard)
   ===================================================================== */
.brand-logo { border-radius: 10px; background: #fff; flex-shrink: 0; }
.brand-logo-login { display: block; margin: 0 auto 8px; border-radius: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.panel + .panel { margin-top: 16px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.panel .table-wrap { box-shadow: none; border-radius: 0; background: transparent; }
.table-wrap th { background: #f7f9f7; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #555; white-space: nowrap; }
.table-wrap tbody tr:hover { background: #fafcfa; }
.table-wrap small { font-size: 11px; }
.kecil { font-size: 12px; }
.wajib { color: var(--merah); }
.alert-info { background: #e8f5e9; color: #1b5e20; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-info.kuning { background: #fff8e1; color: #8a5a00; }
.teks-galat, .galat-kolom { color: var(--merah); font-size: 12px; margin-top: 4px; }
.galat-kolom:empty { display: none; }
.galat-umum { margin-bottom: 12px; }

/* tombol */
button { font-family: inherit; }
.btn-ok, .btn-danger, .btn-gelap, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 13px; font-weight: 600; cursor: pointer;
    transition: filter .15s, background .15s;
}
.btn-ok { background: var(--hijau); color: #fff; }
.btn-danger { background: var(--merah); color: #fff; }
.btn-gelap { background: #455a64; color: #fff; }
.btn-secondary { background: #fff; color: #333; border-color: #cfd8dc; }
.btn-ok:hover, .btn-danger:hover, .btn-gelap:hover { filter: brightness(1.1); }
.btn-secondary:hover { background: #f1f4f2; }
.btn-ok:disabled, .btn-danger:disabled, .btn-gelap:disabled, .btn-secondary:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-unduh-ind, .btn-tindak-lanjut {
    padding: 5px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #cfd8dc; background: #fff; color: #2e7d32; font-weight: 600; cursor: pointer;
}
.btn-unduh-ind:hover, .btn-tindak-lanjut:hover { background: #e8f5e9; }
.stat-card .btn-unduh-ind { margin-top: 6px; display: block; }
.modal-box .btn-secondary { width: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
td.aksi { white-space: nowrap; text-align: right; }
td.aksi .btn-sm + .btn-sm { margin-left: 4px; }
.kol-aksi { width: 1%; }

/* isian */
.input-cari { min-width: 260px; flex: 1; max-width: 420px; }
.field-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #444; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.form-group input[type=checkbox] { width: auto; }
.form-group textarea { resize: vertical; }
.form-group small { display: block; margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(46,125,50,.35); border-color: var(--hijau); }

/* modal kelola */
.modal-box.lebar { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; }
.kelola-modal h3 { font-size: 18px; }
.kotak-sandi { background: #f4f6f8; border: 1px dashed #90a4ae; border-radius: 8px; padding: 14px; text-align: center; margin: 12px 0; }
.kotak-sandi code { font-size: 20px; letter-spacing: .08em; user-select: all; }

/* tab */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e0e6e1; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
    padding: 9px 16px; border: none; background: transparent; cursor: pointer; font-size: 14px; color: #555;
    border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0;
}
.tab:hover { background: #eef3ee; }
.tab.active { color: var(--hijau); border-bottom-color: var(--hijau); font-weight: 700; }
.tab-count { display: inline-block; min-width: 20px; padding: 1px 7px; margin-left: 4px; border-radius: 10px; background: #e0e6e1; font-size: 11px; font-weight: 700; color: #444; }
.tab.active .tab-count { background: var(--hijau); color: #fff; }
.panel-tab { margin-bottom: 24px; }

/* halaman bernomor */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0; }

/* chip status */
.chip-akun, .chip-jenis {
    display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: #eceff1; color: #546e7a; white-space: nowrap;
}
.chip-akun.disetujui { background: #e8f5e9; color: var(--hijau); }
.chip-akun.menunggu { background: #fff8e1; color: #b26a00; }
.chip-akun.ditolak { background: #ffebee; color: var(--merah); }
.chip-akun.dinonaktifkan { background: #eceff1; color: #78909c; }
.chip-jenis.pertama { background: #e3f2fd; color: #1565c0; }
.chip-jenis.lintas { background: #fff3e0; color: var(--oranye); }
.chip-jenis.dalam { background: #eceff1; color: #546e7a; }

/* saklar aktif/nonaktif */
.saklar { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; cursor: pointer; }
.saklar input { opacity: 0; width: 0; height: 0; position: absolute; }
.saklar-geser { position: absolute; inset: 0; background: #b0bec5; border-radius: 24px; transition: background .2s; }
.saklar-geser::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.saklar input:checked + .saklar-geser { background: var(--hijau); }
.saklar input:checked + .saklar-geser::before { transform: translateX(18px); }
.saklar input:focus-visible + .saklar-geser { outline: 2px solid rgba(46,125,50,.5); outline-offset: 2px; }
.saklar-teks { margin-left: 8px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.saklar-teks.on { color: var(--hijau); } .saklar-teks.off { color: #78909c; }

/* persetujuan akun: pilih massal */
.toolbar-massal { display: none; align-items: center; gap: 12px; padding: 10px 14px; background: #fff8e1; border-radius: 8px; margin-bottom: 12px; }
.toolbar-massal.aktif { display: flex; }
.col-pilih { display: none; width: 34px; }
.mode-pilih .col-pilih { display: table-cell; }

/* kelola: detail balita, log, pengaturan */
.grid-detail { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 20px; font-size: 13px; }
.kepala-detail { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.kepala-detail h2 { margin: 0; }
.baris-rinci > td { background: #fafafa; padding: 10px 16px; }
table.rinci { width: 100%; font-size: 12px; border-collapse: collapse; }
table.rinci th, table.rinci td { padding: 5px 8px; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; word-break: break-word; }
.baris-set { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid #eee; }
.baris-set input { width: 90px; padding: 8px; border: 1px solid #ddd; border-radius: 8px; }
.aksi-laporan { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.panel-laporan { margin-top: 20px; }

/* impor data lama (tabel hasil) */
.tabel-gulir { max-height: 380px; overflow: auto; }

@media (max-width: 768px) {
    .input-cari { min-width: 0; max-width: none; }
    .grid-detail { grid-template-columns: 1fr 1fr; }
}
