.docs-helper {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 50;
    max-width: min(92vw, 420px);
}
.docs-helper-toggle {
    border: 0;
    border-radius: 999px;
    padding: .65rem 1rem;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
}
.docs-helper-panel {
    margin-top: .5rem;
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
}
.docs-helper-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}
.docs-helper-answer {
    max-height: 18rem;
    overflow: auto;
    padding: .75rem;
    border-radius: var(--radius);
    background: var(--gray-50);
}

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-bg: #eef2ff;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
    --drawer-w: 260px;
    --drawer-rail-w: 64px;
    --topbar-h: 56px;
    --bottom-nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--gray-800); background: var(--gray-50); line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Auth page ===== */
.page-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }
.auth-wrap { width: 100%; max-width: 400px; padding: 2rem; }
.auth-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.auth-card .lede { color: var(--gray-500); margin-bottom: 1.5rem; font-size: .9rem; }

/* ===== Flash messages ===== */
.flash-container { padding: .5rem 1rem; }
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; font-size: .875rem; transition: opacity .3s; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== Submit overlay (prevent double-post) ===== */
.crm-submit-overlay {
    position: fixed; inset: 0; z-index: 10050;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.crm-submit-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }
html.crm-submit-locked, html.crm-submit-locked body { overflow: hidden !important; touch-action: none; }
.crm-submit-overlay-card {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 1.5rem 2rem; text-align: center; min-width: 200px; max-width: 90vw;
}
.crm-submit-spinner {
    width: 36px; height: 36px; margin: 0 auto .75rem;
    border: 3px solid var(--gray-200); border-top-color: var(--primary);
    border-radius: 50%; animation: crmSpin .7s linear infinite;
}
@keyframes crmSpin { to { transform: rotate(360deg); } }
.crm-submit-message { font-size: .9rem; font-weight: 500; color: var(--gray-700); margin: 0; }
.btn[aria-busy="true"] { opacity: .7; cursor: wait; }
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-warn, .flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ===== Shell layout ===== */
.shell { display: flex; min-height: 100vh; }
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-content { min-width: 0; }

/* ===== Drawer ===== */
.drawer {
    width: var(--drawer-w); background: var(--gray-900); color: #fff;
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 200; transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1), width .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5); z-index: 199;
    opacity: 0; pointer-events: none; transition: opacity .25s;
}
.drawer.open ~ .drawer-overlay { opacity: 1; pointer-events: auto; }
.drawer-header {
    padding: .875rem 1rem; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--gray-700); flex-shrink: 0; gap: .5rem;
}
.drawer-brand {
    color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; min-width: 0;
    display: flex; align-items: center; gap: .5rem;
}
.drawer-brand:hover { text-decoration: none; color: #fff; }
.drawer-brand-mark {
    display: none;
    width: 2rem; height: 2rem; border-radius: 8px;
    line-height: 0;
    align-items: center; justify-content: center; flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.08);
}
.drawer-brand-mark .app-logo-mark {
    display: block;
    width: 2rem;
    height: 2rem;
}
.drawer-brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-header-actions { display: flex; align-items: center; gap: .15rem; flex-shrink: 0; }
.drawer-close { background: none; border: none; color: var(--gray-400); font-size: 1.4rem; cursor: pointer; padding: .25rem; line-height: 1; }
.drawer-close:hover { color: #fff; }
.drawer-collapse-btn {
    display: none;
    background: none; border: none; color: var(--gray-400); cursor: pointer;
    padding: .35rem; border-radius: var(--radius); line-height: 0;
    align-items: center; justify-content: center;
}
.drawer-collapse-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.drawer-collapse-btn .nav-svg { width: 18px; height: 18px; display: block; }
.drawer-collapse-btn .drawer-collapse-icon-expand { display: none; }
.drawer-nav { flex: 1; overflow-y: auto; padding: .375rem 0; }
.drawer-footer { border-top: 1px solid var(--gray-700); padding: .375rem 0; flex-shrink: 0; }
.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem 1rem; color: var(--gray-300); font-size: .85rem;
    transition: background .15s, color .15s; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon {
    font-size: .9rem; width: 1.25rem; min-width: 1.25rem; height: 1.25rem;
    text-align: center; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: inherit; opacity: .95;
}
.nav-icon-svg { display: inline-flex; align-items: center; justify-content: center; }
.nav-icon-svg .nav-svg,
.nav-icon-svg svg {
    display: block;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    /* Slightly thicker than default for contrast on dark drawer */
    stroke-width: 2.15;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; color: inherit; }
.nav-divider { border-top: 1px solid var(--gray-700); margin: .5rem 0; }
.nav-label {
    padding: .5rem 1rem .25rem; color: var(--gray-500); font-size: .65rem;
    text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
}
.nav-label-sm { padding-top: .25rem; font-size: .6rem; }
.drawer-company-search-wrap { padding: .35rem .75rem .5rem; }
.drawer-company-search {
    width: 100%; box-sizing: border-box;
    padding: .4rem .55rem; border-radius: var(--radius-sm);
    border: 1px solid var(--gray-700); background: var(--gray-800);
    color: #fff; font-size: .8rem;
}
.drawer-company-search::placeholder { color: var(--gray-500); }
.drawer-company-search:focus { outline: none; border-color: var(--primary); }
.drawer-company-row {
    display: flex; align-items: stretch; position: relative;
}
.drawer-company-row .nav-company { flex: 1; min-width: 0; padding-right: 2rem; }
.drawer-company-pin {
    position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--gray-500); cursor: pointer;
    font-size: .85rem; line-height: 1; padding: .25rem .35rem;
}
.drawer-company-pin:hover, .drawer-company-pin.is-pinned { color: #fbbf24; }
.drawer-company-default {
    position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--gray-500); cursor: pointer;
    font-size: 1rem; line-height: 1; padding: .25rem .35rem;
}
.drawer-company-default:hover, .drawer-company-default.is-default { color: var(--primary); }
.drawer-company-home-badge {
    flex-shrink: 0;
    margin-left: .35rem;
    padding: .05rem .35rem;
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--primary);
    background: rgba(59, 130, 246, .15);
}
.drawer-company-search-results .drawer-company-row .nav-item { font-size: .82rem; }
.drawer-company-search-empty {
    padding: .5rem 1rem; color: var(--gray-500); font-size: .75rem;
}
.drawer-company-group { display: flex; flex-direction: column; }
.drawer-company-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-company-chevron { display: none; }
.drawer-company-submenu { display: none; }
.nav-subitem {
    padding-left: 2.35rem !important;
    font-size: .8rem !important;
    color: var(--gray-400) !important;
}
.nav-subitem:hover { color: #fff !important; }
@media (max-width: 899px) {
    .drawer-company-chevron {
        display: block;
        flex-shrink: 0;
        width: .45rem;
        height: .45rem;
        margin-left: .35rem;
        border-right: 2px solid var(--gray-500);
        border-bottom: 2px solid var(--gray-500);
        transform: rotate(-45deg);
        transition: transform .2s ease;
    }
    .drawer-company-group.is-expanded .drawer-company-chevron {
        transform: rotate(45deg);
        margin-top: -.1rem;
    }
    .drawer-company-group.is-expanded .nav-company {
        background: rgba(255, 255, 255, .06);
        color: #fff;
    }
    .drawer-company-group.is-expanded .drawer-company-submenu {
        display: block;
        padding-bottom: .25rem;
    }
    .drawer-company-row .nav-company {
        padding-right: 2.5rem;
    }
}

@media (min-width: 900px) {
    .drawer {
        transform: translateX(0);
    }
    .drawer-overlay { display: none !important; }
    .main-wrap {
        margin-left: var(--drawer-w);
        transition: margin-left .25s cubic-bezier(.4,0,.2,1);
    }
    .menu-btn { display: none !important; }
    .drawer-close { display: none; }
    .drawer-collapse-btn { display: inline-flex; }
    .bottom-nav { display: none !important; }

    /*
     * Desktop collapsed = icon rail (modern SaaS).
     * Icons stay visible/clickable; labels hide; floating name tooltip on hover.
     */
    html.drawer-collapsed .drawer {
        width: var(--drawer-rail-w);
        transform: translateX(0);
        pointer-events: auto;
    }
    html.drawer-collapsed .main-wrap { margin-left: var(--drawer-rail-w); }
    html.drawer-collapsed .menu-btn { display: none !important; }
    html.drawer-collapsed .drawer-header {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: .65rem .4rem;
        gap: .35rem;
    }
    html.drawer-collapsed .drawer-brand {
        justify-content: center;
        width: 100%;
    }
    html.drawer-collapsed .drawer-brand-text { display: none; }
    html.drawer-collapsed .drawer-brand-mark { display: inline-flex; }
    html.drawer-collapsed .drawer-header-actions {
        width: 100%;
        justify-content: center;
    }
    html.drawer-collapsed .drawer-collapse-btn {
        display: inline-flex;
        width: 2.25rem;
        height: 2.25rem;
    }
    html.drawer-collapsed .drawer-collapse-btn .drawer-collapse-icon-collapse { display: none; }
    html.drawer-collapsed .drawer-collapse-btn .drawer-collapse-icon-expand { display: block; }

    /* Hide text labels; keep icons centered and clickable */
    html.drawer-collapsed .nav-item {
        position: relative;
        justify-content: center;
        align-items: center;
        padding: .6rem .4rem;
        gap: 0;
        font-size: 0; /* hides text nodes next to icons */
        overflow: visible;
    }
    html.drawer-collapsed .nav-icon {
        font-size: .9rem;
        width: 1.35rem;
        min-width: 1.35rem;
        height: 1.35rem;
        margin: 0;
    }
    html.drawer-collapsed .nav-icon-svg .nav-svg,
    html.drawer-collapsed .nav-icon-svg svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    html.drawer-collapsed .drawer-company-name,
    html.drawer-collapsed .drawer-company-chevron,
    html.drawer-collapsed .drawer-company-pin,
    html.drawer-collapsed .drawer-company-default,
    html.drawer-collapsed .drawer-company-home-badge,
    html.drawer-collapsed .drawer-company-search-wrap,
    html.drawer-collapsed .drawer-company-search-results,
    html.drawer-collapsed .drawer-company-search-empty,
    html.drawer-collapsed .nav-notif-badge {
        display: none !important;
    }
    html.drawer-collapsed .drawer-company-row .nav-company {
        padding-right: .4rem;
    }
    /* Section labels become thin dividers */
    html.drawer-collapsed .nav-label {
        font-size: 0;
        line-height: 0;
        padding: 0;
        margin: .4rem .7rem;
        height: 1px;
        overflow: hidden;
        background: var(--gray-700);
        color: transparent;
        letter-spacing: 0;
    }
    html.drawer-collapsed .nav-divider {
        margin: .35rem .7rem;
    }
    html.drawer-collapsed .drawer-footer .nav-item {
        padding: .55rem .4rem;
    }
}

/* Floating rail tooltip (body portal — not clipped by drawer overflow) */
.drawer-rail-tooltip {
    position: fixed;
    z-index: 10060;
    left: 0;
    top: 0;
    max-width: min(280px, calc(100vw - 80px));
    padding: .4rem .65rem;
    border-radius: 6px;
    background: #111827;
    color: #f9fafb;
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22), 0 0 0 1px rgba(255, 255, 255, .06);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .12s ease, transform .12s ease;
}
.drawer-rail-tooltip.is-visible {
    opacity: 1;
    transform: translateX(0);
}
.drawer-rail-tooltip::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    background: #111827;
    transform: rotate(45deg);
    box-shadow: -1px 1px 0 rgba(255, 255, 255, .04);
}
/* Only meaningful in collapsed desktop rail; hide otherwise as a safety net */
html:not(.drawer-collapsed) .drawer-rail-tooltip {
    display: none !important;
}
@media (max-width: 899px) {
    .drawer-rail-tooltip { display: none !important; }
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; padding: 0 1rem; gap: .75rem;
    position: sticky; top: 0; z-index: 50;
}
.menu-btn {
    background: none; border: 1px solid var(--gray-200); border-radius: var(--radius);
    font-size: 1.1rem; cursor: pointer; color: var(--gray-600);
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; padding: 0;
}
.menu-btn:hover { background: var(--gray-50); }
.menu-btn .nav-svg {
    width: 1.25rem; height: 1.25rem; display: block;
    stroke: currentColor; fill: none;
}
.topbar-title { font-weight: 600; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.co-name { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-nav { display: none; gap: .125rem; margin-left: .5rem; }
.topbar-nav a {
    padding: .35rem .65rem; border-radius: var(--radius); font-size: .8rem;
    color: var(--gray-500); white-space: nowrap; transition: all .15s;
}
.topbar-nav a:hover { background: var(--gray-100); color: var(--gray-700); text-decoration: none; }
.topbar-nav a.active { background: var(--primary-bg); color: var(--primary); font-weight: 500; }
.topbar-user { margin-left: auto; flex-shrink: 0; }
.topbar-user-link { font-size: .8rem; color: var(--gray-500); text-decoration: none; }
.topbar-user-link:hover { color: var(--primary); text-decoration: none; }

@media (min-width: 768px) {
    .topbar-nav { display: flex; }
}

/* ===== Bottom nav (mobile) ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    height: var(--bottom-nav-h); background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex; align-items: stretch; justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .15rem; color: var(--gray-400); font-size: .6rem; text-decoration: none;
    transition: color .15s;
}
.bottom-nav-item:hover { text-decoration: none; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-icon { font-size: 1.2rem; }

@media (min-width: 900px) {
    .bottom-nav { display: none !important; }
    body { padding-bottom: 0; }
}
@media (max-width: 899px) {
    .main-content { padding-bottom: calc(var(--bottom-nav-h) + .5rem); }
}

/* ===== Badges ===== */
.badge {
    display: inline-block; padding: .15rem .5rem; border-radius: 999px;
    font-size: .7rem; font-weight: 600; white-space: nowrap;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-warn { background: #fffbeb; color: #92400e; }
.badge-success { background: #f0fdf4; color: #166534; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ===== Container / Cards ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem .75rem; min-width: 0; }
@media (min-width: 768px) { .container { padding: 1.5rem 1.5rem; } }

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem; flex-wrap: wrap; gap: .5rem;
}
.page-header h1 { font-size: 1.25rem; }
@media (min-width: 768px) { .page-header h1 { font-size: 1.4rem; } }

.card {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow);
    padding: 1rem; margin-bottom: 1rem;
}
@media (min-width: 768px) { .card { padding: 1.25rem; } }
/* App-managed collapsible panels (Telegram alerts, etc.) */
.crm-app-collapsible .crm-collapsible > summary {
    cursor: pointer;
    list-style: none;
    margin-bottom: 0;
    padding: 1rem;
}
.crm-app-collapsible .crm-collapsible > summary::-webkit-details-marker { display: none; }
.crm-app-collapsible .crm-collapsible > summary::marker { content: ''; }
.crm-collapsible-chevron {
    float: right;
    color: var(--gray-400);
    transition: transform .2s;
}
.crm-collapsible[open] .crm-collapsible-chevron { transform: rotate(180deg); }
html.crm-android-app [data-crm-app-collapse="true"] .crm-collapsible-body { display: none !important; }
html.crm-android-app [data-crm-app-collapse="true"] .crm-collapsible-chevron { display: none; }
html.crm-android-app [data-crm-app-collapse="true"] .crm-collapsible > summary {
    pointer-events: none;
    padding-bottom: 1rem;
}
html.crm-android-app [data-crm-app-collapse="hidden"] { display: none !important; }

.card-header {
    font-weight: 600; margin-bottom: .75rem; font-size: .95rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: .4rem .75rem;
    flex-wrap: wrap;
    min-width: 0;
    overflow-wrap: normal;
    word-break: normal;
}
/* Title: always one horizontal line */
.card-header-title {
    display: block;
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
/* Action cluster — sits under the title, never beside it (avoids squeeze) */
.card-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem;
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    justify-content: flex-start;
}
/* Headers that have a title + actions block: stack title over actions always */
.card-header:has(.card-header-title),
.card-header:has(.card-header-actions),
.card-header.card-header-stack,
.card-header.d-flex:has(.card-header-title),
.card-header.d-flex:has(.card-header-actions) {
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    gap: .45rem;
}
/* Opt-in: title left, actions right on one row (e.g. Activity + LLM) */
.card-header.card-header-inline,
.card-header.card-header-inline:has(.card-header-title),
.card-header.card-header-inline:has(.card-header-actions) {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    gap: .5rem .75rem;
}
.card-header.card-header-inline > .card-header-title {
    width: auto;
    max-width: calc(100% - 5.5rem);
    flex: 1 1 auto;
    min-width: 0;
}
.card-header.card-header-inline > .card-header-actions {
    width: auto;
    max-width: none;
    flex: 0 0 auto;
    margin-left: auto;
    justify-content: flex-end;
}
.card-header > span:first-child:not(.badge):not(.btn):not(.card-header-actions) {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.card-header > .btn,
.card-header > a.btn,
.card-header > button,
.card-header > .badge,
.card-header > form {
    flex: 0 0 auto;
    white-space: nowrap;
    align-self: flex-start;
}

.stat-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: .75rem; margin-bottom: 1.25rem;
}
@media (min-width: 600px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .stat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.stat-card {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow);
    padding: .875rem;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
@media (min-width: 768px) { .stat-card .stat-value { font-size: 1.8rem; } }
.stat-card .stat-label { font-size: .75rem; color: var(--gray-500); margin-top: .15rem; }

/* ===== Forms ===== */
.form-group { margin-bottom: .875rem; }
.form-group label {
    display: block; font-size: .8rem; font-weight: 500;
    margin-bottom: .2rem; color: var(--gray-700);
}
.form-control {
    width: 100%; padding: .5rem .75rem;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: .875rem; background: #fff; transition: border-color .15s;
    -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
select.form-control { appearance: auto; -webkit-appearance: auto; }
textarea.form-control { min-height: 70px; resize: vertical; }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 0; }
@media (max-width: 480px) { .form-row .form-group { min-width: 100%; } }
.form-hint { font-size: .7rem; color: var(--gray-400); margin-top: .15rem; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .5rem 1rem; border-radius: var(--radius);
    font-size: .875rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: all .15s;
    white-space: nowrap; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-outline { background: #fff; border-color: var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: .3rem .6rem; font-size: .75rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0; padding: 0; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .825rem; }
th, td { padding: .6rem .6rem; text-align: left; border-bottom: 1px solid var(--gray-100); }
th { font-weight: 600; color: var(--gray-500); background: var(--gray-50); white-space: nowrap; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--gray-50); }
@media (max-width: 600px) {
    th, td { padding: .5rem .4rem; font-size: .75rem; }
    .hide-mobile { display: none !important; }
}
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
}

/* New lead: full page on mobile / in-app WebView; modal on desktop */
.btn-new-lead-page { display: none; }
@media (max-width: 767px) {
    .btn-new-lead-page { display: inline-flex; }
}
html.crm-android-app .btn-new-lead-page { display: inline-flex !important; }
html.crm-android-app .btn-new-lead-modal,
html.crm-android-app #createLeadModal { display: none !important; }

/* App WebView / mobile: full pages instead of modals */
.crm-app-page-link { display: none; }
html.crm-android-app .crm-app-modal-trigger { display: none !important; }
html.crm-android-app .crm-app-page-link { display: inline-flex !important; }
html.crm-android-app .modal-backdrop { display: none !important; }
@media (max-width: 767px) {
    .crm-app-page-link-mobile { display: inline-flex !important; }
    .crm-app-modal-trigger-mobile { display: none !important; }
}
html.crm-android-app .crm-app-page-link-mobile { display: inline-flex !important; }
html.crm-android-app .crm-app-modal-trigger-mobile { display: none !important; }

.crm-app-page-topbar { margin-bottom: .75rem; }
.crm-app-page-actions {
    flex-direction: column;
    gap: .5rem;
    padding-top: .75rem;
    margin-top: .5rem;
    border-top: 1px solid var(--gray-100);
}
@media (max-width: 767px) {
    .page-lead-schedule .crm-app-page-actions,
    .page-message-library-edit .crm-app-page-actions,
    .page-message-library-edit .message-library-actions,
    .page-whatsapp-templates .crm-app-page-actions,
    .page-whatsapp-templates .message-library-actions,
    .page-lead-assign .crm-app-page-actions,
    .page-calendar-day .crm-app-page-actions,
    .page-company-user-create .crm-app-page-actions,
    .page-webhook-create .crm-app-page-actions {
        position: sticky;
        bottom: 0;
        background: #fff;
        padding-bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
    }
}
html.crm-android-app .page-lead-schedule .crm-app-page-actions,
html.crm-android-app .page-message-library-edit .crm-app-page-actions,
html.crm-android-app .page-message-library-edit .message-library-actions,
html.crm-android-app .page-whatsapp-templates .crm-app-page-actions,
html.crm-android-app .page-whatsapp-templates .message-library-actions,
html.crm-android-app .page-lead-assign .crm-app-page-actions,
html.crm-android-app .page-calendar-day .crm-app-page-actions,
html.crm-android-app .page-company-user-create .crm-app-page-actions,
html.crm-android-app .page-webhook-create .crm-app-page-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
}
.crm-native-file-input { position: absolute; width: 0; height: 0; opacity: 0; }
.crm-file-picker-btn { position: relative; cursor: pointer; }

/* Dedicated new-lead page (mobile / app) */
.page-lead-create .lead-create-topbar {
    margin-bottom: .75rem;
}
.page-lead-create .lead-create-back {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.page-lead-create .lead-create-card {
    padding: 1rem;
}
.page-lead-create .lead-create-form .form-row {
    flex-direction: column;
    gap: 0;
}
.page-lead-create .lead-create-form .form-row .form-group {
    flex: 1 1 100%;
    min-width: 100%;
}
.page-lead-create .lead-create-actions {
    flex-direction: column;
    gap: .5rem;
    padding-top: .75rem;
    margin-top: .5rem;
    border-top: 1px solid var(--gray-100);
}
@media (max-width: 767px) {
    .page-lead-create .form-control {
        font-size: 1rem;
        padding: .625rem .75rem;
    }
    .page-lead-create .lead-create-actions {
        position: sticky;
        bottom: 0;
        background: #fff;
        padding-bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
        margin-bottom: -.25rem;
    }
}

/* ===== Lead Pipeline (Kanban — desktop only) ===== */
.pipeline {
    display: none; gap: .75rem; overflow-x: auto; padding-bottom: 1rem;
    min-height: 400px; -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) { .pipeline { display: flex; } }
.pipeline-col {
    min-width: 220px; max-width: 260px; flex-shrink: 0;
    background: var(--gray-100); border-radius: var(--radius-lg); padding: .625rem;
}
.pipeline-col-header {
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    margin-bottom: .625rem; display: flex; justify-content: space-between; align-items: center;
    padding: 0 .25rem;
}
.pipeline-col-header .count {
    background: rgba(0,0,0,.08); color: inherit; border-radius: 999px;
    padding: .1rem .45rem; font-size: .65rem;
}
.pipeline-cards { display: flex; flex-direction: column; gap: .5rem; min-height: 50px; }
.lead-card {
    background: #fff; border-radius: var(--radius); padding: .625rem .75rem;
    box-shadow: var(--shadow); cursor: grab; border-left: 3px solid var(--primary);
    transition: box-shadow .15s;
}
.lead-card:hover { box-shadow: var(--shadow-lg); }
.lead-card:active { cursor: grabbing; }
.lead-card .lead-name { font-weight: 600; font-size: .85rem; margin-bottom: .15rem; }
.lead-card .lead-meta { font-size: .7rem; color: var(--gray-500); }
.lead-card .lead-followup {
    font-size: .65rem; margin-top: .3rem; padding: .15rem .35rem;
    border-radius: 4px; display: inline-block;
}
.lead-card .lead-followup.overdue { background: #fef2f2; color: #991b1b; }
.lead-card .lead-followup.today { background: #fffbeb; color: #92400e; }
.lead-card .lead-followup.upcoming { background: #eff6ff; color: #1e40af; }
.lead-card .lead-opp-badge {
    margin-top: .35rem; font-weight: 600; color: var(--primary, #4f46e5);
}

/* Mobile lead list (replaces kanban) */
.lead-list-mobile { display: block; }
@media (min-width: 768px) { .lead-list-mobile { display: none; } }
.lead-list-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem; background: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: .5rem; text-decoration: none; color: inherit;
    transition: box-shadow .15s;
}
.lead-list-item:hover { box-shadow: var(--shadow-lg); text-decoration: none; }

/* Dashboard recent leads */
.dashboard-recent-leads {
    list-style: none;
    margin: 0;
    padding: 0;
}
.dashboard-recent-lead-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--gray-100);
    transition: background .15s;
}
.dashboard-recent-lead-item:hover { background: var(--gray-50); }
.dashboard-recent-leads li:last-child .dashboard-recent-lead-item { border-bottom: none; }
.dashboard-recent-lead-status {
    width: 4px;
    align-self: stretch;
    min-height: 2.25rem;
    border-radius: 2px;
    flex-shrink: 0;
}
.dashboard-recent-lead-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}
.dashboard-recent-lead-name {
    font-size: .85rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-recent-lead-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-recent-lead-badge {
    flex-shrink: 0;
    font-size: .65rem;
    white-space: nowrap;
}

.input-with-action {
    display: flex;
    gap: .5rem;
    align-items: stretch;
}
.input-with-action .form-control { flex: 1; }
.user-pass-display {
    font-size: .75rem;
    background: var(--gray-100);
    padding: .15rem .4rem;
    border-radius: 4px;
    word-break: break-all;
}
.lead-list-status {
    width: 4px; align-self: stretch; border-radius: 2px; flex-shrink: 0;
}
.lead-list-body { flex: 1; min-width: 0; }
.lead-list-body .lead-name { font-weight: 600; font-size: .875rem; }
.lead-list-body .lead-meta {
    font-size: .75rem; color: var(--gray-500); margin-top: .1rem;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    max-width: 100%; scrollbar-width: none;
}
.lead-list-body .lead-meta::-webkit-scrollbar { display: none; }
.lead-list-badge { flex-shrink: 0; }

/* Leads table: keep phone numbers full width; scroll horizontally on narrow screens */
.leads-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.leads-table .col-phone { white-space: nowrap; }
@media (max-width: 767px) {
    .leads-table { width: max-content; min-width: 100%; }
    .leads-table .col-phone { min-width: max-content; }
}

/* ===== Filter bar ===== */
.filter-bar { margin-bottom: 1rem; }
.filter-toggle {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .75rem; background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); cursor: pointer; font-size: .8rem; color: var(--gray-600);
    width: 100%;
}
.filter-toggle:hover { border-color: var(--gray-300); }
.filter-toggle .filter-count { background: var(--primary); color: #fff; border-radius: 999px; padding: .1rem .4rem; font-size: .65rem; }
.filter-body { display: none; margin-top: .5rem; }
.filter-body.open { display: block; }
.filter-form {
    display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
    padding: .75rem; background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.filter-form .form-control { width: auto; min-width: 120px; font-size: .8rem; padding: .35rem .5rem; }
@media (max-width: 600px) {
    .filter-form { flex-direction: column; }
    .filter-form .form-control { width: 100%; }
}
.filter-chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .2rem;
    padding: .3rem .65rem; border-radius: 999px; font-size: .75rem;
    cursor: pointer; border: 1px solid var(--gray-200); background: #fff;
    color: var(--gray-600); transition: all .15s; text-decoration: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Leads search autocomplete ===== */
.leads-filter-bar { margin-bottom: 1rem; }
.leads-filter-form { display: flex; flex-direction: column; gap: .65rem; }
.leads-search-hero {
    display: flex; gap: .5rem; align-items: stretch;
    padding: .85rem; background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.leads-search-wrap { position: relative; flex: 1; min-width: 0; }
.leads-search-wrap--prominent { min-width: 0; }
.leads-search-icon {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--gray-400); pointer-events: none; line-height: 0;
}
.leads-search-icon svg { display: block; width: 1rem; height: 1rem; }
.leads-search-input {
    width: 100%; box-sizing: border-box;
    font-size: 1rem; padding: .7rem .75rem .7rem 2.35rem;
    border-radius: var(--radius-sm); min-height: 2.75rem;
}
.leads-search-submit {
    flex-shrink: 0; align-self: stretch; padding-left: 1.1rem; padding-right: 1.1rem;
    font-weight: 600;
}
.leads-search-scope-hint { margin: -.25rem 0 0; padding: 0 .15rem; }
.filter-chips-stages { margin-top: .15rem; }
.filter-more-toggle {
    display: flex; align-items: center; gap: .45rem;
    width: 100%; padding: .55rem .75rem; background: #fff;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    cursor: pointer; font-size: .82rem; color: var(--gray-700);
    text-align: left;
}
.filter-more-toggle:hover { border-color: var(--gray-300); }
.filter-more-toggle-label { flex: 1; min-width: 0; }
.filter-more-chevron {
    flex-shrink: 0; width: .55rem; height: .55rem;
    border-right: 2px solid var(--gray-500); border-bottom: 2px solid var(--gray-500);
    transform: rotate(45deg); margin-top: -.15rem;
    transition: transform .2s ease;
}
.filter-more-toggle.is-open .filter-more-chevron,
.filter-more-toggle[aria-expanded="true"] .filter-more-chevron {
    transform: rotate(-135deg); margin-top: .15rem;
}
.filter-more-body {
    display: none; padding: .75rem; background: #fff;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
}
.filter-more-body.open { display: block; }
.filter-more-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .5rem; margin-bottom: .65rem;
}
.filter-more-field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.filter-more-label {
    font-size: .72rem; font-weight: 600; color: var(--gray-600);
    line-height: 1.2;
}
.filter-more-grid .form-control { width: 100%; min-width: 0; font-size: .82rem; }
.filter-more-grid .filter-date-input {
    min-height: 2.5rem; color: var(--gray-900);
    color-scheme: light;
}
.filter-chips-more { margin-bottom: .65rem; }
.filter-more-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.leads-search-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 120;
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto;
}
.leads-search-group-label {
    padding: .35rem .65rem .15rem; font-size: .65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500);
    background: var(--gray-50); border-bottom: 1px solid var(--gray-100);
}
.leads-search-item {
    display: block; width: 100%; text-align: left; border: none; background: none;
    padding: .55rem .65rem; cursor: pointer; border-bottom: 1px solid var(--gray-100);
}
.leads-search-item:hover, .leads-search-item.active { background: var(--primary-bg); }
.leads-search-item-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.leads-search-label-row {
    display: flex; align-items: center; gap: .4rem; min-width: 0;
}
.leads-search-label { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.leads-search-ownership {
    flex-shrink: 0; font-size: .62rem; font-weight: 600; padding: .12rem .4rem;
    border-radius: 999px; white-space: nowrap;
}
.leads-search-ownership.is-mine { background: #dcfce7; color: #166534; }
.leads-search-ownership.is-unassigned { background: #fef3c7; color: #92400e; }
.leads-search-ownership.is-other { background: var(--gray-100); color: var(--gray-600); }
.leads-search-meta, .leads-search-snippet, .leads-search-co { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leads-search-empty { padding: .65rem .75rem; }
.leads-search-snippet { font-style: italic; }
@media (max-width: 767px) {
    .leads-search-hero { flex-direction: column; padding: .75rem; }
    .leads-search-submit { width: 100%; min-height: 2.5rem; }
    .leads-search-input { font-size: 1.05rem; min-height: 3rem; }
    .filter-more-grid { grid-template-columns: 1fr; }
    .filter-more-grid .filter-date-input {
        font-size: 1rem; min-height: 2.75rem; padding: .55rem .65rem;
    }
}

/* ===== Activity stream ===== */
.stream { max-height: 500px; overflow-y: auto; }
.stream-item { padding: .625rem 0; border-bottom: 1px solid var(--gray-100); display: flex; gap: .625rem; }
.stream-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--primary-bg);
    color: var(--primary); display: flex; align-items: center; justify-content: center;
    font-size: .65rem; font-weight: 600; flex-shrink: 0;
}
.stream-body { flex: 1; min-width: 0; }
.stream-body .stream-author { font-weight: 600; font-size: .8rem; }
.stream-done-badge { color: #166534; font-weight: 600; font-size: .75rem; }
.stream-sched-badge { color: var(--primary); font-weight: 600; font-size: .75rem; }
.schedule-item-overdue { background: #fffbeb; margin: 0 -.5rem; padding-left: .5rem; padding-right: .5rem; border-radius: var(--radius-sm); }
.stream-body .stream-time { font-size: .65rem; color: var(--gray-400); margin-left: .35rem; }
.stream-body .stream-text { font-size: .8rem; margin-top: .15rem; word-wrap: break-word; }
.stream-system { opacity: .65; font-style: italic; }
.stream-system .stream-meta { opacity: 1; font-style: normal; }
/* API / website re-applications with metadata stay full-contrast (replacing WA handoff traffic) */
.stream-ingest-item { opacity: 1; font-style: normal; }
.stream-ingest-item .stream-avatar { font-size: .65rem; letter-spacing: -.02em; }
.stream-ingest-badge {
    display: inline-block; color: #4338ca; font-weight: 600; font-size: .7rem;
    background: #eef2ff; border-radius: 4px; padding: .05rem .35rem; margin-right: .15rem;
}
.stream-ingest-badge.stream-ingest-reapply {
    color: #9a3412; background: #ffedd5;
}
.stream-meta {
    margin-top: .4rem; padding: .45rem .55rem; border-radius: 6px;
    background: var(--gray-50, #f9fafb); border: 1px solid var(--gray-100, #f3f4f6);
    font-style: normal; opacity: 1;
}
.stream-meta-row {
    display: flex; gap: .5rem; align-items: flex-start;
    padding: .15rem 0; font-size: .75rem; line-height: 1.35;
}
.stream-meta-row + .stream-meta-row { border-top: 1px solid var(--gray-100, #f3f4f6); }
.stream-meta-key {
    flex: 0 0 38%; max-width: 9.5rem; color: var(--gray-500); font-weight: 500;
    word-break: break-word;
}
.stream-meta-val {
    flex: 1; min-width: 0; color: var(--gray-800, #1f2937); word-break: break-word;
    white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .72rem;
}
.stream-compose { margin-top: .5rem; }
.stream-compose textarea { width: 100%; min-height: 50px; }
/* Schedule / follow-up datetime + timezone */
.schedule-datetime-wrap {
    margin-bottom: .75rem;
}
.schedule-datetime-row {
    align-items: flex-end;
    gap: .75rem;
}
.schedule-datetime-col {
    flex: 1.4;
    min-width: 0;
}
.schedule-tz-col {
    flex: 1;
    min-width: 10rem;
}
.schedule-tz-preview {
    margin-top: .35rem;
    line-height: 1.45;
    padding: .4rem .55rem;
    background: var(--gray-50, #f9fafb);
    border-radius: var(--radius, 6px);
    border: 1px solid var(--gray-100, #f3f4f6);
}
.schedule-tz-preview-label {
    font-weight: 600;
    color: var(--gray-600, #4b5563);
}
.schedule-tz-display {
    margin-top: .2rem;
    line-height: 1.35;
}

.internal-comment-compose {
    border: 1px solid var(--gray-200);
    border-radius: .65rem;
    background: #f8fafc;
    padding: .75rem;
    overflow: visible;
}
.mention-compose-wrap {
    position: relative;
    overflow: visible;
}
.compose-label {
    display: flex; align-items: baseline; gap: .45rem;
    margin-bottom: .45rem; color: var(--gray-700);
}

/* ===== Lead detail layout ===== */
.detail-column-main,
.detail-column-workflow {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

/* Booking share: collapsed <details> under Schedules */
.lead-booking-share-card {
    padding: 0;
    overflow: hidden;
    /* Match standard .card — no accent left border */
    border: none;
    box-shadow: var(--shadow);
    background: #fff;
    border-radius: var(--radius-lg);
}

/* WhatsApp chat: template + CTA link bubbles */
.wa-template-tag {
    margin-top: .35rem;
    font-size: .68rem;
}
.wa-cta-block {
    margin-top: .45rem;
    padding-top: .35rem;
    border-top: 1px solid rgba(0, 0, 0, .06);
}
.wa-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-weight: 600;
    word-break: break-word;
}
.wa-cta-url {
    margin-top: .2rem;
    word-break: break-all;
    line-height: 1.35;
}
.lead-booking-share-summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 3.35rem;
    padding: .85rem 1rem;
    margin: 0;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease;
}
.lead-booking-share-summary:hover {
    background: var(--gray-50, #f8fafc);
}
.lead-booking-share-summary::-webkit-details-marker { display: none; }
.lead-booking-share-summary::marker { content: ''; }
.lead-booking-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    flex-shrink: 0;
    border-radius: 10px;
    background: #f3f4f6;
    color: #111827;
}
.lead-booking-share-icon svg {
    display: block;
}
.lead-booking-share-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.lead-booking-share-title {
    font-size: .9rem;
    font-weight: 650;
    color: var(--gray-900, #111827);
    line-height: 1.25;
}
.lead-booking-share-sub {
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lead-booking-share-slot {
    color: var(--gray-900, #111827);
    font-weight: 700;
}
.lead-booking-share-badge {
    flex-shrink: 0;
    font-size: .68rem !important;
}
.lead-booking-share-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: #f3f4f6;
    color: var(--gray-600, #4b5563);
    transition: transform .18s ease, background .15s ease, color .15s ease;
}
.lead-booking-share-chevron svg {
    display: block;
}
.lead-booking-share-card[open] .lead-booking-share-summary {
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
    background: #fafafa;
}
.lead-booking-share-card[open] .lead-booking-share-chevron {
    transform: rotate(180deg);
    background: #e5e7eb;
    color: #111827;
}
.lead-booking-share-body {
    padding: .9rem 1rem 1.1rem;
}
.lead-booking-share-active-when {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .3rem .5rem;
}
.lead-booking-share-active {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
}
.lead-booking-share-help {
    margin: 0 0 14px;
}
.lead-booking-share-row {
    margin-bottom: 12px;
}
.lead-booking-share-row-label {
    margin-bottom: 6px;
}
.lead-booking-share-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.lead-booking-share-actions .form-control {
    flex: 1 1 180px;
    min-width: 0;
}
.lead-booking-share-refresh {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100, #f3f4f6);
}
@media (max-width: 767px) {
    .lead-booking-share-summary {
        min-height: 3.6rem;
        padding: .95rem 1rem;
        gap: .7rem;
    }
    .lead-booking-share-icon {
        width: 2.35rem;
        height: 2.35rem;
    }
    .lead-booking-share-title {
        font-size: .95rem;
    }
    .lead-booking-share-sub {
        white-space: normal;
    }
    .lead-booking-share-actions .btn {
        min-height: 2.15rem;
    }
}

.wa-chat-card {
    overflow: visible;
    border: 1px solid #b8e6c8;
    box-shadow: 0 1px 3px rgba(7, 94, 84, 0.1);
}

.wa-chat-card > .wa-chat-panel {
    border-bottom: none;
    margin-bottom: 0;
}

/* ===== WhatsApp chat panel ===== */
.wa-chat-panel {
    margin-bottom: 0;
}
.wa-chat-toggle {
    width: 100%; display: flex; align-items: center; gap: .65rem;
    padding: .75rem 1rem; border: none; background: #f0faf4;
    cursor: pointer; text-align: left; font: inherit; color: inherit;
    border-radius: var(--radius-md); transition: background .15s;
}
.wa-chat-toggle:hover { background: #e3f5ea; }
.wa-chat-panel.wa-chat-open .wa-chat-toggle { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.wa-chat-toggle-icon {
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: #25D366; line-height: 1;
}
.wa-chat-toggle-icon svg { width: 1.35rem; height: 1.35rem; display: block; }
.wa-chat-toggle-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.wa-chat-meta { font-family: ui-monospace, monospace; }
.wa-window-badge {
    font-size: .68rem; font-weight: 600; padding: .2rem .5rem; border-radius: 999px; white-space: nowrap;
}
.wa-window-open { background: #dcf8c6; color: #1b5e20; }
.wa-window-closed { background: #fde8e8; color: #b71c1c; }
.wa-chat-chevron { font-size: .65rem; color: var(--gray-400); }
.wa-chat-body { padding: 0 .5rem .5rem; }
.wa-chat-body[hidden] { display: none !important; }
.wa-chat-panel.wa-chat-open .wa-chat-body { display: block; }
.wa-chat-window {
    border: 1px solid #d1e7dd; border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden; background: #e5ddd5;
}
.wa-chat-header {
    display: flex; align-items: center; gap: .65rem;
    padding: .65rem .85rem; background: #075e54; color: #fff;
}
.wa-chat-header-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: #25D366;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700;
}
.wa-chat-header-name { font-weight: 600; font-size: .85rem; }
.wa-chat-header-sub { opacity: .85; margin-top: .1rem; }
.wa-chat-presence {
    max-width: 260px;
    opacity: .95;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wa-chat-messages {
    min-height: 180px; max-height: 320px; overflow-y: auto;
    padding: .75rem; display: flex; flex-direction: column; gap: .45rem;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c8c4bc' fill-opacity='0.18'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") #e5ddd5;
}
.wa-chat-empty { text-align: center; padding: 2rem 1rem; }
.wa-bubble-row {
    display: flex; align-items: flex-end; gap: .2rem;
    position: relative; touch-action: pan-y;
}
.wa-bubble-in { justify-content: flex-start; }
.wa-bubble-out { justify-content: flex-end; }
.wa-bubble {
    max-width: 78%; padding: .45rem .65rem .3rem;
    border-radius: .55rem; box-shadow: 0 1px 1px rgba(0,0,0,.08);
    font-size: .82rem; line-height: 1.35; word-wrap: break-word;
    position: relative; z-index: 1;
    transition: transform .15s ease-out;
}
.wa-bubble-in .wa-bubble { background: #fff; border-top-left-radius: .15rem; }
.wa-bubble-out .wa-bubble { background: #dcf8c6; border-top-right-radius: .15rem; }
.wa-reply-btn {
    flex-shrink: 0;
    align-self: center;
    border: none;
    background: transparent;
    color: rgba(0,0,0,.28);
    padding: .25rem;
    border-radius: 50%;
    cursor: pointer;
    line-height: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.wa-bubble-in .wa-reply-btn { margin-left: .15rem; }
.wa-bubble-out .wa-reply-btn { margin-right: .15rem; }
.wa-bubble-row[data-activity-id]:hover .wa-reply-btn,
.wa-bubble-row.wa-swipe-reply-active .wa-reply-btn,
.wa-bubble-row.wa-swipe-reply-ready .wa-reply-btn,
.wa-bubble-row.wa-reply-selected .wa-reply-btn {
    opacity: 1;
    pointer-events: auto;
}
.wa-bubble-row.wa-swipe-reply-ready .wa-reply-btn {
    color: #128C7E;
    background: rgba(18, 140, 126, .12);
}
.wa-reply-btn:hover,
.wa-reply-btn:focus-visible {
    color: #128C7E;
    background: rgba(18, 140, 126, .1);
    opacity: 1;
}
.wa-bubble-row[data-activity-id] { cursor: default; }
.wa-bubble-row.wa-swipe-reply-active .wa-bubble {
    transform: translateX(var(--wa-swipe-offset, 0));
    transition: none;
}
.wa-bubble-row.wa-reply-selected .wa-bubble { box-shadow: 0 0 0 2px #25D366; }
@media (hover: none) and (pointer: coarse) {
    .wa-bubble-row[data-activity-id] .wa-reply-btn {
        opacity: .45;
        pointer-events: auto;
    }
}
.wa-reply-preview {
    margin-bottom: .35rem; padding: .3rem .45rem;
    border-left: 3px solid #25D366; border-radius: .35rem;
    background: rgba(0,0,0,.045); overflow: hidden;
}
.wa-reply-preview-author {
    font-size: .68rem; font-weight: 700; color: #128C7E;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wa-reply-preview-text {
    font-size: .72rem; color: rgba(0,0,0,.62);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wa-bubble-meta { font-size: .62rem; color: rgba(0,0,0,.45); margin-top: .2rem; text-align: right; }
.wa-chat-compose {
    padding: .65rem .75rem; background: #f0f2f5; border-top: 1px solid #d1d7db;
    overflow: visible;
    position: relative;
    z-index: 2;
}
.wa-chat-compose textarea { width: 100%; min-height: 44px; resize: vertical; border-radius: 1.25rem; }
.wa-compose-reply-preview {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    margin-bottom: .4rem; padding: .45rem .55rem; background: #fff;
    border-radius: .6rem; border-left: 3px solid #25D366;
}
.wa-compose-reply-preview[hidden] { display: none; }
.wa-compose-reply-clear {
    border: none; background: transparent; color: rgba(0,0,0,.45);
    font-size: 1.1rem; line-height: 1; cursor: pointer; padding: .1rem .25rem;
}
.wa-compose-reply-clear:hover { color: rgba(0,0,0,.75); }
.wa-compose-flow-preview {
    display: flex; align-items: flex-start; justify-content: space-between; gap: .55rem;
    margin-bottom: .4rem; padding: .55rem .65rem; background: #eff6ff;
    border-radius: .6rem; border-left: 3px solid #2563eb;
}
.wa-compose-flow-preview[hidden] { display: none; }
.wa-flow-preview-icon {
    flex: 0 0 auto; width: 1.6rem; height: 1.6rem; border-radius: 999px;
    background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700; margin-top: .05rem;
}
.wa-flow-preview-body { flex: 1 1 auto; min-width: 0; }
.wa-flow-preview-title { font-size: .72rem; font-weight: 700; color: #1d4ed8; text-transform: uppercase; letter-spacing: .02em; }
.wa-flow-preview-name { font-size: .92rem; font-weight: 600; color: #0f172a; margin-top: .1rem; word-break: break-word; }
.wa-flow-preview-warn { font-size: .75rem; color: #64748b; margin-top: .2rem; line-height: 1.3; }
.wa-chat-compose.is-flow-mode #waReplyBox { display: none; }
.wa-chat-compose.is-flow-mode .wa-content-type-select { opacity: .55; pointer-events: none; }
.wa-send-btn.is-start-flow { background: #2563eb; border-color: #2563eb; }
.wa-send-btn.is-start-flow:hover { background: #1d4ed8; border-color: #1d4ed8; }
.wa-chat-compose-actions {
    display: flex; align-items: center; justify-content: space-between; margin-top: .45rem;
}
.wa-send-btn { background: #25D366; border-color: #25D366; color: #fff; }
.wa-send-btn:hover { background: #128C7E; border-color: #128C7E; color: #fff; }
.wa-send-btn:disabled { opacity: .6; cursor: not-allowed; }
.wa-chat-closed-note { padding: .35rem 0; }

.wa-outbound-offer-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-md);
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}
.wa-outbound-offer-text {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .875rem;
    color: var(--gray-700);
}
.wa-outbound-offer-banner .wa-outbound-offer-text strong { color: #065f46; }
.wa-outbound-check-banner,
.wa-outbound-unreachable-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-md);
}
.wa-outbound-check-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
}
.wa-outbound-check-banner .wa-outbound-offer-text strong { color: #92400e; }
.wa-outbound-unreachable-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
}
.wa-outbound-unreachable-banner .wa-outbound-offer-text strong { color: #991b1b; }
.wa-delivery-status { font-size: .75rem; }
.wa-delivery-failed { color: #b91c1c; font-weight: 600; }
.wa-delivery-error { color: #b91c1c; margin-top: .25rem; max-width: 18rem; line-height: 1.35; }
.wa-bubble-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .25rem; }
.wa-bubble-delivery { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .15rem; }
.wa-auto-builder-wrap { display: flex; flex-direction: column; gap: .75rem; padding: .75rem; }
.wa-auto-blocks-panel { border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: .75rem; background: #fff; }
.wa-auto-block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.wa-auto-option-block {
    display: flex; flex-direction: column; align-items: flex-start; gap: .15rem;
    padding: .55rem .65rem; border: 1px solid var(--gray-200); border-radius: var(--radius-md);
    background: var(--gray-50); cursor: pointer; text-align: left; width: 100%;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.wa-auto-option-block:hover { border-color: #6366f1; background: #eef2ff; box-shadow: 0 1px 3px rgba(99,102,241,.15); }
.wa-auto-option-block.is-selected { border-color: #6366f1; background: #eef2ff; box-shadow: inset 0 0 0 1px #6366f1; }
.wa-auto-option-block-title { font-size: .78rem; font-weight: 600; color: var(--gray-800); line-height: 1.25; }
.wa-auto-option-block-desc { font-size: .65rem; color: var(--gray-500); line-height: 1.3; }
.wa-auto-block-group-title { grid-column: 1 / -1; font-size: .68rem; font-weight: 600; text-transform: uppercase; color: var(--gray-500); margin-top: .25rem; }
.wa-auto-direct-badge { font-size: .58rem; background: #7c3aed; color: #fff; padding: .05rem .3rem; border-radius: 3px; font-weight: 600; vertical-align: middle; }
.wa-auto-direct-block { border-color: #c4b5fd; }
.wa-auto-direct-title { color: #6d28d9; }
.wa-auto-direct-note { grid-column: 1 / -1; margin: 0 0 .35rem; }
.wa-auto-workspace { display: grid; grid-template-columns: 1fr 260px; gap: .75rem; min-height: 420px; }
@media (max-width: 900px) { .wa-auto-workspace { grid-template-columns: 1fr; } }
.wa-auto-empty-hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; max-width: 240px; }
.wa-auto-canvas { position: relative; border: 1px solid var(--gray-200); border-radius: var(--radius-md); min-height: 400px; }
.wa-auto-props { border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: .65rem; font-size: .85rem; max-height: 520px; overflow-y: auto; }
.wa-auto-props-head { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.wa-auto-option-picker { display: grid; grid-template-columns: 1fr; gap: .35rem; margin-top: .35rem; }
.wa-auto-trigger-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem; margin-bottom: .5rem; }
.wa-auto-flow-settings { padding: .75rem 1rem; background: var(--gray-50); }
.wa-flow-actions { white-space: nowrap; }
.wa-flow-actions .btn { margin-left: .25rem; }
.wa-auto-ai-chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.wa-auto-ai-chat-log {
    min-height: 140px; max-height: 280px; overflow-y: auto;
    border: 1px solid var(--border-color, #e2e8f0); border-radius: var(--radius-md);
    background: #fff; padding: .65rem; display: flex; flex-direction: column; gap: .5rem;
}
.wa-auto-ai-chat-compose { display: flex; gap: .5rem; align-items: flex-end; }
.wa-auto-ai-chat-compose textarea { flex: 1; resize: vertical; min-height: 2.5rem; }
.wa-auto-ai-chat-msg { max-width: 92%; padding: .45rem .65rem; border-radius: .65rem; font-size: .82rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.wa-auto-ai-chat-msg.is-user { align-self: flex-end; background: #dbeafe; color: #1e3a8a; }
.wa-auto-ai-chat-msg.is-assistant { align-self: flex-start; background: #f1f5f9; color: #0f172a; }
.wa-auto-ai-chat-msg.is-system { align-self: center; background: transparent; color: #64748b; font-size: .75rem; font-style: italic; padding: .2rem; }
.wa-auto-ai-chat-msg.is-error { align-self: flex-start; background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.wa-auto-ai-chat.is-loading { opacity: .7; pointer-events: none; }
.wa-auto-ai-draft { padding: .75rem 1rem; background: #f8fafc; }
.wa-auto-ai-actions { display: flex; flex-direction: column; gap: .35rem; }
.wa-auto-ai-summary { padding: .5rem .65rem; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: var(--radius-md); font-size: .82rem; color: #065f46; }
.wa-auto-ai-summary.is-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.wa-auto-ai-draft.is-loading { opacity: .7; pointer-events: none; }
.wa-auto-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .wa-auto-settings-grid { grid-template-columns: 1fr; } }
.wa-auto-settings-title { font-weight: 600; font-size: .85rem; margin-bottom: .5rem; }
.wa-node-label { font-size: .75rem; font-weight: 600; }
.wa-node-sub { font-size: .65rem; color: var(--gray-500); margin-top: .15rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-node-ports { display: flex; justify-content: space-between; font-size: .58rem; color: #6366f1; margin-top: .25rem; width: 100%; }
.wa-node-port-yes { color: #16a34a; }
.wa-node-port-no { color: #dc2626; }
.wa-auto-enroll-banner { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius-md); padding: .65rem .85rem; margin-bottom: .75rem; font-size: .875rem; }
/* Flow builder: labeled output connectors */
.drawflow .drawflow-node { min-width: 168px; }
.drawflow .drawflow-node .output.wa-output-hidden { display: none !important; }
.drawflow .drawflow-node .output { position: relative; }
.drawflow .drawflow-node .wa-output-label {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-size: .58rem;
    font-weight: 500;
    color: var(--gray-600);
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    text-align: right;
}
.drawflow .drawflow-node .wa-output-label.is-timeout { color: #b45309; font-style: italic; }
.wa-auto-props-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid var(--gray-200);
}
.wa-auto-props-type { font-weight: 600; font-size: .82rem; color: var(--gray-800); }
.wa-node-delete { font-size: .72rem; padding: .15rem .5rem; flex-shrink: 0; }
.wa-auto-output-legend {
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: .45rem .55rem;
    margin-bottom: .5rem;
    font-size: .72rem;
    color: var(--gray-700);
}
.wa-auto-output-legend ul { margin: .3rem 0 0; padding: 0; list-style: none; }
.wa-auto-output-legend li { display: flex; align-items: center; gap: .4rem; margin: .2rem 0; line-height: 1.3; }
.wa-auto-output-legend .wa-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6366f1;
    flex-shrink: 0;
}
.wa-auto-output-legend .wa-legend-timeout .wa-legend-dot { background: #f59e0b; }
.wa-auto-output-legend .wa-legend-timeout { color: #92400e; font-style: italic; }
.wa-auto-flow-status { padding: .55rem .75rem; background: #f8fafc; }
.wa-auto-status-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .35rem; }
.wa-auto-pill {
    display: inline-block;
    font-size: .68rem;
    font-weight: 600;
    padding: .15rem .45rem;
    border-radius: 999px;
    border: 1px solid transparent;
}
.wa-auto-pill.is-live { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.wa-auto-pill.is-offline { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.wa-auto-pill.is-draft-changed { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.wa-auto-pill.is-draft-only { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.wa-auto-pill.is-draft-sync { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.wa-auto-status-hint { margin: .35rem 0 0; color: var(--gray-600); }
.wa-auto-revisions summary { cursor: pointer; color: var(--gray-700); }
.wa-auto-rev-list { margin: .35rem 0 0; padding-left: 1rem; }
.wa-auto-rev-list li { margin: .15rem 0; }
.wa-auto-rev-ver { font-weight: 600; color: #6366f1; }
.wa-auto-wiring-warn {
    margin-top: .5rem;
    padding: .45rem .55rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #991b1b;
}
.wa-auto-wiring-warn ul { margin: .25rem 0 0; padding-left: 1rem; }
.wa-auto-wiring-warn code { font-size: .65rem; }
.wa-open-conv-table { font-size: .78rem; }
.wa-open-conv-table code { font-size: .68rem; }
.wa-open-conv-actions { white-space: nowrap; }
.btn-xs { font-size: .68rem; padding: .12rem .4rem; }
.badge-warning { background: #fef3c7; color: #92400e; }
.wa-template-tag { margin-top: .45rem; padding-top: .35rem; border-top: 1px solid rgba(0,0,0,.06); font-style: italic; }
.wa-ticks { display: inline-flex; align-items: center; line-height: 1; color: #8696a0; }
.wa-ticks-read { color: #53bdeb; }
.wa-ticks-pending { opacity: .55; }
.wa-tick-icon { display: block; }
.badge-wa-outbound {
    background: #059669;
    color: #fff;
    font-size: .62rem;
    font-weight: 600;
    vertical-align: middle;
    margin-left: .25rem;
}
.wa-compose-toolbar {
    display: flex; align-items: center; gap: .5rem; margin-bottom: .45rem;
}
.wa-content-type-select { max-width: 180px; font-size: .8rem; padding: .25rem .5rem; }
.wa-fields-panel { margin-bottom: .35rem; }
.wa-fields-panel .form-row { display: flex; gap: .5rem; }
.wa-fields-panel .form-row .form-control { flex: 1; }
.wa-media-thumb { max-width: 100%; max-height: 180px; border-radius: .35rem; display: block; margin-bottom: .25rem; }
.wa-media-video { max-width: 100%; max-height: 180px; border-radius: .35rem; display: block; }
.wa-media-audio { width: 100%; max-width: 320px; display: block; margin-bottom: .25rem; }
.wa-media-caption { font-size: .78rem; margin-top: .2rem; }
.wa-media-removed-thumb { opacity: .92; }
.wa-media-link { font-size: .82rem; word-break: break-all; }
.wa-ad-preview-link { display: block; color: inherit; text-decoration: none; }
.wa-ad-preview-link:hover { text-decoration: none; }
.wa-ad-preview {
    display: flex; gap: .55rem; overflow: hidden;
    background: rgba(0,0,0,.045); border: 1px solid rgba(0,0,0,.06);
    border-radius: .5rem; margin-bottom: .4rem;
}
.wa-ad-thumb {
    width: 92px; min-height: 92px; flex-shrink: 0;
    background: #d8d3ca; display: flex; align-items: center; justify-content: center;
    color: rgba(0,0,0,.45); font-size: .7rem; font-weight: 700;
}
.wa-ad-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wa-ad-thumb-placeholder { letter-spacing: .08em; }
.wa-ad-content { min-width: 0; padding: .5rem .55rem .45rem 0; }
.wa-ad-label {
    font-size: .62rem; color: rgba(0,0,0,.48); text-transform: uppercase;
    letter-spacing: .04em; margin-bottom: .12rem;
}
.wa-ad-title { font-weight: 700; font-size: .82rem; margin-bottom: .18rem; color: rgba(0,0,0,.82); }
.wa-ad-body {
    font-size: .72rem; color: rgba(0,0,0,.66); line-height: 1.3;
    max-height: 6.6em; overflow: hidden;
}
.wa-ad-url {
    font-size: .68rem; color: rgba(0,0,0,.45); margin-top: .25rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wa-ad-customer-text { margin-top: .15rem; }
.wa-reaction-display { font-size: 1.75rem; line-height: 1.2; }
.wa-bubble-reactions {
    display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .35rem;
    padding: .15rem .35rem; background: rgba(255,255,255,.85);
    border-radius: 999px; width: fit-content; max-width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.wa-bubble-out .wa-bubble-reactions { margin-left: auto; background: rgba(255,255,255,.9); }
.wa-reaction-chip { font-size: 1rem; line-height: 1.2; }
.wa-bubble-row[data-reactable="1"] { cursor: pointer; }
.wa-bubble-row[data-reactable="1"] .wa-bubble { transition: box-shadow .15s; }
.wa-bubble-row.wa-react-selected .wa-bubble { box-shadow: 0 0 0 2px #25D366; }
.wa-emoji-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.wa-emoji-btn {
    border: 1px solid var(--gray-200); background: #fff; border-radius: .45rem;
    font-size: 1.2rem; line-height: 1; padding: .25rem .4rem; cursor: pointer;
}
.wa-emoji-btn:hover { background: #f0faf4; border-color: #25D366; }
.wa-react-target {
    padding: .35rem .5rem; background: #fff; border-radius: .35rem;
    border: 1px dashed #25D366; margin-bottom: .35rem;
}
.wa-react-hint { margin: 0 0 .35rem; }
.wa-upload-row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; margin-bottom: .35rem; }
.wa-file-label { margin: 0; cursor: pointer; }
.wa-file-input { display: none; }
.wa-upload-preview { margin-bottom: .35rem; }

/* ===== Calendar ===== */
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 1px; background: var(--gray-200); border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg); overflow: hidden;
}
.cal-header {
    background: var(--gray-100); padding: .35rem; text-align: center;
    font-size: .7rem; font-weight: 600; color: var(--gray-500);
}
.cal-day {
    background: #fff; min-height: 80px; padding: .3rem; font-size: .7rem; position: relative;
}
.cal-day.other-month { background: var(--gray-50); color: var(--gray-400); }
.cal-day.today { background: var(--primary-bg); }
.cal-day-has-events { cursor: pointer; }
.cal-day-has-events:hover { background: var(--gray-50); }
.cal-day-has-events.today:hover { background: var(--primary-bg); filter: brightness(0.98); }
.cal-day-num { font-weight: 600; margin-bottom: .2rem; font-size: .75rem; }
.cal-day-more {
    display: block; width: 100%; margin-top: .1rem; padding: .1rem .2rem;
    border: none; border-radius: 3px; background: var(--gray-200); color: var(--gray-700);
    font-size: .58rem; font-weight: 600; cursor: pointer; text-align: left;
}
.cal-day-more:hover { background: var(--gray-300); }
.cal-day-modal { max-width: 420px; width: calc(100vw - 2rem); }
.cal-day-modal-list {
    list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto;
}
.cal-day-modal-list li {
    display: flex; gap: .65rem; align-items: flex-start;
    padding: .65rem 0; border-bottom: 1px solid var(--gray-100);
}
.cal-day-modal-list li:last-child { border-bottom: none; }
.cal-day-modal-list li.is-done,
.cal-day-modal-list li.is-expired { opacity: 0.65; }
.cal-day-modal-list li.is-done .cal-modal-title { text-decoration: line-through; }
.cal-modal-time {
    display: inline-block; min-width: 4.5rem; font-weight: 700; font-size: .78rem;
    color: var(--primary); font-variant-numeric: tabular-nums;
}
.cal-modal-title { font-size: .85rem; font-weight: 500; }
.cal-modal-meta { font-size: .72rem; color: var(--gray-500); margin-top: .15rem; }
.cal-status-tag {
    display: inline-block; font-size: .62rem; font-weight: 600;
    padding: .05rem .35rem; border-radius: 999px; background: var(--gray-100);
}
.cal-item-done, .cal-item-expired { opacity: 0.65; }
.cal-item-done .schedule-icon, .cal-item-expired .schedule-icon { filter: grayscale(0.8); }
.cal-row-inactive { opacity: 0.55; }
.cal-row-inactive td { color: var(--gray-500); }
.cal-mobile-today { border-left: 3px solid var(--primary); }
.cal-event {
    display: block; padding: .1rem .25rem; border-radius: 3px;
    margin-bottom: .1rem; font-size: .6rem; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; color: #fff;
    cursor: pointer; text-decoration: none;
}
.cal-event:hover { text-decoration: none; opacity: .85; }
.cal-event.type-call { background: var(--info); }
.cal-event.type-meeting { background: var(--primary); }
.cal-event.type-followup { background: var(--warning); }
.cal-event.is-done,
.cal-event.is-expired {
    background: var(--gray-400) !important;
    color: var(--gray-100) !important;
    opacity: 0.72;
}
.cal-event.is-done { text-decoration: line-through; }
.cal-event-co {
    display: inline-block; font-size: .55rem; font-weight: 700;
    background: rgba(0,0,0,.12); border-radius: 3px; padding: 0 3px;
    margin-right: 2px; vertical-align: middle;
}
.page-agent-dashboard .cal-grid { margin-bottom: 0; }

/* ===== Agent assign-to-me prompt ===== */
.assign-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    flex-wrap: wrap; margin-bottom: 1rem; padding: .85rem 1rem;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border: 2px solid #22c55e; border-radius: var(--radius-lg);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
    animation: assignBannerGlow 2.5s ease-in-out infinite;
}
.assign-banner-text { display: flex; flex-direction: column; gap: .15rem; font-size: .85rem; }
.assign-banner-text strong { color: #15803d; font-size: .95rem; }
.assign-banner-form { flex-shrink: 0; }
.btn-assign-me-pulse {
    padding: .55rem 1.35rem !important;
    font-size: .9rem !important;
    font-weight: 700 !important;
    animation: assignBtnPulse 2s ease-in-out infinite;
}
.modal-assign-required { text-align: center; max-width: 380px; }
.modal-assign-required p { margin-bottom: 1rem; line-height: 1.5; }
.assign-blocked-input { cursor: pointer; background: var(--gray-50); }
@keyframes assignBtnPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 0 0 12px rgba(34, 197, 94, 0);
    }
}
@keyframes assignBannerGlow {
    0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.22); }
}
.cal-nav { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.cal-nav h2 { font-size: 1rem; min-width: 160px; text-align: center; }

/* Calendar: mobile shows list instead of grid */
@media (max-width: 600px) {
    .cal-grid { display: none; }
    .cal-list-mobile { display: block !important; }
}
@media (min-width: 601px) {
    .cal-list-mobile { display: none !important; }
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5); z-index: 300;
    display: none; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 1.25rem; width: 100%; max-width: 500px; max-height: 85vh;
    overflow-y: auto; animation: modalSlideUp .2s ease;
    -webkit-overflow-scrolling: touch;
}
@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes modalSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal-lg { max-width: min(760px, 100%); }

/* Mobile: full-width bottom sheet so forms (e.g. New Lead) stay usable */
@media (max-width: 767px) {
    .modal-backdrop {
        align-items: flex-end;
        justify-content: stretch;
        padding: 0;
    }
    .modal {
        width: 100%;
        max-width: none;
        max-height: min(94dvh, 94vh);
        min-height: 50dvh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
        margin: 0;
        animation: modalSheetUp .22s ease;
        overscroll-behavior: contain;
    }
    .modal h2 {
        font-size: 1.05rem;
        margin-bottom: .75rem;
        padding-right: .25rem;
    }
    .modal .form-row {
        flex-direction: column;
        gap: 0;
    }
    .modal .form-row .form-group {
        flex: 1 1 100%;
        min-width: 100%;
        width: 100%;
    }
    .modal .form-control {
        font-size: 1rem;
        padding: .625rem .75rem;
    }
    .modal .btn-group {
        flex-direction: column;
        gap: .5rem;
        margin-top: 1rem;
        padding-top: .75rem;
        border-top: 1px solid var(--gray-100);
    }
    .modal .btn-group .btn { width: 100%; }
    .modal-lead-form {
        min-height: min(78dvh, 78vh);
    }
    .modal-assign-required,
    .cal-day-modal {
        min-height: 0;
        max-height: min(80dvh, 80vh);
    }
}

/* ===== Detail layout ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}
@media (min-width: 768px) {
    .detail-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
        gap: 1.5rem;
    }
}
.detail-section { margin-bottom: 1.25rem; }
.detail-section h3 { font-size: .9rem; margin-bottom: .625rem; padding-bottom: .3rem; border-bottom: 1px solid var(--gray-200); }
.detail-row { display: flex; justify-content: space-between; padding: .25rem 0; font-size: .825rem; gap: .5rem; }
.detail-row .label { color: var(--gray-500); flex-shrink: 0; }

/* ===== View toggle ===== */
.view-toggle { display: none; gap: 0; }
@media (min-width: 768px) { .view-toggle { display: flex; } }
.view-toggle .btn { border-radius: 0; }
.view-toggle .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.view-toggle .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.view-toggle .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Schedule list ===== */
.schedule-list { list-style: none; }
.schedule-item {
    padding: .55rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.schedule-item-main {
    display: flex;
    align-items: flex-start;
    gap: .625rem;
    min-width: 0;
    width: 100%;
}
.schedule-item-content {
    flex: 1 1 auto;
    min-width: 0;
}
.schedule-item-title {
    font-size: .9rem;
    font-weight: 650;
    color: var(--gray-900, #111827);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Primary booked time — bold only (no chip/box) */
.schedule-item-when {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .1rem .35rem;
    margin-top: .12rem;
    line-height: 1.35;
}
.schedule-item-time {
    font-size: .875rem;
    font-weight: 700;
    color: var(--gray-900, #111827);
    line-height: 1.35;
}
.schedule-item-meta {
    font-size: .78rem;
    color: var(--gray-600, #4b5563);
    line-height: 1.35;
}
.schedule-item .schedule-tz-display {
    margin-top: .15rem;
}
/* Tags/buttons: left-aligned under title (same column as title) */
.schedule-item-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: .3rem;
    margin-top: .4rem;
    padding-left: 0;
    width: 100%;
    min-width: 0;
}
.schedule-item-actions .btn,
.schedule-item-actions .badge,
.schedule-item-actions form {
    flex: 0 0 auto;
    white-space: nowrap;
}
.schedule-icon {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem; color: #fff; flex-shrink: 0;
    margin-top: .1rem;
}
.schedule-icon.type-call { background: var(--info); }
.schedule-icon.type-meeting { background: var(--primary); }
.schedule-icon.type-followup { background: var(--warning); }

/* ===== Quick actions (dashboard) ===== */
.quick-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.quick-action {
    display: flex; align-items: center; gap: .4rem;
    padding: .625rem 1rem; background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); font-size: .825rem; color: var(--gray-700);
    text-decoration: none; transition: all .15s; flex: 1; min-width: 120px; justify-content: center;
}
.quick-action:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; box-shadow: var(--shadow); }

/* ===== Pipeline bar (horizontal summary) ===== */
.pipeline-bar { display: flex; border-radius: var(--radius); overflow: hidden; height: 8px; margin-bottom: 1rem; }
.pipeline-bar-seg { transition: width .3s; }

/* ===== Pagination ===== */
.pagination {
    display: flex; align-items: center; gap: .25rem; flex-wrap: wrap;
    margin-top: 1rem; padding: .5rem 0;
}
.pagination-dots { color: var(--gray-400); padding: 0 .25rem; }

/* ===== Toast notifications ===== */
.toast-container {
    position: fixed; bottom: 1rem; right: 1rem;
    z-index: 400; display: flex; flex-direction: column; gap: .5rem;
    max-width: 360px; width: calc(100vw - 2rem);
    pointer-events: none;
}
.toast {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: .75rem 1rem; border-left: 4px solid var(--primary);
    pointer-events: auto; cursor: pointer;
    animation: toastSlideIn .3s ease;
    transition: opacity .3s, transform .3s;
}
.toast:hover { box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.toast-title { font-size: .75rem; font-weight: 600; color: var(--primary); margin-bottom: .15rem; }
.toast-body { font-size: .8rem; color: var(--gray-700); line-height: 1.35; }
.toast-meta { font-size: .65rem; color: var(--gray-400); margin-top: .2rem; }
.toast.toast-lead { border-left-color: var(--success); }
.toast.toast-lead .toast-title { color: var(--success); }
.toast.toast-status { border-left-color: var(--info); }
.toast.toast-status .toast-title { color: var(--info); }
.toast.toast-comment { border-left-color: #d97706; }
.toast.toast-comment .toast-title { color: #d97706; }
.toast.toast-schedule { border-left-color: #4f46e5; }
.toast.toast-schedule .toast-title { color: #4f46e5; }
@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== Inline status select ===== */
.status-select { outline: none; }
.status-select option { background: #fff; color: var(--gray-800); }

/* ===== Phone copy & short-name click hint ===== */
.phone-copy-wrap { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
.phone-copy-num { white-space: nowrap; }
.btn-copy-phone {
    border: none; background: transparent; cursor: pointer; padding: .1rem;
    line-height: 0; opacity: .55; vertical-align: middle; color: var(--gray-500);
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-copy-phone:hover { opacity: 1; color: var(--gray-700); }
.btn-copy-phone.is-copied { opacity: 1; color: #22c55e; }
.btn-copy-phone .icon-copy { display: block; }

/* Copy lead package for LLM (Activity header) */
.btn-copy-llm {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 2rem;
    padding: .35rem .65rem;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-copy-llm .icon-copy {
    display: block;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
.btn-copy-llm-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.btn-copy-llm.is-copied {
    color: #16a34a;
    border-color: #86efac;
    background: #f0fdf4;
}
@media (max-width: 767px) {
    .btn-copy-llm {
        min-height: 2.25rem;
        padding: .4rem .75rem;
        font-size: .8rem;
    }
    .btn-copy-llm .icon-copy {
        width: 16px;
        height: 16px;
    }
}

.phone-field-row { display: flex; align-items: center; gap: .35rem; }
.phone-field-row .form-control { flex: 1; min-width: 0; }
.phone-field-row .phone-copy-wrap .phone-copy-num { display: none; }
.lead-click-hint { font-size: .85em; color: var(--gray-600); font-weight: 500; white-space: nowrap; }
a .lead-click-hint { color: var(--primary, #4f46e5); }

/* ===== Utilities ===== */
.text-muted { color: var(--gray-500); }
.text-sm { font-size: .825rem; }
.text-xs { font-size: .7rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; min-width: 0; }
.flex-1 { flex: 1 1 0; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-danger { color: #dc2626; }
.p-1 { padding: .5rem; }
.form-control-sm { font-size: .8rem; padding: .35rem .5rem; }
.btn-xs { font-size: .75rem; padding: .15rem .45rem; line-height: 1.3; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--gray-400); }
.empty-state p { margin-top: .5rem; font-size: .875rem; }
.hidden { display: none !important; }

/* ===== Notification Bell ===== */
.notif-wrap {
    position: relative;
}
.notif-bell {
    background: none; border: none; cursor: pointer; position: relative;
    font-size: 1.25rem; line-height: 1; padding: .25rem .35rem;
    border-radius: var(--radius); transition: background .15s;
    color: var(--gray-600);
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 2.25rem; min-height: 2.25rem;
}
a.notif-bell:hover { text-decoration: none; color: var(--gray-700); }
.notif-bell:hover { background: var(--gray-100); }
.notif-dot {
    position: absolute; top: 2px; right: 2px;
    min-width: 16px; height: 16px; border-radius: 999px;
    background: #ef4444; color: #fff;
    font-size: .55rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; line-height: 1;
    border: 2px solid #fff;
}

/* ===== Notification Panel (desktop only — mobile/app go to /notifications) ===== */
.notif-panel {
    position: absolute; top: calc(100% + .35rem); right: 0;
    width: 360px; max-width: min(360px, calc(100vw - 1.5rem));
    max-height: 480px; overflow-y: auto;
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); z-index: 500;
    animation: toastSlideIn .2s ease;
    border: 1px solid var(--gray-100, #f3f4f6);
}
.notif-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: .5rem;
    padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100);
    font-size: .85rem; position: sticky; top: 0; background: #fff; z-index: 1;
}
.notif-panel-header .btn { flex-shrink: 0; white-space: nowrap; }
.notif-panel-body { padding: 0; max-height: 360px; overflow-y: auto; }
.notif-panel-footer {
    padding: .6rem .75rem; border-top: 1px solid var(--gray-100);
    position: sticky; bottom: 0; background: #fff;
}
/* Kill any leftover mobile scrim from older builds */
.notif-backdrop { display: none !important; }
@media (max-width: 899px) {
    /* Panel is unused on mobile (JS navigates); hide if still in DOM */
    .notif-panel { display: none !important; }
    .topbar-user-link {
        max-width: 6rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
.nav-notif-badge {
    margin-left: auto;
    min-width: 18px; height: 18px; border-radius: 999px;
    background: #ef4444; color: #fff;
    font-size: .6rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px;
}
.notif-filter-bar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.notif-page-list { padding: 0; overflow: hidden; }
.notif-page-item {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .85rem 1rem; border-bottom: 1px solid var(--gray-100);
    text-decoration: none; color: var(--gray-800);
    transition: background .15s;
}
.notif-page-item:last-child { border-bottom: none; }
.notif-page-item:hover { background: var(--gray-50); text-decoration: none; }
.notif-page-item.unread { background: #eff6ff; }
.notif-page-item.unread:hover { background: #dbeafe; }
.notif-page-item .notif-body-text {
    white-space: normal; overflow: visible; text-overflow: unset;
    margin-top: .2rem; line-height: 1.4;
}
.notif-co-badge {
    display: inline-block; background: var(--gray-100); color: var(--gray-600);
    font-size: .6rem; font-weight: 600; padding: .1rem .4rem; border-radius: 999px;
    margin-right: .35rem;
}
.notif-action-hint {
    font-size: .7rem; color: var(--gray-400); white-space: nowrap; margin-top: .15rem;
}
.notif-item {
    display: flex; gap: .6rem; padding: .6rem 1rem;
    border-bottom: 1px solid var(--gray-50);
    text-decoration: none; color: var(--gray-800);
    transition: background .15s;
}
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-icon {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--gray-100); color: var(--gray-500);
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; flex-shrink: 0; margin-top: 2px;
}
.notif-type-lead_created { background: #dcfce7; color: #16a34a; }
.notif-type-status_change { background: #dbeafe; color: #2563eb; }
.notif-type-comment { background: #fef3c7; color: #d97706; }
.notif-type-mention { background: #fce7f3; color: #db2777; }
.notif-type-schedule_created { background: #e0e7ff; color: #4f46e5; }
.notif-type-schedule_reminder { background: #fef3c7; color: #b45309; }
.notif-type-assignment { background: #f3e8ff; color: #7c3aed; }
.notif-content { flex: 1; min-width: 0; }
.notif-title-text { font-size: .78rem; font-weight: 500; line-height: 1.3; }
.notif-body-text { font-size: .7rem; color: var(--gray-500); margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: .6rem; color: var(--gray-400); margin-top: .15rem; }

/* ===== @Mention ===== */
.mention {
    background: #eff6ff; color: #2563eb; font-weight: 600;
    padding: .05rem .25rem; border-radius: 3px; font-size: inherit;
}
.mention-dropdown {
    position: absolute; left: 0; right: 0;
    bottom: calc(100% + 4px);
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 160px; overflow-y: auto; z-index: 1000;
    min-width: 180px;
}
.mention-item {
    padding: .4rem .75rem; font-size: .8rem; cursor: pointer;
    transition: background .1s;
}
.mention-item:hover { background: var(--primary); color: #fff; }

.wa-compose-text-wrap { position: relative; overflow: visible; }
.library-dropdown {
    position: absolute; left: 0; bottom: 100%;
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 200px; overflow-y: auto; z-index: 210;
    min-width: 240px; margin-bottom: .25rem;
}
.library-dropdown[hidden] { display: none !important; }
.library-item {
    padding: .45rem .75rem; font-size: .8rem; cursor: pointer;
    display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap;
    transition: background .1s;
}
.library-item:hover, .library-item-active { background: var(--primary); color: #fff; }
.library-item:hover .library-item-type,
.library-item-active .library-item-type,
.library-item:hover .msglib-kind-quick-reply,
.library-item-active .msglib-kind-quick-reply,
.library-item:hover .msglib-kind-outbound-template,
.library-item-active .msglib-kind-outbound-template {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    opacity: 1;
}
.library-item-slug { font-family: monospace; font-weight: 600; }
.library-item-title { flex: 1; min-width: 0; }
.library-item-type {
    font-size: .7rem; opacity: .85; text-transform: uppercase;
}

/* ===== Message Library (quick replies) & WhatsApp Templates ===== */
.page-message-library .page-header,
.page-whatsapp-templates .page-header { align-items: flex-start; }
.page-message-library .msglib-actions,
.page-whatsapp-templates .msglib-actions {
    display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
}
.page-message-library .msglib-actions form,
.page-whatsapp-templates .msglib-actions form { display: inline-flex; margin: 0; }
.page-message-library .msglib-actions .btn,
.page-whatsapp-templates .msglib-actions .btn { width: auto; max-width: 100%; }
.page-whatsapp-templates .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.page-whatsapp-templates .table-wrap td:last-child { min-width: 9rem; white-space: normal; }
@media (max-width: 640px) {
    .page-message-library .hide-mobile,
    .page-whatsapp-templates .hide-mobile { display: none !important; }
}
.msglib-kind-badge {
    display: inline-block;
    font-size: .7rem; font-weight: 600; line-height: 1.3;
    padding: .15rem .4rem; border-radius: 3px; white-space: nowrap;
}
.msglib-kind-quick-reply { background: #e0f2fe; color: #0369a1; }
.msglib-kind-outbound-template { background: #fef3c7; color: #92400e; }
.message-library-form .form-group { margin-bottom: .75rem; }
.message-library-form .form-group:last-child { margin-bottom: 0; }
.page-message-library-edit .card {
    background: transparent; box-shadow: none; padding: 0; margin-bottom: 0;
}
.page-message-library-edit .message-library-form {
    display: flex; flex-direction: column; gap: 0;
}
@media (max-width: 767px) {
    .page-message-library-edit .message-library-actions {
        flex-direction: column;
        gap: .5rem;
        padding-top: .75rem;
        margin-top: .5rem;
        border-top: 1px solid var(--gray-100);
    }
    .page-message-library-edit .message-library-actions .btn { width: 100%; }
}
.card-flat {
    background: #f8fafc; border: 1px solid var(--border, #e2e8f0);
    border-radius: .5rem; padding: 1rem; box-shadow: none;
}
.template-section-title { font-size: 1rem; margin: 0 0 .75rem; font-weight: 600; }
.template-var-toolbar { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.template-variables-editor .template-var-editor-row {
    display: grid; grid-template-columns: 4.5rem 1fr 1fr; gap: .75rem; align-items: start;
    padding: .5rem 0; border-bottom: 1px solid #e2e8f0;
}
.template-variables-editor .template-var-editor-row:last-child { border-bottom: none; }
.template-variables-editor .template-var-editor-key { padding-top: 1.65rem; }
.template-variables-editor .form-group { margin-bottom: 0; }
.message-template-form .template-section { margin-bottom: .75rem; }
.message-template-form .template-section:last-of-type { margin-bottom: 0; }
@media (max-width: 640px) {
    .template-variables-editor .template-var-editor-row { grid-template-columns: 1fr; }
    .template-variables-editor .template-var-editor-key { padding-top: 0; }
}
@media (max-width: 767px) {
    .page-whatsapp-templates .modal-lg .template-variables-editor .template-var-editor-row { grid-template-columns: 1fr; }
    .page-whatsapp-templates .modal-lg .template-variables-editor .template-var-editor-key { padding-top: 0; }
}
.wa-template-compose { padding: .5rem 0; }
.wa-template-vars .form-group { margin-bottom: .5rem; }
.wa-template-preview { background: var(--gray-50); padding: .5rem; border-radius: var(--radius); white-space: pre-wrap; }
.msglib-preview-img, .wa-upload-preview-img {
    max-width: 120px; max-height: 80px; border-radius: var(--radius);
    display: block;
}

/* ===== Mention toast type ===== */
.toast.toast-mention { border-left-color: #db2777; }
.toast.toast-mention .toast-title { color: #db2777; }

@media (max-width: 600px) {
    .toast-container {
        bottom: calc(var(--bottom-nav-h) + .75rem);
        left: .75rem; right: .75rem; top: auto;
        max-width: none; width: auto;
    }
    .toast { animation: toastSlideUp .3s ease; }
}

/* ===== Documentation pages ===== */
.page-docs .main-content { padding-bottom: 2rem; }
.docs-page .docs-card { padding: 0; overflow: hidden; }
.docs-content {
    padding: 1.25rem 1.5rem 2rem;
    max-width: 52rem;
    line-height: 1.65;
    font-size: .9rem;
    color: var(--gray-700);
}
.docs-content h2 {
    font-size: 1.15rem; color: var(--gray-900);
    margin: 1.75rem 0 .6rem; padding-top: .5rem;
    border-top: 1px solid var(--gray-100);
}
.docs-content h2:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.docs-content h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; color: var(--gray-800); }
.docs-content p { margin: 0 0 .75rem; }
.docs-content ul, .docs-content ol { margin: 0 0 1rem 1.25rem; }
.docs-content li { margin-bottom: .35rem; }
.docs-content code {
    background: var(--gray-100); padding: .1rem .35rem;
    border-radius: 4px; font-size: .82em;
}
.docs-lede {
    font-size: .95rem; color: var(--gray-600);
    padding: .75rem 1rem; background: var(--gray-50);
    border-radius: var(--radius); margin-bottom: 1rem;
}
.docs-toc {
    background: #f8fafc; border: 1px solid var(--gray-100);
    border-radius: var(--radius); padding: .75rem 1rem;
    margin-bottom: 1.5rem; font-size: .8rem;
}
.docs-toc ul { margin: .35rem 0 0; list-style: none; padding: 0; }
.docs-toc li { margin: .2rem 0; }
.docs-toc a { color: var(--primary); text-decoration: none; }
.docs-toc a:hover { text-decoration: underline; }
.docs-pre {
    background: #1e293b; color: #e2e8f0;
    padding: .85rem 1rem; border-radius: var(--radius);
    overflow-x: auto; font-size: .75rem; line-height: 1.5;
    margin: .5rem 0 1rem;
}
.docs-pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.docs-table {
    width: 100%; border-collapse: collapse;
    font-size: .8rem; margin: .5rem 0 1rem;
}
.docs-table th, .docs-table td {
    border: 1px solid var(--gray-200); padding: .4rem .6rem;
    text-align: left; vertical-align: top;
}
.docs-table th { background: var(--gray-50); font-weight: 600; }
.docs-method {
    display: inline-block; font-size: .65rem; font-weight: 700;
    padding: .15rem .4rem; border-radius: 4px;
    background: var(--gray-200); color: var(--gray-700);
    vertical-align: middle; margin-right: .25rem;
}
.docs-method-post { background: #dbeafe; color: #1d4ed8; }

/* ===== Master dashboard analytics ===== */
.dashboard-master .chip { text-decoration: none; }
.analytics-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}
@media (max-width: 900px) {
    .analytics-charts-grid { grid-template-columns: 1fr; }
}
.chart-wrap {
    position: relative;
    height: 220px;
    padding: .5rem 1rem 1rem;
}
.chart-wrap-tall { height: 280px; }
.analytics-leaderboards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}
@media (max-width: 768px) {
    .analytics-leaderboards { grid-template-columns: 1fr; }
}
.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--gray-100);
}
.leaderboard-item:last-child { border-bottom: none; }
.leaderboard-rank {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: .7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.leaderboard-item:first-child .leaderboard-rank {
    background: #fef3c7;
    color: #b45309;
}
.leaderboard-body { flex: 1; min-width: 0; }
.leaderboard-name { font-size: .85rem; font-weight: 600; }
.leaderboard-meta { margin-top: .2rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.leaderboard-score {
    font-size: .9rem;
    font-weight: 700;
    color: var(--primary);
}

.analytics-chart-split {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1rem;
    padding: 0 0 .5rem;
}
@media (max-width: 900px) {
    .analytics-chart-split { grid-template-columns: 1fr; }
}
.chart-picker-panel {
    border-left: 1px solid var(--gray-100);
    padding: .75rem 1rem 1rem;
    max-height: 320px;
    display: flex;
    flex-direction: column;
}
@media (max-width: 900px) {
    .chart-picker-panel { border-left: none; border-top: 1px solid var(--gray-100); max-height: 240px; }
}
.chart-picker-list {
    overflow-y: auto;
    flex: 1;
    margin-top: .35rem;
}
.chart-picker-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .25rem;
    font-size: .78rem;
    cursor: pointer;
    border-radius: 4px;
}
.chart-picker-row:hover { background: var(--gray-50); }
.chart-picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-picker-stat { color: var(--gray-400); font-size: .7rem; white-space: nowrap; }
.table-wrap-scroll { max-height: 420px; overflow: auto; }

/* ===== Agent / combined mobile overflow containment ===== */
.page-agent-dashboard .container,
.page-calendar .container,
.combined-leads-page .container {
    max-width: 100%;
    min-width: 0;
}
.page-agent-dashboard .card-header,
.combined-leads-page .combined-leads-toolbar,
.combined-leads-page .d-flex.justify-between {
    flex-wrap: wrap;
}
@media (max-width: 767px) {
    .page-agent-dashboard .table-wrap,
    .combined-leads-page .table-wrap {
        max-width: 100%;
    }
    .combined-leads-page .combined-leads-table-card {
        display: none;
    }
}
@media (min-width: 768px) {
    .combined-leads-page .lead-list-mobile {
        display: none;
    }
}

/* ===== Company pages mobile overflow containment ===== */
@media (max-width: 767px) {
    body.page-company {
        overflow-x: hidden;
    }
}
.page-company .container,
.page-company .leads-filter-form,
.page-company .leads-search-hero {
    max-width: 100%;
}
.page-company .topbar-title {
    flex: 1;
    overflow: hidden;
}
.page-company .card {
    max-width: 100%;
    min-width: 0;
}
.page-company .company-leads-table-card {
    overflow: hidden;
}
.page-company .card-header,
.page-company .card-header.d-flex,
.page-company .leads-bulk-toolbar,
.page-company .leads-per-page-toolbar {
    flex-wrap: wrap;
    gap: .5rem;
}
.page-company .schedule-item,
.page-company .dashboard-recent-lead-item,
.page-company .stream-item {
    min-width: 0;
    max-width: 100%;
}
.page-company .schedule-list,
.page-company .dashboard-recent-leads {
    padding: 0;
    margin: 0;
}
.page-company .filter-chips {
    max-width: 100%;
}
.page-company .analytics-charts-grid,
.page-company .stat-grid,
.page-company .detail-grid {
    max-width: 100%;
    min-width: 0;
}
.page-company .detail-grid > div {
    min-width: 0;
    max-width: 100%;
}
.page-company .page-header.d-flex {
    flex-wrap: wrap;
    gap: .5rem;
}
@media (max-width: 767px) {
    .page-company .company-leads-table-card,
    .page-company .company-leads-bulk-toolbar {
        display: none;
    }
    .page-company .toast-container {
        left: .75rem;
        right: .75rem;
        width: auto;
        max-width: none;
    }
}
@media (min-width: 768px) {
    .page-company .company-leads-list-mobile {
        display: none;
    }
}

/* ===== Lead tags ===== */
.lead-tag-chips { display: inline-flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.lead-tag-chip {
    display: inline-flex; align-items: center;
    padding: .15rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 600; line-height: 1.3;
    color: #fff; background: var(--tag-color, #6366f1);
    max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lead-tag-picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.lead-tag-pick { display: inline-flex; align-items: center; cursor: pointer; margin: 0; }
.lead-tag-pick input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.lead-tag-pick input:not(:checked) + .lead-tag-chip {
    background: transparent; color: var(--gray-700);
    box-shadow: inset 0 0 0 1.5px var(--tag-color, #6366f1);
}
.lead-tag-pick input:focus-visible + .lead-tag-chip { outline: 2px solid var(--primary); outline-offset: 2px; }
.lead-tag-picker-filter .lead-tag-chip { font-size: .7rem; }

/* ===== WhatsApp template demo bubble ===== */
.wa-template-demo {
    max-width: 280px;
    background: #dcf8c6;
    border-radius: 8px 8px 2px 8px;
    padding: .65rem .75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    font-size: .85rem;
    color: #111;
    line-height: 1.4;
    position: relative;
}
.wa-template-demo-wrap {
    background: #e5ddd5;
    padding: 1rem;
    border-radius: var(--radius);
    display: inline-block;
    min-width: 200px;
}
.wa-template-demo-header { font-weight: 700; margin-bottom: .35rem; }
.wa-template-demo-media {
    background: rgba(0,0,0,.06);
    border-radius: 6px;
    padding: 1.25rem .5rem;
    text-align: center;
    color: var(--gray-600);
    font-size: .75rem;
    margin-bottom: .4rem;
}
.wa-template-demo-body { white-space: pre-wrap; word-break: break-word; }
.wa-template-demo-footer { margin-top: .4rem; font-size: .72rem; color: #667781; }
.wa-template-demo-buttons { margin-top: .5rem; border-top: 1px solid rgba(0,0,0,.06); padding-top: .35rem; }
.wa-template-demo-btn {
    display: block; text-align: center; color: #027eb5;
    font-size: .8rem; font-weight: 500; padding: .35rem 0;
}
.wa-template-demo-meta { font-size: .7rem; color: var(--gray-500); margin-top: .35rem; }

/* ===== WA Marketing ===== */
.wa-mkt-stats { display: flex; flex-wrap: wrap; gap: .75rem; }
.wa-mkt-stat {
    background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: .5rem .85rem; min-width: 5.5rem;
}
.wa-mkt-stat strong { display: block; font-size: 1.1rem; }
.wa-mkt-stat span { font-size: .7rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; }

/* WA Marketing sequence builder */
.wa-mkt-seq-steps { display: flex; flex-direction: column; gap: .75rem; }
.wa-mkt-seq-step {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    position: relative;
}
.wa-mkt-seq-step + .wa-mkt-seq-step::before {
    content: '↓';
    position: absolute;
    top: -0.85rem;
    left: 1rem;
    color: var(--gray-400);
    font-size: .9rem;
    background: var(--gray-50);
    padding: 0 .25rem;
}

/* ===== Entity picker (search-first multi-select) ===== */
.entity-picker { position: relative; }
.entity-picker-chips {
  display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .4rem; min-height: 0;
}
.entity-picker-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--gray-100, #f4f4f5); border: 1px solid var(--gray-200, #e4e4e7);
  border-radius: 999px; padding: .15rem .55rem .15rem .65rem; font-size: .8rem;
}
.entity-picker-chip-x {
  border: 0; background: transparent; cursor: pointer; font-size: 1rem; line-height: 1;
  color: var(--gray-500); padding: 0 .15rem; border-radius: 50%;
}
.entity-picker-chip-x:hover { color: var(--danger, #dc2626); background: #fee2e2; }
.entity-picker-controls { position: relative; }
.entity-picker-dropdown {
  position: absolute; z-index: 40; left: 0; right: 0; top: 100%;
  margin-top: 2px; max-height: 240px; overflow: auto;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius, 6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  -webkit-overflow-scrolling: touch;
}
/* When portaled to body (fixed), keep list scrollable and above cards/modals */
body > .entity-picker-dropdown {
  position: fixed;
  z-index: 4000;
  margin-top: 0;
}
.card:has(.entity-picker),
.form-group:has(.entity-picker),
.container:has(.entity-picker) {
  overflow: visible;
}
.entity-picker-option {
  display: block; width: 100%; text-align: left; border: 0; background: #fff;
  padding: .5rem .75rem; cursor: pointer; border-bottom: 1px solid var(--gray-100, #f4f4f5);
}
.entity-picker-option:hover, .entity-picker-option.is-active { background: var(--gray-50, #fafafa); }
.entity-picker-option.is-selected { opacity: .7; }
.entity-picker-option-title { font-size: .875rem; font-weight: 500; }
.entity-picker-option-sub { font-size: .75rem; color: var(--gray-500); }
.entity-picker-option-badge { font-size: .65rem; color: var(--primary, #2563eb); float: right; }
.entity-picker-msg { padding: .65rem .75rem; font-size: .8rem; color: var(--gray-500); }
.entity-picker-hidden { display: none; }
