/* Branded modal system */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal-backdrop, 1040);
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.modal-backdrop.is-visible {
    background: rgba(0, 0, 0, 0.45);
}

.branded-modal {
    z-index: var(--z-modal, 1050);
    background: #fff;
    max-width: 440px;
    width: 90%;
    padding: 2.5rem 2.5rem 2rem;
    text-align: center;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal-backdrop.is-visible .branded-modal {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.modal-icon {
    font-size: 2rem;
    margin-bottom: 1.25rem;
    display: block;
}

.modal-icon--success { color: var(--color-success, #A8DDC1); }
.modal-icon--error   { color: var(--color-danger, #c62828); }
.modal-icon--warning { color: var(--color-warning-dark, #e65100); }
.modal-icon--info    { color: var(--text-secondary, #525252); }

.modal-message {
    font-size: 1.0625rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-primary, #111);
    margin: 0 0 0.5rem;
}

.modal-detail {
    font-size: 0.9375rem;
    color: var(--text-secondary, #525252);
    line-height: 1.55;
    margin: 0 0 0.25rem;
}

.modal-input-group {
    margin-top: 1rem;
    text-align: left;
}

.modal-input-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary, #525252);
    margin-bottom: 0.375rem;
}

.modal-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--color-gray-300, #d4d4d4);
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-primary, #111);
    resize: vertical;
    min-height: 4.5rem;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--color-black, #111);
}

.modal-textarea::placeholder {
    color: var(--text-light, #a3a3a3);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Form-style modal variant (dashboard invites, etc.) */
.branded-modal--form {
    max-width: 480px;
    text-align: left;
}

.modal-form-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--text-primary, #111);
}

.modal-text-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--color-gray-300, #d4d4d4);
    border-radius: 0;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-primary, #111);
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.modal-text-input:focus {
    outline: none;
    border-color: var(--color-black, #111);
}

.modal-form-error {
    margin-top: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.875rem;
    border-radius: 0;
}

.branded-modal--form .modal-actions {
    justify-content: flex-end;
}

.branded-modal--form .modal-textarea {
    border-radius: 0;
}

/* Tender vendor invite modal — scrollable on small screens */
.modal-backdrop:has(.tvi-modal) {
    align-items: center;
    padding: max(1rem, env(safe-area-inset-top)) 0 max(1rem, env(safe-area-inset-bottom));
}

.tvi-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 2rem);
    max-height: calc(100svh - 2rem);
    padding: 0;
    overflow: hidden;
    margin: 0 auto;
}

.tvi-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.5rem 1.5rem 0.5rem;
}

.tvi-modal-footer {
    flex-shrink: 0;
    margin-top: 0;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--border-color, #e9ecef);
    background: #fff;
}

.tvi-modal .modal-form-title {
    margin-bottom: 0.5rem;
}

.tvi-modal .modal-detail {
    margin-bottom: 0.75rem;
}

.tvi-modal .modal-input-group {
    margin-top: 0.75rem;
}

.tvi-email-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    min-height: 2.75rem;
    cursor: text;
}

.tvi-email-field:focus-within {
    border-color: var(--color-black, #111);
}

.tvi-email-chips {
    display: contents;
}

.tvi-email-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
    padding: 0.125rem 0.25rem 0.125rem 0.5rem;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    font-size: 0.8125rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.tvi-email-chip.is-invalid {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.tvi-email-chip-remove {
    border: 0;
    background: none;
    padding: 0 0.25rem;
    font-size: 1rem;
    line-height: 1;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
}

.tvi-email-chip-remove:hover {
    opacity: 1;
}

.tvi-email-entry {
    flex: 1 1 10rem;
    min-width: 8rem;
    border: 0;
    outline: none;
    padding: 0.25rem;
    font: inherit;
    color: inherit;
    background: transparent;
}

.tvi-modal .modal-textarea {
    min-height: 3.5rem;
}

.tvi-smart-match {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.tvi-match-group {
    border: 1px solid var(--border-color, #e9ecef);
    background: #fff;
}

.tvi-match-group.tvi-safe-bets {
    border-top: 3px solid #166534;
}

.tvi-match-group.tvi-wild-cards {
    border-top: 3px solid #111;
}

.tvi-match-heading {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.65rem 0.85rem;
    background: #fafafa;
    border-bottom: 1px solid var(--border-color, #e9ecef);
}

.tvi-match-heading strong {
    font-size: 0.8125rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tvi-match-heading span {
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
}

.tvi-match-reason {
    font-size: 0.75rem;
    color: var(--text-secondary, #555);
}

.tvi-match-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.2rem;
}

.tvi-match-tag {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.4rem;
    background: #f0f0f0;
    color: #333;
}

.tvi-match-empty {
    margin: 0 0 0.75rem;
}

/* Tender vendor invite modal */
.tvi-modal .tvi-trusted-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color, #e9ecef);
    border-radius: var(--radius-md, 6px);
    margin-bottom: var(--spacing-md, 1rem);
}

.tvi-modal .trusted-vendor-picker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-color, #e9ecef);
    cursor: pointer;
    margin: 0;
}

.tvi-modal .trusted-vendor-picker-row:last-child {
    border-bottom: none;
}

.tvi-modal .trusted-vendor-picker-row.is-disabled {
    opacity: 0.65;
    cursor: default;
}

.tvi-modal .trusted-vendor-picker-meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.tvi-modal .trusted-vendor-picker-name {
    font-weight: 500;
    font-size: var(--font-size-sm, 0.875rem);
}

.tvi-modal .trusted-vendor-picker-email {
    font-size: var(--font-size-sm, 0.8125rem);
    color: var(--text-secondary, #6c757d);
}

.tender-invite-vendors-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.tender-invite-vendors-card .form-hint {
    margin-bottom: 1rem;
}

/* Invited vendors list (owner view) */
.invited-vendors {
    margin-top: 1.25rem;
}

.invited-vendors-heading {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #717171);
    margin-bottom: 0.5rem;
}

.invited-vendors-items {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color, #e8e8e8);
}

.invited-vendors-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border-color, #e8e8e8);
    font-size: 0.875rem;
}

.invited-vendors-items li:last-child {
    border-bottom: 0;
}

.invited-vendor-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.invited-vendor-email {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted, #717171);
}

.invited-vendor-status {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: #f0f0f0;
    color: #444;
    white-space: nowrap;
}

.invited-vendor-status.is-info { background: #eef4ff; color: #1d4ed8; }
.invited-vendor-status.is-success { background: #ecfdf3; color: #047857; }
.invited-vendor-status.is-muted { background: #f5f5f5; color: #717171; }

@media (max-width: 480px) {
    .invited-vendors-items li {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
}

@media (max-width: 480px) {
    .modal-backdrop:has(.tvi-modal) {
        padding: 0.5rem 0;
    }

    .tvi-modal {
        width: calc(100% - 1rem);
        max-height: calc(100dvh - 1rem);
        max-height: calc(100svh - 1rem);
    }

    .tvi-modal-body {
        padding: 1.25rem 1rem 0.5rem;
    }

    .tvi-modal-footer {
        padding: 0.875rem 1rem 1rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .tvi-modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    .tvi-modal .tvi-trusted-list {
        max-height: 140px;
    }

    .tvi-modal .modal-form-title {
        font-size: 1.125rem;
    }
}

.invited-vendors-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9em;
}
.invited-vendors-items + .invited-vendors-heading {
    margin-top: 1rem;
}

/* Client profile card (js/components/client-profile-card.js) */
.branded-modal.client-card-modal {
    max-width: 460px;
    text-align: left;
}
.client-card-header {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1rem;
}
.client-card-avatar {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid var(--border-color);
}
.client-card-avatar--initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: var(--color-gray-100);
    color: var(--text-secondary);
}
.client-card-name {
    margin: 0;
    font-size: 1.15rem;
}
.client-card-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.client-card-about {
    margin: 0 0 0.9rem;
    white-space: pre-line;
}
.client-card-about--empty {
    color: var(--text-secondary);
    font-style: italic;
}
.client-card-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
    font-size: 0.9rem;
}
.client-card-note {
    margin: 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.tender-client-profile-btn {
    margin-left: auto;
}
