/* ═══════════════════════════════════════════════════════════════
   PayrollManagementSystem — Shared Application Styles
   Design tokens, page shells, table patterns, form patterns,
   badge variants, action buttons. Loaded globally via _Layout.
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --color-brand:        #2a4365;
    --color-brand-dark:   #1a365d;
    --color-brand-light:  #ebf4ff;
    --color-success:      #38a169;
    --color-danger:       #e53e3e;
    --color-warning:      #d69e2e;
    --color-info:         #3182ce;
    --color-muted:        #718096;
    --color-surface:      #ffffff;
    --color-bg:           #f4f6fa;
    --color-border:       #e2e8f0;
    --color-text:         #2d3748;
    --color-text-light:   #718096;
    --radius-sm:          6px;
    --radius-md:          10px;
    --radius-lg:          14px;
    --shadow-sm:          0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:          0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:          0 8px 24px rgba(0,0,0,0.12);
}

/* ── Page Shell ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header-left h4,
.page-header-left h5 {
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0;
}
.page-header-left .page-subtitle {
    font-size: 0.78rem;
    color: var(--color-text-light);
    margin-top: 2px;
}
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ── Breadcrumb ─────────────────────────────────────────────── */
.page-breadcrumb {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.page-breadcrumb a { color: var(--color-info); text-decoration: none; }
.page-breadcrumb a:hover { text-decoration: underline; }
.page-breadcrumb .sep { color: #cbd5e0; }
.page-breadcrumb .current { color: var(--color-text); font-weight: 500; }

/* ── Cards ──────────────────────────────────────────────────── */
.pms-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.pms-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}
.pms-card-header-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.pms-card-body { padding: 1.1rem; }

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; flex-shrink: 0;
}
.kpi-label  { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted); }
.kpi-value  { font-size: 1.75rem; font-weight: 800; line-height: 1.1; color: var(--color-text); }
.kpi-sub    { font-size: 0.7rem; color: var(--color-muted); margin-top: 2px; }

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.validation-summary-valid { display: none; }
.field-validation-valid { display: none; }
.filter-bar-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.filter-bar-form .form-control,
.filter-bar-form .form-select {
    width: auto;
    flex: 0 1 auto;
}
.filter-bar .filter-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ── Tables ─────────────────────────────────────────────────── */
.pms-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: visible;
}
/* Horizontal scroll on narrow screens — applied only when the wrapper
   actually holds a table. Card-style usages of .pms-table-wrap keep
   overflow:visible so sticky side panels etc. inside them still work.
   Dropdown menus inside these scroll containers are repositioned with
   Popper's fixed strategy by site.js so they are not clipped. */
.pms-table-wrap:has(> .pms-table),
.pms-table-wrap:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
/* Same protection for tables placed directly inside a .pms-card */
.pms-card:has(> .pms-table),
.pms-card:has(> table) {
    overflow-x: auto;
}
/* Keep the thead corners clipped inside the rounded card */
.pms-table thead tr:first-child th:first-child { border-top-left-radius: var(--radius-md); }
.pms-table thead tr:first-child th:last-child  { border-top-right-radius: var(--radius-md); }
.pms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.pms-table thead th {
    background: #f8fafc;
    color: var(--color-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.pms-table tbody td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--color-text);
    vertical-align: middle;
}
.pms-table tbody tr:last-child td { border-bottom: none; }
.pms-table tbody tr:hover td { background: #f8fafc; }
.pms-table tbody tr[data-href] { cursor: pointer; }
.pms-table tbody tr[data-href]:hover td { background: #eef2ff; }
.pms-table .td-actions { white-space: nowrap; text-align: right; }

/* Row state tints — Bootstrap's table-danger/table-warning only work on .table,
   so .pms-table gets its own equivalents. */
.pms-table tbody tr.row-danger td        { background: #fff5f5; }
.pms-table tbody tr.row-danger:hover td  { background: #ffe9e9; }
.pms-table tbody tr.row-warning td       { background: #fffbeb; }
.pms-table tbody tr.row-warning:hover td { background: #fdf3d3; }
.pms-table tbody tr.row-success td       { background: #f0fff4; }
.pms-table tbody tr.row-success:hover td { background: #e2f8e9; }

/* ── Stacked card mode for tables on phones ──────────────────
   Opt-in per table: <table class="pms-table pms-table-stack">
   plus data-label="Column name" on each td. Cell roles:
     .td-primary    → card title (tap toggles hidden details)
     .td-stack-more → hidden on phones until the row is expanded
     .td-actions    → rendered as the card footer
   Desktop rendering is completely unchanged; below 768px each
   row becomes a vertical card readable top-to-bottom. */
@media (max-width: 767.98px) {
    .pms-table.pms-table-stack thead { display: none; }
    .pms-table.pms-table-stack tfoot { display: none; }
    .pms-table.pms-table-stack,
    .pms-table.pms-table-stack tbody,
    .pms-table.pms-table-stack tbody tr,
    .pms-table.pms-table-stack tbody td { display: block; width: 100%; }

    /* An inline min-width (set so the table stays readable on desktop) survives the switch to
       display:block and holds the card stack open at its desktop width, so the phone gets a
       sideways-scrolling table instead of cards — the stack silently does nothing. Most stacked
       tables never set one and work by luck rather than design; neutralise it here so the opt-in
       class is sufficient on its own and no view has to remember. */
    .pms-table.pms-table-stack { min-width: 0 !important; }

    /* The outer panel chrome disappears on phones — cards sit directly
       on the page background instead of "cards inside a panel".
       (!important beats Bootstrap's .shadow-sm utility.) */
    .pms-table-wrap:has(> .pms-table-stack),
    .card:has(> .pms-table-stack) {
        background: transparent;
        border: none;
        box-shadow: none !important;
        overflow: visible;
    }
    .pms-table-wrap:has(> .pms-table-stack) > .pms-pagination {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        margin-top: 0.25rem;
    }

    .pms-table.pms-table-stack tbody tr {
        display: flex;
        flex-direction: column;
        border: 1px solid var(--color-border);
        border-left: 3px solid #4e8ef7;
        border-radius: var(--radius-md);
        background: var(--color-surface);
        box-shadow: 0 1px 3px rgba(15,23,42,0.06), 0 4px 14px rgba(15,23,42,0.05);
        margin: 0 0 0.85rem;
        width: auto;
        overflow: hidden;
    }
    /* Accent follows row state */
    .pms-table.pms-table-stack tbody tr.row-danger   { border-left-color: var(--color-danger); }
    .pms-table.pms-table-stack tbody tr.row-warning  { border-left-color: var(--color-warning); }
    .pms-table.pms-table-stack tbody tr.row-inactive { border-left-color: #cbd5e0; }
    /* Title always first, actions always last, whatever the column order */
    .pms-table.pms-table-stack td.td-primary { order: -1; }
    .pms-table.pms-table-stack td.td-actions { order: 99; }
    .pms-table.pms-table-stack tbody tr:hover td { background: inherit; }
    .pms-table.pms-table-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        border-bottom: 1px solid #f4f6fa;
        padding: 0.55rem 1rem;
        text-align: right;
        white-space: normal;
    }
    .pms-table.pms-table-stack tbody td::before {
        content: attr(data-label);
        font-size: 0.66rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: #94a3b8;
        text-align: left;
        flex-shrink: 0;
        padding-top: 2px;
    }
    .pms-table.pms-table-stack tbody td:not([data-label])::before { content: none; }
    .pms-table.pms-table-stack tbody tr td:last-child { border-bottom: none; }
    /* Card title bar — brand accent strip + soft tinted background.
       display:block (not flex) so multi-line content (name + code + email)
       stacks naturally; the expand chevron is absolutely positioned. */
    .pms-table.pms-table-stack td.td-primary {
        display: block;
        position: relative;
        text-align: left;
        background: linear-gradient(180deg, #f6f9ff 0%, #eef4fd 100%);
        border-bottom: 1px solid var(--color-border);
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--color-brand);
        padding: 0.7rem 1rem;
    }
    .pms-table.pms-table-stack tbody tr:has(td.td-stack-more) td.td-primary { padding-right: 2.6rem; }
    /* Mobile-only status chip in the title bar (add .stack-status.d-md-none to a badge) */
    .pms-table.pms-table-stack td.td-primary .stack-status {
        float: right;
        margin-left: 0.5rem;
        font-size: 0.6rem;
        padding: 0.15rem 0.45rem;
    }
    /* Actions footer — larger touch targets, comfortable spacing */
    .pms-table.pms-table-stack td.td-actions {
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.45rem;
        background: #fafbfd;
        border-top: 1px solid var(--color-border);
        padding: 0.6rem 1rem;
    }
    .pms-table.pms-table-stack td.td-actions .btn-action {
        padding: 0.45rem 0.8rem;
        font-size: 0.8rem;
    }
    .pms-table.pms-table-stack td.td-stack-more { display: none; }
    .pms-table.pms-table-stack tr.stack-expanded td.td-stack-more { display: flex; }
    /* chevron hint when a row has hidden details */
    .pms-table.pms-table-stack tbody tr:has(td.td-stack-more) td.td-primary::after {
        content: "▾";
        position: absolute;
        right: 0.8rem;
        top: 50%;
        width: 1.35rem;
        height: 1.35rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(78,142,247,0.12);
        color: #4e8ef7;
        font-size: 0.8rem;
        font-weight: 400;
        transform: translateY(-50%);
        transition: transform 0.15s;
    }
    .pms-table.pms-table-stack tbody tr.stack-expanded:has(td.td-stack-more) td.td-primary::after {
        transform: translateY(-50%) rotate(180deg);
    }
    /* full-width informational rows (empty states etc.) */
    .pms-table.pms-table-stack tbody td[colspan] { display: block; text-align: center; }

    /* ── Compact variant: add .pms-stack-compact to the table ──
       Detail cells pack TWO per row with the label above the value,
       and a Select checkbox cell joins the title bar — much denser
       than the default one-line-per-column layout. */
    .pms-table.pms-stack-compact tbody tr {
        flex-direction: row;
        flex-wrap: wrap;
        position: relative;
    }
    .pms-table.pms-stack-compact tbody td {
        flex-direction: row;
        align-items: baseline;
        justify-content: flex-start;
        text-align: left;
        gap: 0.6rem;
        flex: 1 1 100%;
        width: auto;
        min-width: 0;
        word-break: break-word;
        border-bottom: 1px solid #f4f6fa;
        padding: 0.45rem 1rem;
    }
    .pms-table.pms-stack-compact tbody td::before { padding-top: 0; min-width: 5.2rem; }
    .pms-table.pms-stack-compact td.td-primary { padding-top: 0.55rem; padding-bottom: 0.55rem; }
    .pms-table.pms-stack-compact td.td-actions { padding-top: 0.45rem; padding-bottom: 0.45rem; }
    .pms-table.pms-stack-compact td.td-primary,
    .pms-table.pms-stack-compact td.td-actions,
    .pms-table.pms-stack-compact td.td-stack-full,
    .pms-table.pms-stack-compact tbody td[colspan] { flex: 1 1 100%; width: auto; }
    .pms-table.pms-stack-compact td.td-actions { flex-direction: row; }

    /* Compact mode never expands: secondary (.td-stack-more) cells stay
       hidden on phones — their data lives on the record's details page.
       No chevron, no rail; cards are pure at-a-glance rows. */
    .pms-table.pms-stack-compact td.td-stack-more { display: none !important; }
    .pms-table.pms-stack-compact tbody tr:has(td.td-stack-more) td.td-primary { padding-right: 1rem; }
    .pms-table.pms-stack-compact tbody tr:has(td.td-stack-more) td.td-primary::after { content: none; }

    /* Navigation variant: add .pms-stack-nav when rows navigate (data-href).
       The whole card is tappable and shows a right-edge "go" rail. */
    .pms-table.pms-stack-nav tbody tr[data-href] { padding-right: 1.7rem; }
    .pms-table.pms-stack-nav tbody tr[data-href]::after {
        content: "›";
        position: absolute;
        right: 0.55rem;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
        font-size: 1.25rem;
        font-weight: 600;
    }
    /* Navigation cards: the whole card is the action — hide the button
       footer on phones (everything lives on the details page it opens). */
    .pms-table.pms-stack-nav td.td-actions { display: none; }
    /* Select checkbox joins the title bar instead of taking its own row */
    .pms-table.pms-stack-compact td[data-label="Select"] {
        order: -1;
        width: auto;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        background: linear-gradient(180deg, #f6f9ff 0%, #eef4fd 100%);
        border-bottom: 1px solid var(--color-border);
        padding: 0.7rem 0 0.7rem 1rem;
    }
    .pms-table.pms-stack-compact td[data-label="Select"]::before { content: none; }
    .pms-table.pms-stack-compact tbody tr:has(td[data-label="Select"]) td.td-primary {
        border-left: none;
        width: auto;
        flex: 1 1 0;
        min-width: 0;
    }

    /* ── Actions-footer variant: add .pms-stack-actions to a stacked table ──
       Keeps each row's action buttons as a tap-friendly footer on phones so
       users can act directly, instead of the card only opening the details
       page. Composes with .pms-stack-nav (overrides its "hide the footer" rule
       and drops the floating go-rail) and .pms-stack-compact. The card body
       stays tappable wherever the view wires row navigation (tr[data-href]);
       taps on the footer buttons are excluded from that navigation. */
    .pms-table.pms-stack-actions td.td-actions {
        display: flex;
        justify-content: flex-end;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.45rem;
        background: #fafbfd;
        border-top: 1px solid var(--color-border);
        padding: 0.6rem 1rem;
    }
    .pms-table.pms-stack-actions td.td-actions .btn-action { padding: 0.45rem 0.8rem; font-size: 0.8rem; }
    .pms-table.pms-stack-actions tbody tr[data-href] { padding-right: 0; }
    .pms-table.pms-stack-actions tbody tr[data-href]::after { content: none; }
}

/* Sticky-header utility for tall grids — put on the .pms-table-wrap */
.pms-table-sticky { max-height: 65vh; overflow-y: auto; }
.pms-table-sticky .pms-table thead th,
.pms-table-sticky table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 1px 0 var(--color-border);
}

/* ── Action Buttons ─────────────────────────────────────────── */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.btn-action-primary  { background:#ebf4ff; color:#2a4365; border-color:#bee3f8; }
.btn-action-primary:hover  { background:#bee3f8; color:#1a365d; }
.btn-action-success  { background:#f0fff4; color:#276749; border-color:#9ae6b4; }
.btn-action-success:hover  { background:#9ae6b4; color:#1c4532; }
.btn-action-danger   { background:#fff5f5; color:#c53030; border-color:#feb2b2; }
.btn-action-danger:hover   { background:#feb2b2; color:#9b2c2c; }
.btn-action-warning  { background:#fffbeb; color:#92400e; border-color:#fde68a; }
.btn-action-warning:hover  { background:#fde68a; color:#78350f; }
.btn-action-secondary{ background:#f7fafc; color:#4a5568; border-color:#e2e8f0; }
.btn-action-secondary:hover{ background:#e2e8f0; color:#2d3748; }
/* Aliases used in older views */
.btn-action-edit { background:#ebf4ff; color:#2a4365; border-color:#bee3f8; }
.btn-action-edit:hover { background:#bee3f8; color:#1a365d; }
.btn-action-view { background:#f7fafc; color:#4a5568; border-color:#e2e8f0; }
.btn-action-view:hover { background:#e2e8f0; color:#2d3748; }
.btn-action-delete { background:#fff5f5; color:#c53030; border-color:#feb2b2; }
.btn-action-delete:hover { background:#feb2b2; color:#9b2c2c; }

/* ── Primary CTA Buttons ────────────────────────────────────── */
.btn-pms-primary {
    background: var(--color-brand);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-pms-primary:hover { background: var(--color-brand-dark); color: #fff; }
.btn-pms-success {
    background: var(--color-success);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-pms-success:hover { background: #276749; color: #fff; }
.btn-pms-danger {
    background: var(--color-danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-pms-danger:hover { background: #c53030; color: #fff; }
.btn-pms-outline {
    background: transparent;
    color: var(--color-brand);
    border: 1.5px solid var(--color-brand);
    border-radius: var(--radius-sm);
    padding: 0.42rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.btn-pms-outline:hover { background: var(--color-brand); color: #fff; }
.btn-pms-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.42rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.btn-pms-secondary:hover { background: #f1f5f9; border-color: #c3cdd9; color: var(--color-text); text-decoration: none; }
.btn-pms-ghost {
    background: transparent;
    color: var(--color-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.42rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.btn-pms-ghost:hover { background: #f1f5f9; color: var(--color-text); text-decoration: none; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.pms-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    box-shadow: var(--shadow-sm);
}
.pms-stat-icon {
    width: 42px; height: 42px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.15rem;
}
.pms-stat-body { flex: 1; min-width: 0; }
.pms-stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; color: var(--color-text); }
.pms-stat-label { font-size: 0.75rem; color: var(--color-muted); font-weight: 500; margin-top: 0.1rem; }
.pms-stat-sub   { font-size: 0.7rem;  color: var(--color-muted); margin-top: 0.15rem; }

/* ── Badges ─────────────────────────────────────────────────── */
.pms-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.pms-badge-success  { background:#f0fff4; color:#276749; }
.pms-badge-danger   { background:#fff5f5; color:#c53030; }
.row-inactive td    { opacity:.65; }
.row-inactive:hover td { opacity:.85; }
.pms-badge-warning  { background:#fffbeb; color:#92400e; }
.pms-badge-info     { background:#ebf8ff; color:#2b6cb0; }
.pms-badge-neutral  { background:#f7fafc; color:#4a5568; border:1px solid #e2e8f0; }
.pms-badge-primary  { background:#ebf4ff; color:#2a4365; }

/* ── Form Shell ─────────────────────────────────────────────── */
.form-shell {
    max-width: 640px;
}
.form-shell-wide {
    max-width: 900px;
}
.form-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border);
}
.form-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    margin-top: 1.25rem;
}

/* ── Delete Confirmation Shell ──────────────────────────────── */
.delete-shell {
    max-width: 540px;
    margin: 0 auto;
    text-align: left;
}
.delete-shell .delete-icon-wrap {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #fff5f5;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    color: var(--color-danger);
    margin-bottom: 1rem;
}
.delete-shell .delete-detail-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.delete-shell .delete-detail-row:last-child { border-bottom: none; }
.delete-shell .delete-detail-label { width: 140px; color: var(--color-muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
}
.empty-state i { font-size: 2.5rem; opacity: 0.35; display: block; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.875rem; margin: 0; }

/* ── Pagination ─────────────────────────────────────────────── */
.pms-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.9rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.78rem;
    color: var(--color-muted);
    flex-wrap: wrap;
    gap: 0.5rem;
}
.pms-pagination .page-links { display: flex; gap: 0.25rem; }
.pms-pagination .page-links a,
.pms-pagination .page-links span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    font-size: 0.78rem; font-weight: 600; text-decoration: none;
    border: 1px solid var(--color-border); color: var(--color-text);
    transition: background 0.12s;
}
.pms-pagination .page-links a:hover { background: var(--color-brand-light); }
.pms-pagination .page-links span.active { background: var(--color-brand); color: #fff; border-color: var(--color-brand); }
.pms-pagination .page-links span.disabled { opacity: 0.4; pointer-events: none; }

/* ── Alert overrides ────────────────────────────────────────── */
.alert { border-radius: var(--radius-md); font-size: 0.875rem; }
.alert i { margin-right: 0.35rem; }

/* ── Detail View ────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 0.6rem 1rem; }
.detail-grid .dl-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); padding-top: 2px; }
.detail-grid .dl-value { font-size: 0.875rem; color: var(--color-text); font-weight: 500; }

/* detail-row pattern (used in card-section detail views) */
.detail-row { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.55rem 1rem; border-bottom: 1px solid #f1f5f9; }
.detail-row:last-child { border-bottom: none; }
.detail-label { min-width: 160px; flex-shrink: 0; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted); padding-top: 1px; }
.detail-value { font-size: 0.875rem; color: var(--color-text); font-weight: 500; word-break: break-word; }
.detail-value.fw-500 { font-weight: 600; }

/* card-section header (replaces inline-style section headers) */
.card-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    background: #f8fafc;
}

/* ── Employee Tab Navigation ────────────────────────────────── */
.emp-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.emp-tabs .emp-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.emp-tabs .emp-tab:hover { color: var(--color-text); background: #f1f5f9; }
.emp-tabs .emp-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); background: #ebf4ff; }
.emp-tabs .emp-tab i { font-size: 0.85rem; }

.emp-tab-content .emp-tab-pane { display: none; }
.emp-tab-content .emp-tab-pane.active { display: block; animation: fadeInTab 0.15s ease; }
@keyframes fadeInTab { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* form-shell-tabs — full-width shell for tabbed employee forms */
.form-shell-tabs { max-width: 1100px; }

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 576px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .filter-bar .row > div { margin-bottom: 0.5rem; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-grid .dl-label { margin-bottom: 0; }
}
@media (max-width: 767.98px) {
    /* Filter controls stop fighting fixed widths on phones */
    .filter-bar-form .form-control,
    .filter-bar-form .form-select {
        flex: 1 1 45%;
        min-width: 0 !important;
        max-width: 100% !important;
        width: auto !important;
    }
    .filter-bar-form .btn-pms-primary,
    .filter-bar-form .btn-pms-secondary,
    .filter-bar-form .btn-pms-ghost { flex: 0 0 auto; }
    .page-content { padding: 1rem 0.75rem; }
    main { padding: 1rem 0.85rem; }
}

/* Keyboard access for clickable rows */
.pms-table tbody tr[data-href]:focus-visible {
    outline: 2px solid #4e8ef7;
    outline-offset: -2px;
}

/* ── Utility font weights (referenced app-wide, previously undefined) ── */
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

/* ── Legacy pagination markup (EarningType/DeductionType/TaxSlab/Role
      indexes + Activity) — previously unstyled phantom classes ── */
.pms-pagination-controls { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }
.pms-pagination-info { font-size: 0.78rem; color: var(--color-muted); }
.pms-page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 28px; height: 28px; padding: 0 0.45rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem; font-weight: 600; text-decoration: none;
    border: 1px solid var(--color-border); color: var(--color-text);
    background: var(--color-surface);
    transition: background 0.12s;
}
.pms-page-btn:hover { background: var(--color-brand-light); color: var(--color-brand); }
.pms-page-btn.active { background: var(--color-brand); color: #fff; border-color: var(--color-brand); }
.pms-page-btn.disabled, .pms-page-btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ── Badge aliases used by Compensation/BulkApply preview ── */
.pms-badge.badge-active   { background: #f0fff4; color: #276749; }
.pms-badge.badge-inactive { background: #f7fafc; color: #4a5568; border: 1px solid #e2e8f0; }

/* ── Toast notifications ────────────────────────────────────── */
.pms-toast-wrap {
    position: fixed;
    top: 72px;
    right: 1rem;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(380px, calc(100vw - 2rem));
}
.pms-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-info);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.7rem 0.9rem;
    font-size: 0.875rem;
    color: var(--color-text);
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.2s, transform 0.2s;
}
.pms-toast.visible { opacity: 1; transform: none; }
.pms-toast > i { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.pms-toast-success { border-left-color: var(--color-success); }
.pms-toast-success > i { color: var(--color-success); }
.pms-toast-danger  { border-left-color: var(--color-danger); }
.pms-toast-danger > i { color: var(--color-danger); }
.pms-toast-warning { border-left-color: var(--color-warning); }
.pms-toast-warning > i { color: var(--color-warning); }
.pms-toast-info    { border-left-color: var(--color-info); }
.pms-toast-info > i { color: var(--color-info); }
.pms-toast-msg { flex: 1; word-break: break-word; }
.pms-toast-close {
    background: none; border: none;
    color: var(--color-muted);
    font-size: 1.1rem; line-height: 1;
    cursor: pointer; padding: 0; flex-shrink: 0;
}
.pms-toast-close:hover { color: var(--color-text); }

/* ── Shared UX runtime: confirm dialog + progress overlay ───── */
.pms-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.pms-modal-backdrop.visible { opacity: 1; }
.pms-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.30);
    text-align: center;
    transform: translateY(10px) scale(0.98);
    transition: transform 0.15s ease;
}
.pms-modal-backdrop.visible .pms-modal { transform: none; }
.pms-modal-icon {
    width: 56px; height: 56px;
    border-radius: var(--radius-lg);
    background: var(--color-brand-light);
    color: var(--color-brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}
.pms-modal-icon-danger  { background: #fff5f5; color: var(--color-danger); }
.pms-modal-icon-warning { background: #fffbeb; color: var(--color-warning); }
.pms-modal-title {
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}
.pms-modal-message {
    font-size: 0.875rem;
    color: var(--color-text-light);
    white-space: pre-line;
    text-align: left;
    margin-bottom: 1.25rem;
}
.pms-modal-message:empty { display: none; }
.pms-modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
}
.pms-modal-actions > * { min-width: 110px; justify-content: center; }
.pms-progress-spinner { margin-bottom: 1rem; }
.pms-progress-spinner .spinner-border { width: 2.6rem; height: 2.6rem; border-width: 0.28em; }
.pms-progress-foot {
    font-size: 0.75rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}
.pms-btn-busy { opacity: 0.75; pointer-events: none; }
.pms-btn-spinner { margin-right: 0.45rem; width: 0.9rem; height: 0.9rem; border-width: 0.14em; vertical-align: -0.1em; }
@media (prefers-reduced-motion: reduce) {
    .pms-modal-backdrop, .pms-modal { transition: none; }
}

/* ── Payslip Web View ───────────────────────────────────────── */
.payslip-container {
    max-width: 860px;
    margin: 0 auto;
    font-size: 0.875rem;
}
.payslip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    background: #fff;
    border: 1px solid #e6eef8;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
}
.payslip-brand .company-logo { max-width: 220px; margin-bottom: 0.5rem; display: block; }
.payslip-brand .company-name { font-size: 1.05rem; font-weight: 700; color: #0b5ed7; margin-bottom: 0.2rem; }
.payslip-brand .company-address { font-size: 0.75rem; color: var(--color-muted); max-width: 460px; line-height: 1.4; }
.payslip-meta { text-align: right; flex-shrink: 0; }
.payslip-meta .meta-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); }
.payslip-meta .meta-value { font-size: 0.9rem; font-weight: 700; color: var(--color-text); margin-bottom: 0.6rem; }

.payslip-info {
    background: #fff;
    border: 1px solid #e6eef8;
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}
.payslip-info .info-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); margin-bottom: 0.15rem; }
.payslip-info .info-value { font-size: 0.875rem; font-weight: 600; color: var(--color-text); }

.payslip-ed {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.payslip-panel {
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.payslip-panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
}
.payslip-panel table { width: 100%; border-collapse: collapse; }
.payslip-panel table th { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); padding: 0.5rem 1rem; border-bottom: 1px solid #eef2f7; background: #f8fafc; }
.payslip-panel table td { padding: 0.55rem 1rem; border-bottom: 1px solid #f1f5f9; color: var(--color-text); font-size: 0.85rem; }
.payslip-panel table tr:last-child td { border-bottom: none; }
.payslip-panel table tfoot td { font-weight: 700; background: #f8fafc; border-top: 1px solid #e6eef8; font-size: 0.875rem; }

.payslip-netpay {
    background: #fff;
    border: 1px solid #e6eef8;
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.payslip-netpay .note { font-size: 0.78rem; color: var(--color-muted); font-style: italic; }
.payslip-netpay .net-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); margin-bottom: 0.2rem; text-align: right; }
.payslip-netpay .net-amount { font-size: 1.6rem; font-weight: 800; color: #0b5ed7; letter-spacing: -0.02em; }

@media print {
    .no-print { display: none !important; }
    .payslip-container { max-width: 100%; }
}
@media (max-width: 600px) {
    .payslip-info { grid-template-columns: repeat(2, 1fr); }
    .payslip-ed { grid-template-columns: 1fr; }
    .payslip-header { flex-direction: column; }
    .payslip-meta { text-align: left; }
}

/* ── Receipt evidence in claims grids ────────────────────────
   Thumbnails instead of a paperclip: an approver has to see the receipt
   without leaving the queue. Images open in the lightbox below; PDFs open
   in a new tab (the download endpoint sends X-Frame-Options: DENY). */
.pms-receipts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pms-receipt {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--color-border); background: #f8fafc;
    overflow: hidden; cursor: zoom-in; flex-shrink: 0;
    transition: border-color .12s ease, transform .12s ease;
}
.pms-receipt:hover { border-color: #4e8ef7; transform: translateY(-1px); }
.pms-receipt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pms-receipt-file {
    flex-direction: column; gap: 0; cursor: pointer;
    color: var(--color-danger, #dc2626); text-decoration: none; font-size: .95rem; line-height: 1;
}
.pms-receipt-file span { font-size: .55rem; font-weight: 700; letter-spacing: .04em; margin-top: 2px; }

.pms-lightbox {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(15, 23, 42, .82);
    display: flex; align-items: center; justify-content: center;
    padding: 1.25rem; overscroll-behavior: contain;
}
.pms-lightbox img {
    max-width: 100%; max-height: 82vh; border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45); background: #fff;
}
.pms-lightbox-bar {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: .75rem 1rem; color: #fff; font-size: .85rem;
}
.pms-lightbox-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pms-lightbox-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.pms-lightbox-actions a, .pms-lightbox-actions button {
    background: rgba(255, 255, 255, .14); color: #fff; border: none;
    border-radius: 6px; padding: .3rem .6rem; font-size: .8rem; cursor: pointer;
    text-decoration: none; line-height: 1.4;
}
.pms-lightbox-actions a:hover, .pms-lightbox-actions button:hover { background: rgba(255, 255, 255, .28); }

/* On phones the stacked card puts the receipt on its own row — give it room to breathe. */
@media (max-width: 767.98px) {
    .pms-table.pms-table-stack tbody td .pms-receipts { justify-content: flex-end; }
    .pms-receipt { width: 46px; height: 46px; }
}
