/* Accounts: pay slips, the Salaries & PAYE sheet and the debtor / creditor T account.
   Owned by public/js/accounts.js and loaded after /styles.css. Class names here belong to this module;
   a look shared by several modules goes in /styles.css (npm run check-styles enforces this). */

/* On screen the Pay slips card shows one employee's slip at a time */
/* Pay slips tab: tick boxes for each employee, then the ticked slips one under another */
.ps-controls { display: grid; gap: .7rem; }
.ps-controls .toolbar { margin: 0; }
.ps-controls .spacer { flex: 1; }
.ps-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; }
.ps-pick { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .55rem; padding: .5rem .7rem;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface); }
.ps-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ps-pick input { width: auto; margin: 0; }
.ps-pick-name { display: grid; line-height: 1.2; font-weight: 600; min-width: 0; }
.ps-pick-name small { font-weight: 400; }
.ps-pick-net { font-variant-numeric: tabular-nums; font-size: .88rem; color: var(--muted); }
.ps-holder { display: grid; gap: 1.2rem; justify-items: center; }
.ps-holder .payslip { width: 100%; margin: 0; }

/* ---------- pay slip, as on the Excel "Pay Slip" sheet ---------- */
.payslip { max-width: 820px; display: grid; gap: .9rem; color: #1d2433; background: #fff; }
.ps-company { font-size: 1.7rem; font-weight: 800; color: #1a7f37; line-height: 1.15; }
.ps-title { font-size: 1.15rem; font-weight: 800; color: #1b2a5e; border-bottom: 2px solid #1b2a5e; padding-bottom: .3rem; margin-top: -.6rem; }
.ps-info { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); gap: .3rem 1rem; align-items: baseline; margin-top: .3rem; }
.ps-k { font-weight: 700; }
.ps-hi { color: #1a7f37; font-weight: 700; }
.ps-r { text-align: right; }
.ps-wide { grid-column: span 3; }
@media (max-width: 600px) { .ps-info { grid-template-columns: max-content minmax(0, 1fr); } .ps-wide { grid-column: auto; } .ps-r { text-align: left; } }
table.ps-table { border: 1px solid #1b2a5e; border-collapse: collapse; width: 100%; font-size: .95rem; }
table.ps-table th { background: #1f3a68; color: #fff; text-transform: none; letter-spacing: 0; font-size: .92rem; font-weight: 800; padding: .35rem .5rem; border: 0; }
table.ps-table td { padding: .3rem .5rem; border-bottom: 1px solid #e3e7ef; white-space: normal; color: #1d2433; }
table.ps-table td:nth-child(2), table.ps-table th:nth-child(2) { border-right: 1px solid #1b2a5e; }
table.ps-table td.ps-amt { color: #1a7f37; font-variant-numeric: tabular-nums; }
table.ps-table td.ps-amt.neg { color: #b42318; }
table.ps-table tr.ps-gap td { height: 1.4rem; border-bottom: 0; }
table.ps-table tfoot td { font-weight: 800; border-top: 1.5px solid #1b2a5e; background: #fff; }
.ps-net { display: flex; justify-content: space-between; align-items: center; background: #dde8f5; padding: .65rem .6rem; font-weight: 800; font-size: 1.1rem; }
.ps-net strong { font-size: 1.3rem; }
.ps-sign { display: flex; flex-wrap: wrap; gap: 1rem 3rem; margin-top: 2rem; }
.ps-sign i { display: inline-block; width: 12rem; border-bottom: 1px solid #1d2433; margin-left: .3rem; }
.ps-foot { margin: 0; font-size: .8rem; font-style: italic; color: #5b6475; }
@media print {
  /* "Print pay slips": only the chosen slips, one per page */
  body.print-slips .page > :not(div), body.print-slips .page > div > :not(.payslips) { display: none !important; }
  body.print-slips .payslips { display: block !important; border: 0; padding: 0; box-shadow: none; }
  body.print-slips .payslip:not(.print-target) { display: none !important; }
  body.print-slips .payslip.print-target { display: grid !important; break-after: page; border: 0; box-shadow: none; padding: 0; }
  .ps-company, .ps-hi, .ps-amt, table.ps-table th, .ps-net { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Excel-style Salaries & PAYE sheet ---------- */
.xl-sheet { display: grid; gap: .5rem; }
.xl-title { background: var(--navy, #1b2a5e); color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; padding: .55rem .8rem; border-radius: 6px; }
.xl-title.sm { font-size: .85rem; padding: .4rem .6rem; }
.xl-sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .92rem; }
.xl-note { margin: 0; font-size: .82rem; font-style: italic; color: var(--muted); }
.xl-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
@media (max-width: 1200px) { .xl-grid { grid-template-columns: 1fr; } }
table.xl-table { font-size: .86rem; border: 1px solid var(--border); }
table.xl-table th { background: var(--navy, #1b2a5e); color: #fff; text-transform: none; letter-spacing: 0; font-size: .78rem; white-space: normal; vertical-align: bottom; line-height: 1.25; border-right: 1px solid rgb(255 255 255 / .15); }
table.xl-table td { padding: .35rem .5rem; border-right: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.xl-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
table.xl-table tfoot td { background: var(--accent-soft); font-weight: 800; border-top: 2px solid var(--navy, #1b2a5e); }
/* Input cells, highlighted like the yellow cells in the workbook */
td.xl-in { background: #fff7d6 !important; padding: 0 !important; }
td.xl-in input { width: 100%; min-width: 6.5rem; border: 0; border-radius: 0; background: transparent; text-align: right; padding: .35rem .5rem; font: inherit; font-variant-numeric: tabular-nums; }
td.xl-in input:focus { outline: 2px solid var(--copper); outline-offset: -2px; background: #fff; }
td.xl-calc { font-weight: 600; }
td.xl-net { font-weight: 800; color: var(--navy, var(--accent)); }
tr.just-saved td { animation: saved-flash 1.2s ease-out; }
@keyframes saved-flash { from { background: color-mix(in srgb, var(--ok) 25%, transparent); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) td.xl-in { background: #3a3320 !important; } :root:not([data-theme="light"]) td.xl-in input:focus { background: transparent; } }
@media print { td.xl-in { background: #fff7d6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; } .xl-title, table.xl-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* Debtor / creditor T account (its own names, so it never touches the lay-by T account) */
.t-ledger { display: grid; grid-template-columns: 1fr 1fr; gap: 0; overflow: hidden; }
.ledger-side { padding: .8rem 1rem; min-width: 0; }
.ledger-side + .ledger-side { border-left: 2px solid var(--text); }
.ledger-side h3 { margin: 0 0 .5rem; font-size: .95rem; border-bottom: 2px solid var(--text); padding-bottom: .35rem; }
.ledger-side table { width: 100%; }
.t-total { text-align: right; margin-top: .5rem; border-top: 1px solid var(--border); padding-top: .4rem; }
@media (max-width: 720px) { .t-ledger { grid-template-columns: 1fr; } .ledger-side + .ledger-side { border-left: 0; border-top: 2px solid var(--text); } }

/* Expense / petty cash categories: add one, rename any */
.cat-add { display: flex; gap: .5rem; }
.cat-add input { flex: 1; min-width: 0; }
.cat-list { display: grid; gap: .3rem; max-height: 50dvh; overflow-y: auto; }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .5rem; border-radius: 8px; background: var(--surface-2); }

/* Pay slip: the taxable pay line, when tax-free benefits or NSSA make it differ from gross */
.ps-taxable { margin: .4rem 0 0; font-size: .85rem; color: #4a5568; }
/* Payroll sheet: a figure typed for this month only (it no longer follows the staff record) */
td.xl-typed { position: relative; }
td.xl-typed::after { content: "•"; position: absolute; top: .1rem; right: .25rem; color: var(--copper); font-weight: 800; }

/* Staff form: the + New benefit button on its own row, under the benefit boxes */
.form .benefit-add { flex: 0 0 100%; }

/* Staff & salaries (GAKA 1.107.0): totals on top, a table that fits the screen, commission that opens its loads */
.staff-totals { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1000px) { .staff-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .staff-totals { grid-template-columns: 1fr 1fr; } }
.staff-card .sheet td { vertical-align: top; }
.staff-person strong { display: block; }
.staff-person .badge { margin: .3rem .3rem 0 0; }
.staff-commission { font: inherit; font-variant-numeric: tabular-nums; text-decoration: underline dotted; text-underline-offset: 3px; }
.staff-commission.neg, .staff-loss { color: var(--danger, #b42318); }
.staff-loss { font-size: .75rem; font-weight: 600; }
.staff-net { font-weight: 700; font-size: 1.02rem; }
.staff-total td { font-weight: 700; border-top: 2px solid var(--line, #d9dde6); }
.staff-loss-row td { background: color-mix(in srgb, var(--danger, #b42318) 7%, transparent); }
.staff-commission-view .stats { margin-bottom: .5rem; }
