/* =====================================================
   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: #ffffff;
  color: #012531;
  -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: #ffffff;
  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 #d0dbe2;
  border-radius: var(--r-lg, 10px);
  padding: var(--sp-5, 20px);
  min-width: 0;
}

.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, 14px);
  font-weight: 650;
  color: #012531;
}

.card-subtitle {
  margin-top: var(--sp-1, 4px);
  font-size: var(--fs-xs, 10px);
  color: #7a8a94;
}

.details-button {
  border: 0;
  background: #f5eef2;
  color: #961652;
  font-size: var(--fs-xs, 10px);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: var(--sp-1, 4px) var(--sp-3, 10px);
  border-radius: var(--r-sm, 6px);
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}

.details-button:hover  { background: #e8d5df; color: #7a1042; }
.details-button:active { background: #d9b8c8; color: #5c0c32; }


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

.filter-group label {
  font-size: var(--fs-xs, 10px);
  font-weight: 600;
  color: #7a8a94;
}

.filter-input,
.filter-select {
  height: 36px;
  padding: 0 var(--sp-3, 10px);
  border: 1px solid #d0dbe2;
  border-radius: var(--r-md, 7px);
  background: #ffffff;
  color: #012531;
  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:focus,
.filter-select:focus {
  border-color: #961652;
  box-shadow: 0 0 0 3px rgba(150, 22, 82, 0.08);
}


/* =====================================================
   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, 10px) 0 var(--sp-3, 11px);
  border: 1px solid #d0dbe2;
  border-radius: var(--r-md, 7px);
  background: #ffffff;
  color: #012531;
  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: #961652; }

.custom-select.open .custom-select-trigger {
  border-color: #961652;
  box-shadow: 0 0 0 3px rgba(150, 22, 82, 0.08);
}

.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: #7a8a94;
  transition: transform .18s ease;
}

.custom-select-arrow svg { display: block; }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  padding: var(--sp-1, 5px);
  background: #ffffff;
  border: 1px solid #d0dbe2;
  border-radius: var(--r-lg, 8px);
  box-shadow: 0 8px 24px rgba(1, 37, 49, 0.10), 0 2px 6px rgba(1, 37, 49, 0.05);
  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, 9px);
  border: 0;
  border-radius: var(--r-sm, 6px);
  background: transparent;
  color: #012531;
  font-family: inherit;
  font-size: var(--fs-sm, 12px);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background .12s ease, color .12s ease;
}

.custom-select-option:hover { background: #f5eef2; color: #961652; }

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

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

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


/* =====================================================
   SHARED — CUSTOM DATE
===================================================== */
.custom-date-container {
  background: #ffffff;
  border: 1px solid #d0dbe2;
  border-radius: var(--r-lg, 10px);
  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;
}

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

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

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

.custom-date-field input:focus {
  border-color: #961652;
  box-shadow: 0 0 0 3px rgba(150, 22, 82, 0.08);
}

.apply-date-button {
  height: 34px;
  padding: 0 var(--sp-4, 18px);
  border: 0;
  border-radius: var(--r-md, 7px);
  background: #961652;
  color: #ffffff;
  font-size: var(--fs-sm, 12px);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease;
}

.apply-date-button:hover { background: #7a1042; }


/* =====================================================
   SHARED — EMPTY / LOADING / ERROR
===================================================== */
.chart-empty {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9fb8c4;
  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 #d0dbe2;
  border-top-color: #961652;
  border-radius: 50%;
  animation: loading-spin .7s linear infinite;
}

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

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

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

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

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


/* =====================================================
   LOGOUT CONFIRM MODAL
===================================================== */
.logout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 37, 49, 0.45);
  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.15s ease, visibility 0.15s ease;
}

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

.logout-modal {
  width: 100%;
  max-width: 340px;
  background: #ffffff;
  border-radius: var(--r-lg, 12px);
  padding: var(--sp-6, 24px) var(--sp-5, 22px) var(--sp-5, 20px);
  box-shadow: 0 20px 50px rgba(1, 37, 49, 0.20), 0 4px 12px rgba(1, 37, 49, 0.08);
  text-align: center;
  transform: translateY(6px) scale(0.98);
  transition: transform 0.18s ease;
}

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

.logout-modal-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--sp-3, 14px);
  border-radius: 50%;
  background: #f5eef2;
  color: #961652;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

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

.logout-modal-btn {
  flex: 1;
  height: 40px;
  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: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.logout-modal-btn-cancel {
  background: #ffffff;
  color: #012531;
  border-color: #d0dbe2;
}
.logout-modal-btn-cancel:hover { background: #f5eef2; border-color: #961652; }

.logout-modal-btn-confirm {
  background: #961652;
  color: #ffffff;
  border-color: #961652;
}
.logout-modal-btn-confirm:hover { background: #7a1042; border-color: #7a1042; }

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


/* =====================================================
   PAYMENT STATUS PILLS
===================================================== */
.ia-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  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: #e6f7e9; color: #2a7d3a; border-color: #c5ebcd; }
.ia-pill-unpaid   { background: #f5eef2; color: #961652; border-color: #e2c8d6; }
.ia-pill-deposit  { background: #fff4d6; color: #7a5b00; border-color: #f0d98e; }
.ia-pill-refund   { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.ia-pill-refunded { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }
.ia-pill-empty    { background: #ffffff; color: #7a8a94; border-color: #d0dbe2; }


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

.status-badge--paid   { background: #e6f7e9; color: #2a7d3a; border-color: #c5ebcd; }
.status-badge--unpaid { background: #f5eef2; color: #961652; border-color: #e2c8d6; }


/* =====================================================
   INLINE SELECT — colored pill variant
===================================================== */
.ia-inline-select.ia-pill-paid     { background-color: #e6f7e9; color: #2a7d3a; border-color: transparent; }
.ia-inline-select.ia-pill-unpaid   { background-color: #f5eef2; color: #961652; border-color: transparent; }
.ia-inline-select.ia-pill-deposit  { background-color: #fff4d6; color: #7a5b00; 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,
    #eef2f7 0%,
    #f9fbfe 25%,
    #eef2f7 50%,
    #f9fbfe 75%,
    #eef2f7 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
   Auto-scale untuk layar kecil → mengurangi "card menekan"
   ===================================================== */

:root {
  /* Font base — clamp(min, fluid, max) */
  --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);

  /* Spacing scale — fluid */
  --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);

  /* Radius — fluid */
  --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);
}

/* Base font size body — pakai fluid */
body {
  font-size: var(--fs-base);
}


/* =====================================================
   RESPONSIVE — GLOBAL
   Catatan: TIDAK override html { font-size } karena
   :root pakai clamp() yang sudah fluid otomatis.
   ===================================================== */
@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); }
}

/* Small phones */
@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: #d0dbe2;
  border-radius: 10px;
  border: 2px solid #ffffff;
}
.main::-webkit-scrollbar-thumb:hover { background: #961652; }

html {
  scrollbar-gutter: stable;
}

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

#page-content {
    min-height: 60vh;
    transition: opacity 0.15s ease;
}