:root {
        --crm-rgb: var(--primary-rgb, 228, 31, 7);
        --crm-primary: rgb(var(--crm-rgb));
        --crm-primary-dark: color-mix(in srgb, rgb(var(--crm-rgb)) 85%, #000);
        --crm-primary-soft: rgba(var(--crm-rgb), .08);
        --crm-primary-border: rgba(var(--crm-rgb), .25);
    }

    #crmChatButton {
        position: fixed;
        left: 28px;
        bottom: 26px;
        z-index: 9998;
        width: 60px;
        height: 60px;
        border: 0;
        border-radius: 20px;
        background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-dark));
        color: #fff;
        box-shadow: 0 8px 28px rgba(var(--crm-rgb), .30);
        font-size: 25px;
        transition: .25s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #crmChatButton:hover {
        transform: translateY(-3px);
        box-shadow: 0 12px 32px rgba(var(--crm-rgb), .38);
    }

    #crmChatWindow {
        display: none;
        position: fixed;
        left: 28px;
        bottom: 100px;
        z-index: 9999;
        width: 410px;
        height: min(650px, calc(100vh - 130px));
        max-width: calc(100vw - 28px);
        background: #fff;
        border: 1px solid #e8eaf2;
        border-radius: 22px;
        overflow: hidden;
        box-shadow: 0 24px 80px rgba(25, 30, 65, .20);
        font-family: Inter, -apple-system, BlinkMacSystemFont,
                    "Segoe UI", sans-serif;
        color: #20243a;
    }

    #crmChatWindow.crm-chat-open {
        display: flex;
        flex-direction: column;
        animation: crmChatEnter .22s ease-out;
    }

    @keyframes crmChatEnter {
        from {
            opacity: 0;
            transform: translateY(12px) scale(.98);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    /* Header */
    .crm-chat-header {
        padding: 19px 20px;
        background: linear-gradient(120deg, var(--crm-primary-dark), var(--crm-primary));
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .crm-chat-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }

    .crm-chat-avatar {
        width: 43px;
        height: 43px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,.17);
        border: 1px solid rgba(255,255,255,.25);
        border-radius: 15px;
        font-size: 23px;
    }

    .crm-chat-title {
        font-size: 15px;
        font-weight: 700;
        letter-spacing: -.2px;
        margin-bottom: 5px;
        color: #fff;
    }

    .crm-chat-online {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 11px;
        color: #fff0ed;
    }

    .crm-chat-online-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #58e6a5;
        box-shadow: 0 0 0 3px rgba(88,230,165,.15);
    }

    .crm-chat-header-actions {
        display: flex;
        gap: 6px;
    }

    .crm-chat-header-btn {
        width: 34px;
        height: 34px;
        border: 0;
        border-radius: 10px;
        background: rgba(255,255,255,.13);
        color: #fff;
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .crm-chat-header-btn:hover {
        background: rgba(255,255,255,.24);
    }

    /* Intro */
    .crm-chat-intro {
        padding: 20px 18px 10px;
    }

    .crm-chat-intro-label {
        display: inline-block;
        padding: 5px 9px;
        background: var(--crm-primary-soft);
        color: var(--crm-primary);
        border-radius: 7px;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .7px;
        margin-bottom: 10px;
    }

    .crm-chat-intro h6 {
        font-size: 19px;
        font-weight: 750;
        letter-spacing: -.6px;
        margin: 0 0 7px;
        color: #20243a;
    }

    .crm-chat-intro p {
        font-size: 12px;
        line-height: 1.65;
        color: #85899e;
        margin: 0;
    }

    /* Messages */
    #crmChatMessages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 12px 18px 18px;
        scroll-behavior: smooth;
        background: #fff;
    }

    #crmChatMessages::-webkit-scrollbar {
        width: 5px;
    }

    #crmChatMessages::-webkit-scrollbar-thumb {
        background: #e1e3ed;
        border-radius: 10px;
    }

    .crm-chat-row {
        display: flex;
        gap: 9px;
        align-items: flex-end;
        margin: 13px 0;
    }

    .crm-chat-row.crm-chat-row-user {
        justify-content: flex-end;
    }

    .crm-chat-mini-avatar {
        width: 27px;
        height: 27px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--crm-primary-soft);
        color: var(--crm-primary);
        border-radius: 9px;
        font-size: 14px;
    }

    .crm-chat-message {
        max-width: 83%;
        padding: 11px 13px;
        font-size: 12px;
        line-height: 1.7;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .crm-chat-bot {
        background: #f5f6fb;
        border: 1px solid #eef0f7;
        color: #40445b;
        border-radius: 15px 15px 15px 5px;
    }

    .crm-chat-user {
        background: var(--crm-primary);
        color: #fff;
        border-radius: 15px 15px 5px 15px;
    }

    /* Quick Suggestions */
    .crm-chat-suggestions {
        padding: 8px 18px 13px;
        background: #fff;
    }

    .crm-chat-suggestions-label {
        display: block;
        color: #9699ac;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .7px;
        text-transform: uppercase;
        margin-bottom: 9px;
    }

    .crm-chat-suggestion-list {
        display: flex;
        flex-wrap: wrap;
        gap: 7px;
    }

    .crm-chat-suggestion {
        border: 1px solid var(--crm-primary-border);
        background: #fff;
        color: var(--crm-primary);
        border-radius: 9px;
        padding: 8px 10px;
        font-size: 11px;
        transition: .15s;
        cursor: pointer;
    }

    .crm-chat-suggestion:hover {
        background: var(--crm-primary-soft);
        border-color: var(--crm-primary);
    }

    /* Input Footer */
    .crm-chat-footer {
        padding: 13px 16px 12px;
        background: #fff;
        border-top: 1px solid #eff0f6;
    }

    .crm-chat-input-wrap {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 7px 6px 14px;
        background: #f7f8fc;
        border: 1px solid #e9eaf3;
        border-radius: 14px;
        transition: .2s;
    }

    .crm-chat-input-wrap:focus-within {
        background: #fff;
        border-color: var(--crm-primary);
        box-shadow: 0 0 0 3px rgba(var(--crm-rgb), .08);
    }

    #crmChatInput {
        min-width: 0;
        flex: 1;
        border: 0;
        outline: 0;
        background: transparent;
        color: #292d43;
        font-size: 12px;
        padding: 9px 0;
        box-shadow: none;
    }

    #crmChatInput:focus {
        outline: none;
        box-shadow: none;
    }

    #crmChatInput::placeholder {
        color: #a2a5b6;
    }

    #crmChatSend {
        width: 37px;
        height: 37px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: 11px;
        background: var(--crm-primary);
        color: #fff;
        font-size: 17px;
        transition: .2s;
        cursor: pointer;
    }

    #crmChatSend:hover {
        background: var(--crm-primary-dark);
    }

    #crmChatSend:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

    .crm-chat-footer-note {
        text-align: center;
        font-size: 9px;
        color: #a2a5b6;
        margin-top: 9px;
    }

    /* Typing Indicator */
    .crm-chat-typing {
        display: inline-flex;
        gap: 4px;
        align-items: center;
    }

    .crm-chat-typing span {
        width: 5px;
        height: 5px;
        background: var(--crm-primary);
        border-radius: 50%;
        animation: crmChatTyping 1s infinite ease-in-out;
    }

    .crm-chat-typing span:nth-child(2) {
        animation-delay: .15s;
    }

    .crm-chat-typing span:nth-child(3) {
        animation-delay: .3s;
    }

    @keyframes crmChatTyping {
        0%, 60%, 100% {
            transform: translateY(0);
            opacity: .45;
        }
        30% {
            transform: translateY(-4px);
            opacity: 1;
        }
    }

    /* Mobile Responsive */
    @media (max-width: 480px) {
        #crmChatWindow {
            right: 10px;
            bottom: 82px;
            width: calc(100vw - 20px);
            height: min(680px, calc(100dvh - 100px));
            max-width: none;
            border-radius: 18px;
        }

        #crmChatButton {
            right: 16px;
            bottom: 16px;
        }

        .crm-chat-intro {
            padding-top: 16px;
        }
    }