/* Pay Office page (pay-office.html) — named classes for what used to be inline styles (29/10/2026).
   Same pattern as finance.css (fn-*) and exco.css (ex-*): written `html body .po-…`; spacing and
   alignment carry !important (they replace inline styles, so they must beat component padding/margins);
   colour and display do not, so JS that sets style.display / colours still wins.
   Tokens only. Loaded just before /css/theme.css, which stays last.
   (po-filter-bar, po-no-admin and po-admin-only are older page classes kept in pay-office.html.) */

/* ── Text ─────────────────────────────────────────────────────────────── */
html body .po-kicker { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
html body .po-block-kicker { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px !important; }
html body .po-lead { font-size: 13px; color: var(--text-muted); }
html body .po-note { font-size: 12px; color: var(--text-muted); }
html body .po-note-xs { font-size: 11.5px; color: var(--text-muted); }
html body .po-muted { color: var(--text-muted); }
html body .po-mid { color: var(--text-mid, var(--text)); }
html body .po-text { color: var(--text); }
html body .po-upper { text-transform: uppercase; }
html body .po-fw800 { font-weight: 800; }
html body .po-label { font-size: 12px; font-weight: 600; }
html body .po-warn-text { color: var(--warning); font-weight: 600; }
/* Something is missing or taken back (account number missing, clawback) */
html body .po-danger-strong { color: var(--danger); font-weight: 700; }
html body .po-ok { color: var(--success); }
/* References and account numbers */
html body .po-ref { font-weight: 700; font-size: 12px; color: var(--text-mid, var(--text)); font-family: var(--vq-mono, monospace) !important; }
html body .po-mono-xs { font-size: 11.5px; font-family: var(--vq-mono, monospace) !important; white-space: nowrap; }
/* Text-only button (View PoP) */
html body .po-linkbtn { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0 !important; text-decoration: underline; }

/* ── Chips and badges ─────────────────────────────────────────────────── */
/* Billing type / batch status label: neutral (the words carry the meaning) */
html body .po-chip { font-size: 11.5px; font-weight: 600; background: var(--surface2); color: var(--text-mid, var(--text)); border: 1px solid var(--border); border-radius: 5px; padding: 2px 8px !important; white-space: nowrap; }
/* History "Agents" column: type label then the names */
html body .po-type-row { display: flex; align-items: baseline !important; gap: 5px; margin-bottom: 3px !important; flex-wrap: wrap; }
html body .po-type-chip { font-size: 11px; font-weight: 700; background: var(--surface2); color: var(--text-mid, var(--text)); border: 1px solid var(--border); padding: 1px 6px !important; border-radius: 10px; white-space: nowrap; }
html body .po-type-names { font-size: 11.5px; color: var(--text-mid, var(--text)); line-height: 1.4; }
/* AR "awaiting" strip: one chip per bank */
html body .po-strip-lbl { font-size: 11.5px; font-weight: 700; color: var(--text-muted); align-self: center !important; margin-right: 2px !important; }
html body .po-strip-chip { display: inline-flex; align-items: center !important; gap: 6px; background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 20px; padding: 5px 12px !important; font-size: 12px; cursor: pointer; }
html body .po-strip-val { font-weight: 700; font-family: var(--vq-mono, monospace) !important; font-variant-numeric: tabular-nums; }
html body .po-stale { background: var(--warning-soft); color: var(--warning); border-radius: 8px; padding: 1px 6px !important; font-size: 11px; font-weight: 700; }
/* Paid companies in History: avatar and count in the "paid" colour */
html body .company-avatar.po-avatar-paid { background: var(--success); color: var(--on-accent); }
html body .company-batch-count.po-count-paid { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
html body .company-total.po-total-paid { color: var(--success); }

/* ── Boxes ────────────────────────────────────────────────────────────── */
html body .po-alert-row { display: flex; align-items: flex-start !important; gap: 10px; }
html body .po-alert-icon { flex-shrink: 0; margin-top: 1px !important; }
html body .po-empty-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
/* AR bulk-selection bar (JS shows it with style.display = 'flex') */
html body .po-bulk-bar { align-items: center !important; gap: 10px; background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); border-radius: 10px; padding: 10px 14px !important; margin-bottom: 12px !important; }
html body .po-bulk-count { font-size: 12px; font-weight: 700; color: var(--warning); }
html body .po-toolbar { display: flex; align-items: center !important; justify-content: space-between !important; flex-wrap: wrap; gap: 10px; margin-bottom: 14px !important; }
html body .po-actions { display: flex; gap: 10px; flex-wrap: wrap; }
html body .po-pay-section { margin-top: 24px !important; padding-top: 20px !important; border-top: 1px solid var(--border); }
html body .po-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px !important; }
/* Capture entry: commission preview (JS shows it) */
html body .po-calc-box { background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); border-radius: 8px; padding: 10px 14px !important; font-size: 12px; color: var(--success); margin-bottom: 10px !important; }
/* Instruction yes/no choice: the selected look (border, fill, text) is set by setCeInstructionFlag */
html body .po-choice { flex: 1; padding: 8px !important; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); color: var(--text-muted); font-weight: 600; font-size: 12px; cursor: pointer; }
html body .po-radio { display: flex; align-items: center !important; gap: 6px; font-weight: 400; }
html body .po-readonly { font-weight: 600; background: var(--surface2); }

/* Batch detail: one card per payee */
html body .po-payee { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 16px !important; margin-bottom: 12px !important; }
html body .po-payee-head { display: flex; align-items: flex-start !important; justify-content: space-between !important; flex-wrap: wrap; gap: 8px; margin-bottom: 14px !important; }
html body .po-payee-name { font-weight: 700; font-size: 15px; color: var(--text); }
/* What this person is paid: a payout, not a state — neutral, in figures */
html body .po-payee-amt { font-size: 22px; font-weight: 800; color: var(--text); font-family: var(--vq-mono, monospace) !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
html body .po-lines-tbl { font-size: 12px; background: var(--surface); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
html body .po-cell { padding: 8px 12px !important; border-bottom: 1px solid var(--border); }
html body .po-bg2 { background: var(--surface2); }

/* Return-one-payee dialog (built by returnPayee) */
html body .po-dlg { background: var(--surface); color: var(--text); border-radius: 12px; max-width: 460px; width: 100%; padding: 20px !important; }
html body .po-dlg-title { margin: 0 0 6px !important; font-size: 16px; }
html body .po-dlg-text { margin: 0 0 10px !important; font-size: 13px; color: var(--text-muted); }
html body .po-dlg-ta { width: 100%; margin: 4px 0 12px !important; }

/* ── Tables ───────────────────────────────────────────────────────────── */
html body .po-r { text-align: right !important; }
html body .po-c { text-align: center !important; }
/* Money / count cells: right-aligned (po-r) in Plex Mono with even digits (num, fonts.css) */
html body .po-amt-strong { font-weight: 800; color: var(--text); }
/* Action buttons in a row (kept as the flex cell they were) */
html body .po-actions-cell { white-space: nowrap !important; display: flex; flex-wrap: wrap; gap: 4px; }
html body .po-actions-cell.po-nowrap-cell { flex-wrap: nowrap; }

/* ── Layout ───────────────────────────────────────────────────────────── */
html body .po-flex { display: flex; }
html body .po-wrap { flex-wrap: wrap; } html body .po-grow { flex: 1; }
html body .po-items-center { align-items: center !important; } html body .po-items-end { align-items: flex-end !important; }
html body .po-end { justify-content: flex-end !important; }
html body .po-gap6 { gap: 6px; } html body .po-gap8 { gap: 8px; } html body .po-gap10 { gap: 10px; } html body .po-gap16 { gap: 16px; }
html body .po-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
html body .po-cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Sizes */
html body .po-w100 { width: 100%; } html body .po-w120 { width: 120px; }
html body .po-minw220 { min-width: 220px; } html body .po-minw240 { min-width: 240px; }
html body .po-maxw260 { max-width: 260px; } html body .po-maxw380 { max-width: 380px; } html body .po-maxw480 { max-width: 480px; }
html body .po-maxw520 { max-width: 520px; } html body .po-maxw600 { max-width: 600px; } html body .po-maxw640 { max-width: 640px; }
html body .po-maxw920 { max-width: 920px; }

/* Spacing (same strength as the inline styles they replace) */
html body .po-mt2 { margin-top: 2px !important; } html body .po-mt18 { margin-top: 18px !important; }
html body .po-ml6 { margin-left: 6px !important; }
html body .po-pl20 { padding-left: 20px !important; } html body .po-pr8 { padding-right: 8px !important; } html body .po-pr16 { padding-right: 16px !important; }

/* ── KPI tiles: a large Rand amount (R 1 234 567,89) shrinks to fit its tile instead of wrapping ── */
html body .stat-card { container-type: inline-size; }
html body .stat-card .stat-val { font-size: clamp(14px, 10.5cqi, 20px); white-space: nowrap; }
/* Batch detail facts (company, bank, status…) are words as well as figures: smaller, and they may wrap */
html body .stat-card .stat-val.po-meta-val { font-size: 15px; white-space: normal; overflow-wrap: anywhere; }
/* words (company, bank, status) in the reading font; figures stay Plex Mono */
html body .stat-card .stat-val.po-meta-val:not(.po-money) { font-family: var(--vq-sans) !important; }
html body .stat-card .stat-val.po-meta-val.po-money { font-size: clamp(13px, 11.5cqi, 15px); white-space: nowrap; overflow-wrap: normal; }
/* A narrow tile drops its faint corner icon so the figure has the room */
@container (max-width: 200px) { html body .stat-card .stat-icon { display: none; } }
/* P&L summary: seven tiles share two rows, so each figure keeps a readable size */
html body .po-kpi-wide > .stat-card { flex-basis: 220px; }

/* ── Fixes ────────────────────────────────────────────────────────────── */
/* Capture entry: the amount-collected and travel rows are meant to stay hidden until the outcome needs them
   (onCeOutcomeChange toggles .hidden; the page had no rule for it, so they always showed) */
html body .form-row.hidden { display: none; }
/* Action cells stay table cells (a flex <td> broke the row's border); buttons keep their spacing */
html body td.po-actions-cell { display: table-cell; white-space: normal !important; min-width: 220px; }
html body td.po-actions-cell.po-nowrap-cell { white-space: nowrap !important; min-width: 0; }
html body td.po-actions-cell > :is(.btn, span) { margin: 2px 4px 2px 0 !important; vertical-align: middle; }
/* Month and number fields in the filter bars look like the other fields */
html body .po-filter-bar :is(input[type="month"], input[type="number"]) {
  background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); border-radius: 8px; padding: 7px 10px !important; font-family: inherit;
}
/* Dark theme: destructive buttons (Reject, Withdraw, Delete, Revoke, Reverse) keep their red
   (the theme turns every non-primary button slate). Text mixed towards white for 4.5:1 on dark. */
html[data-theme="dark"] body button.btn.btn-danger:not(.btn-primary) {
  background-color: var(--danger-soft); color: color-mix(in srgb, var(--danger) 70%, var(--text)); border-color: color-mix(in srgb, var(--danger) 50%, transparent);
}

/* Phones: two- and three-column form rows stack (as the inline versions did through theme.css);
   modals give the content more room and the batch facts sit two to a row */
@media (max-width: 520px) {
  html body :is(.po-cols-2, .po-cols-3) { grid-template-columns: 1fr; }
  html body .modal-box { padding: 20px 16px !important; }
  html body .po-meta-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

/* ── AR row actions (29/10/2026): one visible action + a "⋯" menu (toggleRowMenu in pay-office.html) ── */
html body td.po-actions-cell.po-ar-actions { white-space: nowrap !important; min-width: 0; }
html body .po-menu-btn { min-width: 34px; font-weight: 800; letter-spacing: .05em; }
/* The open menu is moved to <body> and placed with position: fixed, so the table's scroll box can't clip it */
html body .po-menu {
  position: fixed; z-index: 1200; min-width: 190px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); padding: 4px !important;
}
html body .po-menu[hidden] { display: none; }
html body .po-menu .po-menuitem {
  display: flex; align-items: center !important; width: 100%; min-height: 36px; gap: 8px;
  background: transparent; color: var(--text); border: none; border-radius: 6px; box-shadow: none;
  padding: 8px 12px !important; margin: 0 !important; font: inherit; font-size: 13px; font-weight: 500;
  text-align: left !important; white-space: nowrap; cursor: pointer;
}
html body .po-menu .po-menuitem:hover, html body .po-menu .po-menuitem:focus { background: var(--surface2); }
html body .po-menu .po-menuitem:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Reject: destructive, so red (mixed towards the text colour for 4.5:1, as the dark danger buttons above) */
html body .po-menu .po-menuitem.po-menuitem-danger { color: color-mix(in srgb, var(--danger) 80%, var(--text)); }
html[data-theme="dark"] body .po-menu .po-menuitem.po-menuitem-danger { color: color-mix(in srgb, var(--danger) 70%, var(--text)); }

/* AR "awaiting" strip chips are buttons now (keyboard reaches them): same look, visible focus ring */
html body button.po-strip-chip { font-family: inherit; line-height: 1.3; text-align: left !important; }
html body button.po-strip-chip:hover { border-color: var(--accent); }
html body button.po-strip-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Screen-reader-only text (the actions column header) */
html body .po-sr { position: absolute; width: 1px; height: 1px; padding: 0 !important; margin: -1px !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Sidebar: dark in both themes, so its text uses the light slate secondaries (#94A3B8 labels ≈ 7:1,
   #CBD5E1 items ≈ 12:1 on #0D1117 / #07090C) — the page's --text-muted is a dark grey in the light theme */
html body .sidebar :is(.sb-section, .sb-brand-role, .sb-user) { color: #94A3B8; }
html body .sidebar :is(.sb-item:not(.active), .sb-signout) { color: var(--on-dark-2, #CBD5E1); }
html body .sidebar :is(.sb-item:not(.active), .sb-signout):hover { color: var(--on-dark, #E3E7EB); }

/* ── Phase 5 redesign: Accounts Payable awaiting payment on the design system (tokens only) ── */
.po-ds { display: flex; flex-direction: column; gap: var(--ds-space-4); }
.po-ds-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ds-space-3); flex-wrap: wrap; }
.po-ds-intro .ds-page-sub { margin: 0; max-width: 72ch; }
.po-ds-h { display: flex; align-items: center; gap: var(--ds-space-2); font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semibold); margin: var(--ds-space-4) 0 var(--ds-space-1); }
.po-ds-note { margin: 0 0 var(--ds-space-3); }
.po-ds-company { margin-bottom: var(--ds-space-4); }
.po-ds-company .ds-card-head .ds-hint { margin: 2px 0 0; }
.po-ds-total { display: flex; flex-direction: column; align-items: flex-end; }
.po-ds-total b { font-size: var(--ds-text-lg); }
.po-ds-ref { display: flex; flex-direction: column; gap: var(--ds-space-1); }
.po-ds-badges { flex-wrap: wrap; gap: var(--ds-space-1); }
.po-ds-act { text-align: right; }
.po-ds .ds-btn--sm { height: auto; min-height: 44px; }
@media (max-width: 640px) {
  .po-ds-act { text-align: left; }
  .po-ds-act .ds-btn { width: 100%; }
}
.po-ds-company .ds-card-head { flex-wrap: wrap; align-items: flex-start; }
.po-ds-total b { white-space: nowrap; }
.po-ds-ref { min-width: 0; max-width: 100%; }
.po-ds-badges .ds-badge { max-width: 100%; }
@media (max-width: 640px) {
  .po-ds-ref { align-items: flex-end; text-align: right; }
  .po-ds-badges { justify-content: flex-end; }
  .po-ds-total { align-items: flex-start; }
}

/* ── Phase 5 redesign: the batch window (tokens only) ── */
.po-bm .po-bm-sub { margin: 0 0 var(--ds-space-3); }
.po-bm .po-bm-kpis { margin-bottom: var(--ds-space-4); }
.po-bm .po-bm-sec { margin-bottom: var(--ds-space-5); }
.po-bm .po-bm-h { font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semibold); margin: 0 0 var(--ds-space-2); }
.po-bm .po-bm-who { display: inline-flex; flex-direction: column; gap: 2px; }
.po-bm .po-bm-copy { display: inline-flex; align-items: center; gap: var(--ds-space-2); flex-wrap: wrap; }
.po-bm .po-bm-bad td { background: var(--ds-warning-soft); }
.po-bm .po-bm-payee { margin-bottom: var(--ds-space-4); display: flex; flex-direction: column; gap: var(--ds-space-3); }
.po-bm .po-bm-payee-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--ds-space-3); flex-wrap: wrap; }
.po-bm .po-bm-name { margin: 0; font-size: var(--ds-text-md, 1rem); font-weight: var(--ds-weight-semibold); }
.po-bm .po-bm-payee-head .ds-hint { margin: 2px 0 0; }
.po-bm .po-bm-amt { display: flex; flex-direction: column; align-items: flex-end; }
.po-bm .po-bm-amt b { font-size: var(--ds-text-lg); white-space: nowrap; }
.po-bm .po-bm-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--ds-space-3); }
.po-bm .po-bm-dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--ds-space-1) var(--ds-space-3); margin: 0; padding: var(--ds-space-3);
  background: var(--ds-surface-2); border: 1px solid var(--ds-divider); border-radius: var(--ds-radius); font-size: var(--ds-text-sm); }
.po-bm .po-bm-dl dt { color: var(--ds-text-muted); }
.po-bm .po-bm-dl dd { margin: 0; overflow-wrap: anywhere; }
.po-bm .po-bm-dl--warn { background: var(--ds-warning-soft); border-color: var(--ds-warning); }
.po-bm .po-bm-actions { display: flex; flex-wrap: wrap; gap: var(--ds-space-2); align-items: center; }
.po-bm .po-bm-spacer { flex: 1; }
.po-bm .po-bm-drop { border: 2px dashed var(--ds-border); border-radius: var(--ds-radius); padding: var(--ds-space-4); text-align: center; background: var(--ds-surface-2); }
.po-bm .po-bm-drop.is-over { border-color: var(--ds-success); background: var(--ds-success-soft); }
.po-bm .po-bm-drop .ds-hint { margin: 0 0 var(--ds-space-2); }
.po-bm .po-bm-chosen { margin: var(--ds-space-2) 0 0; font-weight: var(--ds-weight-semibold); color: var(--ds-success); }
.po-bm .po-bm-notes { min-height: 72px; width: 100%; }
.po-bm .po-bm-pay { border-top: 1px solid var(--ds-divider); padding-top: var(--ds-space-4); display: flex; flex-direction: column; gap: var(--ds-space-3); }
.po-bm .po-bm-pay .ds-hint, .po-bm .po-bm-pay .alert { margin: 0; }
.po-bm .ds-btn { min-height: 44px; height: auto; }
@media (max-width: 640px) {
  .po-bm .po-bm-amt { align-items: flex-start; }
  .po-bm .po-bm-spacer { display: none; }
  .po-bm .po-bm-actions .ds-btn { flex: 1 1 100%; }
}

/* ── Phase 5: Payment history and All Accounts Payable on the design system (tokens only) ── */
.po-ds .po-ds-peoplecell { display: flex; flex-direction: column; gap: var(--ds-space-1); max-width: 340px; white-space: normal; }
.po-ds .po-ds-people { display: block; font-size: var(--ds-text-sm); line-height: var(--ds-leading-tight); }
.po-ds .po-ds-people .ds-badge { margin-right: var(--ds-space-1); }
.po-ds .ds-btn { min-height: 44px; height: auto; }
@media (max-width: 640px) { .po-ds .po-ds-peoplecell { max-width: none; align-items: flex-end; text-align: right; } }

/* ── Phase 5: Held for later and Deductions on the design system (tokens only) ── */
.po-ds .po-ds-who { display: inline-flex; flex-direction: column; gap: 2px; }
.po-ds .po-ds-heldlist { display: flex; flex-direction: column; gap: var(--ds-space-1); font-size: var(--ds-text-sm); white-space: normal; }
.po-ds .po-ds-held .ds-badge { margin-left: var(--ds-space-1); }
.po-ds .po-ds-form { display: flex; flex-direction: column; gap: var(--ds-space-3); }
.po-ds .po-ds-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--ds-space-3); }
.po-ds .po-ds-grow { grid-column: span 2; }
@media (max-width: 640px) { .po-ds .po-ds-grow { grid-column: auto; } .po-ds .po-ds-form .ds-btn { width: 100%; } }

/* ── Phase 5: Creditors, Work orders (read only) and P&L on the design system (tokens only) ── */
.po-ds .po-ds-month { min-width: 180px; margin: 0; }
.po-ds .po-ds-filters { margin-bottom: var(--ds-space-3); max-width: 480px; }
.po-ds .po-ds-btns { flex-wrap: nowrap; gap: var(--ds-space-1); }
@media (max-width: 640px) { .po-ds .po-ds-btns { flex-wrap: wrap; justify-content: flex-end; } }
