.chat-window.presencia-toggle {
    position: fixed;
    right: 18px;
    bottom: 82px;
    z-index: 1045;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 0;
    background: var(--tenant-nav);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
    cursor: pointer;
    transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.chat-window.presencia-toggle:hover,
.chat-window.presencia-toggle:focus {
    background: var(--tenant-menu-accent);
    color: #fff;
    outline: none;
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(0, 0, 0, .28);
}

.chat-window.presencia-toggle i {
    font-size: 22px;
    line-height: 1;
}

.presencia-badge {
    position: absolute;
    top: -4px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #22c55e;
    color: #fff;
    font-size: 11px;
    line-height: 20px;
    font-weight: 700;
    border: 2px solid #fff;
}

.presencia-panel {
    position: fixed;
    top: 75px;
    right: 0;
    bottom: 0;
    z-index: 1040;
    width: 360px;
    max-width: 100vw;
    background: #ffffff;
    border-left: 1px solid #d8dee8;
    box-shadow: -16px 0 32px rgba(15, 23, 42, .16);
    transform: translateX(104%);
    transition: transform .22s ease;
    display: flex;
    flex-direction: column;
}

body.presencia-open .presencia-panel {
    transform: translateX(0);
}

@media (min-width: 992px) {
    body.presencia-open #top {
        padding-right: 360px !important;
        transition: padding-right .22s ease;
    }
}

.presencia-header {
    padding: 16px;
    border-bottom: 1px solid #e8edf4;
    background: #f8fafc;
}

.presencia-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.presencia-title {
    margin: 0;
    color: #1f2937;
    font-size: 18px;
    font-weight: 700;
}

.presencia-close {
    width: 34px;
    height: 34px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.presencia-close:hover,
.presencia-close:focus {
    border-color: var(--tenant-menu-accent);
    color: var(--tenant-nav);
    outline: none;
}

.presencia-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.presencia-stat {
    border: 1px solid #e8edf4;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
    min-width: 0;
}

.presencia-stat strong {
    display: block;
    color: #111827;
    font-size: 18px;
    line-height: 1.1;
}

.presencia-stat span {
    display: block;
    color: #64748b;
    font-size: 11px;
    line-height: 1.2;
    margin-top: 3px;
}

.presencia-tools {
    padding: 12px 16px;
    border-bottom: 1px solid #e8edf4;
}

.presencia-search-wrap {
    position: relative;
}

.presencia-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 13px;
}

.presencia-search {
    width: 100%;
    height: 38px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    padding: 8px 10px 8px 34px;
    color: #1f2937;
}

.presencia-search:focus {
    border-color: var(--tenant-menu-accent);
    box-shadow: 0 0 0 3px var(--tenant-menu-softer);
    outline: none;
}

.presencia-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
}

.presencia-filter {
    height: 34px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    cursor: pointer;
}

.presencia-filter.active {
    border-color: var(--tenant-nav);
    background: var(--tenant-primary-soft);
    color: var(--tenant-nav);
    font-weight: 700;
}

.presencia-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f8fafc;
}

.presencia-user {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid #e8edf4;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 8px;
}

.presencia-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e8edf4;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
}

.presencia-user.online .presencia-avatar {
    background: #dcfce7;
    color: #166534;
}

.presencia-user-main {
    min-width: 0;
}

.presencia-name {
    color: #111827;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.presencia-meta,
.presencia-last {
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.presencia-last {
    margin-top: 3px;
}

.presencia-status {
    border-radius: 999px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 700;
    background: #e5e7eb;
    color: #4b5563;
}

.presencia-user.online .presencia-status {
    background: #dcfce7;
    color: #166534;
}

.presencia-empty,
.presencia-loading,
.presencia-error {
    margin: 18px 8px;
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    background: #fff;
    border: 1px solid #e8edf4;
    color: #64748b;
    font-size: 13px;
}

.presencia-error {
    color: #991b1b;
    border-color: #fecaca;
    background: #fff1f2;
}

.presencia-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(15, 23, 42, .38);
}

@media (max-width: 991px) {
    .presencia-panel {
        top: 0;
        width: min(360px, 92vw);
    }

    body.presencia-open .presencia-backdrop {
        display: block;
    }

    .chat-window.presencia-toggle {
        right: 14px;
        bottom: 76px;
    }
}
