/* ── Theme Variables ───────────────────────────────────────────────────── */
:root {
    --bg-body: #0a0a12;
    --bg-sidebar: #0e0e18;
    --bg-card: #12121e;
    --bg-input: #0a0a12;
    --border: #1a1a2e;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #5558e6;
    --accent-light: #818cf8;
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-info: #3b82f6;
    --status-error: #ef4444;
    --status-cyan: #06b6d4;
}
.theme-light {
    --bg-body: #f5f5f7;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f0f0f3;
    --border: #e2e4e9;
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent: #6366f1;
    --accent-hover: #5558e6;
    --accent-light: #818cf8;
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-info: #3b82f6;
    --status-error: #ef4444;
    --status-cyan: #06b6d4;
}
.theme-high-contrast {
    --bg-body: #000000;
    --bg-sidebar: #0a0a0a;
    --bg-card: #111111;
    --bg-input: #000000;
    --border: #333333;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --accent: #5b9bd5;
    --accent-hover: #4a8bc4;
    --accent-light: #7bb3e0;
    --status-success: #5b9bd5;
    --status-warning: #e6c619;
    --status-info: #5b9bd5;
    --status-error: #e85d5d;
    --status-cyan: #5b9bd5;
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

/* Body lock when mobile overlay is open (prevents iOS keyboard scroll bug) */
body.mobile-overlay-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ── Login ────────────────────────────────────────────────────────────── */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}
.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 14px;
}
.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.login-card input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    margin-bottom: 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.login-card button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}
.login-card button[type="submit"]:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.25);
}
.alert {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-error);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Registration ───────────────────────────────────────────────────── */
.register-card {
    max-width: 520px;
}
.register-card .form-select {
    margin-bottom: 18px;
}
.register-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.register-col label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.register-col input,
.register-col select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    margin-bottom: 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.register-col input:focus,
.register-col select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.password-wrap {
    position: relative;
}
.password-wrap input {
    padding-right: 40px;
}
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
}
.password-toggle:hover {
    color: var(--accent);
}
.password-toggle svg {
    width: 18px;
    height: 18px;
}
.login-forgot {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
}
.login-forgot a {
    color: var(--text-muted);
}
.login-forgot a:hover {
    color: var(--accent);
}
.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
}
.login-footer a {
    color: var(--accent);
    font-weight: 600;
}
.login-footer a:hover {
    color: var(--accent-light);
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-brand {
    padding: 24px 20px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo-img {
    width: 91px;
    height: auto;
    flex-shrink: 0;
}
.mobile-brand-logo {
    width: 72px;
    height: auto;
    flex-shrink: 0;
}
.sidebar-brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.sidebar-nav-item .notif-badge {
    position: static;
    margin-left: auto;
    flex-shrink: 0;
}
.sidebar-nav-item:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}
.sidebar-nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
}
.sidebar-nav-item i { width: 18px; height: 18px; }
.sidebar-bottom {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.sidebar-business {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-signout {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-signout:hover { color: var(--accent-light); }
.sidebar-signout i { width: 14px; height: 14px; }

/* Mobile hamburger */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    z-index: 99;
}
.mobile-hamburger {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}
.mobile-hamburger i { width: 24px; height: 24px; }
.mobile-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-left: 12px;
}
.mobile-notif-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-error);
    margin-left: auto;
}
.mobile-notif-dot.visible { display: block; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

/* ── Main Content ────────────────────────────────────────────────────── */
.main-content {
    margin-left: 240px;
    padding: 32px;
    min-height: 100vh;
    animation: fadeIn 0.35s ease-out;
}

/* ── Range Bar ───────────────────────────────────────────────────────── */
.range-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}
.range-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-right: 4px;
}
.range-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.range-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.range-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
/* ── KPI Cards ───────────────────────────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px 24px;
    transition: border-color 0.25s, box-shadow 0.25s;
    position: relative;
    overflow: hidden;
}
.kpi-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.08);
}
.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.kpi-icon i { width: 18px; height: 18px; }
.kpi-icon.purple { background: rgba(99, 102, 241, 0.12); color: var(--accent); }
.kpi-icon.green  { background: rgba(16, 185, 129, 0.12); color: var(--status-success); }
.kpi-icon.amber  { background: rgba(245, 158, 11, 0.12); color: var(--status-warning); }
.kpi-icon.blue   { background: rgba(59, 130, 246, 0.12); color: var(--status-info); }
.kpi-icon.cyan   { background: rgba(6, 182, 212, 0.12); color: var(--status-cyan); }
.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* ── Charts Toggle Bar ───────────────────────────────────────────────── */
.charts-toggle-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    margin-top: 12px;
    cursor: pointer;
}
.charts-toggle-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.charts-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    margin-left: auto;
}
.charts-toggle-btn:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}
.charts-toggle-btn i {
    width: 18px;
    height: 18px;
    transition: transform 0.25s;
}
.charts-toggle-btn.expanded i {
    transform: rotate(180deg);
}

/* ── Charts Grid ─────────────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
    margin-bottom: 28px;
}
.charts-grid.collapsed {
    display: none;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.chart-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.08);
}
.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}
.chart-wrap {
    position: relative;
    height: 220px;
}
.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Search + Filter Bar ─────────────────────────────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.search-wrap {
    position: relative;
    flex: 0 1 280px;
}
.search-wrap i,
.search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-tabs {
    display: flex;
    gap: 4px;
}
.filter-tab {
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.filter-tab:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.06);
}
.filter-tab.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.2);
}
.filter-tab.awaiting-active {
    border-color: var(--status-warning);
    color: var(--status-warning);
    background: rgba(245, 158, 11, 0.08);
}

/* ── Content Split ───────────────────────────────────────────────────── */
.content-split {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    min-width: 0;
    align-items: start;
}
.lead-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
}
.lead-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.lead-table-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}
.lead-action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}
.lead-table-wrap h2,
.convo-panel h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}


/* ── Lead Table ──────────────────────────────────────────────────────── */
.lead-table { width: 100%; border-collapse: collapse; }
.lead-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.lead-table td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.lead-row {
    cursor: pointer;
    transition: background 0.15s;
}
.lead-row:hover {
    background: rgba(99, 102, 241, 0.04);
}
.lead-row.selected {
    background: rgba(99, 102, 241, 0.08);
}

/* Avatar circle */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
}
.badge.qualified {
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-success);
}

/* Status dots */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    background: #475569;
}
.status-dot.new      { background: var(--status-info); }
.status-dot.active   { background: var(--status-warning); }
.status-dot.qualified { background: var(--status-success); }
.status-dot.closed   { background: var(--text-muted); }

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    padding: 32px 0;
    text-align: center;
}

/* ── Conversation Panel ──────────────────────────────────────────────── */
.convo-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
    position: sticky;
    top: 32px;
    min-width: 0;
}
.convo-back-btn {
    display: none;
}
.convo-details-toggle {
    display: none;
}

/* Lead detail header inside convo panel */
.convo-lead-detail {
    display: none;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.convo-lead-detail.visible { display: block; }
.convo-lead-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
}

.convo-thread {
    flex: 1;
    overflow-y: auto;
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.convo-thread::-webkit-scrollbar { width: 6px; }
.convo-thread::-webkit-scrollbar-track { background: transparent; }
.convo-thread::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.bubble.inbound {
    background: var(--border);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.bubble.outbound {
    background: var(--accent);
    color: #fff;
    margin-left: auto;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.bubble-meta {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.5;
}

/* Loading spinner */
.convo-loading {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}
.convo-loading.visible { display: flex; }
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Detail Panel (shared across dashboard + pipeline) ───────────────── */
.detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-width: 0;
    overflow: hidden;
}
.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.detail-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.detail-meta-item i { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.detail-meta-item span { color: var(--text-secondary); }
a.detail-meta-link { text-decoration: none; color: inherit; cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: -2px -4px; }
a.detail-meta-link:hover { background: var(--bg-hover); }
a.detail-meta-link i { color: var(--accent); }
a.detail-meta-link span { color: var(--accent); }
.detail-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0;
}
.detail-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}
.detail-section-toggle i {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.detail-section-toggle.open i {
    transform: rotate(180deg);
}
.detail-collapsible {
    display: none;
    padding-top: 8px;
}
.detail-collapsible.open {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.detail-convo-title {
    padding-top: 4px;
}
.detail-followups-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.detail-followups {
    gap: 6px;
}
.detail-followup-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.detail-followup-day {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 44px;
}
.detail-followup-date {
    color: var(--text-muted);
    margin-left: auto;
    font-size: 12px;
}
.detail-followup-item .badge-status i { width: 12px; height: 12px; }

/* ── Page Header ─────────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.page-desc {
    font-size: 14px;
    color: var(--text-muted);
}

/* ── Follow-up Badges ────────────────────────────────────────────────── */
.followup-number {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
}
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.badge-status.sent {
    background: rgba(16, 185, 129, 0.1);
    color: var(--status-success);
}
.badge-status.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--status-warning);
}
.followup-row {
    transition: background 0.15s;
}
.followup-row:hover {
    background: rgba(99, 102, 241, 0.04);
}

/* ── Settings ────────────────────────────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}
.settings-card h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.readonly-field {
    padding: 10px 14px;
    background: rgba(10, 10, 18, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    word-break: break-all;
}
.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.checkbox-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.form-textarea::placeholder {
    color: var(--text-muted);
}

.guided-rules-fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 16px 8px;
    margin: 0 0 16px;
}
.guided-rules-fieldset legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 6px;
}

.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}
.alert-success {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.08);
    color: var(--status-success);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

/* ── Mobile Chat Header (popup overlay) ──────────────────────────────── */
/* Hidden by default on desktop, shown only on mobile */
.mobile-chat-header { display: none; }
.convo-thread-expand { display: none; }
.mobile-chat-back {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-chat-back i { width: 20px; height: 20px; }
.mobile-chat-name {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .source-costs-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .content-split { grid-template-columns: 1fr; }
    .convo-panel { position: static; max-height: none; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .mobile-header {
        display: flex;
    }
    .main-content {
        margin-left: 0;
        padding: 72px 16px calc(56px + 24px + env(safe-area-inset-bottom));
    }
    .page-header h1 { font-size: 20px; }
    .page-desc { font-size: 13px; }
    .range-bar { flex-wrap: wrap; }
    .kpi-row { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi-value { font-size: 24px; }
    .chart-wrap { height: 200px; }
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-wrap { flex: 1 1 auto; }
    .lead-table-wrap { padding: 12px; }
    .filter-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 2px; }
    .filter-tab { padding: 6px 8px; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
    .lead-table th:nth-child(3),
    .lead-table td:nth-child(3) { display: none; }
    .lead-table th, .lead-table td { padding: 12px 10px; font-size: 13px; }
    .lead-row { min-height: 44px; }
    .login-wrap { padding: 24px 16px; align-items: flex-start; min-height: 0; }
    .login-card { padding: 32px 24px; }
    .settings-card { padding: 16px; }
    .readonly-field { font-size: 12px; }

    /* Compact inline convo panel on mobile */
    .convo-panel { padding: 12px; max-width: 100%; overflow-x: hidden; }
    .convo-lead-detail { padding-bottom: 8px; margin-bottom: 8px; }
    .detail-meta { gap: 4px; }
    .detail-meta-item { font-size: 12px; }
    .convo-thread { max-height: 120px; overflow-y: auto; cursor: pointer; position: relative; -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 40%); mask-image: linear-gradient(to bottom, transparent 0%, #000 40%); }
    .convo-thread-expand { display: block; text-align: center; font-size: 12px; font-weight: 600; color: var(--accent); padding: 6px 0 0; cursor: pointer; background: none; border: none; width: 100%; font-family: inherit; }
    .convo-thread-expand:hover { color: var(--accent-light); }
    .reply-bar { padding: 8px 0 0; }
    .reply-input { font-size: 16px; min-height: 34px; }
    .reply-channel-select { padding: 6px 8px; font-size: 16px; }
    .reply-send-btn { padding: 6px 10px; font-size: 14px; }

    /* Mobile conversation panel — full-screen overlay */
    .convo-panel.mobile-open {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 98;
        max-height: none;
        border-radius: 0;
        border: none;
        overflow: hidden;
        padding: 16px;
    }
    /* Mobile chat header — shown in popup, replaces back button */
    .convo-panel.mobile-open .mobile-chat-header {
        display: flex;
        align-items: center;
        gap: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 8px;
    }
    .convo-panel.mobile-open .convo-back-btn { display: none !important; }
    .convo-panel.mobile-open .convo-lead-detail { display: none !important; }
    /* Hide original AI toggle in popup (it's in the chat header now) */
    .convo-panel.mobile-open .detail-header .ai-toggle-wrap { display: none !important; }

    /* Hide detail sections on mobile popup — conversation takes priority */
    .convo-panel.mobile-open .detail-meta,
    .convo-panel.mobile-open .detail-followups-section,
    .convo-panel.mobile-open .detail-appointments-section,
    .convo-panel.mobile-open .detail-convo-title {
        display: none !important;
    }
    /* In popup, thread expands fully */
    .convo-panel.mobile-open .convo-thread { max-height: none; cursor: default; -webkit-mask-image: none; mask-image: none; }
    .convo-panel.mobile-open .convo-thread-expand { display: none; }
    /* Show them when details are expanded */
    .convo-panel.mobile-open.mobile-details-open .detail-meta,
    .convo-panel.mobile-open.mobile-details-open .detail-followups-section,
    .convo-panel.mobile-open.mobile-details-open .detail-appointments-section {
        display: block !important;
    }
    /* Details toggle button (mobile only) */
    .convo-panel.mobile-open .convo-details-toggle {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 12px;
        font-family: inherit;
        cursor: pointer;
        padding: 6px 0 0;
        margin: 0;
    }
    .convo-panel.mobile-open .convo-details-toggle i {
        width: 14px;
        height: 14px;
        transition: transform 0.2s;
    }
    .convo-panel.mobile-open.mobile-details-open .convo-details-toggle i {
        transform: rotate(180deg);
    }
    /* Compact lead detail on mobile */
    .convo-panel.mobile-open .convo-lead-detail {
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    /* Reply bar stays single row */
    .convo-panel.mobile-open .reply-bar {
        flex-wrap: nowrap;
        padding: 8px 0 0;
    }
    .convo-panel.mobile-open .reply-input {
        min-width: 0;
        min-height: 34px;
        font-size: 16px; /* Prevents iOS auto-zoom on input focus */
    }
    .convo-panel.mobile-open .reply-channel-select {
        padding: 6px 8px;
    }
    .convo-panel.mobile-open .reply-send-btn {
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-card { padding: 12px; }
    .kpi-value { font-size: 20px; }
    .lead-table th:nth-child(2),
    .lead-table td:nth-child(2) { display: none; }
    .register-row { grid-template-columns: 1fr; }
}

/* ── Kanban Board ────────────────────────────────────────────────────── */
.kanban-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 0;
}
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: start;
}
.kanban-column {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}
.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.kanban-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kanban-column-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.kanban-count {
    margin-left: auto;
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}
.kanban-cards {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 60px;
}

/* ── Kanban Card ─────────────────────────────────────────────────────── */
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: grab;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.kanban-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.kanban-card-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.kanban-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kanban-card-service {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
}
.kanban-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.kanban-card-source {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.kanban-card-source.sms { background: rgba(99, 102, 241, 0.12); color: #818cf8; }
.kanban-card-source.email { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.kanban-card-source.web_form { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.kanban-card-source.chat_widget { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.kanban-card-source.unknown { background: rgba(100, 116, 139, 0.12); color: #94a3b8; }
.kanban-card-date {
    font-size: 11px;
    color: var(--text-muted);
}
.kanban-card-phone {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
.kanban-card-phone i { width: 12px; height: 12px; }

/* SortableJS drag states */
.kanban-card-ghost {
    opacity: 0.4;
}
.kanban-card-chosen {
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.2);
    transform: rotate(1.5deg);
}
.kanban-card-drag {
    opacity: 0;
}

/* ── Kanban Empty State ──────────────────────────────────────────────── */
.kanban-empty {
    text-align: center;
    padding: 80px 0;
    color: var(--text-muted);
}
.kanban-empty i { width: 48px; height: 48px; margin-bottom: 16px; }
.kanban-empty p { font-size: 14px; }

/* ── Kanban Modal (slide-in from right) ──────────────────────────────── */
.kanban-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.kanban-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.kanban-modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 460px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 201;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}
.kanban-modal.open {
    transform: translateX(0);
}
.kanban-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.kanban-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.kanban-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.kanban-modal-close:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}
.kanban-modal-close i { width: 20px; height: 20px; }
.kanban-modal-meta {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.kanban-modal-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.kanban-modal-meta-item i { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.kanban-modal-meta-item strong { color: var(--text-primary); font-weight: 500; }
.kanban-modal-convo {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px 24px;
}
.kanban-modal-convo h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.kanban-modal-convo .convo-thread {
    flex: 1;
    overflow-y: auto;
}
.kanban-modal-loading {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}
.kanban-modal-loading.visible { display: flex; }

/* ── AI Toggle Switch ────────────────────────────────────────────────── */
.lead-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lead-delete-btn:hover {
    color: var(--status-error, #e85d5d);
    background: rgba(232, 93, 93, 0.1);
}
.lead-delete-btn svg { width: 16px; height: 16px; }
.ai-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.ai-toggle-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.ai-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.ai-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.ai-toggle-slider {
    position: absolute;
    inset: 0;
    background: #334155;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.25s;
}
.ai-toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
}
.ai-toggle input:checked + .ai-toggle-slider {
    background: var(--status-success);
}
.ai-toggle input:checked + .ai-toggle-slider::before {
    transform: translateX(20px);
}
.ai-toggle input:disabled + .ai-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Notification Bell ──────────────────────────────────────────────── */
.notif-bell-wrap {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.15s;
    background: none;
    border: none;
    font: inherit;
    color: inherit;
}
.notif-bell-wrap:hover {
    background: rgba(99, 102, 241, 0.08);
}
.notif-bell-wrap i {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    background: var(--status-error);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
}
.notif-badge.visible {
    display: flex;
}

/* ── Notification Dropdown ─────────────────────────────────────────── */
.notif-bell-container {
    position: relative;
}
.notif-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 340px;
    max-height: 420px;
    background: #1e1e2e;
    border: 1px solid #2a2a3e;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 200;
    overflow: hidden;
    margin-bottom: 8px;
}
.notif-dropdown.open {
    display: flex;
    flex-direction: column;
}
.notif-header {
    padding: 14px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid #2a2a3e;
    flex-shrink: 0;
}
.notif-list {
    overflow-y: auto;
    flex: 1;
    max-height: 370px;
}
.notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.notif-item:last-child {
    border-bottom: none;
}
.notif-item:hover {
    background: rgba(99, 102, 241, 0.08);
}
.notif-item.unread {
    background: rgba(99, 102, 241, 0.05);
}
.notif-item.unread:hover {
    background: rgba(99, 102, 241, 0.1);
}
.notif-item-body {
    flex: 1;
    min-width: 0;
}
.notif-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-item-text {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.notif-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 1px;
}

/* ── Toast Notifications ────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
}
.toast {
    background: #1e1e2e;
    border: 1px solid #2a2a3e;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    cursor: pointer;
    animation: toastSlideIn 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}
.toast.dismissing {
    opacity: 0;
    transform: translateX(100%);
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toast-icon i { width: 16px; height: 16px; }
.toast-icon.new_lead { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.toast-icon.lead_responded { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.toast-icon.lead_qualified { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.toast-body {
    flex: 1;
    min-width: 0;
}
.toast-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.toast-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Kanban Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 768px) {
    .kanban-board {
        display: block;
    }
    .kanban-column {
        display: none;
        min-height: 200px;
    }
    .kanban-column.mobile-active {
        display: flex;
    }
    .kanban-column-header {
        display: none;
    }
    .kanban-modal {
        width: 100%;
    }
    .toast-container {
        left: 16px;
        right: 16px;
        bottom: calc(56px + 16px + env(safe-area-inset-bottom));
        max-width: 100%;
    }
    .notif-dropdown {
        width: calc(100vw - 32px);
        left: -8px;
        max-height: 60vh;
    }
    .source-costs-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .source-costs-grid { grid-template-columns: 1fr; }
}

/* ── Kanban Card Value ──────────────────────────────────────────────── */
.kanban-card-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--status-cyan);
    margin-bottom: 6px;
}

/* ── Kanban Column Total ────────────────────────────────────────────── */
.kanban-column-total {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--status-cyan);
    text-align: right;
}

/* ── Detail Value Edit Button ───────────────────────────────────────── */
.detail-value-edit-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 4px;
    transition: color 0.15s, background 0.15s;
}
.detail-value-edit-btn:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}
.detail-value-edit-btn i { width: 12px; height: 12px; }

/* ── Follow-up Day Chips ────────────────────────────────────────────── */
.followup-days-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.followup-day-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-light);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}
.chip-remove {
    background: none;
    border: none;
    color: var(--accent-light);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}
.chip-remove:hover {
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.1);
}
.followup-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.followup-day-input {
    width: 100px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
}
.followup-day-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.btn-secondary {
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
}

/* ── Source Costs Grid ──────────────────────────────────────────────── */
.source-costs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 20px;
}
.input-with-prefix {
    display: flex;
    align-items: stretch;
}
.input-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--border);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}
.input-with-prefix input {
    border-radius: 0 8px 8px 0;
    flex: 1;
    min-width: 0;
}

/* ── Import CSV Button ──────────────────────────────────────────────── */
.import-csv-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* ── Add Lead Modal ─────────────────────────────────────────────────── */
.add-lead-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.add-lead-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.add-lead-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 480px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    z-index: 201;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.add-lead-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}
.add-lead-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.add-lead-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.add-lead-form {
    padding: 20px 24px 24px;
}
.add-lead-form .form-group { margin-bottom: 14px; }

/* ── Third-Party Source Badge Colors ────────────────────────────────── */
.kanban-card-source.yelp { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.kanban-card-source.thumbtack { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }
.kanban-card-source.angi { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.kanban-card-source.google_lsa { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.kanban-card-source.homeadvisor { background: rgba(249, 115, 22, 0.12); color: #f97316; }
.kanban-card-source.nextdoor { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.kanban-card-source.facebook { background: rgba(99, 102, 241, 0.12); color: #818cf8; }
.kanban-card-source.manual { background: rgba(100, 116, 139, 0.12); color: #94a3b8; }
.kanban-card-source.csv_import { background: rgba(100, 116, 139, 0.12); color: #94a3b8; }
.kanban-card-source.google_business { background: rgba(66, 133, 244, 0.12); color: #4285f4; }
.kanban-card-source.google_ads { background: rgba(52, 168, 83, 0.12); color: #34a853; }
.kanban-card-source.instagram { background: rgba(225, 48, 108, 0.12); color: #e1306c; }
.kanban-card-source.tiktok { background: rgba(0, 0, 0, 0.12); color: #ee1d52; }
.kanban-card-source.houzz { background: rgba(77, 190, 70, 0.12); color: #4dbe46; }
.kanban-card-source.porch { background: rgba(0, 150, 136, 0.12); color: #009688; }
.kanban-card-source.bark { background: rgba(0, 123, 255, 0.12); color: #007bff; }
.kanban-card-source.craftjack { background: rgba(255, 152, 0, 0.12); color: #ff9800; }
.kanban-card-source.referral { background: rgba(156, 39, 176, 0.12); color: #9c27b0; }
.kanban-card-source.yard_sign { background: rgba(121, 85, 72, 0.12); color: #795548; }
.kanban-card-source.direct_mail { background: rgba(96, 125, 139, 0.12); color: #607d8b; }

/* ── Source Costs Toggle ──────────────────────────────────────────────── */
.source-costs-collapsible {
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.source-costs-collapsible.collapsed {
    max-height: 0 !important;
}

/* ── Business Hours Grid ─────────────────────────────────────────────── */
.hours-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.hours-preset-btn {
    padding: 6px 14px !important;
    font-size: 13px !important;
    transition: opacity 0.2s, background 0.2s, border-color 0.2s;
}

.hours-presets.has-active .hours-preset-btn {
    opacity: 0.45;
}

.hours-presets.has-active .hours-preset-btn.preset-active {
    opacity: 1;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.hours-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hours-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: opacity 0.2s;
}

.hours-row.hours-closed {
    opacity: 0.45;
}

.hours-day-label {
    width: 100px;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.hours-time-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 14px;
    width: 130px;
}

.hours-time-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.hours-time-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hours-to {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.hours-closed-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
}

.hours-closed-toggle input[type="checkbox"] {
    accent-color: var(--accent);
}

@media (max-width: 480px) {
    .hours-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .hours-day-label {
        width: 100%;
        margin-bottom: 2px;
    }
    .hours-time-input {
        width: calc(50% - 20px);
        flex: 1;
    }
    .hours-closed-toggle {
        margin-left: 0;
        width: 100%;
        margin-top: 2px;
    }
}

/* ── Sortable Tab List (Appearance settings) ──────────────────────────── */
.sortable-tab-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.sortable-tab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: grab;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sortable-tab-item:active {
    cursor: grabbing;
}
.sortable-tab-item i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.sortable-tab-item .drag-handle {
    color: var(--text-muted);
    margin-right: 4px;
}
.sortable-tab-ghost {
    opacity: 0.4;
}
.sortable-tab-chosen {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

/* ── Reset Default Button ─────────────────────────────────────────────── */
.btn-reset {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-reset:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
    border-color: var(--accent);
}

/* ── Light Theme Overrides ────────────────────────────────────────────── */
.theme-light .readonly-field {
    background: var(--bg-input);
}
.theme-light .notif-dropdown {
    background: #ffffff;
    border-color: var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.theme-light .notif-header {
    border-bottom-color: var(--border);
}
.theme-light .notif-item {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}
.theme-light .toast {
    background: #ffffff;
    border-color: var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.theme-light .bubble.inbound {
    background: var(--bg-input);
}
.theme-light .sidebar-logo-img,
.theme-light .mobile-brand-logo {
    filter: invert(1) hue-rotate(180deg);
}

/* ── High Contrast Overrides ──────────────────────────────────────────── */
.theme-high-contrast .notif-dropdown {
    background: #1a1a1a;
    border-color: var(--border);
}
.theme-high-contrast .toast {
    background: #1a1a1a;
    border-color: var(--border);
}

/* ── Welcome Header ──────────────────────────────────────────────────── */
.welcome-header {
    margin-bottom: 24px;
}
.welcome-greeting {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.welcome-stats-row {
    display: flex;
    gap: 12px;
}
.welcome-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    flex: 1;
    min-width: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.welcome-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.06);
}
.welcome-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.welcome-card-link:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.08);
}
.welcome-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.welcome-card-icon i { width: 16px; height: 16px; }
.welcome-card-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--status-success); }
.welcome-card-icon.amber { background: rgba(245, 158, 11, 0.12); color: var(--status-warning); }
.welcome-card-icon.blue  { background: rgba(59, 130, 246, 0.12); color: var(--status-info); }
.welcome-card-body {
    min-width: 0;
}
.welcome-card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.welcome-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── KPI Trend Badges ───────────────────────────────────────────────── */
.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 6px;
}
.kpi-trend.up {
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-success);
}
.kpi-trend.down {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-error);
}
.kpi-trend.neutral {
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-muted);
}
.kpi-trend.inverted.up {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-error);
}
.kpi-trend.inverted.down {
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-success);
}

/* ── Kanban Card Status Borders ─────────────────────────────────────── */
.kanban-card.status-new {
    border-left: 3px solid var(--status-info);
}
.kanban-card.status-active {
    border-left: 3px solid var(--status-warning);
}
.kanban-card.status-qualified {
    border-left: 3px solid var(--status-success);
}
.kanban-card.status-closed {
    border-left: 3px solid var(--text-muted);
}
.kanban-card-qualified {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-success);
    margin-left: 6px;
}
.kanban-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
    transform: translateY(-2px);
}

/* ── Reply Bar ──────────────────────────────────────────────────────── */
.reply-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.reply-input {
    flex: 1;
    min-height: 38px;
    max-height: 120px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.reply-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.reply-input::placeholder {
    color: var(--text-muted);
}
.reply-channel-select {
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    min-width: 68px;
    text-align: center;
}
.reply-channel-select:focus {
    outline: none;
    border-color: var(--accent);
}
.reply-send-btn {
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.reply-send-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}
.reply-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.reply-send-btn i {
    width: 14px;
    height: 14px;
}

/* ── Skeleton Shimmer ───────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(99, 102, 241, 0.06) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Page Fade-in ───────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive: New Components ─────────────────────────────────────── */
@media (max-width: 768px) {
    .welcome-greeting { font-size: 18px; }
    .welcome-stats-row { gap: 8px; }
    .welcome-card { padding: 10px 12px; gap: 10px; }
    .welcome-card-value { font-size: 18px; }
    .welcome-card-label { font-size: 11px; }
    .welcome-card-icon { width: 28px; height: 28px; }
    .welcome-card-icon i { width: 14px; height: 14px; }
    .reply-bar { flex-wrap: nowrap; }
}
@media (max-width: 480px) {
    .kpi-trend { font-size: 11px; padding: 1px 6px; }
    .welcome-greeting { font-size: 16px; }
    .welcome-stats-row { flex-wrap: wrap; }
    .welcome-card { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 8px 10px; gap: 8px; }
    .welcome-card-value { font-size: 16px; }
    .welcome-card-icon { width: 26px; height: 26px; }
    .welcome-card-icon i { width: 13px; height: 13px; }
}

/* ── Calendar ────────────────────────────────────────────────────────── */
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.cal-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.cal-header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}
.cal-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cal-nav-btn {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}
.cal-nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.cal-nav-btn i { width: 16px; height: 16px; }
.cal-today-btn { padding: 6px 14px; }
.cal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 8px;
}
.cal-view-switcher {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.cal-view-btn {
    padding: 7px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.cal-view-btn:hover { color: var(--text-primary); }
.cal-view-btn.active {
    background: var(--accent);
    color: #fff;
}
.cal-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.cal-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    min-height: 500px;
}
.cal-loading {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10;
}

/* Month View */
.cal-month-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}
.cal-month-day-name {
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(100px, auto);
}
.cal-day-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 100px;
}
.cal-day-cell:nth-child(7n) { border-right: none; }
.cal-day-cell:hover { background: rgba(99, 102, 241, 0.04); }
.cal-day-cell.cal-today { background: rgba(99, 102, 241, 0.06); }
.cal-day-cell.cal-other-month { opacity: 0.35; }
.cal-day-num {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.cal-today .cal-day-num {
    background: var(--accent);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-day-appts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Appointment Pills */
.cal-appt-pill {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s;
}
.cal-appt-pill:hover { opacity: 0.8; }
.cal-appt-pill.appt-cancelled { opacity: 0.4; text-decoration: line-through; }

.appt-indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.appt-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.appt-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.appt-green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.appt-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.appt-cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.appt-pink { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
.appt-gray { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

.cal-more-link {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    padding: 1px 4px;
    cursor: pointer;
}

/* Week / Day View */
.cal-week-header {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}
.cal-time-gutter { padding: 10px; }
.cal-week-day-header {
    padding: 10px;
    text-align: center;
    border-left: 1px solid var(--border);
}
.cal-week-day-header.cal-today { background: rgba(99, 102, 241, 0.06); }
.cal-week-day-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.cal-week-day-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.cal-week-day-header.cal-today .cal-week-day-num { color: var(--accent); }

.cal-week-body {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    position: relative;
}
.cal-day-view {
    display: grid;
    grid-template-columns: 60px 1fr;
    position: relative;
}
.cal-time-column {
    border-right: 1px solid var(--border);
}
.cal-time-slot {
    height: 60px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    border-bottom: 1px solid rgba(26, 26, 46, 0.3);
}
.cal-week-col, .cal-day-col {
    position: relative;
    border-left: 1px solid var(--border);
}
.cal-week-col.cal-today-col, .cal-day-col.cal-today-col {
    background: rgba(99, 102, 241, 0.03);
}
.cal-hour-cell {
    height: 60px;
    border-bottom: 1px solid rgba(26, 26, 46, 0.3);
    cursor: pointer;
    transition: background 0.1s;
}
.cal-hour-cell:hover { background: rgba(99, 102, 241, 0.06); }

/* Week/Day Appointment Blocks */
.cal-week-appt {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    overflow: hidden;
    z-index: 5;
    transition: opacity 0.15s;
}
.cal-week-appt:hover { opacity: 0.85; }
.cal-week-appt.appt-cancelled { opacity: 0.4; }
.cal-week-appt-time {
    font-weight: 600;
    font-size: 11px;
    margin-bottom: 2px;
}
.cal-week-appt-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-week-appt-loc {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 2px;
}

/* Calendar Modals */
.cal-modal-overlay, .cal-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.cal-modal-overlay.open, .cal-detail-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.cal-modal, .cal-detail-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 480px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    z-index: 201;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.cal-modal.open, .cal-detail-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}
.cal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.cal-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.cal-modal-form {
    padding: 20px 24px 24px;
}
.cal-modal-form .form-group { margin-bottom: 14px; }

/* Detail Modal */
.cal-detail-body {
    padding: 20px 24px;
}
.cal-detail-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.cal-detail-row i { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.cal-detail-row strong { color: var(--text-primary); }
.cal-detail-type {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.cal-detail-actions {
    display: flex;
    gap: 8px;
    padding: 0 24px 24px;
    flex-wrap: wrap;
}
.cal-detail-action {
    font-size: 13px;
}
.cal-action-cancel { color: var(--status-warning) !important; border-color: rgba(245, 158, 11, 0.3) !important; }
.cal-action-cancel:hover { background: rgba(245, 158, 11, 0.1) !important; }
.cal-action-delete { color: var(--status-error) !important; border-color: rgba(239, 68, 68, 0.3) !important; }
.cal-action-delete:hover { background: rgba(239, 68, 68, 0.1) !important; }

/* Appointment section in lead detail */
.detail-appointments-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.detail-appt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    margin-bottom: 6px;
}
.detail-appt-type {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}
.detail-appt-date {
    color: var(--text-muted);
    margin-left: auto;
    font-size: 12px;
}
.detail-appt-status {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
}
.detail-appt-status.scheduled { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.detail-appt-status.confirmed { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.detail-appt-status.completed { background: rgba(100, 116, 139, 0.12); color: #94a3b8; }
.detail-appt-status.cancelled { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.detail-appt-status.no_show { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

.book-appt-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 6px;
}
.book-appt-btn:hover { background: rgba(99, 102, 241, 0.2); }
.book-appt-btn i { width: 12px; height: 12px; }

/* Calendar toast notification type */
.toast-icon.appointment_booked { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.toast-icon.emergency_lead { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Calendar Responsive */
@media (max-width: 1024px) {
    .cal-header { flex-direction: column; align-items: flex-start; }
    .cal-month-grid { grid-auto-rows: minmax(80px, auto); }
}
@media (max-width: 768px) {
    .cal-header-left { flex-direction: column; align-items: flex-start; gap: 12px; }
    .cal-header-right { flex-direction: column; align-items: flex-start; gap: 8px; }
    .cal-title { font-size: 16px; margin-left: 0; }
    .cal-month-grid { grid-auto-rows: minmax(60px, auto); }
    .cal-day-cell { min-height: 60px; padding: 4px; }

    /* Hide pills, show dots on mobile month view */
    .cal-appt-pill { display: none; }
    .cal-more-link { display: none; }
    .cal-day-dots {
        display: flex;
        gap: 3px;
        flex-wrap: wrap;
        margin-top: 2px;
    }
    .cal-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
    }
    .cal-dot.appt-indigo { background: #818cf8; }
    .cal-dot.appt-blue { background: #60a5fa; }
    .cal-dot.appt-amber { background: #fbbf24; }
    .cal-dot.appt-green { background: #34d399; }
    .cal-dot.appt-purple { background: #a78bfa; }
    .cal-dot.appt-cyan { background: #22d3ee; }
    .cal-dot.appt-pink { background: #f472b6; }
    .cal-dot.appt-gray { background: #94a3b8; }

    /* Week view — hide all columns, show only .mobile-active */
    .cal-week-header { grid-template-columns: 60px 1fr; }
    .cal-week-header .cal-week-day-header { display: none; }
    .cal-week-header .cal-week-day-header.mobile-active { display: block; }
    .cal-week-body { grid-template-columns: 60px 1fr; }
    .cal-week-body .cal-week-col { display: none; }
    .cal-week-body .cal-week-col.mobile-active { display: block; }

    /* Full-screen modals on mobile */
    .cal-modal, .cal-detail-modal {
        top: 0;
        left: 0;
        transform: translateY(100%);
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    .cal-modal.open, .cal-detail-modal.open {
        transform: translateY(0);
    }
    .cal-modal-header {
        flex-shrink: 0;
        padding: 16px 16px;
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    .cal-modal-form {
        flex: 1;
        overflow-y: auto;
        padding: 16px 16px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
    .cal-modal-form .btn-primary {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        z-index: 202;
    }
    .cal-detail-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px 16px;
    }
    .cal-detail-actions {
        flex-shrink: 0;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
    }

    /* Modal close button — 44px touch target */
    .cal-modal .kanban-modal-close,
    .cal-detail-modal .kanban-modal-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .cal-modal .kanban-modal-close i,
    .cal-detail-modal .kanban-modal-close i {
        width: 24px;
        height: 24px;
    }
}

/* ── Week View Tab Switcher (mobile) ─────────────────────────────────── */
.cal-week-tabs {
    display: none;
}
@media (max-width: 768px) {
    .cal-week-tabs {
        display: flex;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 10px;
        overflow: hidden;
        margin-bottom: 12px;
    }
    .cal-week-tab {
        flex: 1;
        padding: 8px 4px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 12px;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
        text-align: center;
        transition: all 0.15s;
        -webkit-user-select: none;
        user-select: none;
    }
    .cal-week-tab:active { opacity: 0.7; }
    .cal-week-tab.active {
        background: var(--accent);
        color: #fff;
    }
    .cal-week-tab-day {
        display: block;
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    .cal-week-tab-num {
        display: block;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.2;
    }
}

/* ── Day Agenda Bottom Sheet (mobile) ────────────────────────────────── */
.cal-agenda-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 198;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.cal-agenda-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.cal-day-agenda {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    z-index: 199;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
}
.cal-day-agenda.open {
    transform: translateY(0);
}
.cal-agenda-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.cal-agenda-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.cal-agenda-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
}
.cal-agenda-close:active { background: rgba(99, 102, 241, 0.08); }
.cal-agenda-close i { width: 20px; height: 20px; }
.cal-agenda-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 20px;
}
.cal-agenda-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: opacity 0.1s;
    -webkit-user-select: none;
    user-select: none;
}
.cal-agenda-item:last-child { border-bottom: none; }
.cal-agenda-item:active { opacity: 0.7; }
.cal-agenda-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-agenda-dot.appt-indigo { background: #818cf8; }
.cal-agenda-dot.appt-blue { background: #60a5fa; }
.cal-agenda-dot.appt-amber { background: #fbbf24; }
.cal-agenda-dot.appt-green { background: #34d399; }
.cal-agenda-dot.appt-purple { background: #a78bfa; }
.cal-agenda-dot.appt-cyan { background: #22d3ee; }
.cal-agenda-dot.appt-pink { background: #f472b6; }
.cal-agenda-dot.appt-gray { background: #94a3b8; }
.cal-agenda-info {
    flex: 1;
    min-width: 0;
}
.cal-agenda-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.cal-agenda-title {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-agenda-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 14px;
}
.cal-agenda-empty i {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}
.cal-agenda-add {
    margin: 12px 20px 16px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ── Calendar Empty State ────────────────────────────────────────────── */
.cal-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}
.cal-empty-state i {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
    opacity: 0.4;
}

/* ── Help Link Icons ──────────────────────────────────────────────────── */
.help-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    opacity: 0.45;
    text-decoration: none;
    transition: opacity 0.15s, color 0.15s;
    vertical-align: middle;
    margin-left: 6px;
}
.help-link i, .help-link svg {
    width: 14px;
    height: 14px;
}
.help-link:hover {
    opacity: 1;
    color: var(--accent);
}

/* ── Documentation Page ───────────────────────────────────────────────── */
.docs-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 32px;
    align-items: start;
}
.docs-toc {
    position: sticky;
    top: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.docs-toc-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.docs-toc a {
    display: block;
    padding: 5px 0;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s;
}
.docs-toc a:hover {
    color: var(--accent);
}
.docs-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.docs-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 28px;
    scroll-margin-top: 24px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.docs-card:target {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
    animation: docsHighlight 2s ease-out;
}
.docs-card h3:target {
    color: var(--accent);
    animation: docsHighlight 2s ease-out;
    border-radius: 6px;
    padding-left: 8px;
    margin-left: -8px;
}
@keyframes docsHighlight {
    0% { background: rgba(99, 102, 241, 0.15); }
    100% { background: transparent; }
}
.docs-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.docs-card h2 i, .docs-card h2 svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}
.docs-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 10px 0;
}
.docs-card ul {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    padding-left: 20px;
    margin: 0 0 10px 0;
}
.docs-card strong {
    color: var(--text-primary);
}
.docs-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 8px 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    scroll-margin-top: 24px;
}
.docs-card h3:first-of-type {
    margin-top: 12px;
}
.docs-card h3 i, .docs-card h3 svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}
@media (max-width: 1024px) {
    .docs-layout {
        grid-template-columns: 1fr;
    }
    .docs-toc {
        position: static;
    }
}
@media (max-width: 768px) {
    .docs-card {
        scroll-margin-top: 72px;
        padding: 18px 20px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE APP EXPERIENCE — Bottom Tab Bar, Mobile Header, Pipeline Tabs,
   Touch Targets, Safe Areas, PWA
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Mobile Header (simplified — bell instead of hamburger) ─────────── */
.mobile-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}
.mobile-bell-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    border-radius: 8px;
    transition: background 0.15s;
}
.mobile-bell-btn:hover {
    background: rgba(99, 102, 241, 0.08);
}
.mobile-bell-btn i {
    width: 22px;
    height: 22px;
}
.mobile-bell-badge {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--status-error);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.mobile-bell-badge.visible {
    display: block;
}

/* ── Bottom Tab Bar ─────────────────────────────────────────────────── */
.bottom-tab-bar {
    display: none;
}

@media (max-width: 768px) {
    .bottom-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border);
        z-index: 97;
    }
    body.mobile-overlay-open .bottom-tab-bar,
    body.modal-open .bottom-tab-bar {
        display: none;
    }
}

.tab-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
    -webkit-user-select: none;
    user-select: none;
}
.tab-bar-item i {
    width: 22px;
    height: 22px;
}
.tab-bar-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.tab-bar-item.active {
    color: var(--accent);
}
.tab-bar-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tab-bar-badge {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--status-error);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* ── Pipeline Tab Switcher (mobile only) ────────────────────────────── */
.pipeline-tab-bar {
    display: none;
}

@media (max-width: 768px) {
    .pipeline-tab-bar {
        display: flex;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 3px;
        margin-bottom: 16px;
        gap: 2px;
    }
}

.pipeline-tab {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
    white-space: nowrap;
}
.pipeline-tab.active {
    background: var(--accent);
    color: #fff;
}
.pipeline-tab-count {
    display: inline-block;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    margin-left: 2px;
}
.pipeline-tab:not(.active) .pipeline-tab-count {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-secondary);
}

/* ── Calendar Mobile — FAB + Touch Targets ──────────────────────────── */
@media (max-width: 768px) {
    .cal-nav-btn {
        padding: 10px 14px;
        min-width: 44px;
        min-height: 44px;
    }
    .cal-add-btn {
        position: fixed;
        bottom: calc(56px + 16px + env(safe-area-inset-bottom));
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
        z-index: 96;
        font-size: 0;
    }
    .cal-add-btn i {
        width: 24px;
        height: 24px;
    }
}

/* ── Follow-ups Table Mobile ────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Hide Service (col 2) and Sent At (col 6) on followups page */
    .followup-table-wrap th:nth-child(2),
    .followup-table-wrap td:nth-child(2),
    .followup-table-wrap th:nth-child(6),
    .followup-table-wrap td:nth-child(6) {
        display: none;
    }
}

/* ── Global Mobile — iOS Zoom Prevention ────────────────────────────── */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
    /* Disable double-tap-to-zoom on all interactive elements (iOS ignores user-scalable=no) */
    body {
        touch-action: manipulation;
    }
}

/* ── Global Mobile — Touch Feedback ─────────────────────────────────── */
@media (max-width: 768px) {
    .tab-bar-item:active, .pipeline-tab:active,
    .lead-row:active, .kanban-card:active,
    .cal-week-appt:active, .cal-appt-pill:active,
    .cal-day-cell:active, .cal-agenda-item:active {
        opacity: 0.7;
        transition: opacity 0.05s;
    }
}

/* ── Global — No Text Selection on Interactive Elements ─────────────── */
.tab-bar-item, .pipeline-tab, .filter-tab,
.cal-day-cell, .cal-week-appt, .cal-appt-pill {
    -webkit-user-select: none;
    user-select: none;
}

/* ── Notification Dropdown Mobile Positioning ───────────────────────── */
@media (max-width: 768px) {
    .notif-dropdown {
        position: fixed;
        top: 56px;
        left: 16px;
        right: 16px;
        width: auto;
        max-height: calc(100vh - 56px - 56px - env(safe-area-inset-bottom));
        z-index: 200;
    }
}

/* ── Body Modal Open — hides tab bar and pipeline tabs ──────────────── */
body.modal-open .pipeline-tab-bar {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DETERMINISTIC HOOKS — AI Pause Banner, Banned Phrases, DNC List,
   Notification Types
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── AI Pause Banner (Dashboard) ─────────────────────────────────────── */
.ai-pause-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 10px;
    color: #f59e0b;
    font-size: 14px;
    font-weight: 500;
}
.ai-pause-banner a {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 600;
}

/* ── Banned Phrases Tags ─────────────────────────────────────────────── */
.banned-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
}
.banned-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
}
.banned-tag-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    font-weight: 700;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.banned-tag-remove:hover {
    opacity: 1;
}
.banned-phrase-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}

/* ── DNC Management Card ─────────────────────────────────────────────── */
.dnc-list {
    max-height: 300px;
    overflow-y: auto;
}
.dnc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.dnc-row:last-child {
    border-bottom: none;
}
.dnc-row-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.dnc-reason {
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: rgba(100, 116, 139, 0.1);
    border-radius: 4px;
}

/* ── New Notification Type Colors ────────────────────────────────────── */
.toast-icon.sentiment_alert { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.toast-icon.response_blocked { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.toast-icon.opt_out { background: rgba(100, 116, 139, 0.12); color: #94a3b8; }
.toast-icon.escalation_alert { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.toast-icon.review_pending { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.toast-icon.message_send_failed { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

/* ── Escalation Rules (Settings) ────────────────────────────────────── */
.escalation-rule {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}
.escalation-rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.escalation-rule-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Pending Responses (Dashboard — Review Mode) ────────────────────── */
.pending-responses-section {
    margin-bottom: 20px;
}
.pending-responses-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.pending-responses-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
}
.pending-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--status-info);
    color: #fff;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
}
.pending-responses-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}
.pending-response-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.pending-response-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.pending-lead-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.pending-channel {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-light);
}
.pending-edit-text {
    width: 100%;
    min-height: 60px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 10px;
}
.pending-edit-text:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.pending-response-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .pending-responses-list {
        grid-template-columns: 1fr;
    }
}
