.salary-editor {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
}
.salary-heading,
.salary-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.salary-heading p {
    color: var(--muted);
}
.salary-table-wrap {
    overflow-x: auto;
    margin-block: 1rem;
}
.salary-editor table {
    width: 100%;
    border-collapse: collapse;
}
.salary-editor td,
.salary-editor th {
    padding: 0.65rem;
    text-align: start;
    border-bottom: 1px solid var(--line);
}
.salary-editor input,
.salary-editor select {
    width: 100%;
    min-width: 9rem;
}
.salary-editor [data-date] {
    max-width: 16rem;
    display: block;
}
.salary-editor details {
    padding-block: 0.75rem;
}
.salary-editor [data-message] {
    min-height: 1.5em;
}
.salary-modal {
    display: block;
    width: min(900px, 94vw);
    max-height: 90dvh;
    overflow-y: auto;
}
.salary-type-form {
    display: grid;
    gap: 1rem;
    width: min(540px, 94vw);
}
.salary-editor input,
.salary-editor select {
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--text, inherit);
    font: inherit;
}
.salary-editor button:not(.primary-button) {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--text, inherit);
    font: inherit;
    cursor: pointer;
}
.salary-editor th {
    background: var(--card);
    font-weight: 700;
}
.salary-editor label {
    display: grid;
    gap: 6px;
}
.salary-heading {
    padding-block-end: 18px;
}
.salary-actions {
    padding-block: 8px;
}
.salary-editor button:focus-visible,
.salary-editor input:focus-visible,
.salary-editor select:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
.salary-editor input:disabled,
.salary-editor select:disabled {
    opacity: 0.8;
}
html[data-theme='dark'] .salary-editor input,
html[data-theme='dark'] .salary-editor select,
html[data-theme='dark'] .salary-type-form input {
    background: var(--surface-soft, #27272b);
    color: var(--text, #ededee);
    border-color: var(--line, #3c3c42);
}
.salary-types-grid {
    height: max(360px, calc(100dvh - 260px));
    min-width: 0;
}
.salary-type-form .salary-active {
    display: flex;
    align-items: center;
    gap: 10px;
}
.salary-type-form .salary-active input {
    width: 18px;
    height: 18px;
    min-height: 0;
    margin: 0;
    accent-color: var(--primary, #39306e);
}
.salary-type-form .salary-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}
.salary-type-form [data-error]:empty {
    display: none;
}
.salary-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
}

/* Shared by the employee tab and the standalone salary dialog. */
.salary-editor .salary-heading {
    padding-block-end: 12px;
    border-bottom: 1px solid var(--line);
}
.salary-modal .salary-heading {
    padding-inline-end: 46px;
}
.salary-editor .salary-heading h3 {
    margin: 4px 0 8px;
    font-size: 21px;
}
.salary-editor .salary-eyebrow,
.salary-editor .salary-employee,
.salary-footer small {
    font-size: 13px;
    color: var(--muted);
}
.salary-editor .salary-employee {
    margin: 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.salary-employee bdi {
    padding-inline-start: 12px;
    border-inline-start: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}
.salary-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
    align-items: center;
    gap: 24px;
    padding: 14px 18px;
    margin-block: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft, #f7f8fa);
}
.salary-total {
    display: grid;
    gap: 6px;
    justify-items: start;
}
.salary-total > span {
    font-size: 13px;
    color: var(--muted);
}
.salary-total strong {
    font-size: clamp(22px, 3vw, 29px);
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.salary-total small {
    font-size: 12px;
    color: var(--muted);
}
.salary-section-heading,
.salary-action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}
.salary-section-heading {
    justify-content: space-between;
}
.salary-section-heading h4 {
    margin: 0;
    font-size: 15px;
}
.salary-editor .salary-table-wrap {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-block: 12px 18px;
}
.salary-editor table {
    table-layout: fixed;
    min-width: 460px;
}
.salary-editor th {
    background: var(--surface-soft, #f7f8fa);
    font-size: 12px;
    padding: 12px;
}
.salary-editor th:first-child {
    width: 52%;
}
.salary-editor th:last-child {
    width: 80px;
}
.salary-editor td:last-child {
    text-align: center;
}
.salary-editor tbody tr:last-child td {
    border-bottom: 0;
}
.salary-editor input,
.salary-editor select {
    min-width: 0;
    font-size: 14px;
}
.salary-editor [data-amount] {
    font-variant-numeric: tabular-nums;
    text-align: end;
}
.salary-editor [data-message]:empty {
    display: none;
}
.salary-editor [data-message]:not(:empty) {
    padding: 12px 16px;
    border-inline-start: 3px solid var(--primary, #39306e);
    background: var(--surface-soft, #f7f8fa);
    border-radius: 6px;
    font-size: 13px;
}
.salary-editor .salary-history {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 16px;
    margin-block: 12px;
}
.salary-history summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.salary-history [data-history] > details {
    border-top: 1px solid var(--line);
    margin-block-start: 12px;
}
.salary-history-lines {
    margin: 10px 0 0;
}
.salary-history-lines > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-block: 6px;
    font-size: 13px;
}
.salary-history-lines dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}
.salary-editor .salary-footer {
    border-top: 1px solid var(--line);
    padding-block: 16px 0;
    gap: 16px;
}
.salary-action-buttons {
    margin-inline-start: auto;
}
.salary-editor button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
@media (max-width: 600px) {
    .salary-overview {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }
    .salary-editor [data-date] {
        max-width: none;
    }
    .salary-footer small {
        flex-basis: 100%;
    }
    .salary-action-buttons {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Match controls in the full employee editor and the standalone dialog. */
.salary-editor .salary-overview label {
    font-size: 13px;
    line-height: 1.5;
}
.salary-editor .salary-total strong {
    line-height: 1.3;
}
.salary-editor .salary-heading .salary-employee {
    line-height: 1.5;
}
.salary-editor :is(button, input, .searchable-select .select-trigger) {
    font-size: 13px;
    line-height: 1.5;
}
.salary-editor .salary-table-wrap td {
    padding: 8px 10px;
}
.salary-editor .salary-table-wrap :is(input, .select-trigger) {
    min-height: 38px;
    height: 38px;
}
.salary-editor .salary-action-buttons button,
.salary-editor .salary-section-heading button {
    min-height: 38px;
    padding: 8px 14px;
}
.salary-modal.employee-modal {
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
/* Payroll review keeps the calculation readable without expanding the page. */
.payroll-run-page {
    width: 100%;
    min-width: 0;
    min-height: calc(100dvh - 110px);
    padding: 1rem;
}
.payroll-run-page > header,
.payroll-run-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.payroll-run-summary strong {
    font-size: 1.5rem;
}
.payroll-run-page .attendance-grid {
    height: 350px;
    min-height: 250px;
}
.payroll-candidates {
    max-height: 300px;
    overflow: auto;
}
.payroll-run-page .payroll-candidates label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}
.payroll-run-page .payroll-candidates input[type='checkbox'] {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}
.payroll-candidates small {
    margin-inline-start: auto;
}
.payroll-adjustment {
    padding-block: 0.75rem;
}
.payroll-table-scroll {
    overflow-x: auto;
}
.payroll-table-scroll table {
    width: 100%;
    border-collapse: collapse;
}
.payroll-table-scroll th,
.payroll-table-scroll td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border-color, #ddd);
    text-align: start;
}

.payroll-batch-progress {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-block: 1rem;
}
.payroll-batch-progress progress {
    width: 100%;
    height: 8px;
    accent-color: var(--primary);
}
.payroll-batch-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-block: 1rem;
}
.payroll-batch-metrics > div {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.payroll-batch-metrics strong {
    font-size: 1.3rem;
}
.payroll-batch-branches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-height: 320px;
    overflow: auto;
    border-block: 1px solid var(--line);
    margin-block: 1rem;
}
.payroll-run-page .payroll-batch-check {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
}
.payroll-run-page .payroll-batch-check input[type='checkbox'] {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}
.payroll-run-page [data-runs],
.payroll-run-page [data-jobs] {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-block: 1rem;
}

/* The readiness grid owns scrolling; keep summary and server pagination visible. */
.payroll-batch-review {
    width: 100%;
    min-height: 650px;
    height: calc(100dvh - 110px);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow: hidden;
}
.payroll-batch-review > * {
    flex-shrink: 0;
    margin-block: 0;
}
.payroll-batch-review .attendance-grid {
    height: auto;
    min-height: 160px;
    flex: 1 1 0;
}
.payroll-batch-review .attendance-filter {
    gap: 0.75rem;
}
.payroll-batch-review .payroll-batch-metrics > div {
    padding: 0.65rem 0.9rem;
    align-items: center;
}
.payroll-batch-review [data-prepare] {
    max-height: 180px;
    overflow: auto;
}
.payroll-run-page [hidden],
.payroll-batch-review [data-totals]:empty,
.payroll-batch-review [data-runs]:empty,
.payroll-batch-review [data-error]:empty {
    display: none !important;
}
.payroll-batch-review [data-runs] {
    max-height: 110px;
    overflow: auto;
}
.payroll-run-page input[type='checkbox'] {
    accent-color: var(--primary, #3b326f);
}
@media (max-width: 640px), (max-height: 620px) {
    .payroll-batch-review {
        overflow: auto;
    }
    .payroll-batch-review .attendance-grid {
        flex: 0 0 300px;
    }
}

.payroll-list-hidden,
.payroll-run-page[hidden] {
    display: none !important;
}
.payroll-page-header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}
.payroll-page-header h2 {
    font-size: 1.2rem;
    margin: 0;
}
.payroll-run-page [data-start] > label:first-child {
    max-width: 320px;
}
.payroll-run-page [data-jobs] > button {
    padding: 1rem;
}
@media (max-width: 640px) {
    .payroll-page-header {
        flex-wrap: wrap;
    }
    .payroll-batch-review {
        height: auto;
    }
}

.payroll-run-page form > label:not(.payroll-batch-check) {
    display: grid;
    gap: 0.5rem;
    font-size: 13px;
}
.payroll-run-page :is(input:not([type='checkbox']), select, textarea) {
    min-height: 42px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    background: var(--control-bg, var(--surface));
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    max-width: 100%;
}
.payroll-run-page .payroll-batch-branches {
    gap: 0.5rem;
    padding-block: 0.75rem;
    max-height: none;
}
.payroll-run-page .payroll-batch-branches label {
    font-size: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

/* Keep review totals, calculation details and the approval form in separate regions. */
.payroll-review-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.payroll-state {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
}
.payroll-review-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.payroll-review-metrics > div {
    display: grid;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}
.payroll-review-metrics span {
    font-size: 0.8rem;
    color: var(--text-muted, var(--text));
}
.payroll-review-metrics strong {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    text-align: start;
}
.payroll-review-metrics .payroll-net {
    background: var(--surface-soft);
    border-inline-start: 3px solid var(--primary);
}
.payroll-breakdown,
.payroll-confirm-form,
.payroll-history {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    margin-block: 1rem;
}
.payroll-breakdown > header,
.payroll-confirm-form > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.payroll-breakdown h3,
.payroll-confirm-form h3 {
    font-size: 1rem;
    margin: 0.25rem 0 0;
}
.payroll-breakdown small {
    color: var(--text-muted, var(--text));
}
.payroll-breakdown th {
    background: var(--surface-soft);
    font-size: 0.8rem;
}
.payroll-review-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding-block: 1rem;
    border-top: 1px solid var(--line);
}
.payroll-review-actions:empty,
.payroll-review-page [data-error]:empty {
    display: none;
}
.payroll-review-page .payroll-confirm-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    background: var(--surface-soft);
}
.payroll-confirm-form > header,
.payroll-confirm-form .payroll-action-reason,
.payroll-confirm-form .modal-actions {
    grid-column: 1 / -1;
}
.payroll-confirm-form > header {
    justify-content: flex-start;
    margin: 0;
}
.payroll-confirm-form textarea {
    width: 100%;
    resize: vertical;
}
.payroll-confirm-form .modal-actions {
    display: flex;
    justify-content: flex-start;
    gap: 0.5rem;
    margin: 0;
}
.payroll-history summary {
    cursor: pointer;
    font-weight: 600;
}
.payroll-history ol {
    list-style: none;
    padding: 0;
    margin-bottom: 0;
}
.payroll-history li {
    display: grid;
    gap: 0.35rem;
    padding: 0.75rem;
    border-inline-start: 2px solid var(--line);
    margin-top: 0.5rem;
}
.payroll-history small {
    color: var(--text-muted, var(--text));
}
@media (max-width: 1000px) {
    .payroll-review-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .payroll-review-metrics .payroll-net {
        grid-column: 1 / -1;
    }
}
@media (max-width: 600px) {
    .payroll-review-page .payroll-confirm-form {
        grid-template-columns: minmax(0, 1fr);
    }
}
