/* My Messages — violet brand + green unread accents */

.msg-page {
    --msg-green: #16a34a;
    --msg-green-soft: rgba(22, 163, 74, 0.12);
    min-height: 70vh;
    padding-bottom: 2.5rem;
}

.msg-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.msg-kicker {
    margin: 0 0 0.35rem;
    color: var(--brand);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

.msg-page-head h1 {
    margin: 0;
    color: var(--brand-text);
    font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.msg-subtitle {
    margin: 0.35rem 0 0;
    color: var(--brand-muted);
    max-width: 36rem;
}

.msg-unread-chip {
    flex-shrink: 0;
    margin-top: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--msg-green-soft);
    color: var(--msg-green);
    font-weight: 700;
    font-size: 0.85rem;
}

.msg-shell {
    display: grid;
    grid-template-columns: minmax(240px, 320px) 1fr;
    min-height: min(70vh, 720px);
    border: 1px solid var(--brand-border);
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 60% at 0% 0%, rgba(74, 76, 184, 0.08), transparent 55%),
        radial-gradient(ellipse 70% 50% at 100% 100%, rgba(22, 163, 74, 0.06), transparent 50%),
        #fff;
    box-shadow: 0 12px 40px rgba(74, 76, 184, 0.08);
}

.msg-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--brand-border);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(8px);
}

.msg-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--brand-border);
}

.msg-sidebar-head h2 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--brand-text);
}

.msg-refresh {
    width: 34px;
    height: 34px;
    border: 1px solid var(--brand-border);
    border-radius: 10px;
    background: #fff;
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.msg-refresh:hover {
    background: var(--brand-soft);
    transform: rotate(-20deg);
}

.msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.msg-list-item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 0.65rem;
    align-items: center;
    width: 100%;
    text-align: left;
    border: 0;
    border-radius: 14px;
    padding: 0.7rem 0.65rem;
    background: transparent;
    color: inherit;
    transition: background 0.2s ease, transform 0.15s ease;
}

.msg-list-item:hover {
    background: var(--brand-soft);
}

.msg-list-item.is-active {
    background: linear-gradient(135deg, rgba(74, 76, 184, 0.16), rgba(99, 102, 212, 0.1));
    box-shadow: inset 0 0 0 1px rgba(74, 76, 184, 0.22);
}

.msg-list-item.is-unread .msg-list-name {
    color: var(--brand);
    font-weight: 700;
}

.msg-list-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(74, 76, 184, 0.25);
}

.msg-list-copy {
    min-width: 0;
}

.msg-list-name {
    display: block;
    font-weight: 600;
    color: var(--brand-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-list-preview {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.82rem;
    color: var(--brand-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-list-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}

.msg-list-time {
    font-size: 0.72rem;
    color: var(--brand-muted);
    white-space: nowrap;
}

.msg-badge {
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--msg-green);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.msg-list-empty,
.msg-thread-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    padding: 2rem 1.25rem;
    color: var(--brand-muted);
}

.msg-list-empty i,
.msg-thread-empty i {
    font-size: 2rem;
    color: var(--brand);
    opacity: 0.75;
}

.msg-thread {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: linear-gradient(180deg, rgba(248, 249, 255, 0.9), #fff 40%);
}

.msg-thread-empty {
    flex: 1;
}

.msg-thread-empty h3 {
    margin: 0;
    color: var(--brand-text);
    font-size: 1.15rem;
}

.msg-thread-active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.msg-thread-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--brand-border);
    background: rgba(255, 255, 255, 0.9);
}

.msg-back {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--brand-border);
    border-radius: 10px;
    background: #fff;
    color: var(--brand);
}

.msg-peer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--brand-soft);
}

.msg-thread-head strong {
    display: block;
    color: var(--brand-text);
}

.msg-thread-head span {
    display: block;
    font-size: 0.8rem;
    color: var(--brand-muted);
}

.msg-bubbles {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    scroll-behavior: smooth;
}

.msg-bubble {
    max-width: min(78%, 420px);
    padding: 0.7rem 0.9rem;
    border-radius: 16px;
    animation: msgIn 0.28s ease both;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-bubble.is-mine {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--brand) 0%, #6366d4 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.msg-bubble.is-theirs {
    align-self: flex-start;
    background: #fff;
    color: var(--brand-text);
    border: 1px solid var(--brand-border);
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 14px rgba(31, 41, 55, 0.04);
}

.msg-bubble p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    font-size: 0.95rem;
}

.msg-bubble time {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.7rem;
    opacity: 0.75;
}

.msg-composer {
    display: flex;
    gap: 0.65rem;
    align-items: flex-end;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--brand-border);
    background: rgba(255, 255, 255, 0.95);
}

.msg-composer textarea {
    flex: 1;
    resize: none;
    min-height: 46px;
    max-height: 140px;
    border: 1px solid var(--brand-border);
    border-radius: 14px;
    padding: 0.7rem 0.9rem;
    color: var(--brand-text);
    background: #fff;
    line-height: 1.4;
}

.msg-composer textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.msg-composer .brand-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

@media (max-width: 860px) {
    .msg-shell {
        grid-template-columns: 1fr;
        min-height: 68vh;
    }

    .msg-shell.is-chat-open .msg-sidebar {
        display: none;
    }

    .msg-shell:not(.is-chat-open) .msg-thread {
        display: none;
    }

    .msg-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .msg-page-head {
        flex-direction: column;
    }
}

/* Top Accounts contact UI */
.topfx-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-end;
}

.topfx-contact-btn {
    white-space: nowrap;
}

.topfx-contact-bar {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--brand-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.topfx-contact-hint {
    color: var(--brand-muted);
    font-size: 0.9rem;
}

.brand-modal.topfx-contact-modal .modal-body.topfx-contact-body {
    text-align: left;
    padding-top: 1.35rem;
}

.brand-modal.topfx-contact-modal .topfx-contact-label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--brand-text);
}

.brand-modal.topfx-contact-modal .topfx-contact-textarea {
    display: block;
    width: 100%;
    min-height: 140px;
    resize: vertical;
    border: 1px solid var(--brand-border);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    color: var(--brand-text);
    background:
        linear-gradient(180deg, #fafbff 0%, #fff 40%);
    font-size: 0.95rem;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.brand-modal.topfx-contact-modal .topfx-contact-textarea::placeholder {
    color: #9ca3af;
}

.brand-modal.topfx-contact-modal .topfx-contact-textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-soft);
    background: #fff;
}

.brand-modal.topfx-contact-modal .topfx-contact-status {
    margin: 0.85rem 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
}

.brand-modal.topfx-contact-modal .topfx-contact-status.is-error {
    color: #dc2626;
}

.brand-modal.topfx-contact-modal .topfx-contact-status.is-success {
    color: #16a34a;
}

.brand-modal.topfx-contact-modal .topfx-contact-status.is-info {
    color: var(--brand);
}

.brand-modal.topfx-contact-modal .modal-subtitle {
    max-width: 22rem;
    margin: 0.4rem auto 0;
    font-size: 0.95rem;
    font-weight: 400;
    opacity: 0.92;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.45;
}

@media (max-width: 860px) {
    .topfx-row-actions {
        justify-content: stretch;
    }

    .topfx-row-actions .brand-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}
