:root {
    --crm-sidebar-width: 240px;
    --crm-sidebar-bg: #1e2532;
    --crm-topbar-height: 56px;
}

body {
    background: #f5f6fa;
}

.crm-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.crm-sidebar {
    width: var(--crm-sidebar-width);
    background: var(--crm-sidebar-bg);
    color: #cfd6e4;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.crm-brand {
    height: var(--crm-topbar-height);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.crm-nav {
    padding: 0.75rem 0.5rem;
}

.crm-nav .nav-link {
    color: #aab4c8;
    border-radius: 0.4rem;
    padding: 0.55rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.925rem;
}

.crm-nav .nav-link i {
    width: 1.1rem;
    text-align: center;
}

.crm-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.crm-nav .nav-link.active {
    color: #fff;
    background: #0d6efd;
}

.crm-nav-heading {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6d7789;
    padding: 1rem 0.85rem 0.25rem;
}

/* Main area */
.crm-main {
    flex-grow: 1;
    min-width: 0;
}

.crm-topbar {
    height: var(--crm-topbar-height);
    background: #fff;
    border-bottom: 1px solid #e6e9ef;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Cards */
.stat-card {
    border: 0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.08);
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
}

/* Channel badges */
.channel-badge {
    font-size: 0.7rem;
    padding: 0.25em 0.6em;
    border-radius: 1rem;
    color: #fff;
    white-space: nowrap;
}

.channel-whatsapp { background: #25d366; }
.channel-messenger { background: #0084ff; }
.channel-instagram { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); }
.channel-lead_form { background: #6f42c1; }
.channel-manual { background: #6c757d; }

/* Inbox */
.inbox-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - var(--crm-topbar-height) - 3rem);
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.08);
    overflow: hidden;
}

.inbox-list {
    width: 340px;
    flex-shrink: 0;
    border-right: 1px solid #e6e9ef;
    display: flex;
    flex-direction: column;
}

.inbox-list-scroll {
    overflow-y: auto;
    flex-grow: 1;
}

.conversation-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f2f6;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}

.conversation-item:hover,
.conversation-item.active {
    background: #f0f6ff;
}

.conversation-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #dfe5ee;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7c8698;
    flex-shrink: 0;
    overflow: hidden;
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-pane {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e6e9ef;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f7f8fb;
}

.chat-bubble {
    max-width: 70%;
    padding: 0.55rem 0.85rem;
    border-radius: 0.9rem;
    margin-bottom: 0.5rem;
    font-size: 0.925rem;
    word-wrap: break-word;
}

.chat-bubble.in {
    background: #fff;
    border: 1px solid #e6e9ef;
    border-bottom-left-radius: 0.25rem;
    margin-right: auto;
}

.chat-bubble.out {
    background: #d7ecff;
    border-bottom-right-radius: 0.25rem;
    margin-left: auto;
}

.chat-bubble img {
    max-width: 100%;
    border-radius: 0.5rem;
}

.chat-bubble .meta {
    font-size: 0.7rem;
    color: #8a94a6;
    margin-top: 0.2rem;
    text-align: right;
}

.chat-composer {
    border-top: 1px solid #e6e9ef;
    padding: 0.75rem 1rem;
    background: #fff;
}

/* Timeline (lead show) */
.timeline-item {
    border-left: 2px solid #e6e9ef;
    padding: 0 0 1.25rem 1.25rem;
    position: relative;
}

.timeline-item::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0d6efd;
    position: absolute;
    left: -7px;
    top: 3px;
}

.timeline-item.kind-note::before { background: #ffc107; }
.timeline-item.kind-stage::before { background: #6f42c1; }
.timeline-item.kind-activity::before { background: #20c997; }

/* Responsive sidebar */
@media (max-width: 991.98px) {
    .crm-sidebar {
        position: fixed;
        z-index: 1040;
        left: calc(-1 * var(--crm-sidebar-width));
        transition: left 0.2s ease;
    }

    .crm-sidebar.show {
        left: 0;
    }
}
