* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f4f6f8;
  margin: 0;
  padding: 0;
}

/* ================================
   SITE HEADER (login + reset password)
================================ */
#siteHeader {
  background-color: #e8edf2;
  padding: 12px 24px;
  width: 100%;
  border-bottom: 3px solid #f4821f;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#siteHeaderInner {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

#headerLogo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

#siteTitle {
  color: #0f2044;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 0.3px;
  padding-left: 16px;
  border-left: 2px solid #b0bcc8;
}

/* ================================
   AUTH PAGES (index + reset)
================================ */
body.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.auth-card {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.auth-card h2 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #0f2044;
}

.auth-card input,
.auth-card button {
  width: 100%;
}

/* ================================
   DASHBOARD PAGE WRAPPER
================================ */
body.dashboard-page {
  background-color: #efeafb;
  padding: 24px;
}

#appCard {
  display: flex;
  background: white;
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(40, 20, 90, 0.12);
  overflow: hidden;
  min-height: calc(100vh - 48px);
}

/* ================================
   SIDEBAR
================================ */
#sidebar {
  width: 240px;
  background: linear-gradient(180deg, #6C4CF5 0%, #3A1B82 100%);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  flex-shrink: 0;
}

#sidebarBrand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

#sidebarLogo {
  width: 24px;
  height: auto;
}

#sidebarBrandText {
  color: white;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.3px;
}

#menuLabel {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px 12px;
}

.navBtn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  border-radius: 10px;
  margin-bottom: 4px;
}

.navIcon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.navBtn:hover {
  background-color: rgba(255, 255, 255, 0.12);
  color: white;
}

.navBtnActive,
.navBtnActive:hover {
  background-color: white;
  color: #3A1B82;
}

#sidebarSpacer {
  flex: 1;
}

/* ================================
   MAIN CONTENT
================================ */
#mainContent {
  flex: 1;
  min-width: 0;
  background: white;
  display: flex;
  flex-direction: column;
}

#topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 16px;
}

#welcomeText {
  font-size: 22px;
  font-weight: bold;
  color: #1a1a2e;
  margin: 0 0 4px;
}

#userInfo {
  font-size: 13px;
  color: #888;
  margin: 0;
}

#userAvatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #f4821f;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}

.page-content {
  flex: 1;
  padding: 8px 32px 32px;
  background-color: #f7f6fb;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contentCard {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(15, 32, 68, 0.08);
  padding: 24px;
}

.contentCard h2 {
  margin-top: 0;
  margin-bottom: 20px;
}

.cardHeaderRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.cardHeaderRow h2 {
  margin: 0;
}

.headerControls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.headerControls select,
.headerControls input,
.headerControls button {
  margin: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}

.headerControls select,
.headerControls input {
  border: 1px solid #ccc;
  width: auto;
}

.headerControls button {
  border: none;
}

.searchBox {
  display: flex;
}

.searchBox input {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.searchBox button {
  border-radius: 0 4px 4px 0;
  padding: 0 14px;
}

/* ================================
   FORM GROUP (label + field pairs)
================================ */
.formHint {
  font-size: 12px;
  color: #888;
  margin: -8px 0 16px;
}

.required {
  color: #d9534f;
  font-weight: normal;
}

.optional {
  color: #999;
  font-weight: normal;
  font-size: 12px;
}

.formGroup {
  margin-bottom: 16px;
}

.formGroup label {
  margin-bottom: 6px;
}

.formGroup input,
.formGroup select {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

#pemasukanStatus {
  margin: 8px 0 0;
  font-size: 13px;
}

/* ================================
   MODAL
================================ */
.modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 20, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modalBox {
  background: white;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modalBox h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.modalActions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btnSecondary {
  background-color: #e5e5e5;
  color: #333;
}

.btnSecondary:hover {
  background-color: #d0d0d0;
}

.btnBlue {
  background-color: #2e9ac4;
  color: white;
}

.btnBlue:hover {
  background-color: #257f9e;
}

/* ================================
   ACTION BUTTONS (di dalam tabel/paging)
================================ */
.actionBtn {
  padding: 4px 10px;
  font-size: 12px;
  margin-bottom: 0;
  margin-right: 6px;
}

.actionBtn.delete {
  background-color: #d9534f;
}

.actionBtn.delete:hover {
  background-color: #c9302c;
}

.paginationRow {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

#pemasukanPageInfo {
  font-size: 13px;
  color: #666;
}

.gotoPageBox {
  display: flex;
  gap: 6px;
  align-items: center;
}

.gotoPageBox input {
  display: inline-block;
  width: 70px;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
}

/* ================================
   ELEMEN UMUM
================================ */
h2, h3 {
  color: #0f2044;
}

p {
  color: #444;
}

label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
  font-weight: 500;
}

input {
  display: block;
  margin-bottom: 12px;
  padding: 8px 12px;
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

button {
  padding: 8px 16px;
  background-color: #f4821f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 8px;
}

button:hover {
  background-color: #d96e18;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

a {
  color: #2e9ac4;
}

/* Kustomisasi Warna Tombol Khusus Sesuai Tema */
#tambahPemasukanBtn {
  background-color: #10b981; /* Hijau cerah modern */
}

#tambahPemasukanBtn:hover {
  background-color: #059669;
}

#pemasukanGotoBtn {
  background-color: #0ea5e9; /* Biru muda cerah */
}

#pemasukanGotoBtn:hover {
  background-color: #0284c7;
}

/* ================================
   TABEL
================================ */
table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 12px;
}

th {
  background-color: #0f2044;
  color: white;
  padding: 10px 12px;
  text-align: left;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid #ddd;
}

tr:hover {
  background-color: #f0f4f8;
}

select {
  padding: 4px 8px;
  margin-right: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 13px;
}

#pemasukanTable {
  font-size: 13px;
}

#pemasukanTable th:nth-child(1),
#pemasukanTable td:nth-child(1),
#pemasukanTable th:nth-child(5),
#pemasukanTable td:nth-child(5),
#pemasukanTable th:nth-child(6),
#pemasukanTable td:nth-child(6) {
  white-space: nowrap;
}

#pemasukanTable th:nth-child(5),
#pemasukanTable td:nth-child(5) {
  text-align: right;
}

/* ================================
   DATA PENGELUARAN
   (disamakan persis dengan styling Data Pemasukan di atas,
   karena ID elemen di halaman pengeluaran berbeda jadi rule
   #pemasukan... di atas tidak otomatis berlaku di sini)
================================ */
#pengeluaranStatus {
  margin: 8px 0 0;
  font-size: 13px;
}

#pengeluaranPageInfo {
  font-size: 13px;
  color: #666;
}

#tambahPengeluaranBtn {
  background-color: #10b981;
}

#tambahPengeluaranBtn:hover {
  background-color: #059669;
}

#pengeluaranGotoBtn {
  background-color: #0ea5e9;
}

#pengeluaranGotoBtn:hover {
  background-color: #0284c7;
}

#pengeluaranTable {
  font-size: 13px;
}

#pengeluaranTable th:nth-child(1),
#pengeluaranTable td:nth-child(1),
#pengeluaranTable th:nth-child(5),
#pengeluaranTable td:nth-child(5),
#pengeluaranTable th:nth-child(6),
#pengeluaranTable td:nth-child(6) {
  white-space: nowrap;
}

#pengeluaranTable th:nth-child(5),
#pengeluaranTable td:nth-child(5) {
  text-align: right;
}

/* ==========================================================
   KOMPONEN STYLE BARU: DASHBOARD INTERAKTIF & PERIODE FILTER
   ========================================================== */
.dashboard-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.period-filter-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.period-filter-box label {
  margin-bottom: 0;
  font-weight: bold;
  color: #0f2044;
}

.select-clean {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #ccd4dc;
  background-color: white;
  font-size: 14px;
  color: #0f2044;
  cursor: pointer;
  height: 38px;
  outline: none;
  box-sizing: border-box;
  margin: 0; /* Memastikan tidak ada margin bawaan browser/global */
}

.input-clean {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #ccd4dc;
  background-color: white;
  font-size: 14px;
  color: #0f2044;
  width: 95px;
  height: 38px;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  display: inline-block; /* Menimpa display: block dari selector global input */
  margin: 0;             /* PENTING: Menghapus margin-bottom 12px dari global input */
}

/* Sembunyikan spinner bawaan browser pada input type number */
.input-clean::-webkit-outer-spin-button,
.input-clean::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-clean {
  -moz-appearance: textfield;
}

/* Tata Letak Ringkasan Kartu */
.summary-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.card-stat {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  border-left: 5px solid #ccc;
}

.card-pemasukan { border-left-color: #4ade80; }
.card-pengeluaran { border-left-color: #f87171; }
.card-saldo { border-left-color: #2e9ac4; }

.card-stat-header {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #0f2044;
  margin-bottom: 6px;
}

.card-stat-footer {
  font-size: 12px;
  color: #888;
}

/* Grafik Section */
.chart-section-card {
  margin-bottom: 24px;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Breakdown Kategori Terbesar */
.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.top-categories-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
}

.top-category-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 14px;
}

.top-category-item:last-child {
  border-bottom: none;
}

.cat-rank-name {
  color: #334155;
  font-weight: 500;
}

.cat-total-val {
  font-weight: bold;
  color: #0f2044;
}

.empty-list-hint {
  color: #94a3b8;
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* ==========================================================
   KOMPONEN STYLE: GLOBAL LOADING OVERLAY
   ========================================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 20, 40, 0.6); /* Transparansi gelap senada sidebar */
  backdrop-filter: blur(4px);        /* Efek blur background mewah */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;                     /* Wajib di atas modal biasa (1000) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

/* Class pembantu untuk memunculkan loader */
.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
  text-align: center;
  max-width: 320px;
  width: 100%;
}

/* Animasi Spinner Putar */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e2e8f0;
  border-top-color: #2e9ac4; /* Warna biru aksen aplikasi Anda */
  border-radius: 50%;
  animation: spinLoader 0.8s linear infinite;
}

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

.loading-text {
  font-size: 15px;
  font-weight: 700;
  color: #0f2044; /* Warna navy text utama */
  margin: 0;
}

.loading-subtext {
  font-size: 12px;
  color: #64748b;
  margin: -6px 0 0 0;
}

/* ==========================================================
   MODIFIKASI SIDEBAR SUB-MENU (IKHTISAR BULANAN & TAHUNAN)
   ========================================================== */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Container penampung sub-menu */
.sidebar-submenu {
  display: flex;
  flex-direction: column;
  padding-left: 20px;
  margin-top: 2px;
  margin-bottom: 8px;
  gap: 4px;
}

/* Base style item link sub-menu */
.submenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 8px;
  transition: all 0.2s ease-in-out;
}

/* Efek lingkaran kecil penanda di samping teks */
.submenu-dot {
  width: 5px;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transition: all 0.2s ease-in-out;
}

/* Saat di-hover */
.submenu-item:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

.submenu-item:hover .submenu-dot {
  background-color: #ffffff;
  transform: scale(1.3);
}

/* Style ketika sub-menu tersebut aktif dibuka */
.submenu-item.active {
  color: #ffffff;
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.15);
}

.submenu-item.active .submenu-dot {
  background-color: #4ade80; /* Dot berubah menjadi hijau cerah menandakan halaman aktif */
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

/* ==========================================================
   STYLE TOMBOL LOGOUT BARU DI SEBELAH AVATAR TOPBAR
   ========================================================== */
.logout-topbar-btn {
  background-color: transparent !important;
  border: 1px solid #ef4444 !important; /* Border merah soft */
  color: #ef4444 !important; /* Teks merah */
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin-bottom: 0 !important; /* Menghilangkan margin bawaan tag button */
  height: 34px;
  transition: all 0.2s ease;
}

.logout-topbar-btn:hover {
  background-color: #ef4444 !important; /* Merah penuh saat hover */
  color: white !important;
}

.logout-topbar-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ==========================================================
   STYLE SUB-MENU SIDEBAR (BULANAN & TAHUNAN)
   ========================================================== */
.navSubBtn {
  display: block;
  padding: 6px 12px;
  font-size: 13px;
  color: #94a3b8 !important; /* Warna teks abu-abu saat tidak aktif */
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.navSubBtn:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.05);
}

.navSubActive {
  color: #ffffff !important; /* Warna teks putih menyala saat aktif */
  background-color: rgba(255, 255, 255, 0.1) !important; /* Background semi-transparan penanda aktif */
  font-weight: 600;
}