/* ============================================================
   SM3 PAYSLIPS — additions on top of styles.css + offers.css
   ============================================================ */

/* ─── The payslip "paper" (always light — it's a printed document) ─── */
.ps-paper-wrap { background: var(--surface-2); border-radius: var(--radius-lg); padding: 28px; overflow-x: auto; }
.ps-paper {
  background: #fff; color: #1f2328; width: 8.5in; max-width: 100%; min-height: 10.4in; margin: 0 auto;
  padding: 0.55in 0.6in; box-shadow: var(--shadow-lg); border-radius: 4px; box-sizing: border-box;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 12.5px; line-height: 1.45;
  display: flex; flex-direction: column;
}
.ps-paper * { color: inherit; box-sizing: border-box; }
.ps-paper table, .ps-paper th, .ps-paper td { background: none; border: none; text-transform: none; letter-spacing: normal; font-size: inherit; position: static; box-shadow: none; }
.ps-paper tr:hover td { background: none; }
.ps-paper-pdf { box-shadow: none; border-radius: 0; max-width: none; height: 11in; min-height: 0; overflow: hidden; }

.ps-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.ps-logo { height: 54px; width: auto; }
.ps-address { text-align: right; font-size: 11.5px; color: #4b5563; line-height: 1.5; }

.ps-band {
  background: #D9EAD3; border: 1px solid #b7d3ac; text-align: center; font-weight: 700; font-size: 14px;
  letter-spacing: .02em; padding: 9px 12px; margin-bottom: 18px;
}

.ps-info { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.ps-info th { text-align: left; font-weight: 700; padding: 5px 10px 5px 0; white-space: nowrap; width: 17%; color: #1f2328; }
.ps-info td { padding: 5px 24px 5px 0; }

.ps-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; table-layout: fixed; }
.ps-paper .ps-table thead th {
  background: #D9D9D9; font-weight: 700; text-align: left; padding: 7px 10px; border: 1px solid #c4c4c4; font-size: 12px; letter-spacing: .03em;
}
.ps-paper .ps-table tbody td { padding: 7px 10px; border-bottom: 1px solid #ececec; vertical-align: top; word-wrap: break-word; }
.ps-table tfoot td { padding: 8px 10px; }
.ps-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-total-label { font-weight: 700; text-align: right; white-space: nowrap; }
.ps-paper .ps-total { font-weight: 700; border-top: 1.5px solid #9ca3af; }

.ps-net {
  display: flex; justify-content: flex-end; align-items: center; gap: 36px; margin: 4px 0 18px;
  padding: 11px 10px; border-top: 2px solid #1f2328; border-bottom: 2px solid #1f2328; font-weight: 800; font-size: 14px;
}
.ps-net-amt { min-width: 22%; text-align: right; font-size: 16px; font-variant-numeric: tabular-nums; }

.ps-notes { font-size: 11.5px; color: #4b5563; background: #f8f9fa; border-left: 3px solid #D9EAD3; padding: 8px 12px; margin-bottom: 14px; }

.ps-sign { display: flex; justify-content: flex-end; margin-top: auto; padding-top: 24px; }
.ps-sign-box { width: 46%; text-align: center; }
.ps-sig-img { max-height: 58px; max-width: 230px; display: block; margin: 0 auto 2px; }
.ps-sig-typed { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 27px; margin-bottom: 2px; }
.ps-sig-empty { height: 46px; display: flex; align-items: flex-end; justify-content: center; color: #b45309; font-size: 11px; font-style: italic; padding-bottom: 4px; }
.ps-sign-line { border-top: 1px solid #6b7280; margin: 2px 0 6px; }
.ps-sign-name { font-weight: 700; }
.ps-sign-title { font-size: 11px; color: #6b7280; }
.ps-sign-meta { font-size: 10px; color: #9ca3af; margin-top: 3px; }

.ps-foot { text-align: center; font-size: 10.5px; color: #6b7280; margin-top: 22px; padding-top: 10px; border-top: 1px dashed #d1d5db; }

/* ─── Line-item editor ─── */
.line-editor { display: flex; flex-direction: column; gap: 8px; }
.line-row { display: grid; grid-template-columns: 1.1fr 1.1fr 0.9fr auto; gap: 8px; align-items: center; }
.line-row input { min-width: 0; }
.line-row .line-actions { display: flex; gap: 4px; }
.line-head { display: grid; grid-template-columns: 1.1fr 1.1fr 0.9fr auto; gap: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 0 2px; }
.line-head span:last-child { width: 68px; }
.icon-mini { width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.icon-mini:hover { border-color: var(--brand); color: var(--brand-soft); }
.icon-mini.danger:hover { border-color: var(--bad); color: var(--bad); }
.totals-strip { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); font-size: 13px; }
.totals-strip strong { font-size: 15px; }

/* ─── Employee picker ─── */
.emp-picker { position: relative; }
.emp-results { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; }
.emp-results.open { display: block; }
.emp-opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.emp-opt:last-child { border-bottom: none; }
.emp-opt:hover, .emp-opt.is-active { background: var(--brand-dim); }
.emp-opt-name { font-weight: 600; font-size: 13.5px; }
.emp-opt-sub { font-size: 11.5px; color: var(--text-faint); }
.emp-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-top: 10px; }
.emp-card-meta { font-size: 12px; color: var(--text-faint); line-height: 1.5; }

.editor-layout { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.editor-preview { position: sticky; top: 16px; }
.editor-preview .ps-paper-wrap { padding: 16px; max-height: calc(100vh - 120px); overflow: auto; }
.editor-preview .ps-paper { zoom: 0.72; }
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
  .editor-preview .ps-paper { zoom: 0.6; }
}
@media (max-width: 640px) {
  .line-row, .line-head { grid-template-columns: 1fr 1fr; }
  .line-row .line-amount { grid-column: 1; }
  .ps-paper-wrap { padding: 10px; }
}

.warn-box { border: 1px solid rgba(245,158,11,.35); background: rgba(245,158,11,.1); color: var(--text); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.info-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; color: var(--text-dim); }

.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); }
.sync-pill svg { width: 14px; height: 14px; }
.spin svg { animation: ps-spin 1s linear infinite; }
@keyframes ps-spin { to { transform: rotate(360deg); } }

.row-check { width: 16px; height: 16px; cursor: pointer; }

@media print {
  body * { visibility: hidden; }
  .ps-paper, .ps-paper * { visibility: visible; }
  .ps-paper { position: absolute; left: 0; top: 0; box-shadow: none; zoom: 1 !important; }
  .ps-paper-wrap { padding: 0; background: none; }
}

/* ============================================================
   EMPLOYMENT LETTERS — always-light printed document
   ============================================================ */
.lt-paper {
  background: #fff; color: #111; width: 8.5in; max-width: 100%; min-height: 11in; margin: 0 auto;
  padding: 0.55in 0.85in 0.5in; box-shadow: var(--shadow-lg); border-radius: 4px; box-sizing: border-box;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 13.5px; line-height: 1.5;
  display: flex; flex-direction: column;
}
.lt-paper * { color: inherit; box-sizing: border-box; }
.lt-paper-pdf { box-shadow: none; border-radius: 0; max-width: none; height: 11in; min-height: 0; overflow: hidden; }
.lt-head { margin-bottom: 0.75in; }
.lt-logo { height: 62px; width: auto; display: block; }
.lt-address { color: #7c74e8; font-size: 12.5px; line-height: 1.45; margin-top: 4px; }
.lt-title { font-size: 21px; font-weight: 800; text-align: center; margin: 0 0 0.5in; letter-spacing: -0.005em; }
.lt-body p { margin: 0 0 16px; text-align: justify; }
.lt-body strong { font-weight: 700; }
.lt-body sup { font-size: 0.65em; font-weight: 700; }
.lt-sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5in; margin-top: auto; padding-top: 0.4in; font-size: 13px; line-height: 1.4; }
.lt-sigs-single { grid-template-columns: 1fr; }
.lt-signer { align-self: end; }
.lt-signer-name { font-weight: 700; }
.lt-sig-img { max-height: 56px; max-width: 200px; display: block; margin-bottom: -2px; }
.lt-sig-typed { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 26px; line-height: 1.1; }
.lt-sig-space { height: 52px; }
.lt-sig-pending { display: flex; align-items: flex-end; color: #b45309; font-size: 11px; font-style: italic; }
.lt-link { color: #1d4ed8; text-decoration: underline; }
.lt-foot { margin-top: 0.55in; color: #7c74e8; font-weight: 700; font-size: 12px; line-height: 1.6; }

.editor-preview .lt-paper { zoom: 0.72; }
@media (max-width: 1100px) { .editor-preview .lt-paper { zoom: 0.6; } }
.body-editor { width: 100%; min-height: 300px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; }
.pill-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.pill-toggle button { border: none; background: transparent; color: var(--text-dim); padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.pill-toggle button.is-active { background: var(--brand-dim); color: var(--brand-soft); }
@media print { .lt-paper, .lt-paper * { visibility: visible; } .lt-paper { position: absolute; left: 0; top: 0; box-shadow: none; zoom: 1 !important; } }
.main label > input[type=checkbox] { width: 16px !important; height: 16px; flex: 0 0 auto; margin: 0; padding: 0; }
.main label:has(> input[type=checkbox]) { justify-content: flex-start; text-align: left; }
