/* Payment Ledger / Payment Submissions (app/finance/payments): a payment verification workspace.
   Same compact ledger system as the Expenses, Income and Financial Reports pages: 4px spacing scale, brand tokens only, neutral elevation,
   sentence-case labels, tabular numerals. Teal marks selection and the primary action; gold marks what is waiting for a decision.
   Scoped to this page (.pl-page, body[data-nav="payments"]). */

/* ---------------------------------------------------------------- page shell */
body.has-topbar[data-nav="payments"] .admin-header { display: none; }

/* .pl-page is also .admin-content, which grows to fill the viewport: a top-aligned flex column cannot stretch its rows into gaps. */
.pl-page { display: flex; flex-direction: column; align-content: flex-start; gap: 12px; width: 100%; max-width: 1440px; padding-top: 16px; padding-bottom: 32px; caret-color: var(--c-primary); }
.pl-page ::selection, .pl-review ::selection { background: #cde6ec; color: var(--c-text); }
.pl-page > #adminAlert { position: fixed; top: calc(var(--adm-topbar-h, 56px) + 12px); right: 24px; z-index: 200; width: min(420px, calc(100vw - 32px)); margin: 0; box-shadow: var(--e-2); }
.pl-page :where(button, select, input):focus-visible, .pl-review :where(button, a):focus-visible, .pl-stage:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

.pl-head h1 { margin: 0; color: var(--c-text); font-family: var(--font-sans); font-size: 1.5rem; font-weight: 650; line-height: 1.2; letter-spacing: -.02em; }
.pl-head p { margin: 2px 0 0; color: var(--c-text-muted); font-size: .8125rem; }
.pl-note { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; padding: 6px 12px; border: 1px solid #d6e9ef; border-radius: 8px; background: #f4fafc; color: var(--c-text-secondary); font-size: .75rem; line-height: 1.45; }
.pl-note i { flex: none; color: var(--c-primary); font-size: .75rem; }
.pl-note span { min-width: 0; }

/* ---------------------------------------------------------------- summary band: four cells that are also the status filters; what awaits review is gold */
.pl-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); }
.pl-stat { display: grid; align-content: center; gap: 2px; min-width: 0; min-height: 76px; margin: 0; padding: 12px 20px; border: 0; border-left: 1px solid var(--c-border); border-radius: 0; background: none; box-shadow: none; color: var(--c-text); font: inherit; text-align: left; cursor: pointer; transition: background var(--t-fast) var(--ease); }
.pl-stat:first-child { border-left: 0; background: #fff8e8; }
.pl-stat:hover { background: #f8fafb; }
.pl-stat:first-child:hover { background: #fff3d6; }
.pl-stat[aria-pressed="true"] { background: #f4fafc; box-shadow: inset 0 -2px 0 var(--c-primary); }
.pl-stat:first-child[aria-pressed="true"] { background: #fff3d6; box-shadow: inset 0 -2px 0 var(--c-accent); }
.pl-stat .k { color: var(--c-text-muted); font-size: .75rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.pl-stat .v { color: var(--c-text); font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pl-stat:first-child .v { color: #7a4d00; }
.pl-stat .s { color: var(--c-text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- the ledger panel: one compact toolbar, then the table */
.pl-panel { container: pl / inline-size; min-width: 0; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); overflow: clip; }
.pl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--c-border); }
.pl-control { height: 36px; min-width: 0; max-width: 100%; padding: 0 10px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; color: var(--c-text); font: inherit; font-size: .8125rem; }
.pl-control::placeholder { color: var(--c-text-muted); }
.pl-control:hover { border-color: #aab6c2; }
.pl-control:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus-ring); }
select.pl-control { flex: 0 1 160px; min-width: 128px; padding-right: 24px; }
input[type="date"].pl-control { flex: 0 0 140px; }
.pl-search { flex: 1 1 200px; max-width: 320px; min-width: 150px; }
.pl-ghost { flex: none; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--c-text-secondary); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; }
.pl-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.pl-ghost[hidden] { display: none; }
.pl-count { margin-left: auto; color: var(--c-text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.pl-loader { min-height: 0; padding: 16px; }

/* ---------------------------------------------------------------- table */
.pl-table-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
.pl-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: .8125rem; }
.pl-table th { padding: 9px 12px; border-bottom: 1px solid var(--c-border); background: #f8fafb; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; letter-spacing: 0; text-align: left; text-transform: none; white-space: nowrap; }
.pl-table td { padding: 10px 12px; border-bottom: 1px solid #eef1f4; color: var(--c-text-secondary); vertical-align: middle; }
.pl-table th:first-child, .pl-table td:first-child { padding-left: 16px; }
.pl-table th:last-child, .pl-table td:last-child { padding-right: 16px; }
.pl-table tbody tr:last-child td { border-bottom: 0; }
.pl-table tbody tr:hover td { background: #f9fbfc; }
.pl-table tr.is-pending td { background: #fffaf0; }
.pl-table tr.is-pending:hover td { background: #fff5e0; }
.pl-table th.num, .pl-table td.num { text-align: right; }
.pl-table td.num { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--c-text); }
.pl-table td:nth-child(1), .pl-table td:nth-child(5), .pl-table td:nth-child(6) { white-space: nowrap; }
.pl-table td:nth-child(1), .pl-table td:nth-child(6) { font-variant-numeric: tabular-nums; }
.pl-name { display: block; color: var(--c-text); font-weight: 600; }
.pl-sub { display: block; margin-top: 1px; color: var(--c-text-muted); font-size: .75rem; line-height: 1.35; }
.pl-table small { color: var(--c-text-muted); font-size: .75rem; }
.pl-unassigned { font-style: italic; }
.pl-table .tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--c-warning-bg); color: var(--c-warning); font-size: .75rem; font-weight: 600; }
.pl-muted { color: var(--c-text-muted); font-size: .8125rem; }

/* status: a small dot and a name; pending is gold */
.pl-table .badge { display: inline-flex; align-items: center; gap: 8px; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pl-table .badge::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pl-table .badge-pending { background: #fff1d6; color: #7a4d00; }
.pl-table .badge-pending::before { background: var(--c-accent); }
.pl-table .badge-active { background: var(--c-success-bg); color: var(--c-success); }
.pl-table .badge-inactive { background: var(--c-danger-bg); color: var(--c-danger); }

/* receipt column */
.pl-receipt-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border: 1px solid #c4dde5; border-radius: 8px; background: #f4fafc; color: var(--c-primary); font: inherit; font-size: .8125rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.pl-receipt-btn:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.pl-receipt-btn i { font-size: .75rem; }
.pl-noreceipt { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--c-text-muted); font: inherit; font-size: .8125rem; white-space: nowrap; cursor: pointer; }
.pl-noreceipt i { font-size: .75rem; color: #b4bec8; }
.pl-noreceipt:hover { background: var(--c-bg); color: var(--c-text-secondary); }

/* row actions (the existing approve / reject buttons and Reverse) */
.pl-table .pl-actions { white-space: nowrap; }
.pl-table .btn-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: 4px; padding: 0; border: 0; border-radius: 8px; color: #fff; font-size: .8125rem; cursor: pointer; }
.pl-table .btn-icon:last-child { margin-right: 0; }
.pl-table .btn-approve { background: var(--c-success); }
.pl-table .btn-approve:hover { background: #0f5c39; }
.pl-table .btn-delete { background: var(--c-danger); }
.pl-table .btn-delete:hover { background: #8f1c12; }
.pl-table .btn-outline { min-height: 32px; padding: 0 12px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; color: var(--c-text-secondary); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; }
.pl-table .btn-outline:hover { background: var(--c-bg); color: var(--c-text); }
.pl-empty { padding: 32px 16px !important; color: var(--c-text-muted) !important; font-size: .8125rem; text-align: center; }
.pl-empty i { display: block; margin-bottom: 8px; color: #b4bec8; font-size: 1.25rem; }
.pl-more { display: flex; justify-content: center; padding: 12px 16px; border-top: 1px solid var(--c-border); }
.pl-more[hidden] { display: none; }

/* ---------------------------------------------------------------- verification drawer */
.pl-review-backdrop { position: fixed; inset: 0; z-index: 940; background: rgba(4, 24, 34, .5); }
.pl-review-backdrop[hidden], .pl-review[hidden] { display: none; }
.pl-review { position: fixed; top: 0; right: 0; bottom: 0; z-index: 950; display: flex; flex-direction: column; width: min(1000px, 100vw); background: var(--c-surface); box-shadow: var(--e-3); color: var(--c-text); }
.pl-review-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--c-border); }
.pl-review-titles { flex: 1; min-width: 0; }
.pl-review-titles h2 { margin: 0; font-family: var(--font-sans); font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }
.pl-review-titles p { margin: 1px 0 0; overflow: hidden; color: var(--c-text-muted); font-size: .8125rem; text-overflow: ellipsis; white-space: nowrap; }
.pl-review-nav { display: flex; align-items: center; gap: 4px; color: var(--c-text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.pl-iconbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; color: var(--c-text-secondary); font-size: .8125rem; cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.pl-iconbtn:hover:not(:disabled) { background: var(--c-bg); color: var(--c-text); }
.pl-iconbtn:disabled { opacity: .4; cursor: not-allowed; }
.pl-iconbtn[aria-pressed="true"] { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary); }

.pl-review-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.pl-viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--c-border); background: #e9edf0; }
.pl-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--c-border); background: #fff; }
.pl-viewer-title { color: var(--c-text-secondary); font-size: .8125rem; font-weight: 600; }
.pl-zoom { display: flex; align-items: center; gap: 4px; }
.pl-zoomlevel { min-width: 52px; height: 32px; padding: 0 8px; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; color: var(--c-text-secondary); font: inherit; font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.pl-zoomlevel:hover { background: var(--c-bg); color: var(--c-text); }
.pl-stage { position: relative; flex: 1; min-height: 0; display: flex; overflow: auto; background: #e9edf0; scrollbar-width: thin; }
.pl-stage.is-zoomed { cursor: grab; }
.pl-stage.is-dragging { cursor: grabbing; user-select: none; }
.pl-stage img { display: block; border-radius: 4px; background: #fff; box-shadow: var(--e-2); }
.pl-stage.is-fit img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; border-radius: 0; background: transparent; box-shadow: none; }
.pl-stage.is-zoomed img { flex: none; max-width: none; margin: auto; }
.pl-stage.is-zoomed { padding: 12px; }
.pl-viewer.is-full { position: fixed; inset: 0; z-index: 960; border: 0; }
.pl-viewer.is-full .pl-stage { background: #0f1b2a; }

/* receipt states: loading, nothing uploaded, cannot be shown */
.pl-state { display: grid; justify-items: center; align-content: center; gap: 8px; width: 100%; padding: 24px; text-align: center; }
.pl-state i { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: var(--c-text-muted); font-size: 1.125rem; box-shadow: var(--e-1); }
.pl-state strong { color: var(--c-text); font-size: .9375rem; font-weight: 650; }
.pl-state span { max-width: 38ch; color: var(--c-text-secondary); font-size: .8125rem; line-height: 1.5; }
.pl-state .pl-ghost { background: #fff; border: 1px solid var(--c-border-strong); }
.pl-state.is-error i { background: var(--c-danger-bg); color: var(--c-danger); }
.pl-state.is-none i { background: #fff1d6; color: #7a4d00; }
.pl-skel { width: min(300px, 70%); height: min(60%, 420px); border-radius: 8px; background: linear-gradient(90deg, #dde3e8 25%, #eef1f3 50%, #dde3e8 75%); background-size: 200% 100%; animation: pl-shimmer 1.4s ease-in-out infinite; }
@keyframes pl-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* the payment's details, beside the receipt */
.pl-facts { display: flex; flex-direction: column; min-height: 0; padding: 16px; overflow-y: auto; }
.pl-facts dl { display: grid; gap: 12px; margin: 0; }
.pl-facts dl > div { display: grid; gap: 2px; min-width: 0; }
.pl-facts dt { color: var(--c-text-muted); font-size: .75rem; font-weight: 600; }
.pl-facts dd { margin: 0; overflow-wrap: anywhere; color: var(--c-text); font-size: .875rem; font-weight: 600; }
.pl-facts dd small { display: block; margin-top: 1px; color: var(--c-text-muted); font-size: .75rem; font-weight: 400; }
.pl-facts .pl-bigamount { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pl-facts .pl-ref { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.pl-facts .pl-ref button { flex: none; height: 24px; padding: 0 8px; border: 1px solid var(--c-border); border-radius: 6px; background: #fff; color: var(--c-text-secondary); font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer; }
.pl-facts .pl-ref button:hover { background: var(--c-bg); }
.pl-facts .badge { display: inline-flex; align-items: center; gap: 8px; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.pl-facts .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pl-facts .badge-pending { background: #fff1d6; color: #7a4d00; }
.pl-facts .badge-pending::before { background: var(--c-accent); }
.pl-facts .badge-active { background: var(--c-success-bg); color: var(--c-success); }
.pl-facts .badge-inactive { background: var(--c-danger-bg); color: var(--c-danger); }
.pl-review-msg { margin-top: 12px; padding: 8px 12px; border: 1px solid #f3c9c4; border-radius: 8px; background: var(--c-danger-bg); color: var(--c-danger); font-size: .8125rem; line-height: 1.45; }
.pl-review-msg[hidden] { display: none; }
.pl-review-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--c-border); background: var(--c-surface); }
.pl-review-foot p { margin: 0; color: var(--c-text-muted); font-size: .75rem; }
.pl-review-actions { display: flex; flex: none; gap: 8px; }
.pl-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; color: var(--c-text-secondary); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.pl-btn:hover { background: var(--c-bg); color: var(--c-text); }
.pl-btn--approve { border-color: var(--c-success); background: var(--c-success); color: #fff; }
.pl-btn--approve:hover { border-color: #0f5c39; background: #0f5c39; color: #fff; }
.pl-btn--reject { border-color: #e7b9b3; background: #fff; color: var(--c-danger); }
.pl-btn--reject:hover { border-color: var(--c-danger); background: var(--c-danger-bg); color: var(--c-danger); }

/* ---------------------------------------------------------------- responsive (structural: the panel's own width decides when rows become cards) */
@container pl (min-width: 881px) {
  .pl-table td.pl-actions { display: table-cell; }
  .pl-table td.pl-actions .btn-icon, .pl-table td.pl-actions .btn { vertical-align: middle; }
}
@container pl (max-width: 880px) {
  .pl-toolbar { padding-inline: 12px; }
  .pl-search { flex: 1 1 100%; max-width: none; order: -1; }
  select.pl-control { flex: 1 1 calc(50% - 4px); }
  input[type="date"].pl-control { flex: 1 1 calc(50% - 4px); }
  .pl-count { flex-basis: 100%; margin-left: 0; }

  .pl-table-wrap { overflow: visible; }
  .pl-table, .pl-table tbody { display: block; width: 100%; }
  .pl-table thead { position: absolute; left: -9999px; }
  .pl-table tr { display: flex; flex-direction: column; gap: 0; margin: 0; padding: 10px 12px; border-bottom: 1px solid #eef1f4; }
  .pl-table tbody tr:last-child { border-bottom: 0; }
  .pl-table tr.is-pending { background: #fffaf0; }
  .pl-table td, .pl-table td:first-child, .pl-table td:last-child { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; width: auto; padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; white-space: normal !important; }
  .pl-table tbody tr:hover td, .pl-table tr.is-pending td, .pl-table tr.is-pending:hover td { background: transparent; }
  .pl-table td::before { content: attr(data-label); flex: none; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; text-align: left; }
  .pl-table td .pl-name, .pl-table td .pl-sub { text-align: right; }
  .pl-table td.pl-who { order: -2; flex-direction: column; align-items: flex-start; gap: 0; padding-top: 0; font-size: .9375rem; text-align: left; }
  .pl-table td.pl-who::before, .pl-table td.pl-actions::before { display: none; }
  .pl-table td.pl-who .pl-name, .pl-table td.pl-who .pl-sub { text-align: left; }
  .pl-table td.pl-amt { order: -1; font-size: 1.125rem; }
  .pl-table td[data-label="Status"] .badge { margin-left: auto; }
  .pl-table td.pl-actions { justify-content: flex-end; gap: 8px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--c-border); }
  .pl-table td.pl-actions:empty { display: none; }
  .pl-table td.pl-rcpt .pl-receipt-btn, .pl-table td.pl-rcpt .pl-noreceipt { min-height: 36px; }
  .pl-more, .pl-loader { padding-inline: 12px; }
}
@media (max-width: 768px) {
  .pl-table .btn-icon, .pl-table .btn-outline { min-height: 44px; }
  .pl-control { height: 44px; }
  .pl-table .btn-icon { width: 44px; height: 44px; }
  .pl-receipt-btn, .pl-noreceipt { min-height: 44px; }
}
@media (max-width: 820px) {
  .pl-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pl-stat { border-left: 0; border-top: 1px solid var(--c-border); }
  .pl-stat:nth-child(odd) { border-right: 1px solid var(--c-border); }
  .pl-stat:nth-child(-n + 2) { border-top: 0; }
  .pl-review { width: 100vw; }
  .pl-review-body { display: flex; flex-direction: column; overflow-y: auto; }
  .pl-viewer { flex: 0 0 min(58vh, 520px); border-right: 0; border-bottom: 1px solid var(--c-border); }
  .pl-facts { flex: none; overflow: visible; }
  .pl-review-foot { flex-wrap: wrap; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .pl-review-foot p { flex-basis: 100%; }
  .pl-review-actions { flex: 1; }
  .pl-review-actions .pl-btn { flex: 1; min-height: 44px; }
}
@media (max-width: 680px) {
  .pl-page { gap: 8px; padding-top: 8px; }
  .pl-page > #adminAlert { right: 16px; }
  .pl-head h1 { font-size: 1.25rem; }
  .pl-stat { padding: 10px 14px; min-height: 68px; }
  .pl-stat .v { font-size: 1.25rem; }
  .pl-review-titles p { font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) { .pl-skel { animation: none; } .pl-stat, .pl-receipt-btn, .pl-iconbtn, .pl-btn { transition: none; } }
