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

:root {
    --pay-bg: radial-gradient(circle at 12% 12%, rgba(251, 191, 36, 0.15), transparent 42%),
        radial-gradient(circle at 88% 4%, rgba(16, 185, 129, 0.12), transparent 38%),
        linear-gradient(135deg, #f8fafc 0%, #f1f5f9 60%, #e2e8f0 100%);
    --pay-surface: rgba(255, 255, 255, 0.94);
    --pay-border: rgba(148, 163, 184, 0.3);
    --pay-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
}

body.pay-portal-active {
    background: var(--pay-bg);
}

body.pay-portal-active .dashboard-container,
body.pay-portal-active .finance-portal {
    display: none;
}

.pay-portal {
    display: none;
    min-height: 100vh;
    background: var(--pay-bg);
    color: #0f172a;
    font-family: 'Manrope', 'Segoe UI', sans-serif;
}

body.pay-portal-active .pay-portal {
    display: block;
}

.pay-portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2.2rem;
    border-bottom: 1px solid var(--pay-border);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(14px);
}

.pay-portal-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.pay-portal-logo {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #b45309;
    font-size: 1.2rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.26), rgba(16, 185, 129, 0.22));
}

.pay-portal-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.pay-portal-subtitle {
    font-size: 0.84rem;
    color: rgba(71, 85, 105, 0.88);
}

.pay-portal-actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.pay-portal-user {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 0;
    text-align: left;
    font-size: 0.83rem;
    color: rgba(71, 85, 105, 0.9);
    cursor: pointer;
    box-shadow: none;
    transition: all 0.3s ease;
}

.pay-portal-user:hover,
.pay-portal-profile.is-open .pay-portal-user {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(137, 27, 184, 0.18);
    box-shadow: none;
    transform: none;
}

.pay-portal-user-name {
    display: block;
    color: blue;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.pay-portal-user-role {
    display: block;
    color: red;
    font-size: 12px;
    line-height: 1.2;
}

.pay-portal-profile .portal-profile-menu-item i {
    color: #b45309;
}

.pay-portal-exit {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    padding: 0.55rem 1.2rem;
}

.pay-portal-content {
    padding: 1.75rem 2.2rem 2.8rem;
}

.pay-tab-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1.4rem;
}

.pay-tab-button {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    color: rgba(30, 41, 59, 0.82);
    border-radius: 999px;
    padding: 0.54rem 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.pay-tab-button.is-active,
.pay-tab-button:hover {
    color: #0f172a;
    border-color: rgba(251, 191, 36, 0.55);
    background: rgba(251, 191, 36, 0.18);
}

.pay-portal-section {
    display: none;
}

.pay-portal-section.is-active {
    display: block;
}

.pay-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.pay-section-header h2 {
    margin-bottom: 0.25rem;
}

.pay-section-header p {
    margin: 0;
    color: rgba(71, 85, 105, 0.9);
}

.pay-table-tools {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pay-table-tools .form-control {
    min-width: 220px;
}

.pay-table-tools .form-select {
    min-width: 210px;
}

.pay-table-card {
    position: relative;
    background: var(--pay-surface);
    border: 1px solid var(--pay-border);
    border-radius: 16px;
    box-shadow: var(--pay-shadow);
    overflow: auto;
}

.pay-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.pay-table th,
.pay-table td {
    padding: 0.86rem 0.95rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    vertical-align: middle;
}

.pay-table th {
    white-space: nowrap;
    background: rgba(248, 250, 252, 0.9);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(71, 85, 105, 0.86);
}

.pay-table tbody tr:hover {
    background: rgba(251, 191, 36, 0.08);
}

.pay-empty {
    display: none;
    padding: 1.2rem;
    text-align: center;
    color: rgba(100, 116, 139, 0.9);
}

.pay-empty.is-visible {
    display: block;
}

.pay-amount {
    font-weight: 700;
    color: #0f766e;
}

.pay-amount-link {
    border: none;
    background: transparent;
    padding: 0;
    text-align: left;
    display: grid;
    gap: 0.14rem;
    cursor: pointer;
}

.pay-amount-link small {
    font-size: 0.74rem;
    color: rgba(71, 85, 105, 0.88);
}

.pay-amount-original {
    color: rgba(100, 116, 139, 0.9);
    text-decoration: line-through;
    font-size: 0.8rem;
}

.pay-amount-discounted {
    color: #0f766e;
    font-weight: 800;
}

.pay-amount-regular {
    display: grid;
    gap: 0.2rem;
}

.pay-agreement-note {
    color: #b45309;
    font-size: 0.74rem;
    line-height: 1.2;
}

.pay-amount.high {
    color: #b45309;
}

.pay-due {
    font-weight: 600;
}

.pay-due.overdue {
    color: #b91c1c;
}

.pay-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.24rem 0.56rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.pay-badge.unpaid {
    background: rgba(251, 191, 36, 0.18);
    color: #92400e;
}

.pay-badge.paid {
    background: rgba(16, 185, 129, 0.18);
    color: #047857;
}

.pay-link {
    color: #0369a1;
    text-decoration: none;
    font-weight: 600;
}

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

.pay-vendor-name-link {
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.6);
}

.pay-vendor-name-link:hover {
    color: #0369a1;
    border-bottom-color: rgba(3, 105, 161, 0.6);
}

.pay-vendor-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.pay-vendor-drawer-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.pay-vendor-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1045;
    width: min(470px, 95vw);
    height: 100vh;
    background: #ffffff;
    box-shadow: -20px 0 45px rgba(15, 23, 42, 0.2);
    padding: 1rem 1rem 1.2rem;
    overflow: auto;
    transform: translateX(102%);
    transition: transform 0.25s ease;
}

.pay-vendor-drawer.is-visible {
    transform: translateX(0);
}

.pay-vendor-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.pay-vendor-drawer-header h3 {
    margin-bottom: 0.22rem;
}

.pay-vendor-drawer-header p {
    margin: 0;
    color: rgba(71, 85, 105, 0.92);
}

.pay-vendor-overview-grid {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.pay-vendor-overview-card {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 0.68rem 0.78rem;
    background: rgba(248, 250, 252, 0.7);
}

.pay-vendor-overview-card h4 {
    margin-bottom: 0.35rem;
}

.pay-vendor-overview-card.is-open {
    border-color: rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.12);
}

.pay-vendor-overview-card.is-scheduled {
    border-color: rgba(14, 165, 233, 0.45);
    background: rgba(14, 165, 233, 0.1);
}

.pay-vendor-overview-card.is-paid {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.1);
}

.pay-vendor-overview-value {
    font-weight: 800;
    font-size: 1.18rem;
    margin-bottom: 0.18rem;
}

.pay-vendor-overview-meta {
    color: rgba(71, 85, 105, 0.9);
    font-size: 0.84rem;
}

.pay-vendor-section {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    padding: 0.7rem 0.78rem;
    margin-bottom: 0.76rem;
    background: #fff;
}

.pay-vendor-section h4 {
    margin-bottom: 0.45rem;
}

.pay-vendor-section p {
    margin: 0;
    color: rgba(71, 85, 105, 0.9);
}

.pay-vendor-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
}

.pay-vendor-detail-value {
    font-weight: 600;
    color: #0f172a;
}

.pay-vendor-details-grid {
    display: grid;
    gap: 0.45rem;
}

.pay-vendor-detail-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 0.55rem;
}

.pay-vendor-detail-row strong {
    color: rgba(71, 85, 105, 0.95);
}

.pay-vendor-actions {
    padding-top: 0.2rem;
}

.pay-more {
    position: relative;
}

.pay-more-toggle {
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #ffffff;
    border-radius: 10px;
    min-width: 36px;
    height: 34px;
}

.pay-more-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 20;
    min-width: 165px;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
    padding: 0.35rem;
    display: none;
}

.pay-more-menu.is-visible {
    display: block;
}

.pay-more-menu button {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.5rem 0.62rem;
    border-radius: 8px;
    font-size: 0.84rem;
}

.pay-more-menu button:hover {
    background: rgba(248, 250, 252, 0.9);
}

.pay-invoice-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
}

.pay-invoice-modal.is-visible {
    display: flex;
}

.pay-agreement-modal {
    position: fixed;
    inset: 0;
    z-index: 1055;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    padding: 1rem;
}

.pay-agreement-modal.is-visible {
    display: flex;
}

.pay-agreement-dialog {
    width: min(820px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 28px 50px rgba(15, 23, 42, 0.32);
    padding: 1rem;
    display: grid;
    gap: 0.85rem;
}

.pay-agreement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.pay-agreement-header h3 {
    margin: 0;
}

.pay-agreement-body {
    display: grid;
    gap: 0.8rem;
}

.pay-agreement-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.pay-agreement-item {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 11px;
    padding: 0.62rem 0.7rem;
    background: rgba(248, 250, 252, 0.75);
}

.pay-agreement-item span {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(71, 85, 105, 0.85);
    margin-bottom: 0.28rem;
}

.pay-agreement-item strong,
.pay-agreement-item a {
    color: #0f172a;
    font-size: 0.9rem;
    text-decoration: none;
}

.pay-agreement-item a:hover {
    text-decoration: underline;
}

.pay-agreement-item-wide {
    grid-column: 1 / -1;
}

.pay-invoice-dialog {
    width: min(1120px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 30px 50px rgba(15, 23, 42, 0.3);
    padding: 1rem 1rem 1.2rem;
}

.pay-invoice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.pay-invoice-meta {
    margin-bottom: 0.9rem;
    color: rgba(71, 85, 105, 0.9);
}

.pay-invoice-body {
    display: grid;
    gap: 0.8rem;
}

.pay-invoice-card {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    padding: 0.75rem;
    background: rgba(248, 250, 252, 0.65);
}

.pay-invoice-card h4 {
    margin-bottom: 0.6rem;
}

.pay-invoice-preview iframe,
.pay-invoice-preview img {
    width: 100%;
    min-height: 280px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    background: #fff;
}

.pay-invoice-kv {
    display: grid;
    gap: 0.5rem;
}

.pay-invoice-kv-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.7rem;
}

.pay-invoice-kv-row strong {
    color: rgba(71, 85, 105, 0.95);
}

.pay-invoice-line-items table {
    width: 100%;
    border-collapse: collapse;
}

.pay-invoice-line-items th,
.pay-invoice-line-items td {
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 0.42rem 0.5rem;
}

.pay-invoice-history {
    display: grid;
    gap: 0.45rem;
}

.pay-invoice-history-item {
    border-left: 3px solid rgba(251, 191, 36, 0.6);
    background: #ffffff;
    border-radius: 8px;
    padding: 0.48rem 0.65rem;
}

.pay-cf-final-payable-link {
    border: none;
    background: transparent;
    color: #0f766e;
    font-weight: 800;
    padding: 0;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.pay-cf-installment-meta {
    display: grid;
    gap: 0.28rem;
    margin-top: 0.3rem;
    margin-bottom: 0.2rem;
}

.pay-cf-installment-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.58rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.pay-cf-installment-badge.full {
    background: rgba(100, 116, 139, 0.15);
    color: #334155;
}

.pay-cf-installment-badge.paid {
    background: rgba(16, 185, 129, 0.2);
    color: #047857;
}

.pay-cf-installment-badge.pending {
    background: rgba(239, 68, 68, 0.18);
    color: #b91c1c;
}

.pay-cf-installment-badge.upcoming {
    background: rgba(245, 158, 11, 0.22);
    color: #b45309;
}

.pay-cf-installment-modal {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
}

.pay-cf-installment-modal.is-visible {
    display: flex;
}

.pay-cf-installment-dialog {
    width: min(760px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.3);
    padding: 1rem;
    display: grid;
    gap: 0.8rem;
}

.pay-cf-installment-details-dialog {
    width: min(920px, 100%);
}

.pay-cf-installment-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.9rem;
}

.pay-cf-installment-header p {
    margin: 0.2rem 0 0;
    color: rgba(71, 85, 105, 0.9);
}

.pay-cf-installment-total-card {
    border: 1px solid rgba(15, 118, 110, 0.25);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(240, 253, 250, 0.8), rgba(236, 253, 245, 0.9));
    padding: 0.72rem 0.8rem;
    display: grid;
    gap: 0.26rem;
}

.pay-cf-installment-total-card span {
    color: rgba(15, 23, 42, 0.72);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pay-cf-installment-total-card strong {
    font-size: 1.35rem;
    color: #0f766e;
}

.pay-cf-installment-toggle {
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    padding: 0.72rem 0.8rem;
    background: rgba(248, 250, 252, 0.7);
    display: grid;
    gap: 0.56rem;
}

.pay-cf-installment-toggle-title {
    font-weight: 700;
    color: #0f172a;
}

.pay-cf-installment-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
}

.pay-cf-installment-toggle-row label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    color: #334155;
}

.pay-cf-installment-advanced {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.pay-cf-installment-field {
    display: grid;
    gap: 0.32rem;
}

.pay-cf-installment-field label {
    font-size: 0.78rem;
    color: rgba(51, 65, 85, 0.9);
    font-weight: 600;
}

.pay-cf-installment-preview {
    border: 1px dashed rgba(15, 118, 110, 0.35);
    border-radius: 12px;
    background: rgba(240, 253, 250, 0.6);
    padding: 0.65rem 0.75rem;
    color: #0f766e;
    font-weight: 700;
}

.pay-cf-installment-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.pay-cf-installment-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem;
}

.pay-cf-installment-summary-card {
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 10px;
    padding: 0.58rem 0.62rem;
    background: rgba(248, 250, 252, 0.75);
    display: grid;
    gap: 0.2rem;
}

.pay-cf-installment-summary-card span {
    font-size: 0.72rem;
    color: rgba(71, 85, 105, 0.9);
    text-transform: uppercase;
}

.pay-cf-installment-summary-card strong {
    color: #0f172a;
}

.pay-cf-installment-next-due {
    border-radius: 10px;
    background: rgba(254, 252, 232, 0.85);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #92400e;
    padding: 0.6rem 0.72rem;
    font-weight: 600;
}

.pay-cf-installment-table-wrap {
    overflow: auto;
}

.pay-cf-installment-history {
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 10px;
    padding: 0.65rem 0.72rem;
    background: rgba(248, 250, 252, 0.65);
}

.pay-cf-installment-history h4 {
    margin-bottom: 0.45rem;
}

.pay-cf-installment-history ul {
    margin: 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.35rem;
}

.is-hidden {
    display: none !important;
}

.pay-portal-switch {
    border-radius: 999px;
    border-color: rgba(251, 191, 36, 0.55);
    color: #92400e;
}

.pay-portal-switch:hover {
    background: rgba(251, 191, 36, 0.15);
}

@media (max-width: 900px) {
    .pay-portal-header,
    .pay-portal-content {
        padding: 1rem;
    }

    .pay-portal-header {
        flex-wrap: wrap;
        gap: 0.7rem;
    }

    .pay-portal-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .pay-table {
        min-width: 760px;
    }

    .pay-table-tools .form-control,
    .pay-table-tools .form-select {
        min-width: 180px;
    }

    .pay-agreement-grid {
        grid-template-columns: 1fr;
    }

    .pay-cf-installment-advanced,
    .pay-cf-installment-summary-grid {
        grid-template-columns: 1fr;
    }
}
