.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    background: #1f2937;
    color: #f8fafc;
    width: 260px;
    min-height: 100vh;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.app-sidebar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
}

.app-nav .nav-link {
    color: #cbd5e1;
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.app-nav .nav-link:hover {
    color: #ffffff;
    background: rgba(148, 163, 184, 0.2);
}

.app-nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.9;
    flex-shrink: 0;
    filter: invert(88%) sepia(9%) saturate(244%) hue-rotate(175deg) brightness(95%) contrast(88%);
}

.app-nav .nav-link.active {
    color: #ffffff;
    background: rgba(59, 130, 246, 0.35);
    font-weight: 600;
}

.app-nav .nav-link.active .app-nav-icon,
.app-nav .nav-link:hover .app-nav-icon {
    filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(246deg) brightness(106%) contrast(101%);
}

.app-nav .nav-submenu-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    text-align: left;
    justify-content: space-between;
    cursor: pointer;
}

.app-submenu {
    margin: 0.15rem 0 0.45rem 1.05rem;
    border-left: 1px solid rgba(203, 213, 225, 0.25);
    padding-left: 0.55rem;
}

.app-submenu .app-submenu-link {
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    border-radius: 0.45rem;
}

.app-submenu-icon {
    width: 15px;
    height: 15px;
    opacity: 0.85;
}

.submenu-chevron {
    font-size: 0.82rem;
    opacity: 0.8;
}

.app-nav-section {
    color: #9ca3af;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0.8rem 0 0.35rem;
    padding: 0 0.25rem;
}

.app-main {
    flex: 1;
}

.rubro-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.rubro-icon {
    display: inline-flex;
    width: 1.45rem;
    height: 1.45rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    color: #111827;
    background: #f8fafc;
    font-size: 0.9rem;
    line-height: 1;
}

.crm-chat-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid #d1d5db;
    background: #ffffff;
    min-height: 72vh;
}

.crm-chat-sidebar {
    background: #f7f8fa;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.crm-chat-header {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f0f2f5;
}

.crm-chat-title {
    font-size: 1rem;
    font-weight: 700;
}

.crm-chat-count {
    color: #6b7280;
    font-size: 0.8rem;
}

.crm-chat-filters {
    padding: 0.8rem 0.8rem 0.65rem;
    border-bottom: 1px solid #e5e7eb;
}

.crm-chat-quickstats {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.75rem;
    color: #4b5563;
}

.crm-chat-list {
    overflow-y: auto;
    min-height: 0;
}

.crm-chat-item {
    display: flex;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
    text-decoration: none;
    color: #111827;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

.crm-chat-item:hover {
    background: #ecfdf5;
    color: #111827;
}

.crm-chat-item.active {
    background: #dcfce7;
}

.crm-chat-avatar,
.crm-thread-avatar {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: #c7f0d8;
    color: #065f46;
    flex-shrink: 0;
}

.crm-chat-meta {
    min-width: 0;
    width: 100%;
}

.crm-chat-row {
    display: flex;
    justify-content: space-between;
    gap: 0.55rem;
    align-items: center;
}

.crm-chat-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-chat-time {
    color: #6b7280;
    font-size: 0.74rem;
    white-space: nowrap;
}

.crm-chat-preview {
    color: #4b5563;
    font-size: 0.83rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 230px;
}

.crm-chat-badge {
    display: inline-flex;
    min-width: 1.3rem;
    height: 1.3rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.72rem;
    background: #10b981;
    color: #ffffff;
    font-weight: 700;
}

.crm-chat-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.35rem;
}

.crm-chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #efeae2;
}

.crm-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #d1d5db;
    background: #f0f2f5;
}

.crm-thread-contact {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.crm-thread-actions {
    display: flex;
    gap: 0.45rem;
}

.crm-thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem 1rem;
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
}

.crm-bubble-row {
    display: flex;
    margin-bottom: 0.65rem;
}

.crm-bubble-row.entrante,
.crm-bubble-row.sistema {
    justify-content: flex-start;
}

.crm-bubble-row.saliente {
    justify-content: flex-end;
}

.crm-bubble {
    max-width: min(80%, 560px);
    padding: 0.58rem 0.68rem;
    border-radius: 0.6rem;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
    font-size: 0.92rem;
    position: relative;
    padding-bottom: 1.05rem;
}

.crm-bubble.entrante {
    background: #ffffff;
}

.crm-bubble.saliente {
    background: #dcf8c6;
}

.crm-bubble.sistema {
    background: #fef3c7;
    color: #78350f;
}

.crm-bubble-time {
    position: absolute;
    right: 0.55rem;
    bottom: 0.2rem;
    font-size: 0.68rem;
    color: #6b7280;
}

.crm-thread-compose {
    padding: 0.85rem 1rem;
    border-top: 1px solid #d1d5db;
    background: #f0f2f5;
}

.crm-empty-thread {
    display: grid;
    place-items: center;
    text-align: center;
    height: 100%;
    padding: 2rem;
}

.crm-kpi-card {
    border-left: 4px solid #10b981;
}

.crm-kpi-value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.1;
}

.crm-campaign-card {
    border-top: 4px solid #22c55e;
}

.crm-metric-box {
    border: 1px solid #d1d5db;
    border-radius: 0.55rem;
    padding: 0.6rem 0.75rem;
    background: #f8fafc;
}

.crm-metric-box small {
    color: #6b7280;
    display: block;
}

.crm-metric-box strong {
    font-size: 1.05rem;
}

@media (min-width: 992px) {
    .app-shell {
        display: flex;
    }
}

@media (max-width: 991.98px) {
    .crm-chat-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .crm-chat-sidebar {
        max-height: 58vh;
    }

    .crm-chat-preview {
        max-width: 180px;
    }

    .crm-thread-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
