/**

 * Trang Thanh toán — tối giản, trung tính (màu chỉ ở bảng giao dịch)

 * Scope: #page-payments

 */



#page-payments .payment-kpi-grid {
  display: none;
}

@media (min-width: 769px) {
  #page-payments .payment-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  #page-payments .payment-kpi-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  }

  #page-payments .payment-kpi-card--debt {
    border-color: #fecaca;
    background: #fffbfb;
  }

  #page-payments .payment-kpi-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
  }

  #page-payments .payment-kpi-value {
    margin-top: 4px;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
    white-space: nowrap;
  }

  #page-payments .payment-kpi-value--debt {
    color: #dc2626;
  }
}

#page-payments .payment-page-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#page-payments .payment-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

#page-payments .payment-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

#page-payments .payment-page-actions button,
#page-payments .payment-action-btn {
  height: 38px;
  min-height: 38px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0 0.95rem;
}

#page-payments .payment-action-btn--primary {
  background: #2563eb;
  border: 1px solid #2563eb;
  color: #ffffff;
}

#page-payments .payment-action-btn--secondary {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #0f172a;
}

.pay-form-grid {
  gap: 0.65rem 0.9rem;
}

.pay-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #64748b;
}

.pay-form-grid input,
.pay-form-grid select {
  height: 46px;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 0 12px;
  font-size: 0.9375rem;
  color: #0f172a;
  background: #ffffff;
  box-sizing: border-box;
  width: 100%;
}

.pay-form-grid input:focus,
.pay-form-grid select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.payment-modal-btn {
  min-height: 46px;
  padding: 0 1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.payment-modal-btn--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.payment-modal-btn--secondary {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #0f172a;
}

.pay-form-grid--debt {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payment-modal-overlay {
  z-index: 8500;
}

.payment-modal-dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: 720px;
  border-radius: 18px;
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.24);
}

.payment-modal-dialog h3 {
  margin: 0;
  color: #111827;
}

.payment-modal-actions {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
  gap: 0.55rem;
}



/* --- Ledger --- */

#page-payments .debt-ledger-section {

  margin-top: 0.25rem;

}



#page-payments .debt-ledger-head {

  display: flex;

  flex-wrap: wrap;

  align-items: baseline;

  justify-content: space-between;

  gap: 0.35rem 1rem;

  margin-bottom: 0.65rem;

}



#page-payments .debt-ledger-title {

  margin: 0;

  font-size: 0.95rem;

  font-weight: 600;

  color: #111827;

}



#page-payments .debt-ledger-sub {

  font-size: 0.75rem;

  color: #9ca3af;

  font-weight: 500;

}



#page-payments .debt-ledger-table-wrap {

  max-height: calc(100vh - 420px);

  border-radius: 12px;

  border: 1px solid #e5e7eb;

  background: #ffffff;

}



#page-payments table.debt-ledger-table {

  width: 100%;

}



#page-payments table.debt-ledger-table thead th {

  background: #f9fafb;

  color: #6b7280;

  font-weight: 600;

  font-size: 0.7rem;

  text-transform: uppercase;

  letter-spacing: 0.03em;

}



/* Hàng bảng: nền trung tính (màu chỉ ở badge & số tiền) */

#page-payments tr.debt-ledger-row--debt td,

#page-payments tr.debt-ledger-row--pay td {

  background: #ffffff;

}



#page-payments tr.debt-ledger-row:hover td {

  background: #f9fafb;

}



/* Loại giao dịch */

#page-payments .debt-type-badge {

  display: inline-block;

  border-radius: 999px;

  padding: 4px 10px;

  font-size: 0.68rem;

  font-weight: 600;

  letter-spacing: 0.02em;

  line-height: 1.3;

  white-space: nowrap;

}



#page-payments .debt-type-badge--debt {

  background: #fee2e2;

  color: #dc2626;

}



#page-payments .debt-type-badge--pay {

  background: #dcfce7;

  color: #15803d;

}



/* Trạng thái */

#page-payments .debt-status-badge {

  display: inline-block;

  border-radius: 999px;

  padding: 4px 10px;

  font-size: 0.68rem;

  font-weight: 600;

  white-space: nowrap;

}



#page-payments .debt-status-badge--recorded {

  background: #fee2e2;

  color: #dc2626;

}



#page-payments .debt-status-badge--closed {
  background: #fffbeb;
  color: #a16207;
  border: 1px solid #fde68a;
}



#page-payments .debt-status-badge--confirmed {

  background: #dcfce7;

  color: #15803d;

}



#page-payments .debt-status-badge--pending {

  background: #fef3c7;

  color: #b45309;

}



/* Số tiền trong bảng */

#page-payments .debt-amount--debt {

  color: #dc2626;

  font-weight: 700;

}



#page-payments .debt-amount--pay {

  color: #15803d;

  font-weight: 700;

}



@media (max-width: 900px) {
  #page-payments .payment-page-header {
    flex-direction: column;
    align-items: stretch;
  }

  #page-payments .payment-page-actions {
    width: 100%;
  }

  #page-payments .payment-page-actions button {
    flex: 1 1 auto;
  }

  .pay-form-grid--debt {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .payment-modal-dialog {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
  }

  .payment-modal-dialog form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 60px);
  }

  .payment-modal-dialog .grid {
    overflow-y: auto;
    padding-right: 2px;
  }

  .payment-modal-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 2;
    margin-top: 0.7rem;
    padding-top: 0.7rem;
  }

  #page-payments .payment-page-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }
}

@media (max-width: 480px) {
  #page-payments .payment-page-actions {
    grid-template-columns: 1fr;
  }
}

/* Bằng chứng đính kèm */
.proof-upload-section {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

.proof-upload-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 8px;
}

.proof-dropzone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 20px;
  background: #f8fafc;
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.proof-dropzone--over {
  border-color: var(--accent, #2563eb);
  background: #eff6ff;
}

.proof-dropzone-hint {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.4;
}

.proof-dropzone-hint span {
  display: block;
  font-size: 0.75rem;
  margin: 2px 0;
}

.proof-pick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.proof-pick-btn:hover {
  background: #f1f5f9;
}

.proof-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.proof-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.proof-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.proof-thumb-pdf,
.proof-thumb-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #64748b;
  background: #f1f5f9;
}

.proof-thumb-actions {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: linear-gradient(transparent, rgba(15, 23, 42, 0.55));
  opacity: 0;
  transition: opacity 0.12s ease;
}

.proof-thumb:hover .proof-thumb-actions,
.proof-thumb:focus-within .proof-thumb-actions {
  opacity: 1;
}

.proof-thumb-btn {
  flex: 1;
  min-height: 24px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0;
}

.proof-thumb-btn--danger {
  color: #b91c1c;
}

.debt-att-col {
  width: 52px;
  text-align: center;
}

.debt-att-cell {
  text-align: center;
  white-space: nowrap;
}

.debt-att-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f8fafc;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  color: #334155;
  cursor: pointer;
}

.debt-att-badge:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.debt-tx-detail-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: 88vh;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.debt-tx-detail-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
}

.debt-tx-detail-card {
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  padding: 14px 16px;
}

.debt-tx-detail-card h4 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
}

.debt-tx-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8125rem;
  line-height: 1.35;
  padding: 4px 0;
}

.debt-tx-detail-row span:first-child {
  color: #64748b;
  font-weight: 600;
}

.debt-tx-detail-row span:last-child {
  text-align: right;
  font-weight: 600;
  color: #0f172a;
  word-break: break-word;
}

.proof-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.proof-gallery-item,
.proof-gallery-pdf {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 0;
  overflow: hidden;
  background: #f8fafc;
  cursor: pointer;
  font-family: inherit;
}

.proof-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.proof-gallery-pdf {
  width: auto;
  min-width: 80px;
  max-width: 100%;
  height: auto;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  text-align: left;
}

.proof-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: #94a3b8;
}

.proof-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.82);
}

.proof-lightbox.show {
  display: flex;
}

.proof-lightbox-img {
  max-width: min(96vw, 1200px);
  max-height: 82vh;
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  object-fit: contain;
}

.proof-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.proof-lightbox-caption {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: #fff;
  font-size: 0.8125rem;
  max-width: 90vw;
  text-align: center;
}

.debt-mob-att {
  margin-top: 8px;
}

/* --- Hàng hoàn trả tab --- */
#page-payments .payment-hub-tabs {
  margin-bottom: 0.5rem;
}

#page-payments .payment-returns-alert {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.8125rem;
  font-weight: 600;
}

#page-payments .payment-returns-tab-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.68rem;
  font-weight: 700;
}

#page-payments .return-refunds-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

#page-payments .return-refunds-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0.65rem;
}

#page-payments .return-filter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

#page-payments .return-refunds-add-btn,
#page-payments .return-add-btn {
  min-width: 96px;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

#page-payments .return-add-btn .mobile-label {
  display: none;
}

@media (max-width: 640px) {
  #page-payments .return-add-btn .desktop-label {
    display: none;
  }

  #page-payments .return-add-btn .mobile-label {
    display: inline;
  }
}

#page-payments .return-refunds-add-btn:hover,
#page-payments .return-add-btn:hover {
  background: #1d4ed8;
}

#page-payments.payments-tab-returns .payment-page-actions {
  display: none !important;
}

.return-source-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}

.return-source-badge--lot {
  background: #f1f5f9;
  color: #475569;
}

.return-source-badge--manual {
  background: #ede9fe;
  color: #6d28d9;
}

.manual-return-paid-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0.75rem 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
}

.manual-return-paid-fields {
  margin-top: 0.5rem;
  padding-top: 0.65rem;
  border-top: 1px solid #e5e7eb;
}

.pay-form-grid-full {
  grid-column: 1 / -1;
}

.return-refund-mob-source {
  margin: 0 0 6px;
}

#page-payments .return-refunds-search,
#page-payments .return-refunds-status {
  height: 38px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 0 12px;
  font-size: 0.875rem;
  background: #fff;
}

#page-payments .return-refunds-search {
  width: 100%;
  box-sizing: border-box;
}

#page-payments .return-refunds-status {
  width: 100%;
  min-width: 0;
}

#page-payments .return-refunds-table-wrap {
  max-height: calc(100vh - 460px);
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

#page-payments .return-refund-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

#page-payments .return-refund-badge--pending {
  background: #fef3c7;
  color: #b45309;
}

#page-payments .return-refund-badge--partial {
  background: #dbeafe;
  color: #1d4ed8;
}

#page-payments .return-refund-badge--done {
  background: #dcfce7;
  color: #15803d;
}

#page-payments .return-refund-badge--none {
  background: #f1f5f9;
  color: #64748b;
}

#page-payments .return-refund-remaining {
  color: #dc2626;
  font-weight: 700;
}

#page-payments .return-refund-action-btn {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.return-refund-modal-summary {
  margin: 0 0 0.75rem;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 600;
}

.return-refund-mob-card {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.return-refund-mob-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.return-refund-mob-product {
  margin: 0 0 8px;
  font-size: 0.9375rem;
}

.return-refund-mob-amount {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.return-refund-mob-amount strong {
  color: #dc2626;
  font-size: 1rem;
}

.return-refund-mob-meta {
  margin: 0 0 10px;
  font-size: 0.75rem;
  color: #64748b;
}

.return-refund-mob-btn {
  width: 100%;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.return-refunds-kpi-mobile {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fffbfb;
}

.return-refunds-kpi-mobile-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8125rem;
}

.return-refunds-kpi-mobile-value--debt {
  color: #dc2626;
  font-size: 1rem;
}

@media (max-width: 768px) {
  #page-payments .return-refunds-kpi-grid {
    grid-template-columns: 1fr;
  }

  #page-payments .return-refunds-table thead {
    display: none;
  }

  #page-payments .return-refunds-table-wrap {
    max-height: none;
    border: none;
    background: transparent;
  }

  #page-payments .return-refund-mobile-row td {
    display: block;
    padding: 0 0 10px;
    border: none;
  }
}
