/* ============================================================
   WebGIS Kemiskinan Pontianak — Redesign
   Theme: Dark Sidebar + Clean Map UI
   ============================================================ */

/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #0ea5e9;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --sidebar-bg: #0f172a;
    --sidebar-item: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.16);
    --radius: 10px;
    --sidebar-w: 220px;
}

body, html {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
    background: #0f172a;
}

/* ============================================================
   MAP
   ============================================================ */
#map {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    z-index: 1;
    transition: left 0.3s ease;
}

body.sidebar-collapsed #map { left: 64px; }

/* ============================================================
   LEFT SIDEBAR (Vertical Nav)
   ============================================================ */
.left-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100%;
    background: var(--sidebar-bg);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
}

body.sidebar-collapsed .left-sidebar { width: 64px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand-text { flex: 1; overflow: hidden; }
.sidebar-brand-title {
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-brand-sub {
    font-size: 10px;
    color: var(--sidebar-text);
    white-space: nowrap;
}

/* Nav Items */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-nav-label {
    font-size: 9px;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 10px 4px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.sidebar-btn:hover {
    background: var(--sidebar-item);
    color: #e2e8f0;
}

.sidebar-btn.active {
    background: var(--sidebar-active);
    color: white;
}

.sidebar-btn .btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 16px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
}

.sidebar-btn.active .btn-icon {
    background: rgba(255,255,255,0.2);
}

.btn-label {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

/* Collapse Toggle */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    transition: all 0.15s;
}

.sidebar-collapse-btn:hover {
    background: var(--sidebar-item);
    color: #e2e8f0;
}

.collapse-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.collapse-label {
    font-size: 13px;
    font-weight: 500;
}

/* ============================================================
   TOP BAR (search + controls)
   ============================================================ */
.top-bar {
    position: fixed;
    top: 14px;
    left: calc(var(--sidebar-w) + 14px);
    right: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: left 0.3s ease;
    pointer-events: none;
}

body.sidebar-collapsed .top-bar { left: 78px; }

.top-bar > * { pointer-events: auto; }

/* Search */
.search-bar {
    flex: 1;
    max-width: 380px;
    display: flex;
    align-items: center;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    height: 44px;
    overflow: hidden;
    border: 1.5px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12), var(--shadow-md);
}

.search-icon {
    padding: 0 12px;
    color: #94a3b8;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    background: transparent;
}

.search-input::placeholder { color: #94a3b8; }

.search-clear {
    padding: 0 12px;
    color: #cbd5e1;
    cursor: pointer;
    background: none;
    border: none;
    visibility: hidden;
    font-size: 14px;
}

.search-clear:hover { color: #64748b; }

#searchResults {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-width: 380px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    z-index: 1001;
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }

/* Top Bar Buttons */
.top-btn {
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.top-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}

.top-btn.active {
    background: var(--primary);
    color: white;
}

/* Auth button in top bar */
#authWidget {
    margin-left: auto;
}

.btn-login {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    height: 44px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-login:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}

.user-profile-pill {
    background: white;
    border-radius: var(--radius);
    height: 44px;
    padding: 0 8px 0 14px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
}

.user-profile-info { display: flex; flex-direction: column; }
.user-profile-name { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.user-profile-role { font-size: 9px; font-weight: 600; color: var(--primary); text-transform: uppercase; }

.btn-profile-logout {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-profile-logout:hover { background: #fee2e2; color: var(--danger); }

/* ============================================================
   ZOOM CONTROLS
   ============================================================ */
.zoom-controls {
    position: fixed;
    bottom: 80px;
    right: 14px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.zoom-btn {
    width: 38px;
    height: 38px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    transition: all 0.15s;
}

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

/* ============================================================
   LAYER PANEL
   ============================================================ */
.custom-layer-panel {
    position: fixed;
    top: 72px;
    right: 14px;
    z-index: 1000;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    width: 240px;
    display: none;
    border: 1px solid var(--border);
}

.custom-layer-panel.show { display: block; }

.layer-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 12px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.layer-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.layer-option input[type="checkbox"] {
    accent-color: var(--primary);
    width: 15px;
    height: 15px;
}

.layer-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.layer-toggle-icon {
    cursor: pointer;
    padding: 2px 6px;
    color: #94a3b8;
    font-size: 10px;
    border-radius: 4px;
    transition: background 0.15s;
}

.layer-toggle-icon:hover { background: var(--surface-2); }
.layer-toggle-icon i { transition: transform 0.2s; }
.layer-toggle-icon.collapsed i { transform: rotate(-90deg); }

.sub-layer-list {
    padding-left: 16px;
    margin-top: 4px;
    border-left: 2px solid var(--primary-light);
    overflow: hidden;
}

.sub-option { font-size: 12px !important; margin-bottom: 4px !important; }

/* GeoJSON section */
.geojson-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.geojson-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 6px;
}

/* ============================================================
   RIGHT PANEL (Data)
   ============================================================ */
.right-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100%;
    background: white;
    z-index: 1050;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 1px solid var(--border);
}

.right-panel.open { right: 0; }

.right-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: white;
    flex-shrink: 0;
}

.right-panel-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.right-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface-2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.15s;
}

.right-panel-close:hover { background: #fee2e2; color: var(--danger); }

.right-panel-actions {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.right-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}

/* Panel Items */
.panel-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    padding: 40px 20px;
}

.panel-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.15s;
    margin-bottom: 8px;
}

.panel-item:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.panel-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
}

.panel-item-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.panel-item-info { flex: 1; min-width: 0; }
.panel-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.panel-item-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.panel-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.panel-item:hover .panel-item-actions { opacity: 1; }

.panel-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 7px;
    background: white;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.panel-action-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.panel-action-btn.danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* Panel action buttons in header */
.btn-panel-action {
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-panel-action:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-panel-action.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-panel-action.primary:hover {
    background: var(--primary-dark);
}

/* ============================================================
   MODALS
   ============================================================ */
.unified-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.unified-modal.show { display: flex; }

.modal-content {
    background: white;
    border-radius: 14px;
    width: 420px;
    max-width: 95vw;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 400;
    border-radius: 7px;
    background: var(--surface-2);
    transition: all 0.15s;
}

.modal-close:hover { background: #fee2e2; color: var(--danger); }

.modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* Form */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label, .modal-body label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body input[type="password"],
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn-save {
    background: var(--primary);
    color: white;
    border: none;
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-save:hover { background: var(--primary-dark); }

.btn-cancel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.btn-cancel:hover { background: var(--border); }

/* ============================================================
   TOAST
   ============================================================ */
#toastContainer {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    pointer-events: auto;
    animation: toastIn 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    max-width: 320px;
}

.toast.hiding { animation: toastOut 0.25s ease forwards; }
.toast-success { background: #065f46; }
.toast-error   { background: #7f1d1d; }
.toast-info    { background: #1e3a5f; }
.toast-warning { background: #78350f; }
.toast-icon    { font-size: 15px; flex-shrink: 0; }

@keyframes toastIn  { from { opacity:0; transform:translateY(12px) scale(0.92); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(6px) scale(0.95); } }

/* ============================================================
   MAP MARKERS
   ============================================================ */
.emoji-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

.emoji-marker .bubble {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    border: 2px solid rgba(255,255,255,0.9);
    animation: markerPop 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.emoji-marker .bubble span {
    transform: rotate(45deg);
    font-size: 16px;
    line-height: 1;
}

@keyframes markerPop {
    0%   { transform: rotate(-45deg) scale(0); }
    100% { transform: rotate(-45deg) scale(1); }
}

.emoji-marker .bubble.ibadah     { background: linear-gradient(135deg, #f97316, #ea580c); }
.emoji-marker .bubble.miskin-in  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.emoji-marker .bubble.miskin-out { background: linear-gradient(135deg, #10b981, #059669); }

/* ============================================================
   DASHBOARD MODAL
   ============================================================ */
#dashboardModal .modal-content {
    width: min(940px, 96vw);
    max-height: 90vh;
}

#dashboardModal .modal-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    border-radius: 14px 14px 0 0;
}

#dashboardModal .modal-header h3 { color: white; }
#dashboardModal .modal-close { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.1); }
#dashboardModal .modal-close:hover { background: rgba(239,68,68,0.3); color: white; }

#dashboardBody {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--surface-2);
}

.db-tab-bar {
    display: flex;
    gap: 4px;
    padding: 12px 20px 0;
    background: white;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.db-tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}

.db-tab-btn:hover { background: var(--primary-light); color: var(--primary); }
.db-tab-btn.active { background: white; color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

.db-tab-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.db-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 0; color: var(--text-secondary); font-size: 14px; }
.db-spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: dbSpin 0.7s linear infinite; }
@keyframes dbSpin { to { transform: rotate(360deg); } }

.db-error { text-align: center; color: var(--danger); padding: 40px; font-size: 14px; }

.db-ibadah-header {
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: white;
    box-shadow: 0 4px 16px rgba(37,99,235,0.25);
}

.db-ibadah-emoji { font-size: 34px; }
.db-ibadah-name  { font-size: 17px; font-weight: 700; }
.db-ibadah-meta  { font-size: 12px; color: rgba(255,255,255,0.7); margin-top: 2px; }

.db-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }

.db-kpi-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.db-kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
}

.kpi-ibadah::before  { background: linear-gradient(90deg, #f97316, #ea580c); }
.kpi-miskin::before  { background: linear-gradient(90deg, #ef4444, #dc2626); }
.kpi-jiwa::before    { background: linear-gradient(90deg, #2563eb, #1d4ed8); }
.kpi-log::before     { background: linear-gradient(90deg, #10b981, #059669); }

.db-kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.db-kpi-icon  { font-size: 26px; }
.db-kpi-val   { font-size: 28px; font-weight: 800; color: var(--text-primary); }
.db-kpi-label { font-size: 10px; font-weight: 700; color: var(--text-secondary); text-align: center; text-transform: uppercase; letter-spacing: 0.4px; }

.db-section { background: white; border-radius: 12px; padding: 16px; box-shadow: var(--shadow-sm); }
.db-section-title { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.4px; }

.db-coverage-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-primary); flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.db-progress-bar { height: 10px; background: #fee2e2; border-radius: 99px; overflow: hidden; }
.db-progress-fill { height: 100%; border-radius: 99px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

.db-charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.db-chart-card { background: white; border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.db-chart-wide { grid-column: 1 / -1; }
.db-chart-title { font-size: 11px; font-weight: 700; color: var(--text-secondary); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.db-chart-card canvas { width: 100% !important; display: block; }

.db-log-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.db-log-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; transition: background 0.1s; }
.db-log-item:hover { background: var(--primary-light); }
.db-log-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 5px; }
.db-log-info { flex: 1; min-width: 0; }
.db-log-main { font-size: 12px; font-weight: 600; color: var(--text-primary); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.db-log-tipe { background: var(--primary-light); color: var(--primary); padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.db-log-kk { color: var(--text-primary); }
.db-log-meta { font-size: 10px; color: #9ca3af; margin-top: 3px; }

.db-table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
.db-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.db-table thead tr { background: var(--surface-2); }
.db-table th { padding: 9px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border); }
.db-table td { padding: 9px 14px; color: var(--text-primary); border-bottom: 1px solid #f3f4f6; }
.db-table tbody tr:last-child td { border-bottom: none; }
.db-table tbody tr:hover td { background: var(--surface-2); }

.db-badge { background: var(--primary); color: white; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.db-empty { text-align: center; color: #9ca3af; font-size: 13px; padding: 20px; }

/* ============================================================
   USER MANAGEMENT MODAL
   ============================================================ */
#userManagementModal .modal-content {
    width: min(720px, 96vw);
}

/* ============================================================
   CUSTOM CURSOR TOOLTIP
   ============================================================ */
.custom-cursor-tooltip {
    position: absolute;
    display: none;
    background: rgba(15,23,42,0.85);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
}

/* ============================================================
   POPUP FORM (Leaflet)
   ============================================================ */
.popup-form { display: flex; flex-direction: column; gap: 8px; width: 200px; }
.popup-form label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.popup-form input[type="text"], .popup-form input[type="number"] { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.popup-form button { padding: 7px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 12px; }
.popup-form button.btn-danger { background: var(--danger); }

/* ============================================================
   MISC
   ============================================================ */
.leaflet-draw-tooltip { display: none !important; }

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 6px 10px;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.leaflet-popup-tip { display: none; }

/* Attribution */
.leaflet-control-attribution {
    font-size: 10px;
}

/* ============================================================
   LOG BANTUAN MODAL
   ============================================================ */
.modal-log-bantuan {
    width: min(560px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-log-bantuan .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.log-form-section {
    padding: 16px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.log-form-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
}

.log-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.log-list-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-list-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.log-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: background 0.15s;
}

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

.log-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.log-tipe-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 99px;
}

.log-tgl {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.log-ibadah {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.log-jenis {
    font-size: 10px;
    background: #f1f5f9;
    color: var(--text-secondary);
    padding: 1px 6px;
    border-radius: 4px;
}

.log-ket {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================================
   RESPONSIVE — MOBILE (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
    :root { --sidebar-w: 64px; }

    .left-sidebar {
        width: 64px !important;
    }

    .sidebar-brand-text,
    .btn-label,
    .sidebar-nav-label,
    .collapse-label {
        display: none !important;
    }

    .sidebar-collapse-btn { display: none !important; }

    #map {
        left: 64px !important;
    }

    .top-bar {
        left: 64px !important;
        padding: 0 8px;
        gap: 6px;
    }

    .top-bar .search-bar { max-width: 100%; }

    .right-panel {
        width: 100vw !important;
        max-width: 100vw;
        right: 0;
        border-radius: 16px 16px 0 0;
        top: auto;
        bottom: 0;
        height: 70vh;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .right-panel.open {
        transform: translateY(0);
    }

    body.right-panel-open #map {
        bottom: 70vh;
    }

    .modal-content {
        width: 96vw !important;
        margin: auto 2vw;
        max-height: 90vh;
    }

    .log-form-grid {
        grid-template-columns: 1fr;
    }

    #userManagementModal .modal-content {
        width: 96vw !important;
    }

    #userManagementModal [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .zoom-controls {
        bottom: calc(70vh + 12px) !important;
    }

    .custom-layer-panel {
        left: 72px;
        max-width: calc(100vw - 80px);
    }

    .db-charts-grid {
        grid-template-columns: 1fr !important;
    }

    .db-kpi-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ============================================================
   RESPONSIVE — TABLET (769px – 1024px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-w: 180px; }

    .right-panel { width: 300px; }

    body.right-panel-open #map { right: 300px; }
}

/* ============================================================
   DATA CARD — Panel Kiri (Ibadah & Miskin)
   ============================================================ */
.data-card {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.data-card:hover { border-color: #bfdbfe; box-shadow: 0 2px 10px rgba(37,99,235,0.08); }
.data-card.expanded { border-color: var(--primary); }

.data-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
}

.data-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.card-icon-ibadah      { background: #fef3c7; }
.card-icon-miskin-in   { background: #dcfce7; }
.card-icon-miskin-out  { background: #fee2e2; }

.data-card-info { flex: 1; min-width: 0; }
.data-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-card-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.data-card-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 99px;
    white-space: nowrap;
}
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }

.data-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.data-card:hover .data-card-actions { opacity: 1; }

.btn-card-action {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s;
}
.btn-card-edit:hover   { background: var(--primary); color: white; border-color: var(--primary); }
.btn-card-delete:hover { background: var(--danger);  color: white; border-color: var(--danger); }

/* Expanded section */
.data-card-expand {
    display: none;
    padding: 0 14px 14px;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed var(--border);
}
.data-card.expanded .data-card-expand { display: flex; }

.expand-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    gap: 10px;
    padding: 4px 0;
}
.expand-row > span:first-child { color: var(--text-secondary); flex-shrink: 0; }
.expand-row > span:last-child  { color: var(--text-primary); font-weight: 500; text-align: right; }

.btn-log-bantuan {
    margin-top: 6px;
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #c7d2fe;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-log-bantuan:hover {
    background: #4338ca;
    color: white;
    border-color: #4338ca;
}

/* Panel action buttons */
.btn-panel-add, .btn-panel-import {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.btn-panel-add {
    background: var(--primary);
    color: white;
}
.btn-panel-add:hover { background: var(--primary-dark); }
.btn-panel-import {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-panel-import:hover { background: var(--surface-2); color: var(--text-primary); }

/* Section title inside panel */
.panel-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 2px 4px;
}

/* ============================================================
   LOG BANTUAN PANEL — Kartu Penduduk (lebih bagus)
   ============================================================ */
.log-person-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.18s;
    text-decoration: none;
}
.log-person-card:hover {
    border-color: var(--primary);
    background: #f0f5ff;
    transform: translateX(2px);
    box-shadow: 0 2px 10px rgba(37,99,235,0.1);
}
.log-person-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.log-person-avatar.avatar-makan  { background: linear-gradient(135deg, #f97316, #ef4444); }
.log-person-avatar.avatar-pmbr   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.log-person-info { flex: 1; min-width: 0; }
.log-person-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.log-person-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.log-person-arrow {
    color: #c7d2fe;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.15s, color 0.15s;
}
.log-person-card:hover .log-person-arrow {
    color: var(--primary);
    transform: translateX(3px);
}

/* Panel hint strip */
.panel-hint {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 11px;
    color: #1e40af;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Improved log-item in modal */
.log-item {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.15s;
    margin-bottom: 8px;
}
.log-item:hover { border-color: #bfdbfe; background: #f8faff; box-shadow: 0 2px 8px rgba(37,99,235,0.07); }

.log-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.log-tipe-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    letter-spacing: 0.2px;
}
.log-tgl {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.log-ibadah {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}
.log-jenis {
    font-size: 10px;
    background: #f1f5f9;
    color: var(--text-secondary);
    padding: 1px 6px;
    border-radius: 5px;
}
.log-ket {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 2px;
    border-top: 1px dashed var(--border);
    margin-top: 2px;
}

/* Log bantuan modal improvements */
.modal-log-bantuan {
    width: min(560px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-log-bantuan .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.log-form-section {
    padding: 16px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.log-form-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.log-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}
.log-list-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.log-list-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
