/* =====================================================
   GLOBAL RESET
===================================================== */
* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  /* Background Kuning Soft / Warm White */
  background: #FFFBEB;
  color: #171717; /* Teks Gelap */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-size: 13px;
  line-height: 1.5;
}


/* =====================================================
   APP LAYOUT
===================================================== */
.app {
  width: 100%;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #FFFBEB; /* Menyatu dengan body */
  min-width: 0;
}

.page-content {
  width: 100%;
  min-height: 100%;
  min-width: 0;
}


/* =====================================================
   UTILITY — TEXT & LAYOUT HELPERS
===================================================== */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-nowrap  { white-space: nowrap; }

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { align-items: center; justify-content: space-between; }
.flex-1      { flex: 1; }
.min-w-0     { min-width: 0; }


/* =====================================================
   SHARED — CARD, TITLE, SUBTITLE
===================================================== */
.dashboard-card {
  background: #ffffff;
  border: 1px solid #FEF3C7; /* Border kuning pastel */
  border-radius: var(--r-lg, 12px);
  padding: var(--sp-5, 20px);
  min-width: 0;
  box-shadow: 0 4px 20px -4px rgba(180, 83, 9, 0.05); /* Shadow warm tipis */
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4, 15px);
  margin-bottom: var(--sp-4, 18px);
}

.card-title {
  font-size: var(--fs-md, 15px);
  font-weight: 700;
  color: #171717; /* Judul dibuat gelap elegan */
}

.card-subtitle {
  margin-top: var(--sp-1, 4px);
  font-size: var(--fs-xs, 11px);
  color: #6B7280; /* Abu-abu netral */
}

.details-button {
  border: 0;
  background: #FEEA93;
  color: #b86b00; /* Teks cokelat gelap agar kontras dengan kuning */
  font-size: var(--fs-xs, 11px);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: var(--sp-1, 6px) var(--sp-3, 12px);
  border-radius: var(--r-sm, 6px);
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}

.details-button:hover  { background: #f0d98e; color: #7a4a00; }
.details-button:active { background: #e6cb76; color: #5c3800; }


/* =====================================================
   SHARED — FILTERS
===================================================== */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1, 6px);
  position: relative;
  min-width: 0;
}

.filter-group label {
  font-size: var(--fs-xs, 10px);
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-input,
.filter-select {
  height: 36px;
  padding: 0 var(--sp-3, 12px);
  border: 1px solid #e5e7eb;
  border-radius: var(--r-md, 8px);
  background: #ffffff;
  color: #171717;
  font-size: var(--fs-sm, 12px);
  font-family: inherit;
  outline: none;
  min-width: 140px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.filter-input::placeholder,
.filter-select::placeholder {
  color: #9ca3af;
}

.filter-input:focus,
.filter-select:focus {
  border-color: #FE8A3B;
  box-shadow: 0 0 0 3px rgba(254, 138, 59, 0.15);
}


/* =====================================================
   SHARED — CUSTOM DROPDOWN
===================================================== */
.custom-select {
  position: relative;
  width: 100%;
  min-width: 145px;
  z-index: 20;
}

.custom-select.open { z-index: 1000; }

.custom-select-trigger {
  width: 100%;
  height: 36px;
  padding: 0 var(--sp-3, 12px);
  border: 1px solid #e5e7eb;
  border-radius: var(--r-md, 8px);
  background: #ffffff;
  color: #171717;
  font-size: var(--fs-sm, 12px);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.custom-select-trigger:hover { border-color: #d1d5db; }

.custom-select.open .custom-select-trigger {
  border-color: #FE8A3B;
  box-shadow: 0 0 0 3px rgba(254, 138, 59, 0.15);
}

.custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: transform .18s ease, color .15s ease;
}

.custom-select.open .custom-select-arrow {
  color: #FE8A3B;
  transform: rotate(180deg);
}

.custom-select-arrow svg { display: block; }

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  padding: var(--sp-1, 6px);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-lg, 10px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
  max-height: 280px;
  overflow-y: auto;
  z-index: 1;
}

.custom-select.open .custom-select-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.custom-select-option {
  width: 100%;
  min-height: 34px;
  padding: 0 var(--sp-2, 10px);
  border: 0;
  border-radius: var(--r-sm, 6px);
  background: transparent;
  color: #171717;
  font-family: inherit;
  font-size: var(--fs-sm, 12px);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background .12s ease, color .12s ease;
}

.custom-select-option:hover { background: #FFFBEB; color: #FE8A3B; }

.custom-select-option.active {
  background: #FE8A3B;
  color: #ffffff;
  font-weight: 600;
}

.custom-select-option.active:hover { background: #e07a2f; }

.custom-select-menu::-webkit-scrollbar { width: 5px; }
.custom-select-menu::-webkit-scrollbar-track { background: transparent; }
.custom-select-menu::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 10px; }
.custom-select-menu::-webkit-scrollbar-thumb:hover { background: #FE8A3B; }


/* =====================================================
   SHARED — CUSTOM DATE
===================================================== */
.custom-date-container {
  background: #ffffff;
  border: 1px solid #FEF3C7;
  border-radius: var(--r-lg, 12px);
  padding: var(--sp-3, 14px);
  margin-bottom: var(--sp-4, 18px);
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3, 12px);
  justify-content: flex-end;
  box-shadow: 0 4px 20px -4px rgba(180, 83, 9, 0.05);
}

.custom-date-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1, 6px);
}

.custom-date-field label {
  font-size: var(--fs-xs, 10px);
  font-weight: 700;
  color: #374151;
}

.custom-date-field input {
  height: 36px;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-md, 8px);
  padding: 0 var(--sp-3, 12px);
  font-family: inherit;
  font-size: var(--fs-sm, 12px);
  color: #171717;
  background: #ffffff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.custom-date-field input:focus {
  border-color: #FE8A3B;
  box-shadow: 0 0 0 3px rgba(254, 138, 59, 0.15);
}

.apply-date-button {
  height: 36px;
  padding: 0 var(--sp-4, 18px);
  border: 0;
  border-radius: var(--r-md, 8px);
  background: #FE8A3B;
  color: #ffffff;
  font-size: var(--fs-sm, 12px);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, transform .1s ease;
  box-shadow: 0 4px 10px rgba(254, 138, 59, 0.2);
}

.apply-date-button:hover { background: #e07a2f; transform: translateY(-1px); }
.apply-date-button:active { transform: translateY(0); }


/* =====================================================
   SHARED — EMPTY / LOADING / ERROR
===================================================== */
.chart-empty {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: var(--fs-sm, 12px);
}

.page-loading {
  width: 100%;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #FEF3C7;
  border-top-color: #FE8A3B;
  border-radius: 50%;
  animation: loading-spin .7s linear infinite;
}

.loading-text {
  margin-top: var(--sp-3, 10px);
  font-size: var(--fs-sm, 12px);
  color: #6b7280;
}

@keyframes loading-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.page-error {
  margin: var(--sp-7, 40px);
  padding: var(--sp-6, 30px);
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--r-lg, 12px);
}

.page-error-title {
  font-size: var(--fs-xl, 16px);
  font-weight: 700;
  color: #DC2626;
}

.page-error-message {
  margin-top: var(--sp-1, 6px);
  font-size: var(--fs-base, 13px);
  color: #991B1B;
}


/* =====================================================
   LOGOUT CONFIRM MODAL
===================================================== */
.logout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 23, 23, 0.4); /* Overlay netral */
  backdrop-filter: blur(2px); /* Efek blur modern */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5, 20px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 99999;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.logout-modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.logout-modal {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: var(--r-lg, 16px);
  padding: var(--sp-6, 24px);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
  text-align: center;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.logout-modal-overlay.open .logout-modal { transform: translateY(0) scale(1); }

.logout-modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-4, 16px);
  border-radius: 50%;
  background: #FFFBEB;
  color: #FE8A3B;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-modal-title {
  font-size: var(--fs-xl, 18px);
  font-weight: 700;
  color: #171717;
  margin-bottom: var(--sp-1, 8px);
}

.logout-modal-message {
  font-size: var(--fs-base, 13px);
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: var(--sp-6, 24px);
}

.logout-modal-actions { display: flex; gap: var(--sp-3, 12px); }

.logout-modal-btn {
  flex: 1;
  height: 42px;
  border-radius: var(--r-md, 8px);
  font-family: inherit;
  font-size: var(--fs-base, 13px);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.logout-modal-btn-cancel {
  background: #ffffff;
  color: #374151;
  border-color: #d1d5db;
}
.logout-modal-btn-cancel:hover { background: #f3f4f6; }

.logout-modal-btn-confirm {
  background: #FE8A3B;
  color: #ffffff;
  border-color: #FE8A3B;
  box-shadow: 0 4px 10px rgba(254, 138, 59, 0.2);
}
.logout-modal-btn-confirm:hover { background: #e07a2f; border-color: #e07a2f; }

.logout-modal-btn:active { transform: scale(0.97); }


/* =====================================================
   PAYMENT STATUS PILLS
===================================================== */
.ia-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--r-sm, 6px);
  font-size: var(--fs-xs, 10px);
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: .02em;
  text-transform: uppercase;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ia-pill-paid     { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ia-pill-unpaid   { background: #FFFBEB; color: #b45309; border-color: #fde68a; }
.ia-pill-deposit  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ia-pill-refund   { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.ia-pill-refunded { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.ia-pill-empty    { background: #f9fafb; color: #6b7280; border-color: #e5e7eb; }


/* =====================================================
   STATUS BADGE
===================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--r-sm, 6px);
  font-size: var(--fs-xs, 10px);
  font-weight: 700;
  line-height: 1.2;
  background: #FFFBEB;
  color: #b45309;
  border: 1px solid #fde68a;
  white-space: nowrap;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.status-badge--paid   { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.status-badge--unpaid { background: #FFFBEB; color: #b45309; border-color: #fde68a; }


/* =====================================================
   INLINE SELECT — colored pill variant
===================================================== */
.ia-inline-select.ia-pill-paid     { background-color: #ecfdf5; color: #047857; border-color: transparent; }
.ia-inline-select.ia-pill-unpaid   { background-color: #FFFBEB; color: #b45309; border-color: transparent; }
.ia-inline-select.ia-pill-deposit  { background-color: #eff6ff; color: #1d4ed8; border-color: transparent; }
.ia-inline-select.ia-pill-refund   { background-color: #f3e8ff; color: #6b21a8; border-color: transparent; }
.ia-inline-select.ia-pill-refunded { background-color: #f3e8ff; color: #6b21a8; border-color: transparent; }


/* =====================================================
   SKELETON LOADING
===================================================== */
@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f3f4f6 0%,
    #ffffff 25%,
    #f3f4f6 50%,
    #ffffff 75%,
    #f3f4f6 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--r-sm, 6px);
}

.skeleton-line    { height: 14px; border-radius: var(--r-sm, 4px); }
.skeleton-line-sm { width: 60%; }
.skeleton-line-md { width: 80%; }
.skeleton-line-lg { width: 100%; }


/* =====================================================
   FLUID TYPOGRAPHY & SPACING
===================================================== */
:root {
  --fs-xs:   clamp(9px,  0.55vw + 0.4rem, 11px);
  --fs-sm:   clamp(10px, 0.65vw + 0.45rem, 12.5px);
  --fs-base: clamp(11px, 0.75vw + 0.5rem, 14px);
  --fs-md:   clamp(12px, 0.85vw + 0.55rem, 15px);
  --fs-lg:   clamp(14px, 1vw + 0.6rem,   18px);
  --fs-xl:   clamp(16px, 1.2vw + 0.7rem, 22px);
  --fs-2xl:  clamp(18px, 1.5vw + 0.8rem, 26px);

  --sp-1: clamp(2px,  0.2vw + 1px,  4px);
  --sp-2: clamp(4px,  0.3vw + 2px,  8px);
  --sp-3: clamp(6px,  0.5vw + 3px,  12px);
  --sp-4: clamp(8px,  0.7vw + 4px,  16px);
  --sp-5: clamp(10px, 1vw + 5px,    20px);
  --sp-6: clamp(12px, 1.3vw + 6px,  24px);
  --sp-7: clamp(16px, 1.6vw + 8px,  32px);
  --sp-8: clamp(20px, 2vw + 10px,   40px);

  --r-sm: clamp(4px, 0.3vw + 2px, 6px);
  --r-md: clamp(6px, 0.5vw + 3px, 9px);
  --r-lg: clamp(8px, 0.7vw + 4px, 12px);
  --r-xl: clamp(10px, 0.9vw + 5px, 14px);
}

body {
  font-size: var(--fs-base);
}


/* =====================================================
   RESPONSIVE — GLOBAL
===================================================== */
@media (max-width: 768px) {
  .custom-date-container {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-input,
  .filter-select,
  .custom-select {
    width: 100%;
    min-width: 0;
  }
  .dashboard-card { padding: var(--sp-4, 16px); }
  .page-error { margin: var(--sp-5, 20px); padding: var(--sp-4, 20px); }
}

@media (max-width: 480px) {
  .logout-modal { max-width: 100%; }
  .card-header  { flex-direction: column; align-items: stretch; }
  .details-button { align-self: flex-start; }
}


/* =====================================================
   SCROLLBAR (global, subtle)
===================================================== */
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 10px;
  border: 2px solid #FFFBEB;
}
.main::-webkit-scrollbar-thumb:hover { background: #FE8A3B; }

html {
  scrollbar-gutter: stable;
}

html.modal-open,
html.modal-open body {
  overflow: hidden;
}