/* =========================================================
   PAYSLIP PAGE (A4) - mirrors AssistHealth_Payslip_Revised.pdf
   ========================================================= */
.ps-page {
    width: 210mm;
    padding: 12mm 12mm 8mm;
    background: #ffffff;
    color: #222;
    font-family: Arial, Helvetica, 'Liberation Sans', sans-serif;
    font-size: 12.5px;
    line-height: 1.3;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.ps-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ps-company {
    flex: 1;
    background: #fff2cc;
    color: #1f3864;
    font-size: 22px;
    font-weight: 700;
    padding: 18px 12px;
}

.ps-logo {
    width: 140px;
    height: auto;
}

.ps-address {
    margin: 12px 0 10px;
    font-size: 11.5px;
    color: #333;
}

.ps-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 2px;
    table-layout: fixed;
}

.ps-grid td {
    padding: 7px 6px;
    vertical-align: middle;
    word-wrap: break-word;
    font-size: 12.5px;
    border: none;
    text-align: left;
}

/* Shield the payslip from main.css global/responsive table rules so it renders the same on every screen */
.ps-page table.ps-grid {
    width: 100%;
    min-width: 0;
    font-size: 12.5px;
}

.ps-page tr:hover,
.ps-page tr:hover td.ps-lbl {
    background: transparent;
}

.ps-page tr:last-child td {
    border-bottom: none;
}

.ps-lbl {
    color: #222;
}

.ps-val {
    background: #cdeffb;
}

.ps-calc {
    background: #f8e9dc;
}

.ps-grid td.ps-amt,
.ps-grid td.ps-right {
    text-align: right;
}

.ps-sub {
    font-size: 11px;
    color: #444;
}

.ps-bar td {
    background: #00b050;
    color: #ffffff;
    font-weight: 700;
    padding: 5px 6px;
}

.ps-gap td {
    padding: 3px 0;
    background: transparent;
}

.ps-net td {
    font-size: 14px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.ps-footer {
    margin-top: 22px;
    text-align: center;
    font-style: italic;
    color: #666;
    font-size: 11px;
}

/* =========================================================
   PAYROLL SCREEN
   ========================================================= */
.pr-tabs {
    display: inline-flex;
    background: #eef1f5;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 1.25rem;
    gap: 4px;
}

.pr-tab {
    border: none;
    background: transparent;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    color: #5a6b7b;
    cursor: pointer;
    font-size: 0.95rem;
}

.pr-tab.active {
    background: #ffffff;
    color: #00a34a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.pr-tab .pr-count {
    background: #e3e8ee;
    color: #4a5a6a;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.75rem;
    margin-left: 6px;
}

.pr-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pr-toolbar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pr-toolbar label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #5a6b7b;
}

.pr-toolbar input,
.pr-toolbar select {
    padding: 0.55rem 0.7rem;
    border: 1px solid #d5dbe1;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 38px;
}

.pr-toolbar .pr-grow {
    flex: 1;
    min-width: 200px;
}

.pr-toolbar .pr-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.pr-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pr-stat {
    background: #f7f9fb;
    border: 1px solid #e6eaee;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.pr-stat span {
    display: block;
    font-size: 0.75rem;
    color: #6c7a89;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.pr-stat strong {
    font-size: 1.25rem;
    color: #2c3e50;
}

.pr-stat.pr-stat-net strong {
    color: #00a34a;
}

.pr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.pr-table th {
    background: #f4f6f8;
    color: #4a5a6a;
    font-weight: 600;
    text-align: left;
    padding: 0.6rem 0.5rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.pr-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #eef1f4;
    vertical-align: middle;
}

.pr-table tr.pr-selected td {
    background: #f1fbf5;
}

.pr-table tr.pr-inactive td {
    opacity: 0.55;
}

.pr-table .pr-num {
    text-align: right;
    white-space: nowrap;
}

.pr-table input.pr-cell {
    width: 90px;
    padding: 0.4rem 0.45rem;
    border: 1px solid #d5dbe1;
    border-radius: 5px;
    text-align: right;
    font-size: 0.88rem;
}

.pr-table input.pr-cell.pr-small {
    width: 60px;
}

.pr-table input.pr-cell:focus {
    outline: none;
    border-color: #00b050;
    box-shadow: 0 0 0 2px rgba(0, 176, 80, 0.18);
}

.pr-emp-name {
    font-weight: 600;
    color: #2c3e50;
}

.pr-emp-meta {
    font-size: 0.78rem;
    color: #7f8c8d;
}

.pr-net {
    font-weight: 700;
    color: #00a34a;
}

.pr-badge {
    display: inline-block;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.pr-badge-generated { background: #d4edda; color: #155724; }
.pr-badge-draft { background: #fff3cd; color: #856404; }
.pr-badge-new { background: #eef1f4; color: #6c7a89; }
.pr-badge-dirty { background: #e3f2fd; color: #1976d2; }

.btn-icon.btn-view { background-color: #e8f5e9; color: #2e7d32; }
.btn-icon.btn-view:hover { background-color: #c8e6c9; }
.btn-icon.btn-download { background-color: #fff3e0; color: #ef6c00; }
.btn-icon.btn-download:hover { background-color: #ffe0b2; }

.pr-hint {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 0.5rem;
}

/* ---------- Modals ---------- */
.pr-modal .modal-content {
    max-width: 920px;
}

.pr-modal.pr-wide .modal-content {
    max-width: 1280px;
    width: 96%;
}

.pr-modal .modal-header {
    background: linear-gradient(135deg, #00b050 0%, #12925a 100%);
}

.pr-form-section {
    margin-bottom: 1.25rem;
}

.pr-form-section h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #00a34a;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #e6eaee;
    padding-bottom: 0.35rem;
}

.pr-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 1rem;
}

.pr-form-grid.pr-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pr-form-grid .form-group input,
.pr-form-grid .form-group select {
    padding: 0.55rem 0.65rem;
}

.pr-form-grid .form-group label {
    font-size: 0.82rem;
    margin-bottom: 0.3rem;
}

.pr-check {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1.5rem;
}

.pr-gross-preview {
    background: #f1fbf5;
    border: 1px solid #cdebd8;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: #2c3e50;
}

.pr-modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
    margin-top: 0.5rem;
}

.pr-modal-footer .pr-spacer {
    flex: 1;
}

/* ---------- Bulk add grid ---------- */
.pr-bulk-steps {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.pr-bulk-step {
    flex: 1;
    min-width: 220px;
    border: 1px dashed #c8d1da;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    background: #fafbfc;
    font-size: 0.85rem;
    color: #4a5a6a;
}

.pr-bulk-step b {
    color: #2c3e50;
}

.pr-bulk-step .btn-secondary,
.pr-bulk-step .btn-success {
    margin-top: 0.5rem;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
}

.pr-dropzone.pr-drag {
    border-color: #00b050;
    background: #f1fbf5;
}

.pr-bulk-wrap {
    overflow: auto;
    max-height: 48vh;
    border: 1px solid #e6eaee;
    border-radius: 8px;
}

.pr-bulk-table {
    border-collapse: collapse;
    font-size: 0.82rem;
    min-width: 100%;
}

.pr-bulk-table th {
    background: #f4f6f8;
    padding: 0.45rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    color: #4a5a6a;
}

.pr-bulk-table th.pr-req::after {
    content: ' *';
    color: #e74c3c;
}

.pr-bulk-table td {
    padding: 0;
    border: 1px solid #eef1f4;
}

.pr-bulk-table td.pr-rownum {
    padding: 0 0.5rem;
    color: #9aa7b3;
    text-align: center;
    background: #fafbfc;
}

.pr-bulk-table input {
    border: none;
    padding: 0.45rem;
    width: 120px;
    font-size: 0.82rem;
    background: transparent;
}

.pr-bulk-table input:focus {
    outline: 2px solid #00b050;
    outline-offset: -2px;
    background: #ffffff;
}

.pr-bulk-table td.pr-err {
    background: #fdecea;
}

.pr-bulk-table td.pr-err input {
    color: #b71c1c;
}

.pr-bulk-table .pr-row-del {
    border: none;
    background: none;
    color: #c0c8d0;
    cursor: pointer;
    padding: 0 0.5rem;
}

.pr-bulk-table .pr-row-del:hover {
    color: #d32f2f;
}

.pr-bulk-summary {
    font-size: 0.85rem;
    font-weight: 600;
}

.pr-bulk-summary .ok { color: #00a34a; }
.pr-bulk-summary .bad { color: #d32f2f; }

/* ---------- Review (form + live preview) ---------- */
.pr-review {
    display: grid;
    grid-template-columns: minmax(320px, 400px) 1fr;
    gap: 1.25rem;
    align-items: start;
}

.pr-review-form {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.pr-review-preview {
    background: #e9edf1;
    border-radius: 8px;
    padding: 12px;
    max-height: 70vh;
    overflow: auto;
}

.pr-preview-scale {
    transform-origin: top left;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    width: 210mm;
}

.pr-review-nav {
    font-size: 0.85rem;
    color: #6c7a89;
}

/* ---------- Toast ---------- */
.pr-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #2c3e50;
    color: #ffffff;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    z-index: 11000;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s ease;
    max-width: 420px;
}

.pr-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.pr-toast.success { background: #00a34a; }
.pr-toast.error { background: #d32f2f; }

.pr-busy {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.96);
    z-index: 10500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.75rem;
    font-weight: 600;
    color: #2c3e50;
}

.pr-busy i {
    font-size: 2rem;
    color: #00b050;
}

/* Render target for PDF generation: sits at the document origin behind the busy overlay */
.pr-pdf-stage {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    background: #ffffff;
    z-index: -1;
    pointer-events: none;
}

@media (max-width: 1000px) {
    .pr-review { grid-template-columns: 1fr; }
    .pr-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pr-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .pr-form-grid,
    .pr-form-grid.pr-cols-2 { grid-template-columns: 1fr; }
    .pr-toolbar .pr-actions { margin-left: 0; }
}

.pr-preview-box {
    overflow: hidden;
    margin: 0 auto;
}

/* Global .btn-* rules are full-width (login form); keep payroll buttons sized to content */
#payroll-screen .btn-primary,
#payroll-screen .btn-secondary,
#payroll-screen .btn-success,
.pr-modal .btn-primary,
.pr-modal .btn-secondary,
.pr-modal .btn-success {
    width: auto;
    margin-top: 0;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.6rem 1.1rem;
    font-size: 0.9rem;
}

.pr-modal .btn-primary:disabled,
#payroll-screen .btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.pr-actions-wrap {
    display: flex;
    gap: 6px;
}

.pr-emp-cell {
    min-width: 170px;
}

.pr-bulk-summary {
    white-space: nowrap;
}

.pr-modal-footer select {
    padding: 0.55rem 0.7rem;
    border: 1px solid #d5dbe1;
    border-radius: 6px;
    font-size: 0.9rem;
}

.pr-review-nav {
    white-space: nowrap;
}

.pr-modal.pr-wide .pr-review-form,
.pr-modal.pr-wide .pr-review-preview {
    max-height: calc(90vh - 190px);
}

/* ---------- Employees tab: compact toolbar ---------- */
.pr-toolbar-compact {
    align-items: center;
}

.pr-search {
    position: relative;
    display: flex;
    align-items: center;
}

.pr-search i {
    position: absolute;
    left: 12px;
    color: #9aa7b3;
    font-size: 0.9rem;
    pointer-events: none;
}

.pr-toolbar .pr-search input {
    width: 100%;
    height: 40px;
    padding-left: 36px;
}

.pr-segment {
    display: inline-flex;
    background: #eef1f5;
    border-radius: 8px;
    padding: 3px;
    height: 40px;
    box-sizing: border-box;
}

.pr-segment button {
    border: none;
    background: transparent;
    padding: 0 0.9rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a6b7b;
    cursor: pointer;
}

.pr-segment button.active {
    background: #ffffff;
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

#payroll-screen .pr-toolbar .btn-primary,
#payroll-screen .pr-toolbar .btn-secondary,
#payroll-screen .pr-toolbar input,
#payroll-screen .pr-toolbar select {
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
}

#payroll-screen .pr-toolbar .btn-primary,
#payroll-screen .pr-toolbar .btn-secondary {
    padding-top: 0;
    padding-bottom: 0;
}

/* ---------- Empty states ---------- */
.pr-empty {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
    color: #6c7a89;
}

.pr-empty h4 {
    color: #2c3e50;
    font-size: 1.15rem;
    margin: 0 0 0.35rem;
}

.pr-empty p {
    margin: 0 0 1.25rem;
    font-size: 0.92rem;
}

.pr-empty i {
    font-size: inherit;
}

.pr-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #eaf4fc;
    color: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.pr-empty-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 260px));
    justify-content: center;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.pr-option {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-align: left;
    background: #ffffff;
    border: 1px solid #e1e6eb;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.pr-option:hover {
    border-color: #3498db;
    box-shadow: 0 4px 14px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
}

.pr-option-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.pr-option-icon.pr-blue { background: #eaf4fc; color: #3498db; }
.pr-option-icon.pr-green { background: #e8f8ef; color: #27ae60; }

.pr-option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pr-option-text b {
    color: #2c3e50;
    font-size: 0.95rem;
}

.pr-option-text small {
    color: #7f8c8d;
    font-size: 0.8rem;
    margin-top: 2px;
}

.pr-option-arrow {
    color: #c0c8d0;
    font-size: 0.8rem !important;
}

.pr-link {
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.pr-link:hover {
    text-decoration: underline;
}

@media (max-width: 700px) {
    .pr-empty-options { grid-template-columns: 1fr; }
    .pr-toolbar-compact .pr-search { flex-basis: 100%; }
}

/* ---------- Settings: toggle switch ---------- */
.pr-switch-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    margin-bottom: 1rem;
}

.pr-switch-row b {
    display: block;
    color: #2c3e50;
    font-size: 0.92rem;
}

.pr-switch-row small {
    display: block;
    color: #7f8c8d;
    font-size: 0.8rem;
    margin-top: 2px;
}

.pr-switch {
    position: relative;
    flex-shrink: 0;
    width: 42px;
    height: 24px;
}

.pr-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pr-switch span {
    position: absolute;
    inset: 0;
    background: #c8d1da;
    border-radius: 24px;
    transition: background 0.2s ease;
}

.pr-switch span::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pr-switch input:checked + span {
    background: #2ecc71;
}

.pr-switch input:checked + span::before {
    transform: translateX(18px);
}

.pr-switch input:focus-visible + span {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.35);
}
