/* ============================================================
   Leads Dashboard Styles — Premium SaaS Design
   ============================================================ */

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #999);
}

.empty-state i {
    color: var(--text-light, #ddd);
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-state h3 {
    margin: 20px 0 10px 0;
    color: var(--text-primary, #333);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.empty-state p {
    color: var(--text-secondary, #999);
    font-size: 15px;
    line-height: 1.5;
}

/* ── Leads Stats Grid ── */
.leads-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg, white);
    border-radius: var(--radius-lg, 12px);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    border-radius: 3px 0 0 3px;
    background: var(--stat-accent, #667eea);
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border-color: rgba(102, 126, 234, 0.15);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--white);
    flex-shrink: 0;
}

.stat-content h4 {
    margin: 0 0 2px 0;
    font-size: 28px;
    color: var(--text-primary, #333);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.stat-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary, #666);
    font-weight: 500;
}

/* ── Table Wrapper — horizontal scroll when needed ── */
.table-wrapper {
    background: var(--card-bg, white);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Custom scrollbar for horizontal scroll on mobile */
.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.2);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.4);
}

/* ── Leads Table ── */
.leads-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.leads-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
}

.leads-table thead th {
    padding: 13px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: none;
    white-space: nowrap;
    border-bottom: none;
}

.leads-table thead th:first-child {
    border-radius: 12px 0 0 0;
}

.leads-table thead th:last-child {
    border-radius: 0 12px 0 0;
}

.leads-table thead th i {
    margin-right: 6px;
    font-size: 12px;
    opacity: 0.85;
}

.leads-table tbody tr {
    border-bottom: 1px solid var(--border-color, #f1f1f1);
    transition: background 0.15s ease;
}

.leads-table tbody tr:nth-child(even) {
    background: rgba(102, 126, 234, 0.015);
}

.leads-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.leads-table tbody tr:last-child {
    border-bottom: none;
}

.leads-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary, #333);
    vertical-align: middle;
}

.leads-table tbody td strong {
    color: var(--text-primary, #1e293b);
    font-weight: 600;
}

.leads-table tbody td a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.15s ease;
}

.leads-table tbody td a:hover {
    color: #5a6fd6;
    text-decoration: underline;
}

/* ── Source Badge ── */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--white);
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.source-badge i {
    font-size: 10px;
}

/* ── Lead Status Select ── */
.lead-status-select {
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    border: 1.5px solid;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
}

.lead-status-select:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.lead-status-select:focus-visible {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

/* ── Action Buttons ── */
.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}

.btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-radius: 10px;
    background: var(--gray-50, #f8fafc);
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    position: relative;
}

.btn-icon i {
    font-size: 13px;
    line-height: 1;
}

.btn-icon:hover {
    background: #667eea;
    color: var(--white);
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.btn-icon:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.2);
}

.btn-icon:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.btn-icon.btn-danger {
    background: rgba(239, 68, 68, 0.06);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.15);
}

.btn-icon.btn-danger:hover {
    background: #ef4444;
    color: var(--white);
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-icon.btn-danger:focus-visible {
    outline-color: rgba(239, 68, 68, 0.5);
}

/* WhatsApp icon button color override */
.btn-icon[style*="color:#25D366"],
.btn-icon[style*="color: #25D366"] {
    border-color: rgba(37, 211, 102, 0.15);
    background: rgba(37, 211, 102, 0.06);
}

.btn-icon[style*="color:#25D366"]:hover,
.btn-icon[style*="color: #25D366"]:hover {
    background: #25D366;
    color: var(--white) !important;
    border-color: #25D366;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
}

/* ── Conversation Modal ── */
.conversation-modal .modal-content {
    max-width: 700px;
}

.conversation-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: var(--gray-50, #f8fafc);
}

.conversation-container::-webkit-scrollbar {
    width: 5px;
}

.conversation-container::-webkit-scrollbar-track {
    background: transparent;
}

.conversation-container::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.15);
    border-radius: 3px;
}

.conversation-container::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.3);
}

.conversation-message {
    display: flex;
    margin-bottom: 20px;
    gap: 12px;
}

.conversation-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.conversation-message.user .message-avatar {
    background: #667eea;
    color: var(--white);
}

.conversation-message.bot .message-avatar {
    background: #f093fb;
    color: var(--white);
}

.message-bubble {
    max-width: 70%;
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.55;
    word-wrap: break-word;
    font-size: 14px;
}

.conversation-message.user .message-text {
    background: #667eea;
    color: var(--white);
    border-bottom-right-radius: 6px;
}

.conversation-message.bot .message-text {
    background: var(--card-bg, white);
    color: var(--text-primary, #333);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.message-time {
    font-size: 11px;
    color: var(--text-light, #999);
    margin-top: 4px;
    padding: 0 16px;
}

.conversation-message.user .message-time {
    text-align: right;
}

/* ── Lead Details Modal ── */
.lead-details {
    padding: 10px 0;
}

.detail-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 15px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color, #f1f1f1);
}

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

.detail-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary, #666);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-label i {
    color: #667eea;
    font-size: 13px;
}

.detail-value {
    color: var(--text-primary, #333);
    word-wrap: break-word;
    font-size: 14px;
}

.detail-value code {
    background: var(--gray-50, #f5f7ff);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Cascadia Code', 'Courier New', monospace;
    font-size: 12px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
}

/* ── Export Button ── */
.export-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-bottom: 20px;
    font-family: inherit;
}

.export-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.export-button:active {
    transform: translateY(0);
}

.export-button:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.export-button i {
    font-size: 15px;
}

/* ── Responsive: Tablet & Mobile ── */
@media (max-width: 768px) {
    .leads-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .leads-table {
        min-width: 1100px;
    }

    .detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .detail-label {
        font-weight: 700;
        font-size: 12px;
    }

    .conversation-container {
        max-height: 400px;
    }

    .message-bubble {
        max-width: 85%;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }

    .action-buttons {
        gap: 4px;
    }
}

@media (max-width: 640px) {
    .leads-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px 16px;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .stat-content h4 {
        font-size: 24px;
    }

    .stat-content p {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .leads-table thead th {
        font-size: 12px;
        padding: 10px 12px;
    }

    .leads-table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        border-radius: 8px;
    }

    .btn-icon i {
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .leads-stats {
        grid-template-columns: 1fr;
    }
}

/* ── Modal Styles ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal.active,
.modal[style*="display: block"] {
    display: flex !important;
}

.modal-content {
    background: var(--card-bg, white);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content::-webkit-scrollbar {
    width: 5px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.15);
    border-radius: 3px;
}

.modal-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--border-color, #f1f1f1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-primary, #333);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.modal-header h2 i {
    color: #667eea;
    font-size: 18px;
}

.modal-close {
    background: var(--gray-100, #f3f4f6);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 20px;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: #667eea;
    color: var(--white);
    transform: rotate(90deg);
}

.modal-close:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--border-color, #f1f1f1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 9px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.btn-secondary {
    background: var(--gray-100, #f3f4f6);
    color: var(--text-secondary, #666);
}

.btn-secondary:hover {
    background: var(--gray-200, #e5e7eb);
}

.btn-secondary:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.3);
    outline-offset: 2px;
}

/* ── Lead Score Cell (table column) ── */
.lead-score-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 80px;
}

.lead-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.score-icon {
    font-size: 12px;
}

.score-number {
    font-variant-numeric: tabular-nums;
}

.score-bar-track {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.score-category-label {
    margin-top: 1px;
}

/* ── Pillar Breakdown Bars (detail modal) ── */
.pillar-row {
    display: grid;
    grid-template-columns: 120px 1fr 50px;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.pillar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #444);
    white-space: nowrap;
}

.pillar-bar-track {
    height: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.pillar-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.pillar-value {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary, #555);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Intent Signal Pills ── */
.intent-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── Responsive pillar row ── */
@media (max-width: 768px) {
    .pillar-row {
        grid-template-columns: 90px 1fr 40px;
    }
}

/* ============================================================
   DARK MODE — Leads Dashboard
   ============================================================ */

/* Stat card accent bar in dark mode */
body[data-dashboard-theme="dark"] .stat-card {
    border-color: rgba(99, 102, 241, 0.12);
}

body[data-dashboard-theme="dark"] .stat-card:hover {
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Table wrapper dark border */
body[data-dashboard-theme="dark"] .table-wrapper {
    border-color: rgba(99, 102, 241, 0.12);
}

/* Score bar tracks: visible on dark bg */
body[data-dashboard-theme="dark"] .score-bar-track {
    background: rgba(255, 255, 255, 0.14);
}

body[data-dashboard-theme="dark"] .pillar-bar-track {
    background: rgba(255, 255, 255, 0.1);
}

/* Strengthen badge backgrounds in dark mode */
body[data-dashboard-theme="dark"] .lead-score-badge {
    border-width: 1.5px !important;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Table alternate row in dark mode */
body[data-dashboard-theme="dark"] .leads-table tbody tr:nth-child(even) {
    background: rgba(99, 102, 241, 0.04);
}

/* Table row hover in dark mode */
body[data-dashboard-theme="dark"] .leads-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Table header on dark mode */
body[data-dashboard-theme="dark"] .leads-table thead {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.85) 0%, rgba(139, 92, 246, 0.85) 100%);
}

/* Conversation container dark mode */
body[data-dashboard-theme="dark"] .conversation-container {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

/* Detail value code block in dark mode */
body[data-dashboard-theme="dark"] .detail-value code {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Action icon buttons in dark mode */
body[data-dashboard-theme="dark"] .btn-icon {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

body[data-dashboard-theme="dark"] .btn-icon:hover {
    background: #6366f1;
    color: var(--white);
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

body[data-dashboard-theme="dark"] .btn-icon.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

body[data-dashboard-theme="dark"] .btn-icon.btn-danger:hover {
    background: #ef4444;
    color: var(--white);
    border-color: #ef4444;
}

/* WhatsApp button dark mode */
body[data-dashboard-theme="dark"] .btn-icon[style*="color:#25D366"],
body[data-dashboard-theme="dark"] .btn-icon[style*="color: #25D366"] {
    background: rgba(37, 211, 102, 0.1);
    border-color: rgba(37, 211, 102, 0.2);
}

body[data-dashboard-theme="dark"] .btn-icon[style*="color:#25D366"]:hover,
body[data-dashboard-theme="dark"] .btn-icon[style*="color: #25D366"]:hover {
    background: #25D366;
    border-color: #25D366;
}

/* Status select in dark mode */
body[data-dashboard-theme="dark"] .lead-status-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Modal in dark mode */
body[data-dashboard-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.6);
}

body[data-dashboard-theme="dark"] .modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

body[data-dashboard-theme="dark"] .modal-close {
    background: rgba(255, 255, 255, 0.08);
}

body[data-dashboard-theme="dark"] .modal-close:hover {
    background: #6366f1;
    color: var(--white);
}

/* Scrollbar dark mode */
body[data-dashboard-theme="dark"] .table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.25);
}

body[data-dashboard-theme="dark"] .conversation-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
}

body[data-dashboard-theme="dark"] .modal-content::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
}

/* Empty state in dark mode */
body[data-dashboard-theme="dark"] .empty-state i {
    color: rgba(148, 163, 184, 0.4);
}

/* Export button focus in dark mode */
body[data-dashboard-theme="dark"] .export-button:focus-visible {
    outline-color: rgba(139, 92, 246, 0.5);
}

/* ============================================================
   CRM Quick Wins — New UI Components
   ============================================================ */

/* ── Status Filter Tabs ── */
.leads-status-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 4px;
    background: var(--card-bg, white);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
}

.leads-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.leads-filter-tab:hover {
    background: rgba(102, 126, 234, 0.06);
    color: var(--text-primary, #1e293b);
}

.leads-filter-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.leads-filter-tab.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--gray-100, rgba(0, 0, 0, 0.06));
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ── Agent Badge (in table) ── */
.lead-agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.12);
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-agent-badge i {
    font-size: 10px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* ── Lead Age Badge ── */
.lead-age-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    background: rgba(100, 116, 139, 0.08);
    white-space: nowrap;
}

.lead-age-badge.fresh {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    font-weight: 700;
}

.lead-age-badge.recent {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.lead-age-badge.stale {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    animation: stale-pulse 2s ease-in-out infinite;
}

@keyframes stale-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ── Create Deal Button ── */
.btn-icon.btn-deal {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.15);
}

.btn-icon.btn-deal:hover {
    background: #f59e0b;
    color: var(--white);
    border-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-icon.btn-deal:focus-visible {
    outline-color: rgba(245, 158, 11, 0.5);
}

/* ── Deals Pipeline: Overdue Stat Card ── */
.deals-stat-overdue {
    border-left: 3px solid #ef4444;
}

.deals-stat-overdue .deals-stat-value {
    color: #ef4444;
    font-weight: 800;
}

/* ── Dark Mode Overrides ── */
body[data-dashboard-theme="dark"] .leads-status-filters {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(148, 163, 184, 0.1);
}

body[data-dashboard-theme="dark"] .leads-filter-tab {
    color: rgba(203, 213, 225, 0.7);
}

body[data-dashboard-theme="dark"] .leads-filter-tab:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #e2e8f0;
}

body[data-dashboard-theme="dark"] .filter-count {
    background: rgba(255, 255, 255, 0.08);
}

body[data-dashboard-theme="dark"] .lead-agent-badge {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

body[data-dashboard-theme="dark"] .lead-age-badge {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
}

body[data-dashboard-theme="dark"] .lead-age-badge.fresh {
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
}

body[data-dashboard-theme="dark"] .lead-age-badge.recent {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
}

body[data-dashboard-theme="dark"] .lead-age-badge.stale {
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

body[data-dashboard-theme="dark"] .btn-icon.btn-deal {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

/* ── Responsive: Filter tabs on mobile ── */
@media (max-width: 768px) {
    .leads-status-filters {
        gap: 4px;
        padding: 3px;
    }

    .leads-filter-tab {
        padding: 6px 10px;
        font-size: 12px;
    }

    .filter-count {
        min-width: 18px;
        height: 18px;
        font-size: 10px;
    }
}

/* ── Search Bar ── */
.leads-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-bottom: 16px;
    background: var(--card-bg, white);
    border-radius: var(--radius-lg, 12px);
    border: 1.5px solid var(--border-color, rgba(0, 0, 0, 0.08));
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.04));
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.leads-search-bar:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.leads-search-bar>i {
    color: var(--text-secondary, #94a3b8);
    font-size: 14px;
    flex-shrink: 0;
}

.leads-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary, #1e293b);
}

.leads-search-bar input::placeholder {
    color: var(--text-secondary, #94a3b8);
}

.leads-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.leads-search-clear:hover {
    background: #ef4444;
    color: var(--white);
}

/* ── Bulk Actions Toolbar ── */
.leads-bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border-bottom: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 12px 12px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    animation: bulkSlideIn 0.2s ease-out;
}

@keyframes bulkSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.leads-bulk-toolbar>span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #667eea;
    white-space: nowrap;
}

.leads-bulk-toolbar .bulk-count {
    font-weight: 800;
    font-size: 15px;
}

.leads-bulk-select {
    padding: 5px 10px;
    border-radius: 8px;
    border: 1.5px solid rgba(102, 126, 234, 0.2);
    background: var(--card-bg, white);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-primary, #1e293b);
    cursor: pointer;
    outline: none;
}

.leads-bulk-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.leads-bulk-clear {
    padding: 5px 12px;
    border-radius: 8px;
    border: none;
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.leads-bulk-clear:hover {
    background: #ef4444;
    color: var(--white);
}

/* ── Sticky Table Headers ── */
.leads-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ── Checkbox styling in table ── */
.leads-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
    border-radius: 4px;
}

/* ── Dark Mode: Search & Bulk ── */
body[data-dashboard-theme="dark"] .leads-search-bar {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(148, 163, 184, 0.1);
}

body[data-dashboard-theme="dark"] .leads-search-bar:focus-within {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

body[data-dashboard-theme="dark"] .leads-search-bar input {
    color: #e2e8f0;
}

body[data-dashboard-theme="dark"] .leads-bulk-toolbar {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(118, 75, 162, 0.1));
    border-bottom-color: rgba(139, 92, 246, 0.2);
}

body[data-dashboard-theme="dark"] .leads-bulk-toolbar>span {
    color: #a78bfa;
}

body[data-dashboard-theme="dark"] .leads-bulk-select {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(139, 92, 246, 0.2);
    color: #e2e8f0;
}

body[data-dashboard-theme="dark"] .leads-bulk-select:focus {
    border-color: #8b5cf6;
}

/* ── Responsive: Search & Bulk on mobile ── */
@media (max-width: 768px) {
    .leads-search-bar {
        padding: 8px 12px;
        gap: 8px;
        margin-bottom: 12px;
    }

    .leads-search-bar input {
        font-size: 13px;
    }

    .leads-bulk-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .leads-bulk-select {
        font-size: 12px;
    }
}