*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --primary: #119949;
  --primary-dark: #0d7a3a;
  --primary-light: #ecfdf5;
  --water-blue: #0d74b8;
  --emerald: #059669;
  --emerald-light: #ecfdf5;
  --rose: #e11d48;
  --rose-light: #fff1f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-500: #64748b;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
}
body {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background-color: var(--slate-100);
  color: var(--slate-800);
  line-height: 1.45;
  padding-bottom: 84px;
  -webkit-tap-highlight-color: transparent;
}
.hidden {
  display: none !important;
}
.container {
  max-width: 680px;
  margin: 0 auto;
}

.app-header {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    #0d8242 70%,
    var(--water-blue) 100%
  );
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
  object-fit: contain;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.header-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}
.header-addr {
  font-size: 0.64rem;
  color: #e0f2fe;
  line-height: 1.2;
  margin-top: 2px;
}
.header-sub {
  font-size: 0.72rem;
  color: #dcfce7;
  font-weight: 600;
  margin-top: 2px;
}
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
}
.badge-online {
  background: #ffffff;
  color: var(--primary-dark);
}
.badge-offline {
  background: #fbbf24;
  color: #0f172a;
}
.badge-role {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  margin-top: 4px;
  cursor: pointer;
}
.offline-bar {
  margin-top: 10px;
  background: #fbbf24;
  color: var(--slate-900);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.btn-sync-now {
  background: var(--slate-900);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--slate-200);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-flex {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 2px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  position: relative;
  min-width: 0;
}
.nav-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}
.nav-btn.active {
  color: var(--primary);
  font-weight: 800;
}
.nav-btn.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  background: var(--slate-200);
  padding: 4px;
  border-radius: 10px;
}
.sub-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 6px;
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--slate-700);
  cursor: pointer;
}
.sub-tab-btn.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.main-content {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.card-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--slate-800);
  margin-bottom: 10px;
}
.card-danger {
  background: var(--rose-light);
  border-color: #fecdd3;
}
.form-group {
  margin-bottom: 10px;
}
.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--slate-700);
  margin-bottom: 4px;
}
.input,
.select {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--slate-300);
  border-radius: 8px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--slate-900);
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
}
.input-lg {
  font-size: 1.1rem;
  font-weight: 700;
}
.input-primary {
  border-color: var(--primary);
}
.input-emerald {
  border-color: var(--water-blue);
  color: #0c4a6e;
}
.input-readonly {
  background: var(--slate-100);
  color: var(--primary-dark);
  font-weight: 700;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.login-box {
  max-width: 420px;
  margin: 20px auto;
}
.mode-switch {
  display: flex;
  background: var(--slate-200);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 14px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--slate-700);
  cursor: pointer;
}
.mode-btn.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.camera-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--primary-light);
  border: 1.5px dashed var(--primary);
  border-radius: 10px;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}
.ocr-status {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}
.ocr-loading {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
.ocr-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.ocr-warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.photo-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--slate-300);
  margin-top: 8px;
}

.info-box {
  background: var(--primary-light);
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.78rem;
  margin-top: 10px;
}
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}
.calc-box {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.8rem;
}
.calc-total {
  border-top: 1px solid var(--slate-200);
  margin-top: 6px;
  padding-top: 6px;
  font-weight: 700;
  font-size: 0.88rem;
}
.result-box {
  background: var(--amber-light);
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.78rem;
}
.btn {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-dark {
  background: var(--slate-800);
  color: #fff;
}
.btn-danger {
  background: var(--rose);
  color: #fff;
}
.btn-blue {
  background: var(--water-blue);
  color: #fff;
}
.btn-sm {
  width: auto;
  padding: 5px 10px;
  font-size: 0.72rem;
  border-radius: 6px;
}
.btn-chip-green {
  background: #d1fae5;
  color: #065f46;
}
.btn-chip-gray {
  background: var(--slate-200);
  color: var(--slate-700);
}
.btn-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.stat-box {
  padding: 8px;
  border-radius: 8px;
  text-align: center;
}
.stat-label {
  font-size: 0.66rem;
  color: var(--slate-500);
  display: block;
}
.stat-val {
  font-size: 0.84rem;
  font-weight: 800;
  margin-top: 2px;
  display: block;
}
.list-item {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}
.pill-done {
  background: #d1fae5;
  color: #065f46;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.66rem;
}
.pill-wait {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.66rem;
}
.pill-blue {
  background: #e0f2fe;
  color: #075985;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.66rem;
}
.chk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
  font-size: 0.74rem;
}
.chk-label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--slate-50);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--slate-200);
}
.text-emerald {
  color: var(--emerald);
}
.text-rose {
  color: var(--rose);
}
.text-blue {
  color: var(--water-blue);
}
.text-muted {
  color: var(--slate-500);
  font-size: 0.72rem;
}

@keyframes spinLoader {
  to {
    transform: rotate(360deg);
  }
}

.photo-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 150px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
}

.photo-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #cbd5e1;
  border-top-color: #119949;
  border-radius: 50%;
  animation: spinLoader 0.75s linear infinite;
}

/* Modal Pop-up Warga & Detail Rekap */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 18px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.2),
    0 8px 10px -6px rgba(0, 0, 0, 0.15);
  animation: modalFadeIn 0.18s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Toast Notification (Pengganti alert URL browser) */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 92%;
  max-width: 400px;
  pointer-events: none;
}

.toast-item {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.2s ease-out;
}

.toast-item.success {
  background: #065f46;
  border-left: 4px solid #34d399;
}
.toast-item.error {
  background: #991b1b;
  border-left: 4px solid #f87171;
}
.toast-item.warn {
  background: #92400e;
  border-left: 4px solid #fbbf24;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dialog Notifikasi Custom dengan Tombol OK */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dialog-box {
  background: #ffffff;
  width: 100%;
  max-width: 340px;
  border-radius: 16px;
  padding: 20px 18px 16px;
  text-align: center;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.25);
  animation: modalFadeIn 0.16s ease-out;
}

.dialog-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.dialog-icon.success {
  background: #dcfce7;
  color: #15803d;
}
.dialog-icon.error {
  background: #fee2e2;
  color: #b91c1c;
}

.dialog-title {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.dialog-msg {
  font-size: 0.86rem;
  color: #475569;
  line-height: 1.45;
  margin-bottom: 16px;
}

/* ==================== CUSTOM SPLASH ANIMATION ==================== */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  background: linear-gradient(160deg, #16a34a 0%, #119949 48%, #065f46 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition:
    opacity 0.45s ease,
    transform 0.45s ease,
    visibility 0.45s ease;
}

.splash-screen.splash-hide {
  opacity: 0;
  transform: scale(1.04);
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
  color: #ffffff;
  max-width: 320px;
  width: 100%;
  animation: splashFadeUp 0.6s ease-out both;
}

.splash-logo-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-ring {
  position: absolute;
  inset: -6px;
  border-radius: 28px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  animation: splashPulseRing 1.8s ease-out infinite;
}

.splash-logo {
  position: relative;
  z-index: 2;
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 22px;
  padding: 8px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25);
  animation: splashFloat 2.2s ease-in-out infinite;
}

.splash-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.splash-subtitle {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 20px;
}

.splash-bar-track {
  width: 170px;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto 24px;
}

.splash-bar-fill {
  width: 45%;
  height: 100%;
  background: #ffffff;
  border-radius: 999px;
  animation: splashSlideBar 1.1s ease-in-out infinite;
}

.splash-credit {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.78);
}

@keyframes splashFadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes splashFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes splashPulseRing {
  0% {
    transform: scale(0.95);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}

@keyframes splashSlideBar {
  0% {
    transform: translateX(-110%);
    width: 45%;
  }
  50% {
    width: 70%;
  }
  100% {
    transform: translateX(240%);
    width: 45%;
  }
}

body.dark-mode {
  background: #0f172a;
  color: #f1f5f9;
}
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .info-box,
body.dark-mode .calc-box,
body.dark-mode .result-box,
body.dark-mode .list-item {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #334155;
}
body.dark-mode .input,
body.dark-mode .select {
  background: #0f172a;
  color: #f8fafc;
  border-color: #475569;
}
body.dark-mode .text-muted,
body.dark-mode .form-label {
  color: #94a3b8;
}
body.dark-mode .bottom-nav {
  background: #0f172a;
  border-top-color: #1e293b;
}

input[type="checkbox"].chk-fasum:disabled {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.65;
}