/* ==========================================================================
   WP Invoice Manager — Frontend Invoice  (Modern redesign)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --aferp-primary:       #0044aa;
    --aferp-primary-dark:  #003388;
    --aferp-primary-light: #ddeaff;
    --aferp-success:       #10b981;
    --aferp-success-dark:  #065f46;
    --aferp-success-light: #d1fae5;
    --aferp-warning:       #f59e0b;
    --aferp-danger:        #ef4444;
    --aferp-gray-50:  #f9fafb;
    --aferp-gray-100: #f3f4f6;
    --aferp-gray-200: #e5e7eb;
    --aferp-gray-300: #d1d5db;
    --aferp-gray-400: #9ca3af;
    --aferp-gray-500: #6b7280;
    --aferp-gray-600: #4b5563;
    --aferp-gray-700: #374151;
    --aferp-gray-800: #1f2937;
    --aferp-gray-900: #111827;
}

body.aferp-invoice-page {
    background: #f1f5f9;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    color: var(--aferp-gray-800);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.aferp-invoice-wrap { max-width: 900px; margin: 0 auto; padding: 32px 16px 72px; }

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.aferp-invoice-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}
.aferp-invoice-toolbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--aferp-gray-500);
    font-weight: 500;
}
.aferp-invoice-toolbar__brand strong { color: var(--aferp-gray-800); }
.aferp-invoice-toolbar__actions { display: flex; gap: 8px; }

.aferp-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .18s cubic-bezier(.4,0,.2,1);
    font-family: inherit;
    white-space: nowrap;
}
.aferp-btn--outline {
    background: #fff;
    border: 1.5px solid var(--aferp-gray-200);
    color: var(--aferp-gray-700);
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.aferp-btn--outline:hover {
    background: var(--aferp-gray-50);
    border-color: var(--aferp-gray-300);
    color: var(--aferp-gray-900);
    box-shadow: 0 3px 8px rgba(0,0,0,.08);
    transform: translateY(-1px);
}
.aferp-btn--primary {
    background: var(--aferp-primary);
    border: 1.5px solid var(--aferp-primary-dark);
    color: #fff;
    box-shadow: 0 1px 3px rgba(99,102,241,.35);
}
.aferp-btn--primary:hover {
    background: var(--aferp-primary-dark);
    box-shadow: 0 4px 12px rgba(99,102,241,.4);
    transform: translateY(-1px);
    color: #fff;
}

/* ── Document ───────────────────────────────────────────────────────────────── */
.aferp-invoice-doc {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,.07),
                0 20px 40px -8px rgba(0,0,0,.1);
    overflow: hidden;
}

/* ── Top accent strip ──────────────────────────────────────────────────────── */
.aferp-inv-accent {
    height: 5px;
    background: #0044aa;
}

/* ── Document inner padding ────────────────────────────────────────────────── */
.aferp-inv-body { padding: 52px 56px; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.aferp-inv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 48px;
    gap: 32px;
}
.aferp-inv-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.aferp-inv-logo {
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}
.aferp-inv-company {
    font-size: 20px;
    font-weight: 800;
    color: var(--aferp-gray-900);
    letter-spacing: -.3px;
    margin: 0;
}
.aferp-inv-address { font-size: 13px; color: #555; font-weight: 400; line-height: 1.7; }

.aferp-inv-header__meta { text-align: right; flex-shrink: 0; }
.aferp-inv-title {
    font-size: 38px;
    font-weight: 900;
    color: var(--aferp-gray-900);
    text-transform: uppercase;
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 8px;
}
.aferp-inv-number {
    font-size: 14px;
    color: var(--aferp-gray-500);
    font-weight: 500;
    font-family: ui-monospace, monospace;
    margin-bottom: 10px;
}

/* Dates block (right column, below badge) */
.aferp-inv-dates {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-top: 1px solid rgba(255,255,255,.15);
    padding-top: 12px;
}
.aferp-inv-date-item {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 8px;
}
.aferp-inv-date-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--aferp-gray-400);
}
.aferp-inv-date-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--aferp-gray-700);
}

/* Amount due (right cell of addresses row) */
.aferp-inv-amount-due {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding: 20px 24px;
    background: var(--aferp-primary-light);
    border-radius: 12px;
    text-align: right;
}
.aferp-inv-amount-due__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--aferp-primary);
    margin-bottom: 6px;
}
.aferp-inv-amount-due__value {
    font-size: 26px;
    font-weight: 800;
    color: var(--aferp-primary-dark);
    letter-spacing: -.5px;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.aferp-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
}
.aferp-badge--grey   { background: var(--aferp-gray-100); color: var(--aferp-gray-600); }
.aferp-badge--blue   { background: #dbeafe; color: #1e40af; }
.aferp-badge--green  { background: var(--aferp-success-light); color: var(--aferp-success-dark); }
.aferp-badge--red    { background: #fee2e2; color: #991b1b; }
.aferp-badge--dark   { background: var(--aferp-gray-200); color: var(--aferp-gray-600); }
.aferp-badge--purple { background: var(--aferp-primary-light); color: var(--aferp-primary-dark); }


/* ── Addresses ──────────────────────────────────────────────────────────────── */
.aferp-inv-addresses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--aferp-gray-100);
}
.aferp-inv-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--aferp-gray-400);
    margin-bottom: 10px;
}
.aferp-inv-billed-to__name {
    font-size: 15px;
    font-weight: 400;
    color: var(--aferp-gray-900);
    margin-bottom: 4px;
}
.aferp-inv-billed-to__line {
    font-size: 13px;
    color: var(--aferp-gray-500);
    line-height: 1.7;
}

/* ── Items table ────────────────────────────────────────────────────────────── */
.aferp-inv-items { margin-bottom: 32px; }
.aferp-items-table { width: 100%; border-collapse: collapse; }
.aferp-items-table thead tr {
    border-bottom: 2px solid var(--aferp-gray-900);
}
.aferp-items-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--aferp-gray-500);
}
.aferp-items-table thead th:not(:first-child) { text-align: right; }
.aferp-items-table tbody tr {
    border-bottom: 1px solid var(--aferp-gray-100);
    transition: background .12s;
}
.aferp-items-table tbody tr:hover { background: var(--aferp-gray-50); }
.aferp-items-table tbody tr:last-child { border-bottom: none; }
.aferp-items-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--aferp-gray-700);
    vertical-align: middle;
}
.aferp-items-table tbody td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.aferp-items-table .aferp-item-desc { font-weight: 500; color: var(--aferp-gray-900); }
.aferp-items-table .aferp-item-total { font-weight: 700; color: var(--aferp-gray-900); }

/* ── Totals ─────────────────────────────────────────────────────────────────── */
.aferp-inv-totals-wrap {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 40px;
}
.aferp-inv-totals {
    min-width: 280px;
    border-radius: 12px;
    overflow: hidden;
    border: none;
}
.aferp-inv-totals table { width: 100%; border-collapse: collapse; }
.aferp-inv-totals td {
    padding: 11px 18px;
    font-size: 14px;
    border-bottom: 1px solid var(--aferp-gray-200);
    font-variant-numeric: tabular-nums;
}
.aferp-inv-totals tr:last-child td { border-bottom: none; }
.aferp-inv-totals td:first-child { color: var(--aferp-gray-500); }
.aferp-inv-totals td:last-child { text-align: right; font-weight: 600; color: var(--aferp-gray-800); }
.aferp-total-row { background: #0044aa !important; }
.aferp-total-row td { color: #fff !important; font-size: 15px; font-weight: 700; border-bottom: none !important; }
/* When total row is the last (and only) row, remove box padding below it */
.aferp-total-row:last-child td:first-child { border-radius: 0 0 0 12px; }
.aferp-total-row:last-child td:last-child { border-radius: 0 0 12px 0; }
.aferp-due-row { background: var(--aferp-success-light) !important; }
.aferp-due-row td { color: var(--aferp-success-dark) !important; font-size: 16px; font-weight: 800; border-bottom: none !important; }

/* ── Notes & terms ──────────────────────────────────────────────────────────── */
.aferp-inv-notes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 40px;
    padding: 24px;
    background: var(--aferp-gray-50);
    border: 1px solid var(--aferp-gray-200);
    border-radius: 12px;
}
.aferp-inv-notes__block h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--aferp-gray-400);
    margin-bottom: 8px;
}
.aferp-inv-notes__block p {
    font-size: 13px;
    color: var(--aferp-gray-600);
    line-height: 1.7;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.aferp-inv-footer {
    border-top: 1px solid var(--aferp-gray-100);
    padding-top: 20px;
    font-size: 12px;
    color: #555;
    font-weight: 400;
    text-align: center;
    letter-spacing: .2px;
}

/* ── Thank-you banner (paid invoices) ──────────────────────────────────────── */
.aferp-inv-paid-banner {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border: 1px solid #6ee7b7;
    border-radius: 10px;
    padding: 16px 24px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--aferp-success-dark);
    font-size: 15px;
}
.aferp-inv-paid-banner span { font-size: 22px; }

/* ── Payment Plan table ─────────────────────────────────────────────────────── */
.aferp-inv-plan {
    margin-bottom: 40px;
}
.aferp-inv-plan__title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--aferp-gray-900);
    margin-bottom: 14px;
}
.aferp-inv-plan__table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--aferp-gray-200);
}
.aferp-inv-plan__table thead tr {
    background: #0044aa;
}
.aferp-inv-plan__table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #fff;
}
.aferp-inv-plan__table thead th:not(:first-child) { text-align: left; }
.aferp-inv-plan__table thead th:last-child { text-align: right; }
.aferp-inv-plan__table tbody tr {
    border-bottom: 1px solid var(--aferp-gray-100);
    transition: background .12s;
}
.aferp-inv-plan__table tbody tr:last-child { border-bottom: none; }
.aferp-inv-plan__table tbody tr:nth-child(even) { background: var(--aferp-gray-50); }
.aferp-inv-plan__table tbody td {
    padding: 13px 16px;
    font-size: 14px;
    color: var(--aferp-gray-700);
}
.aferp-inv-plan__ordinal {
    font-weight: 700;
    color: var(--aferp-primary);
}
.aferp-inv-plan__amount {
    text-align: right;
    font-weight: 700;
    color: var(--aferp-gray-900);
    font-variant-numeric: tabular-nums;
}

/* ── Payment Details + Signature ────────────────────────────────────────────── */
.aferp-inv-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--aferp-gray-100);
}
.aferp-inv-payment__title,
.aferp-inv-signature__title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #0044aa;
    margin-bottom: 12px;
}
.aferp-inv-payment__intro {
    font-size: 13px;
    color: var(--aferp-gray-600);
    line-height: 1.65;
    margin-bottom: 12px;
}
.aferp-inv-payment__methods {
    list-style: none;
    margin: 0 0 4px;
    padding: 0;
}
.aferp-inv-payment__method {
    font-size: 13px;
    color: #555;
    font-weight: 400;
    line-height: 1.9;
}
.aferp-inv-payment__method--bold {
    font-weight: 700;
    color: var(--aferp-gray-800);
}
.aferp-inv-payment__receiver {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--aferp-gray-200);
    font-weight: 400;
    font-size: 13px;
    color: #222222;
    line-height: 1.8;
}
.aferp-inv-payment__receiver-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #0044aa;
    margin-bottom: 6px;
}
.aferp-inv-payment__receiver strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--aferp-gray-800);
    margin-bottom: 2px;
}

.aferp-inv-signature {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    text-align: center;
}
.aferp-inv-signature__img {
    display: block;
    max-height: 80px;
    width: auto;
    object-fit: contain;
    margin-bottom: 10px;
}
.aferp-inv-signature__line {
    width: 100%;
    max-width: 200px;
    height: 1px;
    background: var(--aferp-gray-300);
    margin-bottom: 10px;
}
.aferp-inv-signature__name {
    font-size: 14px;
    font-weight: 700;
    color: var(--aferp-gray-800);
}
.aferp-inv-signature__role {
    font-size: 12px;
    color: #555;
    font-weight: 400;
    margin-top: 3px;
}

/* ── Print ──────────────────────────────────────────────────────────────────── */
@media print {
    @page { margin: 8mm 10mm; }

    body.aferp-invoice-page { background: #fff; font-size: 16px; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
    .aferp-invoice-toolbar  { display: none !important; }
    .aferp-invoice-wrap     { max-width: none; padding: 0; }
    .aferp-invoice-doc      { box-shadow: none; border-radius: 0; }
    /* Use borders instead of backgrounds so they print without "Background graphics" */
    .aferp-inv-accent       { height: 0; border-top: 6px solid #0044aa !important; background: none; }
    .aferp-inv-amount-due   { background: none !important; border: 2px solid #0044aa !important; }
    .aferp-inv-amount-due__label { color: #0044aa !important; }
    .aferp-inv-amount-due__value { color: #0044aa !important; }
    .aferp-inv-totals .aferp-inv-total-final { border: 2px solid #0044aa !important; }
    .aferp-inv-paid-banner  { border: 2px solid #16a34a !important; background: none !important; }

    /* Tighter body */
    .aferp-inv-body { padding: 18px 26px; }

    /* Header */
    .aferp-inv-header       { margin-bottom: 18px; gap: 16px; }
    .aferp-inv-brand        { margin-bottom: 6px; gap: 8px; }
    .aferp-inv-logo         { max-width: 42px; max-height: 42px; }
    .aferp-inv-company      { font-size: 21px; }
    .aferp-inv-address      { font-size: 14px; line-height: 1.5; }
    .aferp-inv-title        { font-size: 34px; margin-bottom: 4px; }
    .aferp-inv-number       { font-size: 14px; margin-bottom: 6px; }
    .aferp-inv-dates        { margin-top: 8px; padding-top: 8px; gap: 3px; }
    .aferp-inv-date-label   { font-size: 12px; }
    .aferp-inv-date-value   { font-size: 14px; }

    /* Addresses row */
    .aferp-inv-addresses    { gap: 20px; margin-bottom: 18px; padding-bottom: 18px; }
    .aferp-inv-section-label { font-size: 12px; margin-bottom: 6px; }
    .aferp-inv-billed-to__name { font-size: 16px; margin-bottom: 2px; }
    .aferp-inv-billed-to__line { font-size: 14px; line-height: 1.5; }
    .aferp-inv-amount-due   { padding: 12px 16px; border-radius: 8px; }
    .aferp-inv-amount-due__label { font-size: 12px; margin-bottom: 3px; }
    .aferp-inv-amount-due__value { font-size: 26px; }

    /* Items table */
    .aferp-inv-items        { margin-bottom: 14px; }
    .aferp-items-table thead th {
        padding: 8px 10px;
        font-size: 12px;
    }
    .aferp-items-table tbody tr:hover { background: transparent; }
    .aferp-items-table tbody td {
        padding: 8px 10px;
        font-size: 15px;
    }
    .aferp-items-table thead tr { border-bottom-width: 1.5px; }

    /* Totals */
    .aferp-inv-totals-wrap  { margin-bottom: 18px; }
    .aferp-inv-totals       { min-width: 250px; }
    .aferp-inv-totals td    { padding: 8px 14px; font-size: 15px; }

    /* Notes */
    .aferp-inv-notes        { margin-bottom: 18px; padding: 14px; gap: 16px; }
    .aferp-inv-notes__block h3 { font-size: 12px; margin-bottom: 4px; }
    .aferp-inv-notes__block p  { font-size: 14px; }

    /* Payment plan */
    .aferp-inv-plan         { margin-bottom: 16px; }
    .aferp-inv-plan__title  { font-size: 13px; margin-bottom: 10px; }
    .aferp-inv-plan__table thead th { padding: 9px 12px; font-size: 11px; }
    .aferp-inv-plan__table tbody td { padding: 8px 12px; font-size: 13px; }

    /* Payment + Signature */
    .aferp-inv-bottom       { gap: 20px; margin-bottom: 14px; padding-top: 14px; }
    .aferp-inv-payment__title,
    .aferp-inv-signature__title { font-size: 12px; margin-bottom: 6px; }
    .aferp-inv-payment__intro   { font-size: 14px; margin-bottom: 8px; }
    .aferp-inv-payment__method  { font-size: 14px; line-height: 1.65; }
    .aferp-inv-payment__receiver { margin-top: 10px; padding-top: 10px; font-size: 14px; line-height: 1.55; }
    .aferp-inv-payment__receiver strong { font-size: 15px; }
    .aferp-inv-payment__receiver-label  { font-size: 13px; margin-bottom: 4px; }
    .aferp-inv-signature__img  { max-height: 64px; margin-bottom: 6px; }
    .aferp-inv-signature__line { margin-bottom: 6px; }
    .aferp-inv-signature__name { font-size: 15px; }
    .aferp-inv-signature__role { font-size: 13px; }

    /* Paid banner */
    .aferp-inv-paid-banner  { padding: 10px 16px; margin-bottom: 14px; font-size: 14px; }

    /* Footer */
    .aferp-inv-footer       { padding-top: 10px; font-size: 14px; }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media screen and (max-width: 720px) {
    .aferp-inv-body { padding: 28px 24px; }
    .aferp-inv-header { flex-direction: column; gap: 20px; }
    .aferp-inv-header__meta { text-align: left; }
    .aferp-inv-date-item { justify-content: flex-start; }
    .aferp-inv-amount-due { align-items: flex-start; text-align: left; }
    .aferp-inv-title { font-size: 28px; }
    .aferp-inv-addresses { grid-template-columns: 1fr; gap: 24px; }
    .aferp-inv-notes { grid-template-columns: 1fr; gap: 20px; }
    .aferp-inv-bottom { grid-template-columns: 1fr; gap: 28px; }
    .aferp-inv-signature { align-items: center; text-align: center; }
    .aferp-inv-signature__line { max-width: none; }
    .aferp-inv-totals-wrap { justify-content: stretch; }
    .aferp-inv-totals { min-width: 0; width: 100%; }
    .aferp-items-table thead th:nth-child(2),
    .aferp-items-table tbody td:nth-child(2) { display: none; }
}
@media screen and (max-width: 480px) {
    .aferp-invoice-toolbar { flex-direction: column; align-items: flex-start; }
    .aferp-inv-body { padding: 20px 16px; }
}

/* ── Employee Portal ─────────────────────────────────────────────────────── */

/* Defeat theme typography for the entire portal subtree */
.aferp-portal-page,
.aferp-portal-page *,
.aferp-portal-wrap,
.aferp-portal-wrap *,
.aferp-portal-shell,
.aferp-portal-shell * {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}
.aferp-portal-page { background: #f1f5f9; min-height: 100vh; padding: 0; margin: 0; color: #0f172a; }
/* Override theme container constraints on portal pages so the portal goes edge-to-edge */
body.aferp-portal-page .site,
body.aferp-portal-page .site-content,
body.aferp-portal-page #page,
body.aferp-portal-page #content,
body.aferp-portal-page #primary,
body.aferp-portal-page #main,
body.aferp-portal-page main,
body.aferp-portal-page .wp-site-blocks,
body.aferp-portal-page .entry-content,
body.aferp-portal-page .container,
body.aferp-portal-page .wrap,
body.aferp-portal-page article {
    max-width: 100% !important; width: 100% !important; padding-left: 0 !important; padding-right: 0 !important; margin-left: 0 !important; margin-right: 0 !important;
}

/* Sticky top app bar */
.aferp-portal-topbar {
    position: sticky; top: 0; z-index: 100;
    background: #fff; border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.aferp-portal-topbar__inner {
    max-width: 100%; margin: 0; padding: 12px 32px;
    display: flex; align-items: center; gap: 16px;
}
.aferp-portal-topbar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.aferp-portal-topbar__logo { height: 36px; width: auto; }
.aferp-portal-topbar__title { font-size: 16px; font-weight: 700; color: #0f172a; margin: 0; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aferp-portal-topbar__subtitle { font-size: 11px; color: #64748b; margin: 0; text-transform: uppercase; letter-spacing: .5px; }
.aferp-portal-topbar__spacer { flex: 1; }
.aferp-portal-topbar__greeting { font-size: 13px; color: #475569; margin-right: 4px; }
.aferp-portal-topbar__greeting strong { color: #0f172a; }
.aferp-portal-iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: #f1f5f9; color: #475569; border: none; cursor: pointer;
    font-size: 16px; transition: background .15s, color .15s;
    text-decoration: none;
}
.aferp-portal-iconbtn:hover { background: #e2e8f0; color: #0f172a; }
.aferp-portal-iconbtn--danger:hover { background: #fee2e2; color: #dc2626; }

.aferp-portal-signout {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; height: 38px;
    background: #fff; color: #dc2626;
    border: 1.5px solid #fecaca; border-radius: 999px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.aferp-portal-signout:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.aferp-portal-signout__icon { font-size: 14px; line-height: 1; }

/* Month picker (shared with admin) */
.aferp-monthpicker-pop { background:#fff; border:1px solid #e2e8f0; border-radius:10px; box-shadow:0 8px 24px rgba(15,23,42,.15); width:280px; padding:0; overflow:hidden; font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif }
.aferp-mp-head { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; background:#0044aa; color:#fff; margin:0 }
.aferp-mp-head .aferp-mp-year { font-weight:600; font-size:15px; color:#fff }
.aferp-mp-head button { background:transparent; border:0; cursor:pointer; font-size:20px; line-height:1; padding:4px 10px; color:#fff; border-radius:6px; opacity:.9 }
.aferp-mp-head button:hover { background:rgba(255,255,255,.18); opacity:1 }
.aferp-mp-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; padding:12px }
.aferp-mp-month { background:#fff; border:1px solid transparent; border-radius:6px; padding:12px 0; font-size:13px; cursor:pointer; color:#1e293b; transition:background .15s, color .15s }
.aferp-mp-month:hover { background:#f1f5f9; color:#0044aa }
.aferp-mp-month.is-active { background:#0044aa; color:#fff; font-weight:600 }
.aferp-monthpicker-wrap { position:relative; display:inline-block; width:100% }
.aferp-monthpicker-wrap .aferp-monthpicker-display { padding-right:34px !important }
.aferp-monthpicker-icon { position:absolute; right:10px; top:50%; transform:translateY(-50%); pointer-events:auto; cursor:pointer; font-size:14px; opacity:.65 }
@media (max-width: 600px) {
    .aferp-portal-signout__label { display: none; }
    .aferp-portal-signout { width: 38px; padding: 0; justify-content: center; }
}

.aferp-portal-wrap {
    max-width: 100%; margin: 0; padding: 28px 32px 60px;
}
.aferp-portal-wrap--narrow { max-width: 460px; margin: 0 auto; padding-top: 60px; }

/* Two-column layout when authenticated */
.aferp-portal-shell {
    display: grid; grid-template-columns: 300px 1fr; gap: 24px;
    align-items: start;
}
@media (max-width: 880px) {
    .aferp-portal-shell { grid-template-columns: 1fr; }
    .aferp-portal-topbar__greeting { display: none; }
    .aferp-portal-topbar__inner { padding: 12px 16px; }
    .aferp-portal-wrap { padding: 16px 16px 80px; }
}

.aferp-portal-header { text-align: center; margin-bottom: 24px; }
.aferp-portal-header__logo { height: 56px; width: auto; margin-bottom: 12px; }
.aferp-portal-header__title { font-size: 22px; font-weight: 700; color: #0f172a; margin: 0 0 4px; }
.aferp-portal-header__subtitle { font-size: 13px; color: #64748b; margin: 0; }

.aferp-portal-box {
    background: #fff; border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.04);
    padding: 28px;
}
.aferp-portal-box__title { font-size: 18px; font-weight: 700; margin: 0 0 20px; color: #1e293b; }

.aferp-portal-field { margin-bottom: 16px; }
.aferp-portal-field label { display: block; font-size: 12px; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.aferp-portal-input {
    width: 100%; padding: 11px 14px; border: 1.5px solid #e2e8f0;
    border-radius: 8px; font-size: 14px; line-height: 1.4; color: #1e293b;
    background: #fff; box-sizing: border-box; height: 44px;
    transition: border-color .15s, box-shadow .15s;
}
textarea.aferp-portal-input { height: auto; min-height: 80px; }
.aferp-portal-input:focus { outline: none; border-color: #0044aa; box-shadow: 0 0 0 3px rgba(0,68,170,.12); }
/* Custom chevron for native selects */
select.aferp-portal-input {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2364748b' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}
select.aferp-portal-input::-ms-expand { display: none; }

.aferp-portal-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: 8px; border: 1.5px solid #e2e8f0;
    background: #fff; color: #334155; font-size: 14px; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: all .15s;
}
.aferp-portal-btn--primary { background: #4f46e5; color: #fff; border-color: #4f46e5; width: 100%; margin-top: 4px; }
.aferp-portal-btn--primary:hover { background: #4338ca; }

.aferp-portal-hint { text-align: center; font-size: 12px; color: #94a3b8; margin: 14px 0 0; }

.aferp-portal-notice { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.aferp-portal-notice--error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.aferp-portal-avatar {
    width: 64px; height: 64px; border-radius: 50%; background: #4f46e5; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; margin: 0 auto 12px;
}
.aferp-portal-avatar--sm { width: 32px; height: 32px; font-size: 13px; margin: 0; }

/* Profile sidebar (left column on desktop) */
.aferp-portal-profile { text-align: center; }
.aferp-portal-profile__name { font-size: 17px; font-weight: 700; margin: 0 0 4px; color: #0f172a; }
.aferp-portal-profile__role { font-size: 13px; color: #64748b; margin: 0 0 16px; }
.aferp-portal-profile__chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 18px; }
.aferp-portal-profile__chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; background: #f1f5f9; color: #475569;
    border-radius: 999px; font-size: 11px; font-weight: 500;
}
.aferp-portal-profile__contact { text-align: left; border-top: 1px solid #f1f5f9; padding-top: 14px; margin-top: 4px; }
.aferp-portal-profile__contact-row { display: flex; gap: 8px; align-items: center; font-size: 12px; color: #475569; padding: 4px 0; }
.aferp-portal-profile__contact-row strong { color: #0f172a; font-weight: 500; }

.aferp-portal-list { display: flex; flex-direction: column; gap: 0; }
.aferp-portal-list__item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 0; border-bottom: 1px solid #f1f5f9;
    text-decoration: none; color: #1e293b; transition: background .1s;
}
.aferp-portal-list__item:last-child { border-bottom: none; }
.aferp-portal-list__item:hover { background: #f8fafc; margin: 0 -28px; padding: 14px 28px; }

.aferp-portal-payslip { margin-top: 4px; }
.aferp-portal-payslip__header {
    display: flex; justify-content: space-between; align-items: center;
    background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff;
    padding: 16px 20px; border-radius: 10px; margin-bottom: 20px;
}
.aferp-portal-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.aferp-portal-table td { padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.aferp-portal-table td:last-child { text-align: right; font-weight: 600; }
.aferp-portal-table__total td { font-weight: 700; font-size: 16px; border-top: 2px solid #e2e8f0; border-bottom: 2px solid #e2e8f0; padding: 12px 0; }

.aferp-portal-balance {
    display: flex; justify-content: space-between; align-items: center;
    background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px;
    padding: 14px 18px; font-size: 14px; margin-top: 4px;
}
.aferp-portal-balance.aferp-portal-balance--paid { background: #f0fdf4; border-color: #86efac; color: #16a34a; }

@media print {
    /* Hide theme chrome on portal pages ONLY (not invoice pages) */
    body.aferp-portal-page > *:not(.aferp-portal-wrap),
    body.aferp-portal-page > header, body.aferp-portal-page > footer, body.aferp-portal-page > nav,
    body.aferp-portal-page .site-header, body.aferp-portal-page .site-footer, body.aferp-portal-page .site-navigation,
    body.aferp-portal-page .wp-site-blocks > header, body.aferp-portal-page .wp-site-blocks > footer,
    body.aferp-portal-page .main-navigation, body.aferp-portal-page .site-branding,
    body.aferp-portal-page #wmasthead, body.aferp-portal-page #colophon { display: none !important; }

    /* Show only the portal wrap and its contents */
    .aferp-portal-page { background: #fff; display: block !important; }
    .aferp-portal-wrap { padding: 0; max-width: 100%; display: block !important; }

    /* Hide all portal chrome — only show the payslip box */
    .aferp-portal-header,
    .aferp-portal-btn,
    #portal-logout-btn,
    a[href*="aferp_view"],
    .aferp-portal-list { display: none !important; }

    /* Make the payslip box fill the page */
    .aferp-portal-box { box-shadow: none; padding: 0; }

    /* Preserve colors */
    .aferp-portal-payslip__header { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .aferp-portal-balance--paid   { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
