:root {
  --primary: #10B981;   
  --primary-dark: #059669;  
  --primary-light: #D1FAE5; 
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --text-soft: #64748B;
  --border: #E2E8F0;
  --danger: #EF4444;
  --header-height: 70px;
  --sidebar-collapsed: 80px;
  --sidebar-expanded: 270px;
  --font: 'Inter', system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; overflow-y: scroll; transition: background 0.3s; }
body.warga-mode { background: #CBD5E1; }

.page-container { display: none; min-height: 100vh; animation: fadeIn 0.3s ease; }
.page-container.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* LANDING & LOGIN */
#view-landing { flex-direction: column; background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%); }
.glass-nav { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,0.4); }
.landing-card { background: var(--card); border-radius: 16px; border: 1px solid rgba(255,255,255,0.7); box-shadow: 0 10px 30px rgba(16, 185, 129, 0.05); padding: 1.5rem; }
#view-login { background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%); align-items: center; justify-content: center; padding: 1.5rem; }
.login-box { width: 100%; max-width: 1000px; display: grid; grid-template-columns: 1fr; background: var(--card); border-radius: 24px; overflow: hidden; box-shadow: 0 25px 50px -12px rgba(16, 185, 129, 0.15); border: 1px solid var(--border); }
@media (min-width: 896px) { .login-box { grid-template-columns: 1.2fr 1fr; } }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }
.form-group input, .form-group select { width: 100%; padding: 0.85rem 1rem; border: 1.5px solid var(--border); border-radius: 12px; font-size: 0.95rem; font-family: var(--font); transition: all 0.2s; outline: none; background: #F8FAFC; color: var(--text); }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); background: #fff; }
.form-group input[readonly] { background-color: #E2E8F0; cursor: not-allowed; color: #64748B; }

.btn-login.loading span.text-label { display: none; }
.btn-login.loading span.spinner { display: inline-block; }
.btn-login span.spinner { display: none; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }

/* DASHBOARD APP */
#view-app { flex-direction: column; }
.app-wrapper { width: 100%; min-height: 100vh; position: relative; display: flex; flex-direction: column; }

.header { position: fixed; top: 0; left: var(--sidebar-collapsed); right: 0; height: var(--header-height); background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; z-index: 900; transition: left .3s cubic-bezier(.4,0,.2,1); }
.sidebar:hover ~ .app-wrapper .header { left: var(--sidebar-expanded); }
.header-title { font-weight: 600; font-size: 20px; letter-spacing: -0.3px; }
.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-info { text-align: right; display: none; }
@media (min-width: 640px) { .user-info { display: block; } }
.user-name { font-size: 14px; font-weight: 700; display: block; line-height: 1; }
.user-role { font-size: 11px; color: var(--primary-dark); background: var(--primary-light); padding: 2px 8px; border-radius: 999px; font-weight: 600; display: inline-block; margin-top: 4px; }
.avatar { width: 38px; height: 38px; border-radius: 40px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; }
.btn-logout-header { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: all .2s; display: flex; align-items: center; justify-content: center; }
.btn-logout-header:hover { background: var(--danger); color: #fff; }
.hamburger { background: 0; border: none; cursor: pointer; display: none; align-items: center; padding: 6px; border-radius: 8px; color: var(--text); transition: background .2s; }

.sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-collapsed); background: var(--primary); color: #ECFDF5; border-right: 1px solid var(--primary-dark); z-index: 1000; transition: width .3s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; overflow: hidden; }
.sidebar:hover { width: var(--sidebar-expanded); }
.sidebar-header { flex-shrink: 0; padding: 16px 12px; border-bottom: 1px solid rgba(0,0,0,0.1); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; min-height: 44px; color: #fff; padding-right: 8px; }
.sidebar-brand svg.shrink-0 { flex-shrink: 0; }
.brand-text-wrapper { display: flex; flex-direction: column; white-space: nowrap; opacity: 0; width: 0; overflow: hidden; transition: opacity .2s, width .3s; }
.brand-title { font-weight: 700; font-size: 18px; line-height: 1.2; }
.brand-subtitle { font-size: 11px; font-weight: 500; opacity: 0.8; }
.sidebar:hover .brand-text-wrapper { opacity: 1; width: auto; overflow: visible; }
.sidebar-menu { flex: 1; overflow-y: auto; padding: 12px 0; scrollbar-width: thin; }
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }
.menu-header-box { padding: 0.5rem 1.5rem; margin-top: 0.5rem; display: flex; align-items: center; }
.menu-header-text { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: #022C22; font-weight: 800; white-space: nowrap; opacity: 0; width: 0; overflow: hidden; transition: opacity .2s, width .3s; }
.sidebar:hover .menu-header-text { opacity: 1; width: auto; overflow: visible; }

.menu-group { margin-bottom: 4px; }
.menu-toggle { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-radius: 0; cursor: pointer; color: #ECFDF5; transition: all .2s; font-weight: 500; font-size: 15px; border: 0; background: 0 0 !important; width: 100%; text-align: left; position: relative; border-left: 3px solid transparent; }
.menu-toggle:hover { color: #fff; background: rgba(0,0,0,0.1) !important; }
.menu-toggle.active { color: #fff; background: rgba(0,0,0,0.15) !important; border-left-color: #fff; font-weight: 600; }
.menu-toggle .icon { flex-shrink: 0; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.menu-toggle .label { flex: 1; white-space: nowrap; opacity: 0; width: 0; overflow: hidden; transition: opacity .2s, width .3s; }
.sidebar:hover .menu-toggle .label { opacity: 1; width: auto; overflow: visible; }
.sidebar .menu-toggle .arrow { display: none; margin-left: auto; transition: transform .3s; flex-shrink: 0; font-size: 12px; }
.sidebar:hover .menu-toggle .arrow { display: inline-block; }
.menu-toggle .arrow.open { transform: rotate(180deg); }

.sidebar .submenu { max-height: 0 !important; overflow: hidden; transition: max-height .35s ease; background: var(--primary-dark); }
.sidebar:hover .submenu.open { max-height: 600px !important; }
.submenu-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 56px; color: #D1FAE5; font-size: 14px; cursor: pointer; transition: all .15s; text-decoration: none; position: relative; }
.submenu-item:hover { color: #fff; background: rgba(0,0,0,0.1); }
.submenu-item.active { color: #fff; font-weight: 700; background: rgba(0,0,0,0.15); }

/* DYNAMIC MAIN CONTENT WIDTH */
.main { margin-left: var(--sidebar-collapsed); margin-top: var(--header-height); padding: 24px 28px; flex: 1; transition: margin-left .3s cubic-bezier(.4,0,.2,1); background: var(--bg); display: block; width: calc(100% - var(--sidebar-collapsed)); }
.sidebar:hover ~ .app-wrapper .main { margin-left: var(--sidebar-expanded); width: calc(100% - var(--sidebar-expanded)); }

/* LAYOUT WARGA (MOBILE NATIVE VIEW) */
.warga-topbar-wrapper { position: fixed; top: 0; left: 0; right: 0; background: var(--card); border-bottom: 1px solid var(--border); z-index: 900; box-shadow: 0 2px 10px rgba(0,0,0,0.03); }
.warga-topbar-inner { max-width: 800px; margin: 0 auto; height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.warga-bottomnav-wrapper { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); z-index: 1000; box-shadow: 0 -2px 10px rgba(0,0,0,0.03); padding-bottom: env(safe-area-inset-bottom); }
.warga-bottomnav-inner { max-width: 800px; margin: 0 auto; height: 68px; display: flex; justify-content: space-between; align-items: center; width: 100%; }
.warga-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-soft); font-size: 0.75rem; font-weight: 600; gap: 4px; transition: all 0.2s; cursor: pointer; border: none; background: transparent; height: 100%; width: 100%; }
.warga-nav-item svg { width: 22px; height: 22px; transition: transform 0.2s; stroke-width: 1.8px; }
.warga-nav-item.active { color: var(--primary); }
.warga-nav-item.active svg { transform: translateY(-3px); stroke-width: 2.5px; }

@media (max-width: 640px) { .warga-nav-item { font-size: 0.65rem; } .warga-nav-item svg { width: 20px; height: 20px; } }

.main-warga { padding: 80px 20px 88px 20px !important; flex: 1; background: var(--bg); display: flex; flex-direction: column; max-width: 800px; margin: 0 auto !important; width: 100%; min-height: 100vh; }

.mobile-app-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem 0.5rem; margin-top: 1.5rem; }
@media (min-width: 640px) { .mobile-app-grid { grid-template-columns: repeat(6, 1fr); gap: 1.5rem; } }

.app-icon-btn { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; border: none; background: transparent; cursor: pointer; transition: transform 0.2s; }
.app-icon-btn:active { transform: scale(0.95); }
.app-icon-btn:hover .app-icon-box { transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.app-icon-box { width: 3.8rem; height: 3.8rem; border-radius: 1.2rem; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: all 0.2s; }
.app-icon-text { font-size: 0.75rem; font-weight: 600; color: var(--text); text-align: center; line-height: 1.2; }

.icon-blue { background: linear-gradient(135deg, #3B82F6, #2563EB); } .icon-red { background: linear-gradient(135deg, #EF4444, #DC2626); } .icon-purple { background: linear-gradient(135deg, #8B5CF6, #7C3AED); } .icon-yellow { background: linear-gradient(135deg, #F59E0B, #D97706); } .icon-emerald { background: linear-gradient(135deg, #10B981, #059669); } .icon-orange { background: linear-gradient(135deg, #F97316, #EA580C); } .icon-cyan { background: linear-gradient(135deg, #06B6D4, #0891B2); } .icon-indigo { background: linear-gradient(135deg, #6366F1, #4F46E5); } .icon-teal { background: linear-gradient(135deg, #14B8A6, #0F766E); } .icon-rose { background: linear-gradient(135deg, #F43F5E, #E11D48); }

.warga-screen { display: none; }
.warga-screen.active { display: block; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* COMPONENT STYLES */
.page-placeholder { display: flex; align-items: center; justify-content: center; min-height: 60vh; padding: 20px; flex: 1; }
.page-placeholder .content { background: var(--card); padding: 40px; border-radius: 12px; border: 1px solid var(--border); max-width: 500px; width: 100%; text-align: center; box-shadow: 0 10px 25px rgba(16, 185, 129, 0.04); }
.page-placeholder .content .icon { margin-bottom: 16px; color: var(--primary); display: flex; justify-content: center; }
.page-placeholder .content h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; font-weight: 700; }
.page-placeholder .content p { color: var(--text-soft); font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
.page-placeholder .content .badge-dev { display: inline-block; padding: 6px 20px; background: var(--warning); color: #fff; border-radius: 40px; font-weight: 600; font-size: 13px; }

.table-container { width: 100%; overflow-x: auto; background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
.table-native { width: 100%; border-collapse: collapse; text-align: left; }
.table-native th { background: #F1F5F9; color: var(--text-soft); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-native td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 0.9rem; }
.table-native tr:last-child td { border-bottom: none; }
.table-native tbody tr:hover { background: #F8FAFC; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); z-index: 9999; justify-content: center; align-items: center; padding: 20px; }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-box { background: white; width: 100%; max-width: 600px; border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; }
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #F8FAFC; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; background: #F8FAFC; }

#global-loader { position: fixed; inset: 0; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(4px); z-index: 99999; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity 0.3s ease; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 999; backdrop-filter: blur(2px); }
.overlay.active { display: block; }

@media (max-width:768px) {
  .sidebar { transform: translateX(-100%); width: 270px !important; transition: transform .3s ease; box-shadow: 4px 0 20px rgba(0,0,0,0.1); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .app-wrapper .header { left: 270px; }
  .sidebar .brand-text-wrapper, .sidebar .menu-toggle .label, .sidebar .menu-header-text { opacity: 1; width: auto; overflow: visible; }
  .sidebar .menu-toggle .arrow { display: inline-block; }
  .hamburger { display: flex; }
  .header { left: 0 !important; }
  .sidebar:hover ~ .app-wrapper .header { left: 0 !important; }
  .main { margin-left: 0 !important; width: 100% !important; padding: 16px; }
  .sidebar:hover ~ .app-wrapper .main { margin-left: 0 !important; width: 100% !important; }
  .page-placeholder .content { padding: 30px 20px; }
}
@keyframes spin { to { transform: rotate(360deg); } }
/* CUSTOM FONT UNTUK DOKUMEN IDENTITAS (KTP/KK) */
.font-ocr { 
  font-family: 'OCR A Extended', 'Courier New', Courier, monospace !important; 
  letter-spacing: 0.05em; 
  font-weight: 600;
}
/* Memastikan Pop-Up SweetAlert selalu berada di depan Modal (Z-Index Fix) */
.swal2-container {
  z-index: 99999 !important;
}
.sidebar .sidebar-hide-on-collapse { opacity: 0; width: 0; overflow: hidden; transition: opacity .2s, width .3s; display: inline-block; }
.sidebar:hover .sidebar-hide-on-collapse { opacity: 1; width: 18px; overflow: visible; }