* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #f8fafc;
  color: #1e293b;
  padding-bottom: 75px;
  min-height: 100vh;
  font-size: 14px;
  transition: background-color 0.3s, color 0.3s;
}

/* ================= Z-INDEX SPREAD UNTUK POPUP LAYER TERATAS ================= */
.swal2-container {
  z-index: 100000 !important;
}

/* ================= DARK MODE STYLES ================= */
body.dark-mode {
  background-color: #0f172a;
  color: #f1f5f9;
}
body.dark-mode .card-stat,
body.dark-mode .progress-box,
body.dark-mode .voter-card,
body.dark-mode .fullscreen-modal,
body.dark-mode .loading-card {
  background-color: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}
body.dark-mode .sticky-filter-box {
  background-color: #1e293b;
  border-bottom-color: #334155;
}
body.dark-mode .bottom-nav {
  background-color: #1e293b;
  border-top-color: #334155;
}
body.dark-mode .nav-item {
  color: #94a3b8;
}
body.dark-mode .nav-item.active {
  color: #ef4444;
}
body.dark-mode .voter-name,
body.dark-mode .voter-body span.val {
  color: #f8fafc;
}
body.dark-mode .voter-body span.lbl {
  color: #94a3b8;
}
body.dark-mode .form-control {
  background-color: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}
body.dark-mode .form-control:focus {
  border-color: #ef4444;
}
body.dark-mode .progress-bar-bg {
  background-color: #334155;
  border-color: #475569;
}
body.dark-mode .btn-theme-toggle {
  background: #334155;
  color: #fef08a;
  border-color: #475569;
}

/* ================= 1. HALAMAN LOGIN MERAH PUTIH ELEGAN ================= */
#loginPage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #b91c1c 0%, #991b1b 45%, #7f1d1d 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 30px 20px;
  z-index: 10000;
  overflow-y: auto;
}
.login-header {
  text-align: center;
  color: white;
  margin-top: 10px;
}
.logo-wrapper {
  width: 100px;
  height: 100px;
  margin: 0 auto 14px;
  background: white;
  border-radius: 50%;
  padding: 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35), 0 0 0 3px #fbbf24;
  display: flex;
  justify-content: center;
  align-items: center;
}
.login-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.login-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-transform: uppercase;
  line-height: 1.3;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.login-subtitle {
  font-size: 25px;
  font-weight: 700;
  color: #fef08a;
  margin-top: 4px;
  letter-spacing: 1px;
}
.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 360px;
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
  margin: 20px 0;
  border-top: 5px solid #dc2626;
}
.login-info-text {
  font-size: 12px;
  text-align: center;
  color: #64748b;
  margin-bottom: 18px;
  font-weight: 600;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 6px;
  text-transform: uppercase;
}
body.dark-mode .form-group label {
  color: #fca5a5;
}

.form-control {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}
.form-control:focus {
  border-color: #dc2626;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.btn-submit-login {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(185, 28, 28, 0.4);
  transition: transform 0.1s;
}
.btn-submit-login:active {
  transform: scale(0.98);
}
.login-footer {
  text-align: center;
  color: #fecdd3;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
}

/* ================= 2. APP MAIN LAYOUT ================= */
#appPage {
  display: none;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  color: white;
  padding: 12px 16px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid #fef08a;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  padding: 2px;
  object-fit: contain;
}
.header-title {
  font-size: 14px;
  font-weight: 800;
}
.header-user {
  font-size: 11px;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 12px;
  margin-top: 1px;
  display: inline-block;
  font-weight: 600;
  color: #fff;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.btn-logout {
  background: #ffffff;
  color: #991b1b;
  border: none;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  min-height: 28px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-theme-toggle {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 65px;
  background: #ffffff;
  border-top: 2px solid #f1f5f9;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.nav-item i {
  font-size: 20px;
  display: block;
  margin-bottom: 3px;
}
.nav-item.active {
  color: #b91c1c;
  font-weight: 800;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px;
}

.stat-title {
  font-size: 13px;
  font-weight: 800;
  color: #991b1b;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
body.dark-mode .stat-title {
  color: #fca5a5;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.card-stat {
  background: white;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.card-stat-full {
  grid-column: span 2;
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.25);
}
.card-stat .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.8;
}
.card-stat .value {
  font-size: 24px;
  font-weight: 800;
  margin-top: 4px;
}

.btn-export-excel {
  width: 100%;
  height: 44px;
  background: #166534;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.25);
  margin-bottom: 14px;
}
.btn-export-excel:active {
  transform: scale(0.98);
}

.progress-box {
  background: white;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  margin-bottom: 14px;
}
.progress-bar-bg {
  background: #f1f5f9;
  border-radius: 10px;
  height: 16px;
  width: 100%;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid #e2e8f0;
}
.progress-bar-fill {
  background: linear-gradient(90deg, #10b981, #059669);
  height: 100%;
  width: 0%;
  text-align: center;
  color: white;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  transition: width 0.4s ease;
}

/* STICKY SEARCH & FILTER BOX DI PEMUTAKHIRAN DATA */
.sticky-filter-box {
  position: sticky;
  top: 61px;
  z-index: 90;
  background: #f8fafc;
  padding: 12px 14px;
  margin: -14px -14px 14px -14px;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}
.search-input-box {
  position: relative;
  margin-bottom: 8px;
}
.search-input-box i {
  position: absolute;
  left: 14px;
  top: 16px;
  color: #991b1b;
  font-size: 16px;
}
body.dark-mode .search-input-box i {
  color: #fca5a5;
}
.search-input-box input {
  padding-left: 42px;
}
.filter-row {
  display: flex;
  gap: 8px;
}

/* VOTER CARD UI */
.voter-card {
  background: white;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.voter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 8px;
}
.voter-name {
  font-weight: 800;
  font-size: 15px;
  color: #0f172a;
}
.voter-nik {
  font-size: 12px;
  font-weight: 700;
  color: #dc2626;
  margin-top: 2px;
}

/* BADGE STATUS CORNER */
.badge-status {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-belum {
  background: #fef3c7;
  color: #d97706;
}
.badge-sesuai {
  background: #d1fae5;
  color: #059669;
}
.badge-baru {
  background: #dbeafe;
  color: #2563eb;
}
.badge-tms {
  background: #fee2e2;
  color: #dc2626;
}

.voter-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
}
.voter-body .lbl {
  color: #64748b;
  font-weight: 600;
  display: block;
  font-size: 10px;
  text-transform: uppercase;
}
.voter-body .val {
  font-weight: 700;
  color: #334155;
}

.voter-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}
.btn-act {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  transition: transform 0.1s;
}
.btn-act:active {
  transform: scale(0.96);
}
.btn-sesuai {
  background: #10b981;
  color: white;
}
.btn-ubah {
  background: #f59e0b;
  color: white;
}
.select-tms {
  flex: 1;
  height: 38px;
  border: 1.5px solid #ef4444;
  border-radius: 8px;
  font-weight: 800;
  font-size: 11px;
  color: #dc2626;
  background: #fff5f5;
  padding: 0 6px;
  outline: none;
  cursor: pointer;
}

.fab-add {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 22px;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.4);
  cursor: pointer;
  z-index: 900;
}

/* MODAL POPUP */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 20000;
  overflow-y: auto;
  padding: 20px;
  display: none;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 12px;
}
.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: #991b1b;
}

#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 90000;
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  color: white;
  backdrop-filter: blur(4px);
}
.loading-card {
  background: white;
  color: #1e293b;
  padding: 24px 30px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #dc2626;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
