:root {
    /* FESA Brand Colors */
    --bg: #f8f9fc;
    --bg-accent: rgba(255, 114, 0, 0.07);
    --card: rgba(255, 255, 255, 0.96);
    --card-border: rgba(13, 38, 68, 0.10);
    --text: #0d2644;
    --muted: rgba(13, 38, 68, 0.55);
    --primary: #ff7200;
    --primary-dark: #e06400;
    --secondary: #ffaa66;
    --navy: #0d2644;
    --navy-light: rgba(13, 38, 68, 0.08);
    --cta: #ff7200;
    --accent-soft: rgba(255, 114, 0, 0.10);
    --success: #10b981;
    --odoo-brand: #714b67;
    --n8n-brand: #ff6c37;
    --django-brand: #092e20;
    --font-heading: 'Inter', 'Fira Sans', system-ui;
    --font-mono: 'Fira Code', 'Space Grotesk', monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-heading);
    background:
        radial-gradient(circle at top right, rgba(255, 114, 0, 0.06), transparent 45%),
        radial-gradient(circle at bottom left, rgba(13, 38, 68, 0.05), transparent 50%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── TOPBAR ─── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
    margin: 1rem;
    border-radius: 1rem;
    background: var(--navy);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 24px rgba(13, 38, 68, 0.18);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.brand__logo-img {
    height: 38px;
    width: auto;
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

.brand__tag {
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    display: none;
}

.topbar__nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.topbar__nav a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.5rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.topbar__nav a:hover,
.topbar__nav a:focus-visible {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.topbar__nav a.nav-active {
    color: var(--primary);
    background: rgba(255, 114, 0, 0.12);
}

.topbar__user {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.topbar__user .ghost {
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
}

.topbar__user .ghost:hover,
.topbar__user .ghost:focus-visible {
    color: white;
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
}

.pill {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 114, 0, 0.15);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid rgba(255, 114, 0, 0.25);
}

.main {
    flex: 1;
    padding: 2rem clamp(1.5rem, 6vw, 5rem) 4rem;
}

/* ─── HERO ─── */
.hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2.5rem;
    align-items: center;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.4rem);
    margin-bottom: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--navy), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.35em;
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    margin: 0 0 0.35rem 0;
}

.lead {
    color: var(--muted);
    max-width: 48ch;
    font-size: 1.05rem;
    line-height: 1.65;
}

/* ─── QUICK ACTIONS ─── */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quick-actions a {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1.1rem;
    border-radius: 0.85rem;
    border: 1px solid var(--card-border);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    background: var(--card);
}

.quick-actions a:hover,
.quick-actions a:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(255, 114, 0, 0.10);
    transform: translateX(4px);
}

.quick-actions span {
    font-weight: 600;
    color: var(--text);
}

.quick-actions small {
    color: var(--muted);
    font-size: 0.83rem;
    margin-top: 0.15rem;
}

/* ─── PANEL ─── */
.panel {
    background: var(--card);
    border-radius: 1.25rem;
    padding: 2rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 30px rgba(13, 38, 68, 0.06);
}

/* ─── STATS GRID ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 2.5rem 0 1rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
    background: var(--card);
    border-radius: 1.25rem;
    padding: 1.75rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 16px rgba(13, 38, 68, 0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(255, 114, 0, 0.10);
    border-color: var(--primary);
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 114, 0, 0.04), transparent 60%);
    pointer-events: none;
}

.stat-card h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    position: relative;
    margin: 0;
}

.stat-card__icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(255, 114, 0, 0.09);
    color: var(--primary);
    margin-bottom: 1.1rem;
    transition: background 0.3s, color 0.3s;
}

.stat-card:hover .stat-card__icon-wrapper {
    background: var(--primary);
    color: white;
}

.stat-number {
    font-size: 2.6rem;
    font-family: var(--font-mono);
    font-weight: 700;
    margin: 0.4rem 0 0;
    position: relative;
    color: var(--navy);
}

/* pulse animation */
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
    vertical-align: middle;
}

/* ─── PANEL HEADER ─── */
.panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

/* ─── TABLE ─── */
.table {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.table__head,
.table__row {
    display: grid;
    grid-template-columns: 1.2fr 2fr 0.6fr 0.8fr;
    gap: 1rem;
}

.table__head {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 0 1.25rem;
}

.table__row {
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--card-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    align-items: center;
}

.table__row:hover {
    transform: translateX(5px);
    border-color: var(--primary);
    box-shadow: 0 6px 20px rgba(255, 114, 0, 0.07);
    background: white;
}

.muted {
    color: var(--muted);
    margin: 0.1rem 0;
}

/* ─── AVATAR / BADGE ─── */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 3px 8px rgba(255, 114, 0, 0.2);
    flex-shrink: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge--info {
    background: rgba(255, 114, 0, 0.1);
    color: var(--primary);
}

.badge--secondary {
    background: rgba(13, 38, 68, 0.08);
    color: var(--navy);
}

/* ─── BUTTONS ─── */
.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.8rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 0.75rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(255, 114, 0, 0.25);
}

.primary:hover,
.primary:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 114, 0, 0.30);
}

.ghost {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text);
    border-radius: 0.65rem;
    padding: 0.65rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.ghost:hover,
.ghost:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(255, 114, 0, 0.04);
}

.danger {
    background: transparent;
    border: 1px solid #e53e3e;
    color: #e53e3e;
    border-radius: 0.65rem;
    padding: 0.65rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.danger:hover {
    background: #e53e3e;
    color: white;
}

.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── FLASH MESSAGES ─── */
.flash {
    margin-bottom: 1.5rem;
}

.flash__item {
    background: rgba(255, 114, 0, 0.08);
    border: 1px solid rgba(255, 114, 0, 0.2);
    padding: 0.85rem 1.1rem;
    border-radius: 0.75rem;
    color: var(--text);
    font-weight: 500;
}

.flash__item.error {
    background: rgba(229, 62, 62, 0.08);
    border-color: rgba(229, 62, 62, 0.2);
}

.flash__item.success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
}

/* ─── LIST ─── */
.list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
}

.list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(13, 38, 68, 0.06);
}

.list li:last-child {
    border-bottom: none;
}

/* ─── SEARCH ─── */
.search {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

input, textarea, select {
    background: white;
    border: 1px solid var(--card-border);
    border-radius: 0.65rem;
    padding: 0.8rem 1rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 114, 0, 0.10);
}

/* ─── ODOO GRID (connection cards) ─── */
.odoo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
}

/* ─── CONNECTION CARDS ─── */
.connection-card {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.connection-card:hover {
    transform: translateY(-4px);
}

.connection-card--odoo { border-top: 4px solid var(--odoo-brand); }
.connection-card--odoo:hover { box-shadow: 0 16px 36px rgba(113, 75, 103, 0.10); }

.connection-card--django { border-top: 4px solid var(--django-brand); }
.connection-card--django:hover { box-shadow: 0 16px 36px rgba(9, 46, 32, 0.10); }

.connection-card--api { border-top: 4px solid var(--n8n-brand); }
.connection-card--api:hover { box-shadow: 0 16px 36px rgba(255, 108, 55, 0.10); }

.connection-card__header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-right: 0.75rem;
}

.connection-card--odoo .connection-card__header-icon { background: rgba(113, 75, 103, 0.10); color: var(--odoo-brand); }
.connection-card--django .connection-card__header-icon { background: rgba(9, 46, 32, 0.10); color: var(--django-brand); }
.connection-card--api .connection-card__header-icon { background: rgba(255, 108, 55, 0.10); color: var(--n8n-brand); }

/* ─── CODE BOX ─── */
.code-box {
    position: relative;
    background: #0f172a;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin: 0.75rem 0;
    overflow-x: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.code-box code {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #cbd5e1;
    padding: 0.3rem 0.6rem;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    margin-left: 0.75rem;
    flex-shrink: 0;
}

.copy-btn:hover { background: rgba(255, 255, 255, 0.2); color: white; }
.copy-btn:active { transform: scale(0.95); }

/* ─── FORMS ─── */
.form-card,
.auth-card {
    background: var(--card);
    padding: 2.5rem;
    border-radius: 1.25rem;
    border: 1px solid var(--card-border);
    max-width: 680px;
    margin: 3rem auto;
    box-shadow: 0 8px 30px rgba(13, 38, 68, 0.07);
}

.form-wrapper {
    max-width: 960px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-field label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--muted);
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
}

.form-field small {
    color: var(--muted);
    font-size: 0.8rem;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 0.5rem;
}

.meta {
    margin-top: 0.25rem;
    margin-bottom: 1.25rem;
    color: var(--muted);
    font-size: 0.95rem;
}

/* ─── PAGINATION ─── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--muted);
}

/* ─── LEADS FILTER ─── */
.leads-filter {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.leads-filter__selects {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.db-card { max-width: 520px; }

/* ─── CHAT LAYOUT ─── */
.chat-layout {
    display: flex;
    gap: 1.5rem;
    min-height: 75vh;
    margin-top: 1.5rem;
}

.chat-sidebar {
    width: 32%;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text);
    border-radius: 1.25rem;
    padding: 1.5rem 1.25rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 6px 24px rgba(13, 38, 68, 0.05);
}

.chat-sidebar__header h1 {
    color: var(--text);
    margin: 0.25rem 0 1rem;
    font-size: 1.55rem;
    font-weight: 700;
}

.chat-search {
    position: relative;
    width: 100%;
}

.chat-search input {
    width: 100%;
    background: white;
    border: 1px solid var(--card-border);
    color: var(--text);
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 0.9rem;
    border-radius: 0.65rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 114, 0, 0.10);
}

.chat-search::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(13,38,68,0.4)' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat center/contain;
    pointer-events: none;
    z-index: 2;
}

.chat-thread-list {
    margin-top: 1.25rem;
    max-height: calc(75vh - 160px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0.25rem;
}

.chat-thread-list::-webkit-scrollbar,
.chat-panel__body::-webkit-scrollbar {
    width: 5px;
}

.chat-thread-list::-webkit-scrollbar-track,
.chat-panel__body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-thread-list::-webkit-scrollbar-thumb,
.chat-panel__body::-webkit-scrollbar-thumb {
    background: rgba(255, 114, 0, 0.15);
    border-radius: 999px;
}

.chat-thread-list::-webkit-scrollbar-thumb:hover,
.chat-panel__body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 114, 0, 0.30);
}

.chat-thread-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
    border-radius: 0.85rem;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(13, 38, 68, 0.05);
    transition: background-color 0.25s, border-color 0.25s, transform 0.2s, box-shadow 0.25s;
}

.chat-thread-item:hover {
    background: white;
    border-color: rgba(255, 114, 0, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(255, 114, 0, 0.07);
}

.chat-thread-item.is-active {
    background: linear-gradient(135deg, rgba(255, 114, 0, 0.07), rgba(13, 38, 68, 0.03));
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(255, 114, 0, 0.08);
}

.chat-thread-item__avatar {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(255, 114, 0, 0.20);
}

.chat-thread-item.is-active .chat-thread-item__avatar::after,
.chat-thread-item:hover .chat-thread-item__avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background-color: var(--success);
    border: 2px solid white;
    border-radius: 50%;
}

.chat-thread-item__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.chat-thread-item__meta strong {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-thread-item__count {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--primary);
    background: rgba(255, 114, 0, 0.09);
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.chat-thread-item__body p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.83rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.60);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 1.25rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 6px 24px rgba(13, 38, 68, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel__header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
}

.chat-panel__header h2 {
    margin: 0 0 0.1rem 0;
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
}

.chat-panel__body {
    flex: 1;
    padding: 2rem;
    background-color: rgba(248, 249, 252, 0.5);
    background-image:
        radial-gradient(rgba(255, 114, 0, 0.04) 1px, transparent 1px),
        radial-gradient(rgba(255, 114, 0, 0.04) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    overflow-y: auto;
}

.chat-bubbles {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.chat-bubble-container {
    display: flex;
    width: 100%;
}

.chat-bubble-container.is-agent { justify-content: flex-end; }
.chat-bubble-container.is-prospect { justify-content: flex-start; }

.chat-bubbles .chat-bubble {
    max-width: min(540px, 80%);
    padding: 0.85rem 1.1rem 0.6rem 1.1rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 2px 8px rgba(13, 38, 68, 0.04);
    position: relative;
}

.chat-bubble-container.is-agent .chat-bubble {
    background: rgba(255, 114, 0, 0.08);
    color: var(--text);
    border-radius: 1.1rem 0 1.1rem 1.1rem;
    border-color: rgba(255, 114, 0, 0.18);
}

.chat-bubble-container.is-prospect .chat-bubble {
    background: white;
    color: var(--text);
    border-radius: 0 1.1rem 1.1rem 1.1rem;
    border-color: var(--card-border);
}

.chat-bubble__body {
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 0.3rem;
    word-break: break-word;
}

.chat-bubble__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.72rem;
    color: var(--muted);
    border-top: 1px solid rgba(13, 38, 68, 0.05);
    padding-top: 0.2rem;
}

.chat-bubble__sender { font-weight: 600; }
.chat-bubble__time { font-family: var(--font-mono); opacity: 0.75; }

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--muted);
}

.chat-empty svg {
    color: var(--primary);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.chat-filters {
    display: flex;
    gap: 0.4rem;
    margin: 0.85rem 0 0.5rem;
    flex-wrap: wrap;
}

.chat-filter-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--card-border);
    color: var(--muted);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.chat-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.chat-filter-btn.is-active { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 3px 10px rgba(255, 114, 0, 0.20); }

/* ─── LEADS ─── */
.lead-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
}

.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}

.timeline li {
    border-left: 2px solid rgba(255, 114, 0, 0.25);
    padding-left: 1rem;
    margin-bottom: 1rem;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .topbar__nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .actions { flex-direction: column; }

    .chat-layout { flex-direction: column; }
    .chat-sidebar, .chat-panel { width: 100%; }
    .chat-thread-list { max-height: 300px; }
}
