/* MotionOptima Portal — Light theme on teal brand
   Structure: white main content, teal-dark sidebar, teal primary actions */
:root {
    /* Brand palette */
    --mo-teal:        #1D9E75;
    --mo-teal-dark:   #085041;
    --mo-teal-light:  #9FE1CB;
    --mo-teal-faint:  #E1F5EE;
    --mo-brand-blue:  #378ADD;

    /* Generic aliases so pages can use either name */
    --color-primary:       var(--mo-teal);
    --color-primary-dark:  var(--mo-teal-dark);
    --color-primary-light: var(--mo-teal-light);
    --color-primary-faint: var(--mo-teal-faint);

    /* Legacy aliases used across the portal */
    --accent:         var(--mo-teal);
    --accent-hover:   var(--mo-teal-dark);
    --accent-glow:    rgba(29, 158, 117, .15);

    /* Surfaces — now light */
    --bg-primary:     #F8FAFB;
    --bg-secondary:   #FFFFFF;
    --bg-card:        #FFFFFF;
    --bg-card-hover:  var(--mo-teal-faint);
    --bg-input:       #FFFFFF;

    --border-color:   var(--mo-teal-faint);
    --border-hover:   var(--mo-teal-light);

    --text-primary:   #0F172A;
    --text-secondary: #374151;
    --text-muted:     #6B7280;

    /* Status colors */
    --success: #059669;
    --warning: #d97706;
    --danger:  #dc2626;
    --info:    #3b82f6;
    --google:  #4285f4;
    --meta:    #1877f2;
    --tiktok:  #ff0050;

    --radius:     .75rem;
    --radius-sm:  .5rem;
    --shadow:     0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg:  0 8px 32px rgba(15, 23, 42, .08);
    --transition: all .2s ease;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    font-size: .9rem;
    line-height: 1.6;
}
::selection    { background: var(--mo-teal-light); color: var(--mo-teal-dark); }
:focus-visible { outline: 2px solid var(--mo-teal); outline-offset: 2px; }

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px;
    background: var(--mo-teal-dark);
    border-right: 1px solid rgba(0, 0, 0, .15);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform .3s ease;
}
.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex; align-items: center; gap: .75rem;
    text-decoration: none; color: #fff;
}
.sidebar-brand img {
    display: block;
    height: 40px;
    width: auto;
    max-width: 100%;
}
.sidebar-brand .brand-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--mo-teal);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .9rem; color: #fff;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.sidebar-section {
    padding: 16px 16px 4px;
    margin-top: 0;
    font-size: 10px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(159, 225, 203, .5);
}
.sidebar--light .sidebar-section { color: #9ca3af; }

.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: 10px 16px;
    margin: 2px 8px;
    color: var(--mo-teal-light); text-decoration: none;
    transition: var(--transition); font-weight: 500;
    font-size: 13px;
    border-left: 3px solid transparent;
    border-radius: 8px;
}
.nav-item:hover {
    background: rgba(255, 255, 255, .07);
    color: #ffffff;
}
.nav-item.active {
    color: #ffffff;
    background: rgba(29, 158, 117, .3);
    border-left-color: var(--mo-teal);
    padding-left: 13px;
}
.nav-item i { width: 18px; text-align: center; font-size: .9rem; }

/* Light sidebar (Business / Sales) */
.sidebar--light {
    background: #fff;
    border-right: 1px solid var(--mo-teal-faint);
}
.sidebar--light .sidebar-brand { border-bottom-color: var(--mo-teal-faint); color: var(--mo-teal-dark); }
.sidebar--light .nav-item {
    color: #374151;
}
.sidebar--light .nav-item:hover {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
}
.sidebar--light .nav-item.active {
    background: var(--mo-teal-faint);
    color: var(--mo-teal);
    border-left-color: var(--mo-teal);
}
.sidebar--light .sidebar-footer {
    border-top-color: var(--mo-teal-faint);
}
.sidebar--light .user-badge { color: var(--text-secondary); }
.sidebar--light .user-name { color: var(--mo-teal-dark); }
.sidebar--light .user-role { color: var(--text-muted); }
.sidebar--light .user-avatar { background: var(--mo-teal); }

/* Mobile collapse to icons-only is handled in the responsive section */
@media (min-width: 769px) {
    .sidebar.is-collapsed { width: 56px; }
    .sidebar.is-collapsed .sidebar-brand img,
    .sidebar.is-collapsed .admin-pill,
    .sidebar.is-collapsed .sidebar-section,
    .sidebar.is-collapsed .nav-item span:not(.nav-tooltip),
    .sidebar.is-collapsed .user-info { display: none; }
    .sidebar.is-collapsed .nav-item { justify-content: center; padding: 10px; }
    .sidebar.is-collapsed ~ .main-content { margin-left: 56px; }
}
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.user-badge {
    display: flex; align-items: center; gap: .75rem;
    text-decoration: none; color: var(--mo-teal-light);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--mo-teal);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; color: #fff;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: .85rem; font-weight: 600; color: #ffffff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: .7rem; color: rgba(159, 225, 203, .7); }

/* Pill next to the sidebar logo (Admin / Business / Sales) */
.admin-pill {
    background: var(--mo-teal);
    color: #fff;
    font-size: 11px; font-weight: 500;
    padding: 2px 8px; border-radius: 999px;
    margin-left: 8px; vertical-align: middle;
    line-height: 1.5;
}
.admin-pill--blue { background: var(--mo-brand-blue); }
.admin-pill--dark { background: var(--mo-teal-dark); color: var(--mo-teal-light); }

/* ── Main Content ────────────────────────────────────── */
.main-content { margin-left: 260px; padding: 2rem; min-height: 100vh; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-title {
    font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em;
    margin: 0; color: var(--mo-teal-dark);
}
.page-subtitle { color: var(--text-muted); font-size: .85rem; margin: .25rem 0 0; }

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--mo-teal-faint);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover { border-color: var(--mo-teal-light); }
.card-header-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; padding-bottom: .75rem;
    border-bottom: 1px solid var(--mo-teal-faint);
}
.card-title { font-weight: 600; font-size: 1rem; margin: 0; color: var(--mo-teal-dark); }

/* ── Stat / KPI Cards ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }

.stat-card, .kpi-card {
    background: #ffffff; border: 1px solid var(--mo-teal-faint);
    border-radius: 14px; padding: 22px 24px;
    position: relative;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.stat-card:hover, .kpi-card:hover { border-color: var(--mo-teal-light); }
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.accent::before  { background: var(--mo-teal); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.info::before    { background: var(--info); }
.stat-card.danger::before  { background: var(--danger); }

.stat-card__value, .kpi-card__value, .stat-value {
    font-size: 30px; font-weight: 600;
    color: var(--mo-teal-dark); line-height: 1;
    letter-spacing: -.02em;
}
.stat-card__label, .kpi-card__label, .stat-label {
    font-size: 12px; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-top: 6px; font-weight: 500;
}
.stat-card__delta, .stat-change, .kpi-card__delta-up, .kpi-card__delta-down {
    font-size: 12px; font-weight: 500; margin-top: 8px;
}
.stat-card__delta--up, .stat-change.up, .kpi-card__delta-up     { color: var(--mo-teal); }
.stat-card__delta--down, .stat-change.down, .kpi-card__delta-down { color: #dc2626; }
.stat-icon { position: absolute; top: 1.25rem; right: 1.25rem; font-size: 1.5rem; color: var(--mo-teal-light); opacity: .8; }

.stat-card--featured, .kpi-card--featured { border-left: 3px solid var(--mo-teal); padding-left: 21px; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap {
    background: var(--bg-card); border-radius: 12px;
    border: 1px solid var(--mo-teal-faint); overflow: hidden;
    box-shadow: var(--shadow);
}
.table-wrap table, .table { width: 100%; border-collapse: collapse; }
.table-wrap table thead th, .table-wrap thead th, .table thead th {
    background: var(--mo-teal-faint);
    color: var(--mo-teal-dark);
    font-size: 11px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1.5px solid var(--mo-teal-light);
    padding: 10px 14px; text-align: left;
}
.table-wrap table tbody td, .table-wrap tbody td, .table tbody td {
    padding: 11px 14px; font-size: 14px;
    border-bottom: 1px solid var(--mo-teal-faint);
    vertical-align: middle;
}
.table-wrap table tbody tr:hover, .table-wrap tbody tr:hover, .table tbody tr:hover {
    background: var(--mo-teal-faint); cursor: pointer;
}
.table-wrap tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: none; }
.table-wrap table tbody tr.no-hover, .table tbody tr.no-hover { cursor: default; }
.table-wrap table tbody tr.no-hover:hover, .table tbody tr.no-hover:hover { background: transparent; }
@media (max-width: 640px) {
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
.table tbody tr.selected {
    background: rgba(29, 158, 117, .08);
    border-left: 3px solid var(--mo-teal);
}

/* ── Status Badges ───────────────────────────────────── */
.badge,
[class^="badge-"], [class*=" badge-"] {
    display: inline-block;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    white-space: nowrap;
    line-height: 1.4;
}
.badge { display: inline-flex; align-items: center; gap: .3rem; }

/* Solid teal — primary success states */
.badge-active, .badge-qualified, .badge-confirmed,
.badge-active-campaign, .badge-paid {
    background: var(--mo-teal); color: #ffffff;
}

/* Faint teal — neutral / planned states */
.badge-prospect, .badge-scheduled, .badge-trial,
.badge-new, .badge-draft, .badge-accrued {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
}

/* Light teal — soft active states */
.badge-contacted {
    background: var(--mo-teal-light); color: var(--mo-teal-dark);
}

/* Dark teal on light teal — completed/booked emphasis */
.badge-completed, .badge-booked {
    background: var(--mo-teal-dark); color: var(--mo-teal-light);
}

/* Red — destructive / churn / failure */
.badge-churn, .badge-churned, .badge-cancelled,
.badge-disqualified, .badge-reversed {
    background: #fee2e2; color: #991b1b;
}

/* Amber — paused / past-due / warning */
.badge-paused, .badge-past-due, .badge-noshow,
.badge-onboarding, .badge-nurture, .badge-warning {
    background: #fef3c7; color: #92400e;
}

/* Gray — inactive / ended / muted */
.badge-unresponsive, .badge-ended, .badge-manual {
    background: #f3f4f6; color: #6b7280;
}

/* Source badges */
.badge-google { background: rgba(66,133,244,.15); color: #1a4e99; }
.badge-meta   { background: rgba(24,119,242,.15); color: #0e4aa8; }

/* Brand blue — secondary action color (sales pill, secondary attribution) */
.badge-blue, .badge-self-claimed {
    background: rgba(55, 138, 221, .15); color: var(--mo-brand-blue);
}

/* Priority pills */
.badge-priority-high   { background: #fee2e2; color: #991b1b; }
.badge-priority-medium { background: #fef3c7; color: #92400e; }
.badge-priority-low    { background: #f3f4f6; color: #6b7280; }

/* Tier badges */
.badge-tier-starter { background: #f3f4f6; color: #6b7280; }
.badge-tier-growth  { background: var(--mo-teal); color: #fff; }
.badge-tier-pro     { background: var(--mo-teal-dark); color: var(--mo-teal-light); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .55rem 1.15rem; border-radius: 8px;
    font-size: .85rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
    text-decoration: none; line-height: 1;
}
.btn-primary, button[type="submit"].btn-primary, .btn.btn-primary {
    background: var(--mo-teal);
    border-color: var(--mo-teal);
    color: #ffffff;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--mo-teal-dark);
    border-color: var(--mo-teal-dark);
    color: #ffffff;
}
.btn-primary:active { transform: scale(0.98); }

.btn-outline, .btn-outline-primary {
    background: transparent;
    color: var(--mo-teal);
    border-color: var(--mo-teal);
}
.btn-outline:hover, .btn-outline-primary:hover {
    background: var(--mo-teal-faint);
    color: var(--mo-teal-dark);
    border-color: var(--mo-teal);
}

.btn-ghost-primary {
    color: var(--mo-teal);
    background: transparent;
    border: none;
}
.btn-ghost-primary:hover {
    color: var(--mo-teal-dark);
    background: var(--mo-teal-faint);
    border-radius: 6px;
}

.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .35rem; }
.form-input, .form-select, input[type="text"], input[type="email"],
input[type="password"], input[type="tel"], input[type="number"],
input[type="date"], textarea, select {
    width: 100%; padding: .6rem .85rem; font-size: .9rem;
    background: var(--bg-input);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: var(--text-primary);
    transition: border-color .15s ease, box-shadow .15s ease;
    outline: none;
    font-family: inherit;
}
.form-input:focus, .form-select:focus,
input:focus, textarea:focus, select:focus {
    border-color: var(--mo-teal);
    box-shadow: 0 0 0 3px rgba(29, 158, 117, .15);
}
.form-input::placeholder, input::placeholder, textarea::placeholder { color: #9ca3af; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--mo-teal); }

/* ── Timeline ────────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: ''; position: absolute; left: 7px; top: 0; bottom: 0;
    width: 2px; background: var(--mo-teal-faint);
}
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-dot {
    position: absolute; left: -2rem; top: .2rem;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--bg-card); border: 2px solid var(--mo-teal);
}
.timeline-dot.success { border-color: var(--success); }
.timeline-dot.warning { border-color: var(--warning); }
.timeline-dot.danger  { border-color: var(--danger); }
.timeline-time  { font-size: .72rem; color: var(--text-muted); }
.timeline-title { font-weight: 600; font-size: .85rem; margin: .15rem 0; color: var(--text-primary); }
.timeline-body  { font-size: .82rem; color: var(--text-secondary); }

/* ── Chart Container ─────────────────────────────────── */
.chart-container { position: relative; width: 100%; height: 280px; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* ── Auth pages (login, register, forgot, reset, confirm) ─── */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--mo-teal-faint) 0%, #ffffff 60%, var(--bg-primary) 100%);
    padding: 24px 20px;
}
.auth-card {
    width: 100%; max-width: 420px;
    padding: 2.5rem;
    background: #ffffff;
    border: 1px solid var(--mo-teal-faint);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.auth-card--wide { max-width: 520px; }

.auth-brand { text-align: center; margin-bottom: 1.75rem; }
.auth-brand img { display: block; margin: 0 auto; height: 63px; width: auto; max-width: 100%; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin: .75rem 0 0; }

.auth-lede { color: var(--text-secondary); font-size: .88rem; margin: 0 0 1.25rem; line-height: 1.55; }
.auth-hint { color: var(--text-muted); font-size: .8rem; margin: .5rem 0 1rem; line-height: 1.55; }

.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.auth-subtle-link { font-size: .78rem; color: var(--mo-teal); font-weight: 600; text-decoration: none; }
.auth-subtle-link:hover { color: var(--mo-teal-dark); text-decoration: underline; }
.auth-subtle-center { display: inline-block; margin-top: 1rem; text-align: center; }

.auth-btn { justify-content: center; margin-top: .5rem; }
.auth-inline-form { margin: 0 0 .75rem; text-align: left; }
.auth-inline-form .form-group { margin-bottom: .75rem; }

.auth-error {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: var(--radius-sm); padding: .65rem 1rem;
    color: #991b1b; font-size: .82rem; margin-bottom: 1rem;
    display: flex; align-items: center; gap: .5rem;
}
.auth-info {
    background: #ecfdf5; border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm); padding: .55rem .85rem;
    color: #065f46; font-size: .82rem; margin: 0 0 1rem;
    display: flex; align-items: center; gap: .5rem;
}

.auth-footer {
    text-align: center; margin-top: 1.5rem; padding-top: 1.25rem;
    border-top: 1px solid var(--mo-teal-faint);
    font-size: .85rem; color: var(--text-secondary);
}
.auth-footer a { color: var(--mo-teal); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { color: var(--mo-teal-dark); text-decoration: underline; }

/* Two-column form row that collapses on narrow auth cards */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ── Confirmation / result states (used on success + failure pages) ─── */
.auth-confirm { text-align: center; }
.auth-confirm-icon {
    width: 64px; height: 64px; margin: 0 auto 1.25rem;
    border-radius: 50%; background: var(--mo-teal-faint);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; color: var(--mo-teal-dark);
}
.auth-confirm-icon--success { background: #d1fae5; color: #047857; }
.auth-confirm-icon--error   { background: #fee2e2; color: #991b1b; }
.auth-confirm h2 {
    font-size: 1.25rem; font-weight: 700; margin: 0 0 .5rem;
    color: var(--mo-teal-dark); letter-spacing: -.01em;
}
.auth-confirm p {
    font-size: .88rem; color: var(--text-secondary); line-height: 1.6;
    margin: 0 0 .5rem;
}

/* ── Password strength meter + live checks ───────────────── */
.password-strength {
    margin-top: .6rem; padding: .65rem .85rem;
    background: var(--mo-teal-faint);
    border: 1px solid var(--mo-teal-light);
    border-radius: var(--radius-sm);
    font-size: .78rem;
}
.password-strength-bar {
    height: 6px; border-radius: 999px;
    background: rgba(8, 80, 65, .1);
    overflow: hidden; margin-bottom: .4rem;
}
.password-strength-bar span {
    display: block; height: 100%; width: 0;
    background: #dc2626; border-radius: inherit;
    transition: width .18s ease, background .18s ease;
}
.password-strength-bar span[data-level="weak"]    { background: #dc2626; }
.password-strength-bar span[data-level="medium"]  { background: #d97706; }
.password-strength-bar span[data-level="strong"]  { background: var(--mo-teal); }
.password-strength-label {
    font-size: .72rem; font-weight: 600; letter-spacing: .02em;
    margin-bottom: .45rem; color: var(--text-muted);
    text-transform: uppercase;
}
.password-strength-label[data-level="weak"]   { color: #991b1b; }
.password-strength-label[data-level="medium"] { color: #92400e; }
.password-strength-label[data-level="strong"] { color: var(--mo-teal-dark); }

.password-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.password-checks li {
    display: flex; align-items: center; gap: .5rem;
    color: #6b7280; line-height: 1.4;
}
.password-checks li i { font-size: .72rem; color: #9ca3af; width: 14px; text-align: center; }
.password-checks li.is-ok { color: var(--mo-teal-dark); }
.password-checks li.is-ok i { color: var(--mo-teal); }

.password-match {
    margin-top: .45rem; padding: .35rem .65rem;
    font-size: .78rem; color: #991b1b;
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; gap: .5rem;
}
.password-match i { font-size: .75rem; }
.password-match.is-ok {
    color: var(--mo-teal-dark);
    background: var(--mo-teal-faint);
    border-color: var(--mo-teal-light);
}
.password-match.is-ok i { color: var(--mo-teal); }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 60px 24px;
    color: #6b7280;
}
.empty-state i, .empty-state__icon {
    font-size: 36px; margin-bottom: 12px; display: block;
    color: var(--mo-teal-light); opacity: 0.4;
}
.empty-state__title {
    font-size: 16px; font-weight: 500; color: #374151;
    margin: 0 0 6px;
}
.empty-state__text {
    font-size: 14px; line-height: 1.6; margin: 0;
}
.empty-state p { margin: 0; }
.empty-state__actions { margin-top: 1rem; display: inline-flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }

/* ── Loading spinner ─────────────────────────────────── */
.spinner-border, .spinner-grow { color: var(--mo-teal) !important; }
.mo-spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--mo-teal-faint);
    border-top-color: var(--mo-teal);
    border-radius: 50%;
    animation: mo-spin 0.7s linear infinite;
}
@keyframes mo-spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────── */
.mobile-toggle {
    display: none; position: fixed; top: 1rem; left: 1rem; z-index: 200;
    background: var(--mo-teal-dark); border: 1px solid var(--mo-teal-dark);
    color: #ffffff; padding: .5rem .75rem;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 1.1rem;
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
    .mobile-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ───────────────────────────────────────── */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-accent, .text-primary-teal { color: var(--mo-teal) !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }
.w-full { width: 100%; }
.overflow-auto { overflow-x: auto; }
a { color: var(--mo-teal); }
a:hover { color: var(--mo-teal-dark); }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--mo-teal-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--mo-teal); }

/* ── Error pages ─────────────────────────────────────── */
.error-page {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary); color: var(--text-primary);
    min-height: 100vh; margin: 0;
    display: flex; align-items: center; justify-content: center;
}
.error-shell { max-width: 520px; padding: 3rem 1.5rem; text-align: center; }
.error-code {
    font-size: 6rem; font-weight: 800;
    color: var(--mo-teal); line-height: 1; margin-bottom: 1rem;
}
.error-title   { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.5rem; color: var(--mo-teal-dark); }
.error-message { color: var(--text-muted); margin: 0 0 2rem; }
.error-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.error-footer  { margin-top: 3rem; color: var(--text-muted); font-size: 0.85rem; }

/* ============================================================
   Onboarding v2 — instructional step cards
   ============================================================ */
.onboarding-summary {
    padding: 1.25rem 1.5rem;
}
.onboarding-summary-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.onboarding-summary-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .25rem;
}
.onboarding-summary-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.onboarding-summary-percent {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--mo-teal);
    line-height: 1;
    letter-spacing: -0.02em;
}
.onboarding-summary-percent span { font-size: 1rem; font-weight: 500; color: var(--text-muted); }

.onboarding-progress {
    height: 8px;
    border-radius: 999px;
    background: var(--mo-teal-faint);
    overflow: hidden;
    margin-bottom: 1rem;
}
.onboarding-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--mo-teal) 0%, var(--mo-teal-light) 100%);
    transition: width .3s ease;
}

.onboarding-next {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    background: var(--mo-teal-faint);
    border: 1px solid var(--mo-teal-light);
    border-radius: var(--radius-sm);
    color: var(--mo-teal-dark);
    font-size: .9rem;
}
.onboarding-next i { color: var(--mo-teal); }
.onboarding-next > span { flex: 1; }
.onboarding-next-done {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.onboarding-steps-v2 {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.onboarding-step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.onboarding-step-card:hover { box-shadow: var(--shadow-lg); }
.onboarding-step-card.is-done {
    border-color: #a7f3d0;
    background: linear-gradient(180deg, #f0fdf4 0%, var(--bg-card) 24%);
}
/* <details>/<summary> reset for the collapsible step card */
details.onboarding-step-card > summary { list-style: none; cursor: pointer; }
details.onboarding-step-card > summary::-webkit-details-marker { display: none; }
.onboarding-step-head {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
}
details.onboarding-step-card[open] > .onboarding-step-head,
details.onboarding-step-card[open] > summary.onboarding-step-head {
    border-bottom: 1px solid var(--border-color);
}
details.onboarding-step-card.is-done[open] > summary.onboarding-step-head { border-bottom-color: #bbf7d0; }
.onboarding-step-chevron {
    color: var(--text-muted);
    font-size: .9rem;
    transition: transform .15s ease;
}
details.onboarding-step-card[open] > summary .onboarding-step-chevron { transform: rotate(180deg); }
.onboarding-step-foot {
    padding: 0 1.5rem 1.25rem;
    display: flex;
    justify-content: flex-end;
}
.onboarding-step-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--mo-teal-faint);
    color: var(--mo-teal-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}
.is-done .onboarding-step-num {
    background: var(--mo-teal);
    color: #fff;
}
.onboarding-step-title h3 {
    margin: 0 0 .15rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: .55rem;
}
.onboarding-step-title h3 i { color: var(--mo-teal); font-size: .95em; }
.onboarding-step-status { font-size: .8rem; }

.onboarding-step-body {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem 1.5rem;
}
@media (max-width: 768px) {
    .onboarding-step-head { grid-template-columns: 40px 1fr auto; }
    .onboarding-step-body { grid-template-columns: 1fr; gap: 1rem; }
    .onboarding-step-foot > a.btn { flex: 1; text-align: center; }
}
.onboarding-sublabel {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: .4rem;
}
.onboarding-why p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: .92rem;
}
.onboarding-what ol {
    margin: 0;
    padding-left: 1.15rem;
    color: var(--text-primary);
}
.onboarding-what li {
    margin-bottom: .4rem;
    font-size: .92rem;
    line-height: 1.6;
}
.onboarding-what li:last-child { margin-bottom: 0; }

/* Pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
}
.pill-success { background: #ecfdf5; color: #047857; }
.pill-todo    { background: #fffbeb; color: #92400e; }
.pill-muted   { background: var(--bg-primary); color: var(--text-muted); border: 1px solid var(--border-color); }
.pill i { font-size: .7em; }
.pill-success i { color: #10b981; }
.pill pill-success { vertical-align: middle; }

/* ============================================================
   Widget install snippet + guides
   ============================================================ */
.install-card .install-intro {
    color: var(--text-secondary);
    line-height: 1.65;
    max-width: 820px;
}
.snippet-block {
    margin: 1.25rem 0 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: #0f172a;
}
.snippet-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1rem;
    background: #1e293b;
    color: #e2e8f0;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    flex-wrap: wrap;
    gap: .5rem;
}
.snippet-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.snippet-actions .btn-outline { color: #cbd5e1; border-color: #475569; background: transparent; }
.snippet-actions .btn-outline:hover { background: rgba(255,255,255,.08); color: #fff; }
.snippet-code {
    margin: 0;
    padding: 1rem 1.25rem;
    color: #e2e8f0;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: .82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}
.snippet-hint {
    margin: 0;
    padding: .65rem 1rem;
    background: #0f172a;
    color: #94a3b8;
    font-size: .78rem;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.snippet-hint i { color: var(--mo-teal-light); }

.install-guides {
    display: grid;
    gap: .5rem;
    margin-bottom: 1.25rem;
}
.install-guides details {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: .25rem .85rem;
    transition: var(--transition);
}
.install-guides details[open] {
    border-color: var(--mo-teal-light);
    background: var(--mo-teal-faint);
}
.install-guides summary {
    cursor: pointer;
    padding: .65rem 0;
    font-weight: 600;
    font-size: .92rem;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.install-guides summary::-webkit-details-marker { display: none; }
.install-guides summary::after {
    content: '+';
    margin-left: auto;
    color: var(--mo-teal);
    font-size: 1.2rem;
    font-weight: 400;
}
.install-guides details[open] summary::after { content: '−'; }
.install-steps {
    padding: 0 0 .65rem 1.25rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.65;
}
.install-steps li { margin-bottom: .3rem; }
.install-steps code {
    background: rgba(15, 23, 42, .06);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: 'Menlo', 'Monaco', monospace;
    font-size: .85em;
    color: var(--mo-teal-dark);
}
.install-guides details p {
    margin: 0 0 .65rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.65;
}

.install-preview {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--mo-teal-faint);
    border: 1px dashed var(--mo-teal-light);
    border-radius: var(--radius-sm);
    color: var(--mo-teal-dark);
}
.install-preview strong { display: block; margin-bottom: .25rem; }
.install-preview .muted { color: var(--text-secondary); margin: 0; font-size: .88rem; line-height: 1.6; }

/* ============================================================
   Conversations — split-pane list + transcript
   ============================================================ */
.conv-filter-tabs { display: flex; gap: .5rem; }

.conv-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1rem;
    min-height: 560px;
}
@media (max-width: 900px) {
    .conv-layout { grid-template-columns: 1fr; }
}
.conv-list {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 720px;
}
.conv-list-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.conv-list-items {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}
.conv-list-item a {
    display: block;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}
.conv-list-item a:hover { background: var(--mo-teal-faint); }
.conv-list-item.is-active a {
    background: var(--mo-teal-faint);
    border-left: 3px solid var(--mo-teal);
    padding-left: calc(1rem - 3px);
}
.conv-list-item-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .35rem;
}
.conv-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mo-teal);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}
.conv-list-item-name {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}
.conv-list-item-name strong {
    font-size: .9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-time { font-size: .72rem; color: var(--text-muted); flex-shrink: 0; }
.conv-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.conv-dot-open { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.conv-list-item-preview {
    font-size: .82rem;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: .35rem;
}
.conv-list-item-meta {
    display: flex;
    gap: .75rem;
    font-size: .72rem;
    color: var(--text-muted);
}
.conv-list-item-meta i { margin-right: .2rem; }
.conv-lead-tag { color: #047857; font-weight: 600; }
.conv-lead-tag i { color: #10b981; }

.conv-detail {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 720px;
}
.conv-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 2rem;
    text-align: center;
}
.conv-detail-empty i { font-size: 3rem; color: var(--mo-teal-light); margin-bottom: .75rem; }

.conv-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
    flex-wrap: wrap;
}
.conv-detail-head h2 {
    margin: 0 0 .35rem;
    font-size: 1.1rem;
    font-weight: 700;
}
.conv-detail-contact {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    font-size: .8rem;
    color: var(--text-muted);
    align-items: center;
}
.conv-detail-contact i { margin-right: .2rem; color: var(--mo-teal); }
.conv-detail-contact a { color: var(--text-muted); }
.conv-contact-chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: rgba(29, 158, 117, 0.08);
    border: 1px solid rgba(29, 158, 117, 0.2);
    color: var(--text-primary);
    font-weight: 500;
}
.conv-contact-chip a { color: inherit; text-decoration: none; }
.conv-contact-chip a:hover { text-decoration: underline; }

.conv-detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.conv-lead-banner {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin: 1rem 1.25rem 0;
    padding: .85rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}
.conv-lead-banner-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1rem;
    color: #fff;
}
.conv-lead-banner-body { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.conv-lead-banner-body strong { font-size: .95rem; color: var(--text-primary); }
.conv-lead-banner-body span { font-size: .82rem; color: var(--text-muted); }
.conv-lead-banner.is-success {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.3);
}
.conv-lead-banner.is-success .conv-lead-banner-icon { background: #10b981; }
.conv-lead-banner.is-prompt {
    background: rgba(29, 158, 117, 0.04);
    border-color: rgba(29, 158, 117, 0.25);
}
.conv-lead-banner.is-prompt .conv-lead-banner-icon { background: var(--mo-teal); }

.conv-convert-form {
    margin: .75rem 1.25rem 0;
    padding: 1rem;
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    background: #f8fafb;
}
.conv-convert-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: .75rem;
}
@media (max-width: 720px) {
    .conv-convert-grid { grid-template-columns: 1fr; }
}

.conv-list-item.has-unlinked-contact {
    background: linear-gradient(90deg, rgba(29, 158, 117, 0.05), transparent 60%);
}
.conv-contact-dot {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    color: var(--mo-teal);
    font-weight: 600;
}

.conv-thread {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f8fafb;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.conv-thread-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}
.conv-bubble-row { display: flex; }
.conv-bubble-row.is-visitor { justify-content: flex-end; }
.conv-bubble-row.is-ai      { justify-content: flex-start; }
.conv-bubble {
    max-width: 78%;
    padding: .65rem .9rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.conv-bubble-row.is-visitor .conv-bubble {
    background: var(--mo-teal);
    color: #fff;
    border-color: var(--mo-teal);
}
.conv-bubble-row.is-visitor .conv-bubble strong { color: #fff; }
.conv-bubble-meta {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .25rem;
    font-size: .72rem;
    opacity: .82;
}
.conv-bubble-meta strong { font-weight: 600; }
.conv-bubble-content { font-size: .92rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }

/* ── Lead detail page ────────────────────────────────────────────────── */
.badge-widget { background: rgba(29, 158, 117, .15); color: var(--mo-teal-dark, #085041); }
.badge-tiktok { background: #111827; color: #ffffff; }
.pill-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

.lead-flash { margin-bottom: 1rem; }

.lead-detail { display: flex; flex-direction: column; gap: 1.25rem; }

.lead-hero {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
    padding: 1.25rem 1.5rem;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.lead-hero-main { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.lead-hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.lead-avatar {
    width: 56px; height: 56px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--mo-teal, #1D9E75), var(--mo-teal-dark, #085041));
    color: #fff; font-size: 1.4rem; font-weight: 600;
    flex-shrink: 0;
}

.lead-name { margin: 0 0 .35rem 0; font-size: 1.35rem; font-weight: 600; }
.lead-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.lead-score {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .55rem; border-radius: 999px;
    background: var(--bg-primary, #f8fafc);
    border: 1px solid var(--border-color);
    font-size: .75rem; font-weight: 600; color: var(--text-primary);
}
.lead-score i { color: var(--mo-teal, #1D9E75); }

.lead-next-step {
    display: flex; align-items: flex-start; gap: .85rem;
    padding: .95rem 1.15rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 10px;
}
.lead-next-step-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: #fef3c7; color: #b45309;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.lead-next-step strong { display: block; font-size: .85rem; color: #92400e; margin-bottom: .1rem; }
.lead-next-step span { font-size: .88rem; color: #78350f; line-height: 1.4; }

.lead-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 960px) {
    .lead-grid { grid-template-columns: 1fr; }
}
.lead-sidebar, .lead-main { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

.lead-kv { display: flex; flex-direction: column; gap: .55rem; }
.lead-kv > div { display: flex; justify-content: space-between; gap: .75rem; font-size: .85rem; }
.kv-key { color: var(--text-muted); }
.kv-val { color: var(--text-primary); font-weight: 500; text-align: right; word-break: break-word; }

.lead-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .9rem; }

.lead-status-form { margin: 0; }
.lead-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .45rem;
}
.lead-status-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .55rem .4rem;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
    display: flex; align-items: center; justify-content: center;
}
.lead-status-btn:hover:not(:disabled) {
    background: var(--bg-primary, #f8fafc);
    border-color: var(--mo-teal, #1D9E75);
}
.lead-status-btn:active:not(:disabled) { transform: scale(.97); }
.lead-status-btn.is-current {
    background: rgba(29, 158, 117, .08);
    border-color: var(--mo-teal, #1D9E75);
    cursor: default;
    opacity: .85;
}
.lead-status-btn:disabled { cursor: default; }

.lead-help {
    font-size: .8rem; color: var(--text-muted); line-height: 1.45;
    margin: 0 0 .65rem 0;
}
.lead-help-warn {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: .65rem .85rem;
    border-radius: 8px;
    display: flex; align-items: center; gap: .5rem;
}
.lead-help-warn i { color: #b45309; }

.lead-appt-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: .5rem;
}
.lead-appt {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
    padding: .6rem .75rem;
    background: var(--bg-primary, #f8fafc);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: .82rem;
}
.lead-appt.is-upcoming { border-left: 3px solid var(--mo-teal, #1D9E75); }
.lead-appt.is-past { opacity: .7; }
.lead-appt strong { font-weight: 600; color: var(--text-primary); }
.lead-appt-notes { color: var(--text-muted); font-size: .78rem; flex-basis: 100%; }

/* Composer tabs */
.lead-composer-tabs {
    display: flex; gap: .25rem; flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    margin: -1.25rem -1.25rem 1rem -1.25rem;
    padding: 0 1.25rem;
}
.lead-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: .85rem .95rem;
    font-size: .85rem; font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: .4rem;
    transition: color .15s ease, border-color .15s ease;
    margin-bottom: -1px;
}
.lead-tab:hover { color: var(--text-primary); }
.lead-tab.is-active {
    color: var(--mo-teal-dark, #085041);
    border-bottom-color: var(--mo-teal, #1D9E75);
}
.lead-tab-panel { display: none; }
.lead-tab-panel.is-active { display: block; }

.lead-composer-foot {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
    margin-top: .85rem;
}
.lead-composer-foot .lead-help { margin: 0; flex: 1; min-width: 200px; }

/* Timeline */
.lead-timeline {
    display: flex; flex-direction: column; gap: 0;
    position: relative;
}
.lead-timeline::before {
    content: "";
    position: absolute;
    left: 15px; top: 8px; bottom: 8px;
    width: 2px;
    background: var(--border-color);
}
.lead-timeline-item {
    display: flex; gap: .85rem;
    padding: .65rem 0;
    position: relative;
}
.lead-timeline-dot {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary, #f8fafc);
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    flex-shrink: 0;
    position: relative; z-index: 1;
    font-size: .75rem;
}
.lead-timeline-item.is-inbound .lead-timeline-dot { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }
.lead-timeline-item.is-outbound .lead-timeline-dot { background: rgba(29,158,117,.12); border-color: var(--mo-teal, #1D9E75); color: var(--mo-teal-dark, #085041); }
.lead-timeline-item.is-note .lead-timeline-dot { background: #fffbeb; border-color: #f59e0b; color: #b45309; }
.lead-timeline-item.is-appt .lead-timeline-dot { background: #ecfdf5; border-color: #10b981; color: #047857; }
.lead-timeline-body { flex: 1; min-width: 0; }
.lead-timeline-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: .5rem; flex-wrap: wrap;
    margin-bottom: .15rem;
}
.lead-timeline-head strong { font-size: .85rem; font-weight: 600; color: var(--text-primary); }
.lead-timeline-time { font-size: .72rem; color: var(--text-muted); }
.lead-timeline-text {
    font-size: .85rem; color: var(--text-primary);
    line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}

/* ── Settings: jump nav ───────────────────────────────────────────────── */
.settings-nav {
    display: flex; flex-wrap: wrap; gap: .4rem;
    padding: .6rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.25rem;
    position: sticky; top: 0; z-index: 10;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.settings-nav-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .7rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .78rem; font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    white-space: nowrap;
}
.settings-nav-chip i { font-size: .72rem; opacity: .85; }
.settings-nav-chip:hover {
    background: var(--bg-primary, #f8fafc);
    color: var(--text-primary);
}
.settings-nav-chip.is-active {
    background: var(--mo-teal-faint, #e9faf2);
    color: var(--mo-teal-dark, #085041);
    border-color: var(--mo-teal-light, #b6ecd4);
}
.settings-nav-chip.is-active i { opacity: 1; color: var(--mo-teal, #1D9E75); }

.settings-flash {
    display: flex; align-items: center; gap: .5rem;
    margin-bottom: 1rem;
}

/* ── Settings: per-section card ───────────────────────────────────────── */
.settings-section { padding: 0; overflow: hidden; scroll-margin-top: 80px; margin-bottom: 1.25rem; }
.settings-profile { padding: 0; overflow: hidden; scroll-margin-top: 80px; }

.settings-section-header {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 1.35rem;
    background: linear-gradient(180deg, var(--mo-teal-faint, #e9faf2) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.settings-section-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--mo-teal, #1D9E75);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(29, 158, 117, .25);
}
.settings-section-title { flex: 1; min-width: 220px; }
.settings-section-title h3 {
    margin: 0 0 .15rem 0;
    font-size: 1.1rem; font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -.01em;
}
.settings-section-title p {
    margin: 0;
    font-size: .82rem; color: var(--text-muted);
    line-height: 1.45;
}

.settings-progress { flex-shrink: 0; min-width: 140px; text-align: right; }
.settings-progress-bar {
    height: 6px; width: 140px;
    background: rgba(8, 80, 65, .1);
    border-radius: 999px; overflow: hidden;
    margin-bottom: .3rem;
}
.settings-progress-bar > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--mo-teal, #1D9E75), var(--mo-teal-dark, #085041));
    border-radius: inherit;
    transition: width .4s ease;
}
.settings-progress-label {
    font-size: .72rem; font-weight: 600;
    color: var(--mo-teal-dark, #085041);
    letter-spacing: .02em;
}

.settings-form { padding: 1.35rem; display: flex; flex-direction: column; gap: 1.5rem; }

.settings-group {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.15rem 1.15rem;
    margin: 0;
    background: var(--bg-card, #fff);
}
.settings-group-title {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: 0 .5rem;
    font-size: .85rem; font-weight: 600;
    color: var(--mo-teal-dark, #085041);
    letter-spacing: -.005em;
    background: var(--bg-card, #fff);
}
.settings-group-title i { color: var(--mo-teal, #1D9E75); }
.settings-group-help {
    margin: .35rem 0 1rem 0;
    font-size: .78rem; line-height: 1.5;
    color: var(--text-muted);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.1rem;
}
.settings-grid-span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) {
    .settings-grid { grid-template-columns: 1fr; }
    .settings-grid-span-2 { grid-column: auto; }
}

.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field .form-label {
    display: inline-flex; align-items: center; gap: .4rem;
    margin-bottom: .4rem;
}
.form-field .form-label i {
    color: var(--mo-teal, #1D9E75);
    width: 14px; text-align: center; font-size: .8rem;
}
.form-hint {
    margin-top: .35rem;
    font-size: .72rem; line-height: 1.4;
    color: var(--text-muted);
}
.form-error {
    margin-top: .35rem;
    font-size: .72rem; line-height: 1.4;
    color: #b91c1c;
    display: flex; align-items: center; gap: .35rem;
}
.form-error[hidden] { display: none !important; }

.form-input.is-invalid,
input.is-invalid {
    border-color: #dc2626 !important;
    background: #fef2f2;
}
.form-input.is-invalid:focus,
input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .15) !important;
}

.settings-input-affix {
    display: flex; align-items: stretch;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: var(--bg-input, #fff);
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.settings-input-affix:focus-within {
    border-color: var(--mo-teal, #1D9E75);
    box-shadow: 0 0 0 3px rgba(29, 158, 117, .15);
}
.settings-input-affix .form-input {
    border: none !important;
    border-radius: 0 !important;
    background: transparent;
    flex: 1; min-width: 0;
}
.settings-input-affix .form-input:focus { box-shadow: none !important; }
.settings-input-prefix,
.settings-input-suffix {
    display: flex; align-items: center;
    padding: 0 .85rem;
    font-size: .85rem; font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-primary, #f8fafc);
    white-space: nowrap;
}
.settings-input-prefix { border-right: 1px solid var(--border-color); color: var(--mo-teal-dark, #085041); }
.settings-input-suffix { border-left: 1px solid var(--border-color); font-weight: 500; font-size: .78rem; }

.settings-form-foot {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
    padding: 1rem 1.15rem;
    background: var(--bg-primary, #f8fafc);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.settings-form-foot-hint {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .78rem; color: var(--text-muted);
    text-decoration: none;
}
a.settings-form-foot-hint:hover { color: var(--mo-teal-dark, #085041); }
.settings-form-foot-hint i { color: var(--mo-teal, #1D9E75); }

/* Status pill in section header */
.settings-status { flex-shrink: 0; }
.settings-status-pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    font-size: .72rem; font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.settings-status-pill.is-ok    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.settings-status-pill.is-todo  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.settings-status-pill.is-muted { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.settings-status-pill.is-info  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* "Optional" mini-tag next to labels */
.settings-label-opt {
    display: inline-block;
    margin-left: .4rem;
    padding: .05rem .4rem;
    font-size: .65rem; font-weight: 500;
    background: #f3f4f6; color: #6b7280;
    border-radius: 4px;
    text-transform: uppercase; letter-spacing: .04em;
}

/* Toggle row — checkbox switch + label/description pair */
.settings-toggle-row {
    display: flex; align-items: flex-start; gap: .85rem;
}
.settings-toggle-row strong {
    display: block;
    font-size: .88rem; font-weight: 600;
    color: var(--text-primary);
}
.settings-switch {
    position: relative;
    display: inline-block;
    width: 42px; height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}
.settings-switch input {
    opacity: 0; width: 0; height: 0;
    position: absolute;
}
.settings-switch-slider {
    position: absolute; inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background-color .2s ease;
    cursor: pointer;
}
.settings-switch-slider::before {
    content: ""; position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s ease;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .2);
}
.settings-switch input:checked + .settings-switch-slider { background: var(--mo-teal, #1D9E75); }
.settings-switch input:checked + .settings-switch-slider::before { transform: translateX(18px); }
.settings-switch input:focus-visible + .settings-switch-slider {
    box-shadow: 0 0 0 3px rgba(29, 158, 117, .25);
}

/* Repeater tables (sequence / custom fields) */
.settings-repeater { margin: 0; }
.settings-repeater thead th {
    font-size: .72rem; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.settings-repeater td { padding: .5rem .6rem; vertical-align: top; }
.settings-repeater td .form-input { margin: 0; }
.settings-repeater-idx {
    font-weight: 600;
    color: var(--mo-teal-dark, #085041);
    text-align: center;
    width: 32px;
}
.settings-repeater-remove {
    padding: .3rem .55rem !important;
    color: #991b1b;
    border-color: #fecaca !important;
}
.settings-repeater-remove:hover {
    background: #fee2e2;
    color: #7f1d1d;
}
.settings-repeater-add {
    margin-top: .75rem;
    display: flex;
}

/* Color picker affix (chat widget accent) */
.settings-color-affix { padding: 0; align-items: center; }
.settings-color-affix input[type="color"] {
    -webkit-appearance: none; appearance: none;
    width: 44px; height: 38px;
    border: none;
    border-right: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    padding: 4px;
}
.settings-color-affix input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 4px; }
.settings-color-affix input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.settings-color-affix .form-input { text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, monospace; letter-spacing: .02em; }

/* ============================================================
   Conversations — redesigned stats, toolbar, pills, detail
   ============================================================ */

/* Stats strip at the top of the page */
.conv-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .6rem;
    margin-bottom: 1rem;
}
@media (max-width: 900px) {
    .conv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .conv-stats { grid-template-columns: 1fr 1fr; }
}
.conv-stat {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .7rem .9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 0;
}
.conv-stat-label {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.conv-stat-label i { color: var(--mo-teal); }
.conv-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.conv-stat.is-cta {
    background: linear-gradient(135deg, rgba(29, 158, 117, 0.08), rgba(29, 158, 117, 0.02));
    border-color: rgba(29, 158, 117, 0.35);
}
.conv-stat.is-cta .conv-stat-value { color: var(--mo-teal-dark, #085041); }

/* Toolbar — filter tabs + search */
.conv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.conv-filter-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.conv-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}
.conv-filter-chip:hover {
    background: var(--mo-teal-faint);
    color: var(--text-primary);
    border-color: var(--mo-teal-light);
}
.conv-filter-chip.is-active {
    background: var(--mo-teal);
    border-color: var(--mo-teal);
    color: #fff;
    box-shadow: 0 2px 8px rgba(29, 158, 117, 0.25);
}
.conv-filter-chip.is-active i { color: #fff; }

.conv-search {
    position: relative;
    flex: 1;
    min-width: 240px;
    max-width: 420px;
}
.conv-search i.fa-search {
    position: absolute;
    top: 50%;
    left: .75rem;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .85rem;
    pointer-events: none;
}
.conv-search input[type="search"] {
    width: 100%;
    padding: .55rem 2.75rem .55rem 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: .88rem;
    color: var(--text-primary);
    transition: var(--transition);
}
.conv-search input[type="search"]:focus {
    outline: none;
    border-color: var(--mo-teal);
    box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}
.conv-search-kbd {
    position: absolute;
    top: 50%;
    right: .55rem;
    transform: translateY(-50%);
    padding: .1rem .4rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #f3f4f6;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: .72rem;
    pointer-events: none;
}

/* List hint + "has-unlinked-contact" visual cue */
.conv-list-hint {
    color: var(--mo-teal);
    font-size: .75rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}
.conv-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}

/* Open-session dot on the list avatar */
.conv-avatar.is-open {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #10b981;
}

/* Generic conv-pill (used on list + detail) */
.conv-pill {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.conv-pill i { font-size: .55rem; }
.conv-pill.is-open {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.3);
}
.conv-pill.is-open i { color: #10b981; font-size: .5rem; }
.conv-pill.is-lead {
    background: rgba(29, 158, 117, 0.12);
    color: var(--mo-teal-dark, #085041);
    border-color: rgba(29, 158, 117, 0.3);
}
.conv-pill.is-prompt {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}
.conv-pill.is-closed {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}

/* Detail header: mobile-back, avatar, main title block */
.conv-detail-head-back {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    flex: 1;
}
.conv-detail-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mo-teal);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.conv-detail-head-main { min-width: 0; flex: 1; }
.conv-detail-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    margin-top: .1rem;
}
.conv-detail-meta-item {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .78rem;
    color: var(--text-muted);
}
.conv-detail-meta-item i { color: var(--mo-teal); font-size: .75rem; }

/* Mobile-only back button */
.conv-mobile-back { display: none; }

/* Contact chip row under the header */
.conv-detail-contact-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfc;
}

/* Body wrapper (banner + form + thread) */
.conv-detail-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Convert form footer */
.conv-convert-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.conv-convert-foot .form-hint { margin: 0; }

/* Timestamp separator in transcript */
.conv-thread-sep {
    align-self: center;
    padding: .2rem .7rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border-color);
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 600;
    margin: .25rem 0;
}

/* Bubble avatars + grouping */
.conv-bubble-row { gap: .6rem; align-items: flex-end; }
.conv-bubble-avatar {
    width: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.conv-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mo-teal);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .72rem;
}
.conv-avatar-sm.is-ai {
    background: #fff;
    color: var(--mo-teal);
    border: 1px solid var(--border-color);
}
.conv-bubble-row.is-visitor { flex-direction: row-reverse; }
.conv-bubble-row.is-grouped { margin-top: -.45rem; }
.conv-bubble-row.is-grouped .conv-bubble { border-top-left-radius: 6px; }
.conv-bubble-row.is-grouped.is-visitor .conv-bubble {
    border-top-left-radius: 14px;
    border-top-right-radius: 6px;
}

/* Keyboard shortcut hint bar at page bottom */
.conv-shortcut-hint {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 1rem;
    padding: .5rem;
    font-size: .75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.conv-shortcut-hint kbd {
    display: inline-block;
    padding: .05rem .35rem;
    margin-right: .2rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: .7rem;
    color: var(--text-primary);
}

/* Mobile behavior: detail-focused view when a session is selected */
@media (max-width: 900px) {
    .conv-mobile-back { display: inline-flex; }
    .conv-layout { min-height: 0; }
    .conv-layout[data-selected="detail"] .conv-list { display: none; }
    .conv-layout[data-selected="list"] .conv-detail { display: none; }
    .conv-list, .conv-detail { max-height: none; }
    .conv-detail-head { flex-direction: column; align-items: stretch; }
    .conv-detail-actions { justify-content: flex-end; }
}

/* ============================================================
   Email verify gate — blocking overlay for unverified users
   ============================================================ */
.verify-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    animation: verifyFadeIn .2s ease-out;
}
@keyframes verifyFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.verify-gate-card {
    max-width: 520px;
    width: 100%;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    animation: verifyPopIn .25s ease-out;
}
@keyframes verifyPopIn {
    from { transform: translateY(12px) scale(.97); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}
.verify-gate-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--mo-teal, #1D9E75), var(--mo-teal-dark, #085041));
    color: #fff;
    font-size: 1.8rem;
    box-shadow: 0 8px 20px rgba(29, 158, 117, .28);
}
.verify-gate-card h2 {
    margin: 0 0 .5rem;
    font-size: 1.4rem;
    font-weight: 800;
    color: #0F172A;
}
.verify-gate-sub {
    margin: 0 0 1.25rem;
    color: #475569;
    font-size: .95rem;
    line-height: 1.5;
}
.verify-gate-sub strong { color: var(--mo-teal-dark, #085041); }

.verify-gate-steps {
    list-style: none;
    padding: 0;
    margin: 0 auto 1.25rem;
    text-align: left;
    max-width: 420px;
}
.verify-gate-steps li {
    padding: .55rem .75rem;
    border-radius: 8px;
    background: #F8FAFC;
    margin-bottom: .4rem;
    font-size: .9rem;
    color: #334155;
}
.verify-gate-steps li strong {
    color: var(--mo-teal, #1D9E75);
    margin-right: .25rem;
}

.verify-gate-status {
    margin: 0 auto 1rem;
    padding: .6rem .85rem;
    border-radius: 8px;
    font-size: .85rem;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: .5rem;
    justify-content: center;
}
.verify-gate-status.is-ok {
    background: rgba(16, 185, 129, .1);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, .25);
}
.verify-gate-status.is-err {
    background: rgba(220, 38, 38, .08);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, .2);
}

.verify-gate-actions {
    display: flex;
    gap: .6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
}
.verify-gate-actions .btn { min-width: 220px; }

.verify-gate-foot {
    margin: 0;
    font-size: .8rem;
    color: #64748B;
}
.verify-gate-foot a {
    color: var(--mo-teal, #1D9E75);
    font-weight: 600;
    text-decoration: none;
}
.verify-gate-foot a:hover { text-decoration: underline; }

/* Lock the page behind the gate so the user can't scroll / interact. */
body:has(.verify-gate) {
    overflow: hidden;
}

@media (max-width: 540px) {
    .verify-gate-card { padding: 2rem 1.25rem 1.5rem; }
    .verify-gate-actions .btn { min-width: 0; width: 100%; }
}

/* ── Shared portal utilities (Admin/Business/Sales) ───────────────────── */

/* TempData success/error banners rendered by _PageMessages.cshtml.
   Placed above RenderBody() in every layout so the markup never lives in
   individual pages. */
.page-message {
    position: relative;
    display: flex; align-items: center; gap: .75rem;
    padding: 12px 44px 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 1rem;
    font-size: .9rem; line-height: 1.4;
    transform: translateY(-12px);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
    will-change: transform, opacity;
}
.page-message.is-visible { transform: translateY(0); opacity: 1; }
.page-message.dismissing { transform: translateY(-12px); opacity: 0; }
.page-message i { font-size: 1.05rem; flex-shrink: 0; }
.page-message-success {
    background: var(--mo-teal-faint);
    border-left: 4px solid var(--mo-teal);
    color: var(--mo-teal-dark);
}
.page-message-success i { color: var(--mo-teal); }
.page-message-error {
    background: #fee2e2;
    border-left: 4px solid #dc2626;
    color: #991b1b;
}
.page-message-error i { color: #dc2626; }
.page-message__dismiss {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: transparent; border: none; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    color: inherit; opacity: .6;
    display: flex; align-items: center; justify-content: center;
    transition: opacity .15s, background .15s;
}
.page-message__dismiss:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* Impersonation banner — amber alert across Business / Sales layouts. */
.impersonation-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    color: #92400e;
    padding: 10px 24px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    font-size: 13px; font-weight: 500;
    margin: -2rem -2rem 1.5rem;
}
.impersonation-banner i { color: #b45309; }
.impersonation-banner form { margin: 0; }
.impersonation-banner__exit, .impersonation-banner .btn {
    background: transparent;
    color: var(--mo-teal-dark);
    border: 1px solid var(--mo-teal);
    padding: 4px 12px; border-radius: 6px;
    font-size: 12px; font-weight: 500;
    display: inline-flex; align-items: center; gap: .35rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.impersonation-banner__exit:hover, .impersonation-banner .btn:hover {
    background: var(--mo-teal); color: #fff;
}
@media (max-width: 768px) {
    .impersonation-banner { margin: -1rem -1rem 1rem; padding: 10px 12px; }
}

/* Form grid — 1/2/3 column auto-responsive grid for stacked form fields.
   Override with inline style="grid-template-columns:..." for custom widths. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: start;
    margin-bottom: 1rem;
}
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid > .form-row-full { grid-column: 1 / -1; }
.form-grid label {
    display: block; font-size: .85rem; font-weight: 600;
    margin-bottom: .25rem; color: var(--text-primary, #111827);
}
@media (max-width: 768px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

/* Status pills for commission ledger / attribution method / etc. —
   extends the existing .badge vocabulary with ledger-specific variants. */
.badge-accrued  { background: #e1f5ee; color: #085041; }
.badge-paid     { background: #1D9E75; color: #fff; }
.badge-reversed { background: #fee2e2; color: #991b1b; }

/* ── CSV import wizard styles ─────────────────────────────────────────── */
.csv-drop-area {
    border: 2px dashed var(--mo-teal-light);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    background: var(--mo-teal-faint);
    transition: border-color 0.15s, background 0.15s;
}
.csv-drop-area.dragover, .csv-drop-area.csv-drop-hover {
    border-color: var(--mo-teal);
    background: #d1f0e6;
}
.csv-drop-area i { font-size: 2.25rem; color: var(--mo-teal); margin-bottom: .75rem; display: block; }
.csv-drop-area input[type=file] { margin-top: 1rem; }

.csv-mapping-table { width: 100%; border-collapse: collapse; }
.csv-mapping-table th, .csv-mapping-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--mo-teal-faint);
    text-align: left;
}
.csv-mapping-table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.csv-mapping-table select { width: 100%; padding: .35rem .5rem; }

/* CSV wizard step indicator */
.csv-wizard-steps {
    display: flex; gap: 1rem; align-items: center;
    margin-bottom: 1.5rem; padding: .5rem 0;
}
.csv-wizard-step {
    display: flex; align-items: center; gap: .5rem;
    color: var(--text-muted); font-size: .85rem;
}
.csv-wizard-step__num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .8rem;
}
.csv-wizard-step.is-active { color: var(--mo-teal-dark); font-weight: 600; }
.csv-wizard-step.is-active .csv-wizard-step__num { background: var(--mo-teal); color: #fff; }
.csv-wizard-step.is-done .csv-wizard-step__num { background: var(--mo-teal-dark); color: #fff; }
.csv-wizard-step__sep { flex: 1; height: 1px; background: var(--mo-teal-faint); }

.csv-map-status { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; }
.csv-map-status.is-ok { color: var(--mo-teal); }
.csv-map-status.is-warn { color: #b45309; }
.csv-map-status.is-error { color: #dc2626; }
.csv-required-missing { background: rgba(220, 38, 38, .08); border-left: 3px solid #dc2626; }

.csv-progress-bar {
    height: 8px; border-radius: 999px; background: var(--mo-teal-faint); overflow: hidden;
}
.csv-progress-bar > span { display: block; height: 100%; background: var(--mo-teal); transition: width .25s ease; }

/* ── Sortable column headers ─────────────────────────────────────────── */
th.sortable {
    cursor: pointer; user-select: none;
}
th.sortable:hover { color: var(--mo-teal); }
th.sortable::after {
    content: ' ↕'; opacity: 0.4; font-size: 10px;
}
th.sortable.asc::after  { content: ' ↑'; opacity: 1; color: var(--mo-teal); }
th.sortable.desc::after { content: ' ↓'; opacity: 1; color: var(--mo-teal); }
/* Backwards-compat: existing pages use <a> inside the header */
th.sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
th.sortable a:hover { color: var(--mo-teal-dark, #085041); }
th.sortable .sort-arrow { opacity: .4; font-size: .7rem; }
th.sortable.sorted::after { content: ''; }
th.sortable.sorted .sort-arrow { opacity: 1; color: var(--mo-teal); }

/* ── Pagination control ──────────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; gap: 4px; justify-content: center;
    margin-top: 1rem; padding: .75rem 0;
    flex-wrap: wrap;
}
.pagination .page-btn,
.pagination a,
.pagination span.current,
.pagination span.disabled {
    width: 34px; height: 34px; min-width: 34px;
    border-radius: 8px; border: 1px solid var(--mo-teal-faint);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; cursor: pointer;
    transition: all 0.15s;
    text-decoration: none; color: inherit;
    background: transparent;
    padding: 0 .5rem;
    box-sizing: border-box;
}
.pagination .page-btn:hover,
.pagination a:hover {
    border-color: var(--mo-teal); color: var(--mo-teal);
}
.pagination .page-btn:focus-visible,
.pagination a:focus-visible {
    outline: 2px solid var(--mo-teal); outline-offset: 2px;
}
.pagination .page-btn.active,
.pagination span.current {
    background: var(--mo-teal); color: #fff; border-color: var(--mo-teal);
    font-weight: 600;
}
.pagination span.disabled,
.pagination .page-btn[disabled],
.pagination .page-btn.disabled {
    color: var(--text-muted); cursor: not-allowed;
    opacity: .55; border-color: transparent; background: transparent;
}
.pagination .page-info {
    width: auto; height: auto;
    color: #6b7280; font-size: 12px;
    margin-left: 8px;
    border: none;
    cursor: default;
}
.pagination .page-info:hover { border-color: transparent; color: #6b7280; }
.pagination .page-ellipsis {
    width: auto; min-width: 20px; height: 34px;
    color: var(--text-muted); border: none;
    cursor: default;
}

/* ── Loading skeleton (UX-1) ─────────────────────────────────────────── */
@keyframes shimmer { to { background-position: -200% 0; } }
.loading-skeleton {
    background: linear-gradient(90deg, var(--mo-teal-faint) 25%, #fff 50%, var(--mo-teal-faint) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    color: transparent !important;
    user-select: none;
}
.loading-skeleton--row { height: 44px; margin-bottom: 6px; }
.loading-skeleton--card { height: 110px; margin-bottom: 1rem; }
.loading-skeleton--text { height: 1em; display: inline-block; min-width: 4ch; }
.skeleton-fade { transition: opacity .25s ease; opacity: 1; }
.skeleton-fade.is-fading { opacity: 0; }

/* ── Sidebar collapse + mobile overlay ───────────────────────────────── */
.sidebar-collapse-btn {
    display: none;
    position: absolute; top: 12px; right: -14px;
    width: 28px; height: 28px; border-radius: 50%;
    background: #fff; border: 1px solid var(--mo-teal-faint);
    color: var(--mo-teal-dark); cursor: pointer;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
    z-index: 110;
    font-size: .8rem;
}
@media (max-width: 768px) {
    .sidebar-collapse-btn { display: none; }
}

.sidebar::before {
    content: ''; display: none;
}
.sidebar.open::before {
    display: block;
    position: fixed; top: 0; left: 260px; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    z-index: -1;
}
@media (max-width: 768px) {
    .sidebar { transition: transform .2s ease, width .2s ease; }
}

/* Quick action bar — sticky bottom CTAs on mobile */
.quick-action-bar {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid var(--mo-teal-faint);
    padding: 12px 16px;
    z-index: 50;
    box-shadow: 0 -4px 12px rgba(0,0,0,.05);
    gap: .5rem;
}
@media (max-width: 768px) {
    .quick-action-bar { display: flex; }
    .quick-action-bar .btn { flex: 1; justify-content: center; }
    body.has-quick-action-bar .main-content { padding-bottom: 88px; }
}

/* Filter pills (used across leads/businesses/etc) */
.filter-pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filter-pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: 6px 14px; border-radius: 999px;
    border: 1px solid var(--mo-teal); color: var(--mo-teal);
    background: transparent;
    font-size: 13px; font-weight: 500;
    text-decoration: none; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.filter-pill:hover { background: var(--mo-teal-faint); color: var(--mo-teal-dark); }
.filter-pill.is-active, .filter-pill.active {
    background: var(--mo-teal); color: #fff;
}
.filter-pill__count {
    background: rgba(255,255,255,.25); padding: 1px 6px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
}
.filter-pill:not(.is-active) .filter-pill__count {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
}
.filter-pill--blue { border-color: var(--mo-brand-blue); color: var(--mo-brand-blue); }
.filter-pill--blue.is-active { background: var(--mo-brand-blue); color: #fff; }
.filter-pill--gray { border-color: #d1d5db; color: #6b7280; }
.filter-pill--gray.is-active { background: #6b7280; color: #fff; }

/* Avatar circles (initials) */
.avatar-circle {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--mo-teal); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .8rem;
    flex-shrink: 0;
}
.avatar-circle--lg { width: 56px; height: 56px; font-size: 1.05rem; }

/* Score bar */
.score-bar {
    position: relative; width: 80px; height: 6px;
    background: var(--mo-teal-faint); border-radius: 999px;
    overflow: hidden; display: inline-block; vertical-align: middle;
}
.score-bar > span {
    display: block; height: 100%;
    background: var(--mo-teal);
    transition: width .25s ease;
}
.score-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500;
}

/* Progress bar (subscription usage / budget) */
.progress-bar {
    height: 8px; border-radius: 999px;
    background: var(--mo-teal-faint); overflow: hidden;
}
.progress-bar > span {
    display: block; height: 100%; background: var(--mo-teal);
    transition: width .25s ease;
}
.progress-bar.warn > span { background: #d97706; }
.progress-bar.danger > span { background: #dc2626; }

/* Toggle switch */
.switch {
    display: inline-flex; align-items: center; gap: .5rem;
    cursor: pointer; user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    width: 36px; height: 20px; border-radius: 999px;
    background: #d1d5db; position: relative;
    transition: background .15s;
}
.switch__track::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--mo-teal); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--mo-teal); outline-offset: 2px; }

/* Modal */
.mo-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.mo-modal-backdrop.is-open { display: flex; animation: mo-modal-in .15s ease; }
@keyframes mo-modal-in { from { opacity: 0; } to { opacity: 1; } }
.mo-modal {
    background: #fff; border-radius: 12px;
    max-width: 480px; width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    overflow: hidden;
}
.mo-modal__header {
    padding: 1.25rem 1.5rem .5rem;
    border-bottom: 1px solid var(--mo-teal-faint);
    border-top: 4px solid var(--mo-teal);
}
.mo-modal--danger .mo-modal__header { border-top-color: #dc2626; }
.mo-modal__header h3 { margin: 0 0 .35rem; font-size: 1.1rem; font-weight: 600; color: var(--mo-teal-dark); }
.mo-modal--danger .mo-modal__header h3 { color: #991b1b; }
.mo-modal__body { padding: 1rem 1.5rem 1.5rem; }
.mo-modal__body p { margin: 0 0 1rem; color: var(--text-secondary); line-height: 1.55; }
.mo-modal__footer {
    padding: .75rem 1.5rem 1.25rem;
    display: flex; gap: .75rem; justify-content: flex-end;
}
.mo-modal__type-input {
    width: 100%; padding: .55rem .85rem;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-family: monospace; font-size: .9rem;
    margin-top: .5rem;
}
.mo-modal__confirm--danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.mo-modal__confirm--danger:hover { background: #991b1b; border-color: #991b1b; }
.mo-modal__confirm[disabled] { opacity: .5; cursor: not-allowed; }

/* Role guard / 403 in-place page */
.role-guard {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; padding: 4rem 1.5rem;
    max-width: 540px; margin: 0 auto;
}
.role-guard__logo {
    width: 64px; height: 64px; margin-bottom: 1.5rem;
    color: var(--mo-teal);
}
.role-guard h1 {
    font-size: 1.5rem; font-weight: 700; margin: 0 0 .5rem;
    color: var(--mo-teal-dark);
}
.role-guard p { color: var(--text-secondary); margin: 0 0 .75rem; line-height: 1.6; }
.role-guard__actions { margin-top: 1.5rem; display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }

/* Tab bar (composer) */
.tab-bar {
    display: flex; border-bottom: 1px solid var(--mo-teal-faint);
    margin-bottom: 1rem; gap: .25rem; position: relative;
}
.tab-bar__tab {
    background: transparent; border: none;
    padding: .65rem 1rem; cursor: pointer;
    font-size: .9rem; color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.tab-bar__tab:hover { color: var(--mo-teal); }
.tab-bar__tab.is-active { color: var(--mo-teal-dark); border-bottom-color: var(--mo-teal); font-weight: 600; }

/* Sticky bulk action bar */
.bulk-action-bar {
    position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
    background: var(--mo-teal-dark); color: #fff;
    border-radius: 12px;
    padding: .75rem 1.25rem;
    display: none; align-items: center; gap: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    z-index: 80;
}
.bulk-action-bar.is-visible { display: flex; }
.bulk-action-bar__count { font-weight: 600; }
.bulk-action-bar select { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }

/* Speech bubbles for SMS timeline */
.bubble {
    display: inline-block; max-width: 75%; padding: .5rem .85rem;
    border-radius: 14px; font-size: .9rem; line-height: 1.4;
}
.bubble--in {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
    border-bottom-left-radius: 4px;
}
.bubble--out {
    background: var(--mo-teal); color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}
.bubble-row { display: flex; margin-bottom: .5rem; }
.bubble-row--out { justify-content: flex-end; }

/* Code chip / copy block */
.code-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
    padding: 4px 10px; border-radius: 6px;
    font-family: monospace; font-size: .85rem;
    cursor: pointer;
}
.code-chip:hover { background: var(--mo-teal-light); }
.code-chip.copied { background: var(--mo-teal); color: #fff; }

/* Sparkline canvas tiny constraints */
.sparkline { width: 60px; height: 24px; display: inline-block; vertical-align: middle; }

/* Greeting banner gradient (Sales) */
.greeting-banner {
    background: linear-gradient(90deg, var(--mo-teal-dark) 0%, var(--mo-teal) 100%);
    color: #fff; padding: 1.25rem 1.5rem; border-radius: 14px;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.greeting-banner h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.greeting-banner p { margin: .25rem 0 0; opacity: .85; font-size: .9rem; }

/* Inline-edit save state */
.inline-edit-status {
    font-size: .75rem; color: var(--text-muted); margin-left: .5rem;
}
.inline-edit-status.is-saving { color: #b45309; }
.inline-edit-status.is-saved { color: var(--mo-teal); }

/* Stat card grid responsive overrides */
@media (max-width: 640px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .form-grid { grid-template-columns: 1fr !important; }
}

/* ════════════════════════════════════════════════════════════════════════════
   TOP NAV — Business portal (replaces left sidebar on body[data-portal="business"])
   ════════════════════════════════════════════════════════════════════════════
   Sticky horizontal header with grouped dropdowns. Brand-aligned (MO teal),
   keyboard accessible, mobile drawer pattern below 768px. Co-exists with the
   legacy .sidebar class (still in use by Admin + Sales) — selectors are scoped
   to .topnav and body[data-portal="business"] so they don't collide.
*/

/* Topnav layout applies to every portal that uses the new header (Business +
   Admin + Sales). Each role gets a distinct pill colour but shares the
   scaffold below. */
body[data-portal="business"],
body[data-portal="admin"],
body[data-portal="sales"] {
    padding-top: 64px;
}
body[data-portal="business"] .main-content,
body[data-portal="admin"] .main-content,
body[data-portal="sales"] .main-content {
    margin-left: 0;
    padding: 1.75rem 2rem;
}

/* Per-role pill colours — Business = default teal, Admin = teal-dark,
   Sales = brand blue. Each header is instantly identifiable at a glance. */
.topnav-pill--admin {
    background: var(--mo-teal-dark) !important;
    color: var(--mo-teal-light) !important;
}
.topnav-pill--sales {
    background: var(--mo-brand-blue, #2563eb) !important;
    color: #ffffff !important;
}

.topnav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 40;
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid var(--mo-teal-faint);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02), 0 4px 16px rgba(15, 23, 42, .04);
    backdrop-filter: saturate(180%) blur(8px);
    display: flex; align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
}

/* Brand block on the left — logo + role pill, click-to-dashboard */
.topnav-brand {
    display: flex; align-items: center; gap: .6rem;
    text-decoration: none; color: var(--mo-teal-dark);
    flex-shrink: 0;
    padding: 4px 6px; border-radius: 8px;
    transition: background .15s ease;
}
.topnav-brand:hover { background: var(--mo-teal-faint); }
.topnav-brand img { height: 32px; width: auto; display: block; }
.topnav-brand .topnav-pill {
    font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
    padding: 3px 8px; border-radius: 999px;
    line-height: 1;
}

/* Primary nav row (center) */
.topnav-primary {
    display: flex; align-items: center; gap: .15rem;
    flex: 1; min-width: 0;
    margin-left: .5rem;
}

.topnav-link {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem .8rem;
    border-radius: 8px;
    color: var(--text-secondary, #4b5563);
    font-size: .9rem; font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    background: none;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
    white-space: nowrap;
    line-height: 1;
}
.topnav-link i { font-size: .9rem; opacity: .8; }
.topnav-link:hover { background: var(--mo-teal-faint); color: var(--mo-teal-dark); }
.topnav-link:focus-visible {
    outline: 2px solid var(--mo-teal); outline-offset: 2px;
}
.topnav-link.is-active {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
    border-color: var(--mo-teal-light);
}
.topnav-link.is-active i { opacity: 1; color: var(--mo-teal); }

.topnav-link .caret {
    font-size: .65rem; opacity: .55;
    transition: transform .15s ease;
    margin-left: .15rem;
}
.topnav-item.is-open > .topnav-link .caret { transform: rotate(180deg); }

/* Inline pill / count next to a link label (e.g. unread count) */
.topnav-link .topnav-count {
    background: var(--mo-teal); color: #fff;
    font-size: .65rem; font-weight: 700;
    padding: .12rem .42rem; border-radius: 999px;
    line-height: 1.3; min-width: 1.1rem; text-align: center;
}

/* Dropdown panels */
.topnav-item { position: relative; }
.topnav-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 240px; padding: .5rem;
    background: #ffffff;
    border: 1px solid var(--mo-teal-faint);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    opacity: 0; transform: translateY(-4px) scale(.98);
    pointer-events: none;
    transition: opacity .12s ease, transform .12s ease;
    z-index: 50;
}
.topnav-item.is-open .topnav-dropdown {
    opacity: 1; transform: translateY(0) scale(1);
    pointer-events: auto;
}
.topnav-dropdown-section {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--text-muted, #9ca3af);
    padding: .5rem .65rem .25rem;
}
.topnav-dropdown-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .65rem;
    border-radius: 7px;
    color: var(--text-primary, #1f2937);
    text-decoration: none;
    font-size: .88rem;
    transition: background .1s ease, color .1s ease;
}
.topnav-dropdown-link:hover {
    background: var(--mo-teal-faint);
    color: var(--mo-teal-dark);
}
.topnav-dropdown-link.is-active {
    background: var(--mo-teal-faint);
    color: var(--mo-teal-dark);
    font-weight: 600;
}
.topnav-dropdown-link i {
    width: 18px; text-align: center; opacity: .7;
    color: var(--mo-teal);
}
.topnav-dropdown-link .topnav-dropdown-meta {
    margin-left: auto; font-size: .7rem; color: var(--text-muted, #9ca3af);
}
.topnav-dropdown hr {
    border: none; border-top: 1px solid var(--mo-teal-faint);
    margin: .35rem 0;
}

/* Right-side actions */
.topnav-actions {
    display: flex; align-items: center; gap: .35rem;
    flex-shrink: 0;
}
.topnav-iconbtn {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; background: none; border: none;
    color: var(--text-secondary, #4b5563);
    cursor: pointer; position: relative;
    transition: background .12s ease, color .12s ease;
}
.topnav-iconbtn:hover {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
}
.topnav-iconbtn .topnav-iconbtn-badge {
    position: absolute; top: 5px; right: 5px;
    background: var(--mo-teal); color: #fff;
    font-size: .6rem; font-weight: 700;
    min-width: 16px; height: 16px; line-height: 16px;
    padding: 0 4px; border-radius: 999px;
    border: 2px solid #fff;
}

/* User avatar pill in top nav */
.topnav-user {
    display: inline-flex; align-items: center; gap: .55rem;
    padding: 4px 10px 4px 4px; border-radius: 999px;
    background: none; border: 1px solid transparent;
    color: var(--text-secondary, #4b5563);
    cursor: pointer; font-size: .85rem; font-weight: 500;
    transition: background .12s ease, border-color .12s ease;
}
.topnav-user:hover {
    background: var(--mo-teal-faint);
    border-color: var(--mo-teal-light);
}
.topnav-user .topnav-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--mo-teal); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .75rem;
}
.topnav-user .caret { font-size: .65rem; opacity: .55; }

/* User dropdown anchored to the right edge */
.topnav-item.topnav-item--right .topnav-dropdown {
    left: auto; right: 0; min-width: 220px;
}

.topnav-user-card {
    padding: .65rem .75rem; border-radius: 8px;
    background: var(--mo-teal-faint);
    margin-bottom: .35rem;
}
.topnav-user-card .topnav-user-name {
    font-size: .9rem; font-weight: 600; color: var(--mo-teal-dark);
}
.topnav-user-card .topnav-user-email {
    font-size: .75rem; color: var(--text-muted, #6b7280);
    word-break: break-all;
}

/* Hamburger (visible on mobile only) */
.topnav-hamburger {
    display: none;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    border-radius: 10px; background: none; border: none;
    color: var(--mo-teal-dark); cursor: pointer;
    font-size: 1.1rem;
    transition: background .12s ease;
}
.topnav-hamburger:hover { background: var(--mo-teal-faint); }

/* Mobile drawer (≤768px) — slide-down, full-width, scroll-friendly */
.topnav-drawer {
    position: fixed; top: 64px; left: 0; right: 0;
    background: #ffffff;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    transform: translateY(-110%);
    transition: transform .25s cubic-bezier(.2, .8, .2, 1);
    z-index: 39;
    border-bottom: 1px solid var(--mo-teal-faint);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    padding: .5rem .75rem 1rem;
}
.topnav-drawer.is-open { transform: translateY(0); }
.topnav-drawer-section {
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .07em; color: var(--text-muted, #9ca3af);
    padding: .9rem .75rem .35rem;
}
.topnav-drawer-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .65rem .75rem;
    border-radius: 8px;
    color: var(--text-primary, #1f2937); text-decoration: none;
    font-size: .92rem;
    transition: background .12s ease;
}
.topnav-drawer-link:hover, .topnav-drawer-link.is-active {
    background: var(--mo-teal-faint); color: var(--mo-teal-dark);
}
.topnav-drawer-link.is-active { font-weight: 600; }
.topnav-drawer-link i { width: 22px; text-align: center; color: var(--mo-teal); }
.topnav-backdrop {
    position: fixed; inset: 0; top: 64px;
    background: rgba(15, 23, 42, .35);
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
    z-index: 38;
}
.topnav-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    /* Slim labels at narrow widths to keep everything in one row */
    .topnav-link .topnav-link-label { display: none; }
    .topnav-link i { font-size: 1rem; }
    .topnav-user .topnav-user-name-inline { display: none; }
}
@media (max-width: 768px) {
    .topnav-primary { display: none; }
    .topnav-actions .topnav-iconbtn[data-mobile-hide] { display: none; }
    .topnav-hamburger { display: inline-flex; }
    body[data-portal="business"] .main-content,
    body[data-portal="admin"] .main-content,
    body[data-portal="sales"] .main-content { padding: 1rem; }
}

/* Hide the legacy mobile-toggle on every portal using the new topnav. */
body[data-portal="business"] .mobile-toggle,
body[data-portal="admin"] .mobile-toggle,
body[data-portal="sales"] .mobile-toggle { display: none !important; }

/* When SocialInboxBadges ViewComponent is rendered inside a dropdown, it
   emits its existing .nav-item markup. Rewrite its visual to match the new
   topnav-dropdown-link style so the SignalR data attributes stay intact. */
.topnav-dropdown .nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .65rem; border-radius: 7px;
    color: var(--text-primary, #1f2937);
    background: none !important; border: none;
    font-size: .88rem; line-height: 1.3;
    text-decoration: none;
}
.topnav-dropdown .nav-item:hover {
    background: var(--mo-teal-faint) !important;
    color: var(--mo-teal-dark) !important;
}
.topnav-dropdown .nav-item.active {
    background: var(--mo-teal-faint) !important;
    color: var(--mo-teal-dark) !important;
    font-weight: 600;
}
.topnav-dropdown .nav-item i {
    width: 18px; text-align: center;
    color: var(--mo-teal); opacity: .9;
}
