/* Báo cáo vay — cùng ngôn ngữ thiết kế tối giản với Nhật ký thu chi. */
.loan-card { border: 1px solid #e5e7eb; box-shadow: none; }
.loan-card .card-header { background: #fafafa; border-bottom: 1px solid #e5e7eb; }

.loan-card label,
.loan-form label,
#loanLedgerModal label {
  color: #6b7280;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.loan-card .form-control,
#loanLedgerModal .form-control { border-color: #e5e7eb; font-size: 13px; height: 34px; }

.loan-filters { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 12px; }
.loan-field { min-width: 0; }
.loan-field-date { flex: 0 0 150px; }
.loan-field-select { flex: 1 1 160px; max-width: 200px; }
.loan-field-search { flex: 1 1 200px; }

.loan-search { position: relative; }
.loan-search .fa-search {
  color: #9ca3af;
  font-size: 12px;
  left: 10px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.loan-search .form-control { padding-left: 30px; }

.loan-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.loan-unit .btn { font-size: 12px; height: 34px; }
.loan-btn {
  align-items: center;
  background: #fff;
  border-color: #d1d5db;
  color: #374151;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}
.loan-btn:hover { background: #f3f4f6; color: #111827; }

.loan-summary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.loan-summary-item { border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; }
.loan-summary-label { color: #6b7280; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.loan-summary-value { color: #111827; font-size: 18px; font-variant-numeric: tabular-nums; font-weight: 700; }
.loan-summary-warning { background: #fef2f2; border-color: #fecaca; }
.loan-summary-warning .loan-summary-value { color: #b91c1c; }
.loan-negative { color: #b45309; }

.loan-alert { border: 1px solid #e5e7eb; border-radius: 6px; font-size: 12px; margin-bottom: 8px; padding: 8px 12px; }
.loan-alert-danger { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.loan-alert-warning { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.loan-alert-muted { background: #f9fafb; color: #4b5563; }
.loan-unmapped code { font-size: 11px; }

.loan-table-wrap { border-top: 1px solid #e5e7eb; max-height: calc(100vh - 330px); overflow: auto; }
.loan-table { font-size: 12px; font-variant-numeric: tabular-nums; }
.loan-table thead th {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  border-top: 0;
  color: #6b7280;
  font-size: 11px;
  font-weight: 600;
  position: sticky;
  top: 0;
  white-space: nowrap;
  z-index: 2;
}
.loan-table td { border-top: 1px solid #f3f4f6; vertical-align: middle; white-space: nowrap; }
.loan-table .loan-col-name { min-width: 260px; white-space: normal; }

.loan-group-row td { background: #f3f4f6; color: #111827; font-weight: 700; text-transform: uppercase; }
.loan-facility-row td { background: #fff; font-weight: 600; }
.loan-facility-name { color: #111827; }
.loan-sub { color: #9ca3af; display: block; font-size: 11px; font-weight: 400; margin-left: 20px; }
.loan-toggle { background: none; border: 0; color: #6b7280; padding: 0 6px 0 0; width: 20px; }
.loan-contract-row td { color: #374151; }
.loan-contract-name { padding-left: 28px !important; }
.loan-collateral { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.loan-days { color: inherit; display: block; font-size: 10px; font-weight: 600; }
.loan-due-soon td { background: #fef2f2; color: #991b1b; }
.loan-due-warn td { background: #fffbeb; }

.loan-group-total td { background: #f9fafb; border-top: 1px solid #e5e7eb; font-weight: 700; }
.loan-table tfoot td { background: #111827; color: #fff; font-weight: 700; position: sticky; bottom: 0; }

.loan-status { border-radius: 10px; display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; }
.loan-status-ok { background: #dcfce7; color: #166534; }
.loan-status-warn { background: #fef3c7; color: #92400e; }
.loan-status-bad { background: #fee2e2; color: #991b1b; }
.loan-status-muted { color: #9ca3af; }

.loan-rate-row { align-items: center; display: grid; gap: 8px; grid-template-columns: 180px 120px 20px; margin-bottom: 6px; }
.loan-rate-editor .loan-rate-row { grid-template-columns: 180px 120px 56px 20px; }
.loan-rate-editor > td { background: #fffbeb; }

.loan-ledger-table { font-size: 12px; font-variant-numeric: tabular-nums; }
.loan-ledger-table thead th { background: #f9fafb; font-size: 11px; white-space: nowrap; }
.loan-ledger-opening td { background: #f9fafb; font-weight: 600; }

@media (max-width: 767px) {
  .loan-field-date, .loan-field-select, .loan-field-search { flex: 1 1 100%; max-width: none; }
  .loan-actions { margin-left: 0; }
}

/* Bố cục theo file Excel "Báo cáo vay" của kế toán: mỗi nhóm có dòng tổng trên tiêu đề cột. */
.loan-sheet { border: 0; }
.loan-sheet td, .loan-sheet th { border-color: #e5e7eb; }
.loan-sheet-title {
  caption-side: top;
  color: #111827;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 12px;
  text-align: center;
}
.loan-sheet-title small { color: #6b7280; font-size: 11px; font-weight: 400; margin-left: 8px; }
.loan-sheet .loan-group-row td { background: #fff; border-left: 0; border-right: 0; font-size: 13px; text-transform: none; }
.loan-subtotal-row td { background: #fffbeb; color: #111827; font-weight: 700; }
.loan-header-row th {
  background: #f3f4f6;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  white-space: normal;
}
.loan-header-row th.text-right { text-align: right; }

/* Dòng nhóm + dòng tổng + tiêu đề cột dính trên cùng khi cuộn; nhóm sau đè lên nhóm trước.
   Chiều cao 2 dòng đầu cố định để tính được top của dòng kế tiếp. */
.loan-sheet { --loan-sticky-row: 32px; }
.loan-sheet .loan-group-row td,
.loan-sheet .loan-subtotal-row td,
.loan-sheet .loan-header-row th { position: sticky; z-index: 3; }
.loan-sheet .loan-group-row td { height: var(--loan-sticky-row); top: 0; }
.loan-sheet .loan-subtotal-row td { height: var(--loan-sticky-row); top: var(--loan-sticky-row); }
.loan-sheet .loan-header-row th { box-shadow: inset 0 -1px 0 #d1d5db; top: calc(var(--loan-sticky-row) * 2); }
.loan-sheet .loan-col-lender { color: #111827; font-weight: 600; min-width: 90px; }
.loan-sheet .loan-col-name { cursor: pointer; min-width: 200px; }
.loan-sheet .loan-sub { display: inline; margin-left: 4px; }
.loan-facility-first td { border-top: 2px solid #d1d5db; }
.loan-row-unallocated td { background: #f9fafb; color: #6b7280; font-style: italic; }
.loan-col-actions { width: 1%; }
.loan-spacer td { border: 0; height: 16px; padding: 0; }
.loan-indenture-link { color: #1d4ed8; }
.loan-indenture-link:hover { text-decoration: underline; }
.loan-indenture-badge { background: #eff6ff; border-radius: 10px; color: #1d4ed8; font-size: 10px; font-weight: 600; margin-left: 4px; padding: 1px 6px; }
