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

:root {
    /* Sidebar - dark */
    --bg-sidebar: #141620;
    --border-sidebar: #2a2d3a;
    --text-sidebar: #e4e4e7;
    --text-sidebar-muted: #8b8d9a;

    /* Content - light */
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-secondary: #f8f9fb;
    --bg-input: #f0f1f5;
    --border: #e2e4ea;
    --text: #1a1d27;
    --text-muted: #6b7280;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #eab308;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #141620;
}

.login-card {
    background: #1a1d27;
    border: 1px solid #2a2d3a;
    border-radius: 12px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #e4e4e7;
}

.login-subtitle {
    color: #8b8d9a;
    margin-bottom: 32px;
    font-size: 14px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: #232636;
    border: 1px solid #2a2d3a;
    border-radius: var(--radius);
    color: #e4e4e7;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--accent);
}

.login-card button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.login-card button:hover {
    background: var(--accent-hover);
}

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - stays dark */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-logo {
    padding: 24px 20px;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-sidebar);
    color: var(--text-sidebar);
}

#sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-sidebar-muted);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--text-sidebar);
    background: rgba(255,255,255,0.03);
}

.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(99,102,241,0.08);
}

.nav-item .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}
.nav-item.nav-sub {
    padding-left: 36px;
    font-size: 13px;
    opacity: 0.85;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-sidebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-sidebar-muted);
}

#logout-btn {
    background: none;
    border: 1px solid var(--border-sidebar);
    color: var(--text-sidebar-muted);
    padding: 4px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

#logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Content - light */
.content {
    flex: 1;
    margin-left: 240px;
    padding: 32px;
    background: var(--bg);
    overflow-x: hidden;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}

/* Cards / Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-card .label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

/* Table */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f9fafb;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f9fafb;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-admin { background: rgba(99,102,241,0.12); color: #4f46e5; }
.badge-manager { background: rgba(234,179,8,0.12); color: #b45309; }
.badge-operator { background: rgba(34,197,94,0.12); color: #15803d; }
.badge-inactive { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-success { background: rgba(34,197,94,0.12); color: #15803d; }
.badge-danger { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-warning { background: rgba(234,179,8,0.12); color: #b45309; }
.badge-muted { background: rgba(107,114,128,0.12); color: var(--text-muted); }

/* Lead status badges */
.badge-new { background: rgba(99,102,241,0.12); color: #4f46e5; }
.badge-contacted { background: rgba(234,179,8,0.12); color: #b45309; }
.badge-replied { background: rgba(34,197,94,0.12); color: #15803d; }
.badge-qualified { background: rgba(168,85,247,0.12); color: #7c3aed; }
.badge-rejected { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-converted { background: rgba(20,184,166,0.12); color: #0d9488; }

/* Source badges */
.badge-wellfound { background: rgba(99,102,241,0.12); color: #4f46e5; }
.badge-yelp { background: rgba(239,68,68,0.12); color: #dc2626; }
.badge-crunchbase { background: rgba(34,197,94,0.12); color: #15803d; }
.badge-manual { background: rgba(107,114,128,0.12); color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-primary:active {
    background: #4f46e5;
}

.btn-accent {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}
.btn-accent:hover {
    background: #d97706;
    border-color: #d97706;
}
.btn-accent:disabled {
    opacity: 0.5;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 5px;
}

.btn-danger {
    background: rgba(239,68,68,0.08);
    color: var(--danger);
    border-color: rgba(239,68,68,0.2);
}

.btn-danger:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--bg-secondary);
    border-color: #9ca3af;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: var(--text);
}

.modal label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 12px;
}

.modal input, .modal select, .modal textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.modal input:focus, .modal select:focus, .modal textarea:focus {
    border-color: var(--accent);
}

.modal-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    resize: vertical;
    font-family: inherit;
}

.modal-textarea:focus {
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Leads status tabs */
.leads-status-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.leads-stab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.leads-stab:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.leads-stab-active {
    background: var(--bg-card);
    border-width: 2px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.leads-stab-icon {
    font-size: 20px;
    line-height: 1;
}
.leads-stab-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.leads-stab-active .leads-stab-label {
    color: inherit;
}
.leads-stab-count {
    background: rgba(0,0,0,0.06);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}
.leads-stab-active .leads-stab-count {
    background: currentColor;
    color: white;
}
.leads-stab-count-pulse {
    background: #ef4444 !important;
    color: #fff !important;
    animation: stab-count-pulse 1.5s ease-in-out infinite;
}
@keyframes stab-count-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.leads-stab-pulse {
    border-color: #f59e0b !important;
    color: #d97706 !important;
    font-weight: 600;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-input {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    min-width: 200px;
}

.filter-input:focus {
    border-color: var(--accent);
}

.filter-select {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.filter-select:focus {
    border-color: var(--accent);
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tab-item {
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    text-transform: capitalize;
}

.tab-item:hover {
    color: var(--text);
}

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    padding: 12px 0;
    gap: 4px;
    user-select: none;
}

.pagination .pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination .pg-btn:hover:not(.pg-active):not(.pg-disabled) {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .pg-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    cursor: default;
}

.pagination .pg-disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.pagination .pg-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: default;
}

.pagination .pg-info {
    margin-left: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Bulk bar */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

/* Lead detail */
.lead-detail-grid {
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.detail-label {
    color: var(--text-muted);
    min-width: 120px;
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 11px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Scraper card */
.scraper-card {
    transition: border-color 0.2s;
}

.scraper-card:hover {
    border-color: var(--accent);
}

/* h3 inside content */
.content h3 {
    color: var(--text);
}

/* Settings form */
.settings-form {
    max-width: 640px;
}

.settings-form label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 16px;
}

.settings-form label:first-child {
    margin-top: 0;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
    border-color: var(--accent);
}

.settings-form code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Success button */
.btn-success {
    background: rgba(34,197,94,0.1);
    color: var(--success);
}

.btn-success:hover {
    background: rgba(34,197,94,0.2);
}

/* Modal header with close */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    font-size: 14px;
}

/* Source badge - remoteok */
.badge-remoteok { background: rgba(59,130,246,0.12); color: #2563eb; }
.badge-jobspy { background: #dbeafe; color: #1e40af; }
.badge-gmaps { background: #dcfce7; color: #166534; }
.badge-clutch { background: #ffe4e6; color: #be123c; }
.badge-hackernews { background: #fff7ed; color: #c2410c; }
.badge-upwork { background: #ecfdf5; color: #047857; }
.badge-freelancer { background: #eff6ff; color: #1d4ed8; }
.badge-github { background: #f5f5f5; color: #171717; }

/* Campaign cards */
.campaigns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.campaign-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s;
}

.campaign-card:hover {
    border-color: var(--accent);
}

.campaign-inactive {
    opacity: 0.6;
}

.campaign-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.campaign-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.campaign-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.campaign-stats .stat-value {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.campaign-stats .stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.campaign-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Email section in lead detail */
.email-section {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.email-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.email-type-personal {
    color: var(--success);
    font-size: 11px;
    font-weight: 500;
}

.email-type-generic {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}

/* Pagination info */
.pagination-info {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Email verification badges */
.verified-safe {
    background: #dcfce7 !important;
    color: #166534 !important;
    font-size: 11px;
    padding: 1px 6px;
}
.verified-risky {
    background: #fef3c7 !important;
    color: #92400e !important;
    font-size: 11px;
    padding: 1px 6px;
}
.verified-invalid {
    background: #fee2e2 !important;
    color: #991b1b !important;
    font-size: 11px;
    padding: 1px 6px;
}
.verified-unknown {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
    font-size: 11px;
    padding: 1px 6px;
}

/* Sources page */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}

.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.source-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.source-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.source-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 20px;
}

.source-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.source-stats-row {
    display: flex;
    gap: 24px;
    padding: 12px 0;
    margin-bottom: 12px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.source-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.source-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.source-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.source-card-actions .btn:disabled {
    cursor: not-allowed;
}

/* ========== Lead Detail CRM Card ========== */
.ld-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 12px;
    font-size: 13px;
    flex-wrap: wrap;
}
.ld-bc-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.ld-bc-link:hover { text-decoration: underline; }
.ld-bc-sep {
    color: var(--text-muted);
    margin: 0 8px;
    font-size: 14px;
}
.ld-bc-current {
    color: var(--text-muted);
    white-space: nowrap;
}
.ld-bc-loading {
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
}
.ld-bc-loading:hover { text-decoration: underline; }

.ld-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.ld-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ld-company-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.ld-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ld-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.ld-info-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ld-info-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.ld-info-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ld-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: 14px;
}

.ld-row:last-child {
    border-bottom: none;
}

.ld-row-label {
    color: var(--text-muted);
    min-width: 90px;
    flex-shrink: 0;
    font-size: 13px;
}

.ld-row-value {
    text-align: right;
    word-break: break-word;
}

.ld-email-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ld-email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ld-email-list {
    margin-top: 6px;
}

.ld-email-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.ld-notes-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    max-width: 700px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ld-notes-form label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 12px;
}

.ld-notes-form label:first-child {
    margin-top: 0;
}

.ld-notes-form select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

/* ========== Timeline ========== */
.ld-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tl-item {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s;
}

.tl-item:hover {
    border-color: var(--accent);
}

.tl-outgoing {
    border-left: 3px solid var(--accent);
}

.tl-incoming {
    border-left: 3px solid var(--success);
}

.tl-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.tl-outgoing .tl-icon {
    background: rgba(99,102,241,0.1);
    color: var(--accent);
}

.tl-incoming .tl-icon {
    background: rgba(34,197,94,0.1);
    color: var(--success);
}

.tl-content {
    flex: 1;
    min-width: 0;
}

.tl-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.tl-direction {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tl-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.tl-subject {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}

.tl-body {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    white-space: pre-line;
    word-break: break-word;
}

.tl-expand {
    margin-top: 4px;
    font-size: 12px;
}

.tl-ai-summary {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(99,102,241,0.06);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========== Campaign Full-Width ========== */
.campaigns-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.campaign-card-wide {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s;
}

.campaign-card-wide:hover {
    border-color: var(--accent);
}

.campaign-card-wide.campaign-inactive {
    opacity: 0.6;
}

.campaign-errors {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.campaign-error-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.15);
    border-radius: 6px;
    font-size: 12px;
    color: var(--danger);
}

.campaign-error-item .btn {
    margin-left: auto;
}

.campaign-source-ok {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(34,197,94,0.08);
    border-radius: 12px;
    font-size: 11px;
    color: #15803d;
}

.campaign-wide-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.campaign-wide-info {
    flex: 1;
    min-width: 0;
}

.campaign-wide-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.campaign-wide-stats {
    display: flex;
    gap: 24px;
    padding: 0 24px;
    flex-shrink: 0;
}

.campaign-wide-stats .cw-stat {
    text-align: center;
}

.campaign-wide-stats .cw-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.campaign-wide-stats .cw-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.campaign-wide-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ========== Campaign Detail Page ========== */
.cd-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.cd-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cd-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.cd-campaign-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.cd-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cd-stats-row {
    display: flex;
    gap: 32px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cd-stat {
    text-align: center;
}

.cd-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.cd-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Action Panel — Awaiting Reply */
.cd-action-panel {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: var(--radius);
    padding: 16px 20px;
    animation: cd-pulse-border 2s ease-in-out infinite;
}
@keyframes cd-pulse-border {
    0%, 100% { border-color: #f59e0b; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
    50% { border-color: #d97706; box-shadow: 0 0 12px 2px rgba(245, 158, 11, 0.15); }
}
.cd-action-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.cd-action-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #92400e;
}
.cd-action-panel-count {
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
    padding: 0 6px;
    animation: cd-pulse-count 1.5s ease-in-out infinite;
}
@keyframes cd-pulse-count {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.cd-action-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cd-action-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.cd-action-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
    transform: translateY(-1px);
}
.cd-action-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}
.cd-action-card-who {
    display: flex;
    flex-direction: column;
}
.cd-action-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.cd-action-card-company {
    font-size: 12px;
    color: var(--text-muted);
}
.cd-action-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.cd-action-card-cat {
    font-size: 12px;
    font-weight: 600;
}
.cd-action-card-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.cd-action-card-preview {
    font-size: 13px;
    color: #4b5563;
    font-style: italic;
    line-height: 1.4;
    margin-bottom: 8px;
}
.cd-action-card-footer {
    display: flex;
    justify-content: flex-end;
}

/* Sources tab */
.cd-sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.cd-source-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s;
}

.cd-source-card:hover {
    border-color: var(--accent);
}

.cd-source-disabled {
    border-color: rgba(239,68,68,0.2);
    background: rgba(239,68,68,0.02);
}

.cd-source-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cd-source-error {
    padding: 8px 12px;
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.15);
    border-radius: 6px;
    font-size: 12px;
    color: var(--danger);
    margin-bottom: 12px;
}

.cd-source-stats {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    margin-bottom: 8px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.cd-source-stat {
    text-align: center;
    flex: 1;
}

.cd-source-stat-val {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.cd-source-stat-lbl {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Settings tab */
.cd-settings-form {
    max-width: 100%;
}

.cd-settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cd-settings-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.cd-settings-section label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 12px;
}

.cd-settings-section label:first-of-type {
    margin-top: 0;
}

.cd-settings-section input:not([type="checkbox"]),
.cd-settings-section select,
.cd-settings-section textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.cd-settings-section input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
    cursor: pointer;
}

.cd-settings-section input:not([type="checkbox"]):focus,
.cd-settings-section select:focus,
.cd-settings-section textarea:focus {
    border-color: var(--accent);
}

/* Schedule page */
.sched-queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.sched-queue-next {
    background: rgba(99,102,241,0.04);
    border-color: var(--accent);
}

/* ===== Test Pipeline Tab ===== */
.cd-test-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cd-test-header h4 {
    font-size: 16px;
    font-weight: 600;
}

.cd-test-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.cd-test-input-row {
    display: flex;
    gap: 8px;
}

.cd-test-input-row input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.cd-test-input-row input:focus {
    border-color: var(--accent);
}

.cd-test-form > div input {
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.cd-test-form > div input:focus {
    border-color: var(--accent);
}

.cd-test-log {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cd-test-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

.cd-test-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    transition: all 0.2s;
}

.cd-test-step-done {
    background: rgba(34, 197, 94, 0.06);
    border-color: rgba(34, 197, 94, 0.2);
}

.cd-test-step-running {
    background: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.2);
}

.cd-test-step-error {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
}

.cd-test-step-warning {
    background: rgba(234, 179, 8, 0.06);
    border-color: rgba(234, 179, 8, 0.2);
}

.cd-test-step-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.cd-test-step-content {
    flex: 1;
    min-width: 0;
}

.cd-test-step-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.cd-test-step-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-all;
}

.cd-test-summary {
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    margin-top: 4px;
}

.cd-test-summary-ok {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.cd-test-summary-fail {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ========== Campaigns List (Redesigned) ========== */
/* Client logo */
.cl-card-logo {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}
.cl-card-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cl-card-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(99,102,241,0.08);
}

/* Logo upload in modal */
.cl-logo-upload {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.cl-logo-preview {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.cl-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cl-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(99,102,241,0.08);
}
.cl-logo-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cl-logo-btn {
    cursor: pointer;
}

.cl-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cl-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.cl-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.cl-card-inactive {
    opacity: 0.55;
}

.cl-card-body {
    display: flex;
    align-items: center;
    gap: 24px;
}

.cl-card-main {
    flex: 1;
    min-width: 0;
}

.cl-card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.cl-card-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.cl-card-desc {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cl-card-metrics {
    display: flex;
    gap: 28px;
    flex-shrink: 0;
}

.cl-metric {
    text-align: center;
    min-width: 60px;
}

.cl-metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.cl-metric-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.cl-health {
    font-size: 18px;
    font-weight: 700;
}

.cl-health-ok {
    color: var(--success);
}

.cl-health-warn {
    color: var(--warning);
}

.cl-health-none {
    color: var(--text-muted);
}

.cl-card-actions {
    flex-shrink: 0;
}

/* ========== Client Detail Page ========== */
.cld-page {
    max-width: 100%;
}
.cld-header {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}
.cld-header-logo {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}
.cld-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cld-header-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(99,102,241,0.08);
}
.cld-logo-hover {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 14px;
    color: #fff;
    font-size: 20px;
}
.cld-header-logo:hover .cld-logo-hover {
    opacity: 1;
}
.cld-header-info {
    flex: 1;
    min-width: 0;
}
.cld-header-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.cld-header-name {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}
.cld-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}
.cld-meta-id {
    font-family: monospace;
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.cld-meta-sep {
    color: var(--border);
}
.cld-header-stats {
    display: flex;
    gap: 24px;
    flex-shrink: 0;
}
.cld-stat {
    text-align: center;
    min-width: 60px;
}
.cld-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.cld-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.cld-section {
    margin-bottom: 24px;
}
.cld-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cld-section-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.cld-camp-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.cld-camp-card:hover {
    border-color: var(--accent);
}
.cld-camp-main {
    flex: 1;
    min-width: 0;
}
.cld-camp-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}
.cld-camp-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}
.cld-camp-stats {
    flex-shrink: 0;
}
.cld-smtp-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.cld-smtp-grid {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 12px;
}
@media (min-width: 600px) {
    .cld-smtp-grid {
        grid-template-columns: 1fr 120px 1fr 1fr;
    }
}
.cld-smtp-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cld-smtp-field input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}
.cld-smtp-field input:focus {
    outline: none;
    border-color: var(--accent);
}
.cld-meta-id {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}
.cld-meta-sep {
    color: var(--border);
    margin: 0 2px;
}

/* ========== Campaign New/Edit Page ========== */
.cn-page {
    max-width: 800px;
}

.cn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.cn-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cn-header-left h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.cn-header-right {
    display: flex;
    gap: 8px;
}

.cn-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cn-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cn-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.cn-section label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    margin-top: 12px;
}

.cn-section label:first-of-type {
    margin-top: 0;
}

.cn-section input:not([type="checkbox"]),
.cn-section select,
.cn-section textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.cn-section input:not([type="checkbox"]):focus,
.cn-section select:focus,
.cn-section textarea:focus {
    border-color: var(--accent);
}

.cn-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 4px 0 0;
}

/* Scraper selection grid */
.cn-scrapers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cn-scraper-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    margin: 0 !important;
}

.cn-scraper-item:hover {
    border-color: var(--accent);
    background: rgba(99,102,241,0.03);
}

.cn-scraper-item input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.cn-scraper-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cn-scraper-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.cn-scraper-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.cn-scraper-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* Pipeline items */
.cn-pipeline-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--bg-secondary);
    margin: 0 !important;
}

.cn-pipeline-item:hover {
    border-color: var(--accent);
}

.cn-pipeline-item input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ═══════════ Wizard (campaign-new) ═══════════ */
.w-wizard { max-width: 720px; margin: 0 auto; padding: 20px 0; }
.w-wizard-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.w-wizard-header h2 { font-size: 20px; font-weight: 600; }

.w-progress { display: flex; align-items: center; margin-bottom: 28px; }
.w-progress-step { display: flex; flex-direction: column; align-items: center; cursor: pointer; min-width: 60px; }
.w-progress-circle {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    background: var(--bg-tertiary); color: var(--text-muted);
    border: 2px solid var(--border); transition: all .2s;
}
.w-progress-step.w-active .w-progress-circle { background: var(--accent); color: #fff; border-color: var(--accent); }
.w-progress-step.w-done .w-progress-circle { background: var(--success); color: #fff; border-color: var(--success); }
.w-progress-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.w-progress-step.w-active .w-progress-label { color: var(--accent); font-weight: 600; }
.w-progress-line { flex: 1; height: 2px; background: var(--border); margin: 0 4px; margin-bottom: 18px; }
.w-progress-line.w-done { background: var(--success); }

.w-step-body { min-height: 300px; }
.w-section { margin-bottom: 24px; }
.w-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.w-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.w-optional { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.w-input, .w-textarea {
    width: 100%; padding: 10px 14px; font-size: 14px;
    background: var(--bg-secondary); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius);
    transition: border-color .2s;
}
.w-input:focus, .w-textarea:focus { border-color: var(--accent); outline: none; }
.w-textarea { min-height: 80px; resize: vertical; font-family: inherit; }

.w-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }

/* Errors */
.w-error { color: var(--danger); font-size: 13px; padding: 8px 12px; background: rgba(239,68,68,.1); border-radius: var(--radius); margin-bottom: 8px; }
.w-shake { animation: wshake .4s; }
@keyframes wshake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* Scrapers Grid */
.w-scrapers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.w-scraper-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px 10px; border: 2px solid var(--border); border-radius: var(--radius);
    cursor: pointer; text-align: center; transition: all .15s; background: var(--bg-secondary);
}
.w-scraper-item:hover { border-color: var(--accent); }
.w-scraper-item.w-selected { border-color: var(--accent); background: rgba(99,102,241,.08); }
.w-scraper-icon { font-size: 24px; }
.w-scraper-name { font-weight: 600; font-size: 13px; }
.w-scraper-desc { font-size: 11px; color: var(--text-muted); }

/* Pipeline */
.w-pipeline { display: flex; flex-direction: column; gap: 8px; }
.w-pipeline-item {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; background: var(--bg-secondary); margin: 0 !important;
}
.w-pipeline-item:hover { border-color: var(--accent); }
.w-pipeline-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.w-pl-icon { font-size: 18px; }
.w-pl-title { font-weight: 600; font-size: 13px; }
.w-pl-desc { font-size: 12px; color: var(--text-muted); }

/* AI Improve Button */
.w-field-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.w-field-header h3 { margin-bottom: 0; }
.w-ai-btn { font-size: 12px !important; color: var(--accent) !important; }
.w-ai-btn:hover { background: rgba(99,102,241,.1) !important; }

/* Before/After AI fields */
.w-ai-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.w-ai-pair.w-ai-pair--with-btn { grid-template-columns: 1fr auto 1fr; }
.w-ai-pair-col { display: flex; flex-direction: column; }
.w-ai-pair-mid { display: flex; align-items: flex-end; padding-bottom: 4px; }
.w-ai-expand-btn {
    white-space: nowrap; font-size: 13px; font-weight: 600;
    background: var(--accent) !important; color: #fff !important;
    border: none; border-radius: var(--radius); padding: 8px 16px;
    cursor: pointer; transition: background .15s, transform .1s;
}
.w-ai-expand-btn:hover { background: var(--accent-hover) !important; transform: scale(1.03); }
.w-ai-expand-btn:disabled { opacity: .6; transform: none; }
.w-ai-pair-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.w-ai-pair-col.w-ai-improved .w-textarea,
.w-ai-pair-col.w-ai-improved .w-input { border-color: var(--success); background: rgba(34,197,94,.04); }
.w-tags-dest-area { border-color: var(--success); background: rgba(34,197,94,.04); }
.w-generate-all-section { text-align: center; padding: 20px; background: linear-gradient(135deg, rgba(99,102,241,.06), rgba(99,102,241,.02)); border: 1px dashed var(--accent); border-radius: var(--radius); }
.w-generate-all-btn {
    font-size: 15px; font-weight: 700; padding: 12px 28px;
    background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
    cursor: pointer; transition: background .15s, transform .1s;
}
.w-generate-all-btn:hover { background: var(--accent-hover); transform: scale(1.02); }
.w-generate-all-btn:disabled { opacity: .6; transform: none; cursor: wait; }

/* Toggle switch */
.w-toggle-row {
    display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
    padding: 14px 16px; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px; user-select: none;
}
.w-toggle-row input[type="checkbox"] { display: none; }
.w-toggle-slider {
    flex-shrink: 0; width: 44px; height: 24px; background: #ccc; border-radius: 12px;
    position: relative; transition: background .2s; margin-top: 2px;
}
.w-toggle-slider::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
    background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.w-toggle-row input:checked + .w-toggle-slider { background: var(--accent); }
.w-toggle-row input:checked + .w-toggle-slider::after { transform: translateX(20px); }
.w-toggle-title { font-size: 14px; font-weight: 600; color: var(--text); }
.w-toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* Type selection cards */
.w-type-select { max-width: 800px; margin: 0 auto; }
.w-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 700px) { .w-type-grid { grid-template-columns: 1fr; } }
.w-type-card {
    padding: 28px 20px; border: 2px solid var(--border); border-radius: 12px;
    background: var(--bg-card); cursor: pointer; transition: all .2s; text-align: center;
    position: relative;
}
.w-type-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(99,102,241,.12); }
.w-type-card.w-type-disabled {
    opacity: .55; cursor: default; pointer-events: none;
}
.w-type-icon { font-size: 36px; margin-bottom: 12px; }
.w-type-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.w-type-sources { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 10px; }
.w-type-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.w-type-badge {
    display: inline-block; margin-top: 12px; padding: 4px 12px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 20px; font-size: 11px; font-weight: 600; color: var(--text-muted);
}

/* Goal selector */
.w-goals-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.w-goal-item {
    padding: 8px 16px; border: 2px solid var(--border); border-radius: 8px;
    background: var(--bg-card); cursor: pointer; transition: all .15s;
    font-size: 13px; user-select: none;
}
.w-goal-item:hover { border-color: var(--accent); }
.w-goal-item.w-selected { border-color: var(--accent); background: rgba(99,102,241,.08); }
.w-goal-label { white-space: nowrap; }

/* Follow-up selector */
.w-followup-selector { display: flex; gap: 8px; }
.w-followup-item {
    width: 48px; height: 40px; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--border); border-radius: 8px; cursor: pointer;
    font-size: 14px; font-weight: 600; transition: all .15s; user-select: none;
    background: var(--bg-card);
}
.w-followup-item:hover { border-color: var(--accent); }
.w-followup-item.w-selected { border-color: var(--accent); background: rgba(99,102,241,.08); color: var(--accent); }

/* Layout helpers */
.w-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.w-half {}

/* Review */
.w-review h3 { font-size: 16px; margin-bottom: 16px; }
.w-review-grid { display: flex; flex-direction: column; gap: 12px; }
.w-review-card {
    padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-secondary); cursor: pointer; transition: border-color .15s;
}
.w-review-card:hover { border-color: var(--accent); }
.w-review-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--accent); }
.w-review-row { font-size: 13px; margin-bottom: 4px; }
.w-review-label { color: var(--text-muted); }
.w-review-empty { color: var(--text-muted); }
.w-review-truncate { word-break: break-all; }
.w-warnings { margin-bottom: 16px; }
.w-warning { font-size: 13px; color: var(--warning, #f59e0b); padding: 8px 12px; background: rgba(245,158,11,.08); border-radius: var(--radius); margin-bottom: 4px; }

/* AI Chat in wizard */
.w-ai-chat { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.w-chat-msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.w-chat-ai { align-self: flex-start; }
.w-chat-user { align-self: flex-end; }
.w-chat-badge { font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.w-chat-ai .w-chat-badge { color: #e6a817; }
.w-chat-user .w-chat-badge { color: var(--accent); }
.w-chat-ai .w-chat-text {
    background: linear-gradient(135deg, rgba(230,168,23,.08), rgba(255,200,50,.04));
    border: 1.5px solid rgba(230,168,23,.25); border-radius: 16px 16px 16px 4px;
    padding: 16px 20px; font-size: 15px; line-height: 1.6; white-space: pre-line;
    font-weight: 500; color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(230,168,23,.08);
}
.w-chat-user .w-chat-text {
    background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(99,102,241,.06));
    border: 1.5px solid rgba(99,102,241,.25); border-radius: 16px 16px 4px 16px;
    padding: 16px 20px; font-size: 15px; line-height: 1.6; white-space: pre-line;
    font-weight: 500; color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(99,102,241,.08);
}
.w-chat-user .w-chat-badge { text-align: right; }
.w-chat-input-row { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.w-chat-input-row .w-textarea {
    font-size: 15px; padding: 12px 16px; border-radius: 12px;
    border: 2px solid rgba(230,168,23,.3); transition: border-color .2s;
}
.w-chat-input-row .w-textarea:focus { border-color: #e6a817; outline: none; box-shadow: 0 0 0 3px rgba(230,168,23,.15); }
.w-chat-input-row .btn { padding: 12px 20px; font-size: 14px; font-weight: 700; border-radius: 12px; }
/* AI typing dots animation */
.w-ai-typing::after {
    content: '...'; animation: w-typing 1.2s steps(4, end) infinite;
}
@keyframes w-typing { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* AI Prediction cards */
.w-predictions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.w-pred-card {
    padding: 16px; background: linear-gradient(135deg, rgba(99,102,241,.06), rgba(34,197,94,.04));
    border: 1px solid var(--border); border-radius: 12px; text-align: center;
}
.w-pred-value { font-size: 28px; font-weight: 800; color: var(--accent); }
.w-pred-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
@media (max-width: 500px) { .w-predictions { grid-template-columns: 1fr; } }

/* ========== Pipeline Board (Campaign Detail) — Vertical Funnel ========== */

/* Summary bar at top */
.pipeline-summary {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    height: 28px;
}
.pipeline-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 30px;
}
.pipeline-summary-bar {
    position: absolute;
    inset: 0;
    opacity: 0.15;
}
.pipeline-summary-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    position: relative;
    z-index: 1;
}

/* Sections stacked vertically */
.pipeline-sections {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pipeline-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.pipeline-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-secondary);
    cursor: default;
    user-select: none;
}
.pipeline-section-header[onclick] {
    cursor: pointer;
}
.pipeline-section-header[onclick]:hover {
    background: rgba(99,102,241,0.04);
}
.pipeline-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pipeline-section-icon {
    font-size: 16px;
}
.pipeline-section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.pipeline-section-count {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
.pipeline-section-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 4px;
}
.pipeline-section-toggle {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.pipeline-section.collapsed .pipeline-section-toggle {
    transform: rotate(-90deg);
}
.pipeline-section.collapsed .pipeline-section-body {
    display: none;
}
.pipeline-section-body {
    padding: 0;
    background: rgba(0,0,0,0.01);
}
.pipeline-section-body .pipeline-empty {
    padding: 16px;
}

/* Table inside pipeline sections */
.pipeline-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.pipeline-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pipeline-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    vertical-align: middle;
}
.pipeline-table tr:hover td {
    background: rgba(99,102,241,0.03);
}
.pipeline-table tr:last-child td {
    border-bottom: none;
}
.pipeline-empty {
    text-align: center;
    padding: 16px 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

/* ========== Pipeline & Stats (Lead Detail Info Tab) ========== */
.ld-pipeline-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow-x: auto;
}
.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 8px;
    opacity: 0.35;
    transition: all 0.2s;
}
.pipeline-step.pipeline-done {
    opacity: 0.7;
    background: rgba(16,185,129,0.08);
}
.pipeline-step.pipeline-active {
    opacity: 1;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.3);
    font-weight: 600;
}
.pipeline-step.pipeline-dead {
    opacity: 1;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.2);
}
.pipeline-icon { font-size: 18px; }
.pipeline-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.pipeline-active .pipeline-label { color: var(--accent); }
.pipeline-arrow { color: var(--text-muted); opacity: 0.3; font-size: 14px; margin: 0 2px; }

.ld-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.ld-stat-card {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}
.ld-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.ld-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.ld-stat-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.ld-stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.ld-followup {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    background: rgba(16,185,129,0.06);
    border: 1px solid rgba(16,185,129,0.15);
    color: var(--text);
}
.ld-followup-warn {
    background: rgba(245,158,11,0.06);
    border-color: rgba(245,158,11,0.2);
}

.ld-activity-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.ld-activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.ld-activity-item:last-child { border-bottom: none; }
.ld-activity-icon { font-size: 14px; flex-shrink: 0; }
.ld-activity-text { flex: 1; color: var(--text); }
.ld-activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ========== Chat View (Lead Detail) ========== */
.chat-goal-block {
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04));
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.chat-goal-icon {
    font-size: 16px;
    flex-shrink: 0;
}
.chat-goal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
/* Inline edit pattern */
.inline-edit-wrap { position: relative; }
.inline-edit-display {
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
    line-height: 1.5;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}
.inline-edit-display:hover {
    border-color: rgba(99,102,241,0.25);
    background: rgba(99,102,241,0.03);
}
.inline-edit-display.empty {
    color: var(--text-muted);
    font-style: italic;
}
.inline-edit-pencil {
    opacity: 0;
    font-size: 12px;
    margin-left: 6px;
    transition: opacity 0.15s;
}
.inline-edit-display:hover .inline-edit-pencil { opacity: 0.6; }
.inline-edit-editor textarea {
    width: 100%;
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
    font-family: inherit;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.inline-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.inline-edit-warning {
    font-size: 12px;
    color: #b45309;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 8px;
    line-height: 1.4;
}
.btn-inline-action {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
}
.btn-inline-action:hover {
    color: var(--accent);
    background: rgba(99,102,241,0.08);
}
.chat-template-block {
    padding: 14px 18px;
    background: rgba(16,185,129,0.04);
    border: 1px solid rgba(16,185,129,0.15);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.chat-template-subject {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
}
.chat-template-body {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: pre-line;
}

/* Chat messages container */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    padding: 4px 0;
}

/* Individual message — full width, colored left border */
.chat-msg {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    position: relative;
    box-sizing: border-box;
}

/* AI robot message — indigo/purple */
.chat-msg-ai {
    background: rgba(99,102,241,0.04);
    border-left-color: #6366f1;
}

/* Manager manual message — warm orange */
.chat-msg-manual {
    background: rgba(249,115,22,0.04);
    border-left-color: #f97316;
}

/* Form submission — amber/yellow */
.chat-msg-form {
    background: rgba(234,179,8,0.05);
    border-left-color: #eab308;
}

/* Prospect reply — green, prominent */
.chat-msg-prospect {
    background: rgba(34,197,94,0.06);
    border-left-color: #22c55e;
    border-left-width: 5px;
}

/* Message header */
.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.chat-msg-sender {
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-msg-sender-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    flex-shrink: 0;
}
.chat-msg-ai .chat-msg-sender { color: #6366f1; }
.chat-msg-ai .chat-msg-sender-icon { background: rgba(99,102,241,0.12); }
.chat-msg-manual .chat-msg-sender { color: #ea580c; }
.chat-msg-manual .chat-msg-sender-icon { background: rgba(249,115,22,0.12); }
.chat-msg-form .chat-msg-sender { color: #b45309; }
.chat-msg-form .chat-msg-sender-icon { background: rgba(234,179,8,0.15); }
.chat-msg-prospect .chat-msg-sender { color: #16a34a; }
.chat-msg-prospect .chat-msg-sender-icon { background: rgba(34,197,94,0.12); }

.chat-msg-sender-label {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.chat-msg-ai .chat-msg-sender-label { background: rgba(99,102,241,0.1); color: #6366f1; }
.chat-msg-manual .chat-msg-sender-label { background: rgba(249,115,22,0.1); color: #ea580c; }
.chat-msg-form .chat-msg-sender-label { background: rgba(234,179,8,0.12); color: #92400e; }
.chat-msg-prospect .chat-msg-sender-label { background: rgba(34,197,94,0.1); color: #16a34a; }

.chat-msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}
.chat-msg-category {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}
.chat-msg-category.cat-positive { background: rgba(34,197,94,0.12); color: #16a34a; }
.chat-msg-category.cat-negative { background: rgba(239,68,68,0.1); color: #dc2626; }
.chat-msg-category.cat-question { background: rgba(99,102,241,0.1); color: var(--accent); }
.chat-msg-category.cat-neutral { background: var(--bg-secondary); color: var(--text-muted); }

/* Direction arrow indicator */
.chat-msg-direction {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Subject + body */
.chat-msg-subject {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
}
.chat-msg-body {
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-line;
    word-break: break-word;
}
/* Prospect reply text — larger, more prominent */
.chat-msg-prospect .chat-msg-body {
    font-size: 14px;
}
.chat-reply-text {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    padding: 10px 14px;
    background: rgba(34,197,94,0.08);
    border-left: 3px solid #16a34a;
    border-radius: 4px;
    margin-bottom: 6px;
    line-height: 1.6;
}
.chat-quoted-toggle {
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 0;
    user-select: none;
}
.chat-quoted-toggle:hover { color: var(--primary); }
.chat-quoted-body {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px;
    background: rgba(0,0,0,0.03);
    border-left: 2px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
}
.chat-msg-ai-summary {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(99,102,241,0.06);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Manual reply input */
.chat-channel-info {
    display: flex;
    gap: 16px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 13px;
}
.chat-channel-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-channel-label {
    color: var(--text-muted);
    white-space: nowrap;
}
.chat-channel-value {
    color: var(--text);
}
.chat-channel-value strong {
    color: var(--accent);
}
/* Chat status pipeline */
.chat-pipeline {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.06);
    flex-wrap: wrap;
}
.chat-pipe-step {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.chat-pipe-done {
    background: #dcfce7;
    color: #166534;
}
.chat-pipe-active {
    font-weight: 700;
    box-shadow: 0 0 0 2px #22c55e;
}
.chat-pipe-wait {
    background: #f3f4f6;
    color: #9ca3af;
}
.chat-pipe-error {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 600;
}
.chat-pipe-pending {
    background: #fefce8;
    color: #a16207;
}
.chat-pipe-arrow {
    color: #d1d5db;
    font-size: 10px;
}
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 8px;
}
.chat-action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-start;
}
.chat-compose textarea {
    width: 100%;
    min-height: 80px;
    max-height: 150px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}
.chat-compose textarea:focus {
    border-color: var(--accent);
}
.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-ai-send {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-ai-send:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ai-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Empty chat state */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 8px;
}
.chat-empty-icon {
    font-size: 32px;
    opacity: 0.5;
}
.chat-empty-text {
    font-size: 14px;
}

/* Chat sections */
.chat-section {
    margin-bottom: 16px;
}
.chat-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 4px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Collapsible pipeline step card (email versions) */
.chat-step-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid rgba(99,102,241,0.4);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.chat-step-card:hover {
    border-left-color: var(--accent);
}
.chat-step-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
}
.chat-step-header:hover {
    background: rgba(99,102,241,0.03);
}
.chat-step-chevron {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.chat-step-card.open .chat-step-chevron {
    transform: rotate(90deg);
}
.chat-step-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(99,102,241,0.1);
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}
.chat-step-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
}
.chat-step-reason {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.chat-step-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.chat-step-body {
    display: none;
    padding: 0 14px 12px;
    border-top: 1px solid var(--border);
}
.chat-step-card.open .chat-step-body {
    display: block;
}
.chat-step-body-inner {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

/* Pipeline context label above outgoing messages */
.chat-context-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 4px;
    margin-bottom: 4px;
}
.chat-context-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(99,102,241,0.08);
    color: var(--accent);
}
.chat-context-badge.badge-form {
    background: rgba(234,179,8,0.1);
    color: #b45309;
}
.chat-context-badge.badge-email {
    background: rgba(99,102,241,0.08);
    color: var(--accent);
}
.chat-context-badge.badge-manual {
    background: rgba(100,116,139,0.1);
    color: var(--text-muted);
}

/* (hero/followup styles removed — using full-width color-coded design) */

/* Lead type selector in modal */
.lead-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.lead-type-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    background: var(--bg-card);
    color: var(--text);
}
.lead-type-btn:hover {
    border-color: var(--accent);
}
.lead-type-btn.active {
    border-color: var(--accent);
    background: rgba(99,102,241,0.08);
    color: var(--accent);
}

/* ===================== AI RULES PAGE ===================== */
.ai-section { padding: 16px 0; }
.ai-section-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.ai-rules-list { display: flex; flex-direction: column; gap: 8px; }
.ai-rule-item { display: flex; align-items: flex-start; gap: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ai-rule-num { min-width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border-radius: 6px; font-size: 12px; font-weight: 700; margin-top: 4px; }
.ai-rule-text { flex: 1; }
.ai-rule-input { width: 100%; border: 1px solid transparent; background: transparent; color: var(--text); font-size: 13px; font-family: inherit; resize: vertical; padding: 4px 8px; border-radius: 6px; transition: border-color 0.15s; }
.ai-rule-input:focus { border-color: var(--accent); outline: none; background: var(--bg-input); }
.ai-rule-actions { display: flex; gap: 4px; align-items: center; }
.btn-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-muted); cursor: pointer; font-size: 13px; transition: all 0.15s; }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon-danger:hover { border-color: var(--danger); color: var(--danger); }

.ai-template-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.ai-template-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-template-icon { font-size: 20px; }
.ai-template-words { margin-left: auto; text-align: center; }
.ai-tpl-textarea { width: 100%; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-size: 13px; font-family: inherit; resize: vertical; padding: 10px 12px; border-radius: 8px; box-sizing: border-box; }
.ai-tpl-textarea:focus { border-color: var(--accent); outline: none; }

.ai-forbidden-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-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); color: #ef4444; border-radius: 16px; font-size: 13px; font-weight: 500; }
.ai-tag-x { border: none; background: none; color: inherit; cursor: pointer; font-size: 14px; padding: 0; line-height: 1; }

.ai-example-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 8px; }

.ai-test-email { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ai-test-meta { display: flex; gap: 16px; padding: 10px 16px; background: rgba(99,102,241,0.06); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.ai-test-subject { padding: 12px 16px 4px; font-size: 14px; }
.ai-test-body { padding: 8px 16px 16px; font-size: 13px; line-height: 1.6; color: var(--text); }

/* ─── Content Machine ─────────────────────────────────── */

/* Pipeline chain */
.cm-pipeline-chain { display: flex; flex-direction: column; gap: 0; }

/* Component cards */
.cm-component-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
}
.cm-component-card.enabled { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cm-component-card.coming-soon { opacity: 0.6; }
.cm-component-card:hover { border-color: var(--accent); }

.cm-comp-header { display: flex; align-items: center; justify-content: space-between; }
.cm-comp-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.cm-comp-name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.cm-comp-provider { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.cm-comp-desc { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }
.cm-comp-actions { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* Coming soon badge */
.cm-badge-soon {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Connectors between cards */
.cm-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 28px;
    position: relative;
}
.cm-connector-line {
    width: 2px;
    flex: 1;
    background: var(--border);
}
.cm-connector-arrow {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1;
}

/* Toggle switch */
.cm-toggle-label { position: relative; display: inline-block; width: 36px; height: 20px; }
.cm-toggle-label input { opacity: 0; width: 0; height: 0; }
.cm-toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border); border-radius: 20px; transition: 0.3s;
}
.cm-toggle-slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px;
    background: white; border-radius: 50%; transition: 0.3s;
}
.cm-toggle-label input:checked + .cm-toggle-slider { background: var(--accent); }
.cm-toggle-label input:checked + .cm-toggle-slider:before { transform: translateX(16px); }

/* Info cards (right sidebar) */
.cm-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.cm-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.cm-stat-row:last-child { border-bottom: none; }
.cm-stat-row strong { color: var(--text-primary); }

/* Level badges */
.cm-level {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}
.cm-level-badge {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}

/* Post cards */
.cm-post-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.cm-post-card:hover { border-color: var(--accent); }
.cm-post-type-icon { font-size: 24px; width: 36px; text-align: center; }
.cm-post-topic { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.cm-post-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 4px; }
.cm-status-badge {
    font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 12px;
    text-transform: uppercase; letter-spacing: 0.3px;
}

/* Account cards */
.cm-account-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    transition: border-color 0.2s;
}
.cm-account-card:hover { border-color: var(--accent); }

/* Form groups in modals */
.cm-form-group { display: flex; flex-direction: column; gap: 4px; }
.cm-form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.cm-form-group input, .cm-form-group select, .cm-form-group textarea {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-input, var(--bg-card)); color: var(--text-primary);
    font-size: 13px; font-family: inherit;
}
.cm-form-group input:focus, .cm-form-group select:focus, .cm-form-group textarea:focus {
    border-color: var(--accent); outline: none;
}
