.loyalty-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}
.loyalty-modal.active { display: flex; }

.loyalty-modal-inner {
    width: 900px;
    height: 620px;
    background: #0e1621;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: tgOpen 0.25s ease;
}
@keyframes tgOpen {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Sidebar */
.tg-sidebar {
    width: 280px;
    background: #17212b;
    border-right: 1px solid #0e1621;
    display: flex;
    flex-direction: column;
}
.tg-sidebar-header {
    padding: 12px;
}
.tg-search-bar {
    background: #242f3d;
    color: #6c7883;
    padding: 10px 16px;
    border-radius: 22px;
    font-size: 14px;
}
.tg-chat-list {
    flex: 1;
    overflow-y: auto;
}
.tg-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.tg-chat-item:hover { background: #202b36; }
.tg-chat-item.active { background: #2b5278; }

.tg-chat-item-avatar {
    width: 46px; height: 46px;
    background: linear-gradient(135deg, #e8879a, #c96b7e);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 18px;
    flex-shrink: 0;
}
.av-purple { background: linear-gradient(135deg, #7b68ee, #9b89f5); }
.av-green { background: linear-gradient(135deg, #43b581, #68d69e); }
.av-orange { background: linear-gradient(135deg, #ffa940, #ffcc70); }
.av-pink { background: linear-gradient(135deg, #f06292, #f48fb1); }

.tg-chat-item-info { flex: 1; overflow: hidden; }
.tg-chat-item-top { display: flex; justify-content: space-between; align-items: center; }
.tg-chat-item-name { color: #fff; font-size: 14px; font-weight: 500; }
.tg-chat-item-time { color: #6c7883; font-size: 12px; }
.tg-chat-item-last { color: #6c7883; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tg-chat-item.active .tg-chat-item-last { color: #aaa; }
.tg-chat-item-badge {
    background: #3390ec;
    color: #fff;
    font-size: 12px;
    min-width: 22px; height: 22px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 500;
}

/* Main */
.tg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0e1621;
}

/* Header */
.tg-header {
    background: #17212b;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #0e1621;
}
.tg-header-info { display: flex; align-items: center; gap: 14px; }
.tg-header-avatar {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #e8879a, #c96b7e);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 17px;
}
.tg-header-name { color: #fff; font-size: 15px; font-weight: 500; }
.tg-header-status { color: #6c7883; font-size: 13px; }
.loyalty-modal-close {
    background: none; border: none;
    color: #8e99a4; font-size: 32px;
    cursor: pointer; padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.loyalty-modal-close:hover { color: #fff; }

/* Chat */
.tg-chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tg-chat::-webkit-scrollbar { width: 6px; }
.tg-chat::-webkit-scrollbar-thumb { background: #2b3945; border-radius: 3px; }

.tg-date-divider {
    text-align: center;
    margin: 12px 0;
}
.tg-date-divider span {
    background: #182533;
    color: #6c7883;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 12px;
}

/* Messages */
.tg-msg { display: flex; margin-bottom: 4px; }
.tg-msg.bot { justify-content: flex-start; }
.tg-msg.user { justify-content: flex-end; }

.tg-bubble {
    max-width: 420px;
    padding: 8px 14px 6px;
    border-radius: 12px;
    position: relative;
}
.tg-msg.bot .tg-bubble {
    background: #182533;
    border-top-left-radius: 4px;
}
.tg-msg.user .tg-bubble {
    background: #2b5278;
    border-top-right-radius: 4px;
}
.tg-msg.win .tg-bubble {
    border-left: 3px solid #5eb171;
}

.tg-msg-name {
    color: #6ab3f3;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}
.tg-bubble p {
    color: #f5f5f5;
    font-size: 14px;
    line-height: 1.55;
    margin: 0 0 6px;
}
.tg-bubble p:last-of-type { margin-bottom: 2px; }
.tg-time {
    color: #5a6977;
    font-size: 11px;
    float: right;
    margin-top: 4px;
    margin-left: 12px;
}
.tg-msg.user .tg-time { color: #6e93b4; }

.tg-win-amount {
    color: #5eb171;
    font-size: 26px;
    font-weight: 600;
    margin: 10px 0;
}

/* Inline Buttons */
.tg-inline-row {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}
.tg-inline-btn {
    flex: 1;
    background: rgba(51,144,236,0.12);
    border: none;
    color: #6ab3f3;
    font-size: 13px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.tg-inline-btn:hover { background: rgba(51,144,236,0.22); }

/* Bottom */
.tg-bottom {
    padding: 16px 20px;
    background: #17212b;
    border-top: 1px solid #101921;
}
.tg-start-btn {
    display: block;
    background: #3390ec;
    color: #fff;
    text-decoration: none;
    text-align: center;
    padding: 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: background 0.2s;
}
.tg-start-btn:hover { background: #4ea4f6; }
