/* ===== Base Styles ===== */
:root {
    /* Primary — aligned with marketing landing (teal / cyan) */
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #14b8a6;
    --primary-lighter: #ccfbf1;
    --primary-500: #0d9488;
    --primary-600: #0f766e;
    --primary-700: #115e59;
    
    /* Semantic Colors */
    --accent-green: #4CAF50;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --orange: #f97316;
    
    /* Extended Color Palette */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    
    --yellow-50: #fefce8;
    --yellow-100: #fef9c3;
    --yellow-500: #eab308;
    --yellow-600: #ca8a04;
    --yellow-700: #a16207;
    
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    
    --purple-50: #faf5ff;
    --purple-100: #f3e8ff;
    --purple-500: #a855f7;
    --purple-600: #9333ea;
    --purple-700: #7c3aed;
    
    /* Gray Scale — landing-adjacent cool neutrals */
    --gray-50: #f4f7f6;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Border Radius */
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.3s ease;

    /* Typography — match landing: DM Sans body, Plus Jakarta for UI chrome */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Full-height app shell (sidebar is fixed; main must fill viewport for nested scroll) */
html {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100%;
    min-height: 100dvh;
}

/* Headings & nav labels — slightly tighter for a polished dashboard */
.sidebar-brand .brand-name,
.master-header h2,
.view-header h1,
.view-header h2,
.modal-header h2,
.settings-section-title,
.empty-state h2,
.empty-state h3 {
    font-family: var(--font-sans);
    letter-spacing: -0.025em;
    font-weight: 700;
}

button, .btn, input, select, textarea {
    font-family: var(--font-sans);
}

/* ===== App Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 220px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    pointer-events: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-toggle {
    display: none;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.sidebar-toggle svg {
    display: block;
    transition: transform 0.2s ease;
}

@media (min-width: 769px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transition: width 0.22s ease;
    }

    .main {
        transition: margin-left 0.22s ease;
    }

    body.sidebar-collapsed .sidebar {
        width: 72px;
    }

    body.sidebar-collapsed .main {
        margin-left: 72px;
    }

    body.sidebar-collapsed .brand-name,
    body.sidebar-collapsed .menu-label,
    body.sidebar-collapsed .menu-item > span,
    body.sidebar-collapsed .user-info {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar-brand {
        flex-direction: column;
        justify-content: center;
        gap: 10px;
        padding: 16px 8px;
    }

    body.sidebar-collapsed .menu-item {
        justify-content: center;
        padding: 12px 10px;
    }

    body.sidebar-collapsed .menu-badge {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar-menu {
        padding: 16px 10px;
    }

    body.sidebar-collapsed .user-menu {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    body.sidebar-collapsed .sidebar-utils {
        flex-direction: column;
    }

    body.sidebar-collapsed .sidebar-util-link span,
    body.sidebar-collapsed .sidebar-util-link {
        justify-content: center;
        font-size: 0;
        padding: 8px;
    }

    body.sidebar-collapsed .sidebar-util-link svg {
        width: 16px;
        height: 16px;
    }

    body.sidebar-collapsed .sidebar-toggle svg {
        transform: rotate(180deg);
    }

    body.sidebar-collapsed .sidebar-toggle {
        background: var(--gray-100);
    }

}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 14px;
    margin-bottom: 8px;
    margin-top: 16px;
}

.menu-label:first-child {
    margin-top: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.menu-item:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}

.menu-item.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.menu-item svg {
    flex-shrink: 0;
}

.menu-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: 600;
}

.menu-item.active .menu-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.sidebar-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--gray-100);
}

.sidebar-utils {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
}

.sidebar-util-link {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    padding: 7px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-400);
    text-decoration: none;
    transition: var(--transition-fast);
}

.sidebar-util-link:hover,
.sidebar-util-link.active {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* App Download Card */
.app-download {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-xl);
    padding: 20px;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
}

.app-download::before {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.app-download-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.app-download h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.app-download p {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 12px;
}

.download-btn {
    background: white;
    color: var(--primary);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.download-btn:hover {
    transform: scale(1.02);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex: 1;
    min-height: 0;
}

.view.active {
    display: flex;
    flex-direction: column;
    overflow: auto;
}

/* Sites master–detail manages its own scroll regions */
#sites-view.view.active {
    overflow: hidden;
}

/* Handoffs view should scroll inside panels, not page */
#handoffs-view.view.active {
    overflow: hidden;
    height: 100dvh;
}

/* Full-bleed views: fill main and scroll inside panels */
#conversations-view.view.active > .conversations-layout,
#handoffs-view.view.active > .handoffs-layout {
    flex: 1;
    min-height: 0;
    height: 100%;
}

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 40px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 15px;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.3);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Sites Grid ===== */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.site-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: 24px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.site-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    opacity: 0;
    transition: var(--transition);
}

.site-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.site-card:hover::before {
    opacity: 1;
}

.site-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1), var(--shadow-lg);
}

.site-card.active::before {
    opacity: 1;
}

.site-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.site-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.site-favicon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-lighter), #d1fae5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.site-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.site-url {
    font-size: 13px;
    color: var(--gray-500);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.ready {
    background: #d1fae5;
    color: #059669;
}

.status-badge.crawling {
    background: #fef3c7;
    color: #d97706;
}

.status-badge.error,
.status-badge.failed {
    background: #fef2f2;
    color: #dc2626;
}

.site-card-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: #fef2f2;
    border-radius: var(--radius);
    font-size: 12px;
    color: #dc2626;
    line-height: 1.4;
}

.site-card-error svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.status-badge.pending {
    background: var(--gray-100);
    color: var(--gray-600);
}

.status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.crawling .dot {
    animation: pulse 1s infinite;
}

.site-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

.site-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}

.site-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.site-stat-label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Empty State ===== */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 2px dashed var(--gray-200);
}

.empty-state.hidden {
    display: none;
}

.empty-illustration {
    margin-bottom: 24px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 24px;
    max-width: 300px;
}

/* ===== Chat Layout ===== */
.chat-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--white);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(180deg, var(--white), var(--gray-50));
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.chat-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.site-select {
    padding: 10px 14px;
    padding-right: 36px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: 14px;
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    min-width: 220px;
    font-weight: 500;
}

.site-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--gray-50);
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-lighter), #d1fae5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--primary);
}

.welcome-message h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.message {
    max-width: 720px;
    padding: 16px 20px;
    border-radius: var(--radius-xl);
    font-size: 15px;
    line-height: 1.7;
}

.message.user {
    background: var(--primary);
    color: var(--white);
    margin-left: auto;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.2);
}

.message.assistant {
    background: var(--white);
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}

.message-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.message-sources-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    padding: 4px 8px;
    background: rgba(13, 148, 136, 0.08);
    border-radius: 4px;
    margin-right: 8px;
    margin-bottom: 4px;
}

.source-link:hover {
    background: rgba(13, 148, 136, 0.15);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    background: var(--white);
    border-radius: var(--radius-xl);
    border-bottom-left-radius: 4px;
    width: fit-content;
    border: 1px solid var(--gray-200);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

.chat-input-wrapper {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}

.chat-form {
    display: flex;
    gap: 12px;
    background: var(--gray-100);
    border-radius: var(--radius-xl);
    padding: 8px;
    align-items: flex-end;
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.chat-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.chat-form textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 15px;
    resize: none;
    max-height: 200px;
    font-family: inherit;
    color: var(--gray-800);
}

.chat-form textarea:focus {
    outline: none;
}

.chat-form textarea::placeholder {
    color: var(--gray-400);
}

.chat-send {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.chat-send:hover:not(:disabled) {
    background: var(--primary-light);
    transform: scale(1.05);
}

.chat-send:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== Stats & Settings ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    border-top: 3px solid transparent;
    padding: 18px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.stat-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat-card--teal { border-top-color: var(--primary); }
.stat-card--green { border-top-color: #059669; }
.stat-card--blue { border-top-color: #3b82f6; }
.stat-card--purple { border-top-color: #8b5cf6; }
.stat-card--orange { border-top-color: #f97316; }
.stat-card--red { border-top-color: #ef4444; }

.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.stat-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
    letter-spacing: 0.01em;
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.teal {
    background: var(--primary-lighter);
    color: var(--primary);
}

.stat-icon.blue {
    background: #dbeafe;
    color: #3b82f6;
}

.stat-icon.green {
    background: #d1fae5;
    color: #059669;
}

.stat-icon.purple {
    background: #ede9fe;
    color: #8b5cf6;
}

.stat-icon.orange {
    background: #ffedd5;
    color: #f97316;
}

.stat-icon.red {
    background: #fee2e2;
    color: #ef4444;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-change {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.stat-change-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

/* ===== Settings Layout ===== */
.settings-layout {
    display: flex;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.settings-sidebar {
    width: 200px;
    flex-shrink: 0;
    padding: 28px 12px;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: 28px;
    background: var(--gray-50);
}

.settings-nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    padding: 0 10px;
    margin-bottom: 4px;
    display: block;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition-fast);
}

.settings-nav-item:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.settings-nav-item.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.settings-nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.settings-nav-item.active svg {
    opacity: 1;
}

.settings-content {
    flex: 1;
    padding: 36px 40px;
    overflow-y: auto;
    min-width: 0;
}

.settings-panel {
    display: none;
    max-width: 580px;
}

.settings-panel.active {
    display: block;
}

.settings-panel-header {
    margin-bottom: 24px;
}

.settings-panel-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.settings-panel-header p {
    font-size: 14px;
    color: var(--gray-500);
}

.settings-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    margin-bottom: 12px;
}

.settings-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.settings-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.settings-card-title-row .settings-card-title {
    margin-bottom: 0;
}

.settings-card-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: -10px;
    margin-bottom: 16px;
}

.settings-form-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 4px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Legacy — keep for any remaining references */
.settings-section {
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: 24px;
}

/* Dashboard SPA: hide embed widget; keep sidebar above any stray high z-index layers */
body[data-sitechat-dashboard] .sitechat-widget {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

body[data-sitechat-dashboard] .sidebar {
    z-index: 100001;
}

body:not(.is-admin) .is-admin-only {
    display: none !important;
}

body.is-agent .is-not-agent {
    display: none !important;
}

body.is-agent .menu-item[data-view="admin"],
body.is-agent .menu-item[data-view="team"] {
    display: none !important;
}

/* Agents: force-show core nav (avoids stale cached CSS hiding these) */
body.is-agent .sidebar-menu .menu-item[data-view="sites"],
body.is-agent .sidebar-menu .menu-item[data-view="conversations"],
body.is-agent .sidebar-menu .menu-item[data-view="handoffs"] {
    display: flex !important;
}
body.is-agent .sidebar-utils .sidebar-util-link[data-view="settings"],
body.is-agent .sidebar-utils .sidebar-util-link[data-view="help"] {
    display: flex !important;
}

/* Agents: read-only site management (no add/delete/crawl/upload) */
body.is-agent #add-site-btn,
body.is-agent #empty-add-btn,
body.is-agent #delete-site,
body.is-agent #recrawl-site,
body.is-agent #add-documents-btn {
    display: none !important;
}

/* ===== Team View ===== */
.team-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--gray-200);
}

.team-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius) var(--radius) 0 0;
    white-space: nowrap;
}

.team-tab:hover {
    color: var(--gray-800);
    background: var(--gray-50);
}

.team-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: var(--primary-lighter);
}

.team-tab-count {
    min-width: 20px;
    text-align: center;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    transition: var(--transition);
}

.team-tab.active .team-tab-count {
    background: var(--primary);
    color: white;
}

.team-panel { display: block; }
.team-panel.hidden { display: none; }

/* Members list */
.members-list-wrap {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.members-list-header {
    display: grid;
    grid-template-columns: 1fr 140px 130px 110px;
    padding: 10px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.members-list-header--agents {
    grid-template-columns: 1fr 180px 130px 110px;
}

.member-row {
    display: grid;
    grid-template-columns: 1fr 140px 130px 110px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
}

.member-row--agents {
    grid-template-columns: 1fr 180px 130px 110px;
}

.member-row:last-child { border-bottom: none; }
.member-row:hover { background: var(--gray-50); }

.member-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.member-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.member-details { display: flex; flex-direction: column; gap: 2px; }

.member-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.member-email {
    font-size: 12px;
    color: var(--gray-500);
}

.member-sites-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.member-site-badge {
    background: var(--primary-lighter);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid rgba(13,148,136,0.15);
}

.member-date {
    font-size: 12px;
    color: var(--gray-500);
}

.member-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.members-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 24px;
    color: var(--gray-500);
    text-align: center;
}

.members-empty-icon {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--gray-400);
}

.members-empty p {
    font-size: 14px;
    margin-bottom: 20px;
    color: var(--gray-600);
}

.members-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 24px;
    color: var(--gray-400);
    font-size: 14px;
}

/* Modal type badge */
.modal-header-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-type-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--primary);
}

/* Agent sites checkboxes (used in modal) */
.agent-sites-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.agent-site-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
}

.agent-site-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Team panel stats bar */
.team-panel-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}

.team-panel-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--gray-500);
}

.team-panel-stat-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-800);
    font-family: var(--font-sans);
}

.team-panel-stat-sep {
    width: 1px;
    height: 14px;
    background: var(--gray-200);
    margin: 0 4px;
}

/* Member row — reveal actions on hover */
.member-row .member-actions {
    opacity: 0;
    transition: opacity 0.15s;
}
.member-row:hover .member-actions,
.member-row:focus-within .member-actions {
    opacity: 1;
}

/* Sites select-all header in modal */
.sites-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sites-select-header .form-hint {
    margin: 0;
}

.sites-select-all-btn {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: var(--transition-fast);
    white-space: nowrap;
}
.sites-select-all-btn:hover {
    background: var(--primary-lighter);
}

/* No-sites placeholder in member row */
.member-no-sites {
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
}

/* Spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner { animation: spin 0.8s linear infinite; }

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 20px;
}

.health-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.health-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}

.health-row:hover {
    border-color: var(--gray-200);
}

.health-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.health-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.health-desc {
    font-size: 13px;
    color: var(--gray-500);
}

.health-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.health-badge.loading {
    background: var(--gray-100);
    color: var(--gray-600);
}

.health-badge.healthy {
    background: #d1fae5;
    color: #059669;
}

.health-badge.unhealthy {
    background: #fef2f2;
    color: #dc2626;
}

/* ===== Modals ===== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    overflow-y: auto;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(10px);
    transition: var(--transition);
}

.modal-backdrop.active .modal {
    transform: scale(1) translateY(0);
}

.modal.modal-lg {
    max-width: 640px;
}

.modal.modal-member {
    max-width: 520px;
    width: 100%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-form {
    padding: 0;
}

.modal-body {
    padding: 24px;
}

.form-field {
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-field .optional {
    color: var(--gray-400);
    font-weight: 400;
}

.form-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: 14px;
    transition: var(--transition);
}

.form-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.field-hint {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
}

.modal-footer {
    margin-right: 20px;
margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
    margin-top: 8px;
    border-top: 1px solid var(--gray-100);
}

.modal-error {
    font-size: 13px;
    color: var(--danger);
    margin: 4px 0 0;
}

/* ===== Site Details Modal ===== */
.detail-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.detail-stat {
    background: var(--gray-50);
    padding: 14px 16px;
    border-radius: var(--radius);
}

.detail-stat-label {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.detail-stat-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-800);
}

.detail-url {
    word-break: break-all;
    font-size: 14px;
}

.embed-section {
    margin-bottom: 24px;
}

.embed-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.embed-section p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.embed-section code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.code-block {
    position: relative;
    background: var(--gray-900);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.code-block pre {
    padding: 16px;
    overflow-x: auto;
}

.code-block code {
    color: #e5e7eb;
    font-size: 12px;
    line-height: 1.6;
    background: transparent;
    padding: 0;
}

.code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--gray-800);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius);
    color: var(--gray-300);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.code-copy:hover {
    background: var(--gray-700);
    color: var(--white);
}

.modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===== Spinner ===== */
.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-spinner {
    display: none;
    align-items: center;
    gap: 8px;
}

.btn-spinner.hidden {
    display: none;
}

.btn-label + .btn-spinner:not(.hidden) {
    display: flex;
}

.btn-label:has(+ .btn-spinner:not(.hidden)) {
    display: none;
}

.btn.loading .btn-label {
    display: none;
}

.btn.loading .btn-spinner {
    display: flex;
}

/* ===== User Menu ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: capitalize;
}

.logout-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.logout-btn:hover {
    background: #fef2f2;
    color: var(--danger);
}

/* ===== Admin Only ===== */
.admin-only {
    display: none;
}

body.is-admin .admin-only {
    display: flex;
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* Role badges in Users table */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.role-badge.role-admin {
    background: #fef3c7;
    color: #92400e;
}
.role-badge.role-user {
    background: #d1fae5;
    color: #065f46;
}

.table-btn {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-600);
}

.table-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.table-btn.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.table-btn.danger:hover {
    background: #fef2f2;
}

/* ===== Modal Steps ===== */
.modal-step {
    display: none;
    padding: 24px;
}

.modal-step.active {
    display: block;
}

.step-description {
    color: var(--gray-600);
    margin-bottom: 24px;
    text-align: center;
    font-size: 15px;
}

/* ===== Source Type Selection ===== */
.source-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.source-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    min-height: 180px;
}

.source-type-card:hover {
    border-color: var(--primary);
    background: var(--primary-lighter);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.source-type-card.selected {
    border-color: var(--primary);
    background: var(--primary-lighter);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.source-type-icon {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    color: var(--white);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.source-type-icon svg {
    width: 28px;
    height: 28px;
}

.source-type-card h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 6px;
}

.source-type-card p {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.5;
    margin: 0;
}

@media (max-width: 640px) {
    .source-type-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .source-type-card {
        flex-direction: row;
        text-align: left;
        min-height: auto;
        padding: 16px;
        gap: 16px;
    }
    
    .source-type-icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .source-type-card h4 {
        margin-bottom: 2px;
    }
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
    margin-bottom: 16px;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-lighter);
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-lighter);
    border-style: solid;
}

.upload-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-lighter);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: var(--primary);
}

.upload-icon svg {
    width: 28px;
    height: 28px;
}

.upload-zone h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.upload-zone p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 11px;
    color: var(--gray-400);
    display: block;
}

.upload-icon {
    color: var(--gray-400);
    margin-bottom: 16px;
}

.upload-zone h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.upload-zone p {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.upload-hint {
    font-size: 12px;
    color: var(--gray-400);
}

/* ===== File List ===== */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.file-item:hover {
    border-color: var(--gray-300);
}

.file-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon.pdf { background: #fef2f2; color: #dc2626; }
.file-icon.doc { background: #eff6ff; color: #2563eb; }
.file-icon.txt { background: var(--gray-100); color: var(--gray-600); }
.file-icon.csv { background: #f0fdf4; color: #16a34a; }
.file-icon.ppt { background: #fff7ed; color: #ea580c; }
.file-icon.xls { background: #f0fdf4; color: #16a34a; }
.file-icon.default { background: var(--gray-100); color: var(--gray-500); }

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: var(--gray-500);
}

.file-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
}

.file-status.pending {
    background: var(--gray-100);
    color: var(--gray-600);
}

.file-status.uploading {
    background: #fef3c7;
    color: #d97706;
}

.file-status.success {
    background: #d1fae5;
    color: #059669;
}

.file-status.error {
    background: #fee2e2;
    color: #dc2626;
}

.file-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.file-remove:hover {
    background: #fef2f2;
    color: var(--danger);
}

/* ===== Form Tabs ===== */
.form-tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.form-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.form-tab:hover {
    color: var(--gray-700);
}

.form-tab.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.form-tab-content {
    display: none;
}

.form-tab-content.active {
    display: block;
}

/* ===== Documents Section ===== */
.documents-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius-xl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}

.section-header h4 svg {
    color: var(--gray-400);
}

.documents-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-docs {
    padding: 24px;
    text-align: center;
    color: var(--gray-400);
    font-size: 14px;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.doc-item .file-icon {
    width: 36px;
    height: 36px;
}

.doc-item .file-info {
    flex: 1;
}

.doc-item .file-name {
    font-size: 13px;
}

.doc-item .file-meta {
    font-size: 11px;
    color: var(--gray-400);
}

.doc-delete {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.doc-delete:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* ===== Small Button ===== */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ===== Master-Detail Layout ===== */

.master-detail-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.master-panel {
    width: 260px;
    min-width: 220px;
    max-width: 320px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 0;
}

.master-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.master-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.sites-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.site-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    margin-bottom: 4px;
}

.site-list-item:hover {
    background: var(--gray-50);
}

.site-list-item.active {
    background: var(--primary-lighter);
    border-color: var(--primary);
}

.site-list-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.site-list-info {
    flex: 1;
    min-width: 0;
}

.site-list-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-list-url {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-list-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.site-list-status.completed {
    background: var(--green-100, #dcfce7);
    color: var(--green-700, #15803d);
}

.site-list-status.crawling {
    background: var(--yellow-100, #fef3c7);
    color: var(--yellow-700, #a16207);
}

.site-list-status.failed {
    background: var(--red-100, #fee2e2);
    color: var(--red-700, #b91c1c);
}

.empty-state-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--gray-400);
}

.empty-state-compact svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-compact p {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--gray-500);
}

/* Detail Panel */
.detail-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--gray-50);
}

.detail-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--gray-400);
}

.detail-empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.detail-empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.detail-empty-state p {
    font-size: 14px;
    color: var(--gray-400);
}

.detail-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detail-breadcrumb {
    flex-shrink: 0;
    padding: 12px 24px 0;
    background: var(--white);
}

.detail-breadcrumb-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 4px;
    font-size: 13px;
    color: var(--gray-500);
}

.detail-breadcrumb-link {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
}

.detail-breadcrumb-link:hover {
    text-decoration: underline;
    color: var(--primary-dark, #0f766e);
}

.detail-breadcrumb-sep {
    color: var(--gray-300);
    user-select: none;
}

.detail-breadcrumb-site {
    font-weight: 500;
    color: var(--gray-700);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-breadcrumb-section {
    font-weight: 600;
    color: var(--gray-800);
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.detail-header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-site-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 20px;
}

.detail-header-info h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.detail-site-url {
    font-size: 13px;
    color: var(--gray-500);
    text-decoration: none;
}

.detail-site-url:hover {
    color: var(--primary);
    text-decoration: underline;
}

.detail-header-actions {
    display: flex;
    gap: 8px;
}

.detail-stats-row {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.detail-stat {
    flex: 1;
    text-align: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.detail-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
}

.detail-stat-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.detail-quick-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.detail-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.detail-action-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

.detail-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Site detail: sidebar sections + scrollable content */
.detail-settings-layout {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
    background: var(--white);
}

.detail-settings-nav {
    width: 220px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0 20px;
    border-right: 1px solid var(--gray-200);
    background: linear-gradient(180deg, var(--gray-50) 0%, var(--white) 35%);
    -webkit-overflow-scrolling: touch;
}

.detail-nav-group {
    margin-bottom: 4px;
}

.detail-nav-group-label {
    display: block;
    padding: 16px 18px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gray-400);
    user-select: none;
}

.detail-nav-item-text {
    flex: 1;
    min-width: 0;
}

/* Sidebar tab buttons (share .detail-tab for JS) */
.detail-settings-nav .detail-nav-item.detail-tab {
    display: flex;
    align-items: center;
    width: calc(100% - 16px);
    margin: 1px 8px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--gray-600);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    border-bottom: none;
}

.detail-settings-nav .detail-nav-item.detail-tab:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-900);
}

.detail-settings-nav .detail-nav-item.detail-tab.active {
    background: var(--primary-lighter);
    color: var(--primary-dark);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary);
}

.detail-settings-nav .detail-tab::after {
    display: none !important;
}

.detail-tab-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: var(--white);
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
    .detail-settings-layout {
        flex-direction: column;
    }

    .detail-settings-nav {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
        padding: 10px 10px 12px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 6px 8px;
        background: var(--white);
    }

    .detail-nav-group {
        display: contents;
    }

    .detail-nav-group-label {
        flex-basis: 100%;
        width: 100%;
        padding: 8px 8px 4px;
    }

    .detail-settings-nav .detail-nav-item.detail-tab {
        flex: 1 1 calc(50% - 8px);
        min-width: 140px;
        width: auto;
        margin: 0;
        justify-content: center;
        text-align: center;
        box-shadow: none;
        padding: 10px 8px;
        font-size: 12px;
    }

    .detail-settings-nav .detail-nav-item.detail-tab.active {
        box-shadow: none;
        outline: 2px solid var(--primary);
        outline-offset: -2px;
    }
}

/* Tab Form Styles */
.tab-form {
    max-width: 600px;
}

.tab-form .form-group {
    margin-bottom: 16px;
}

.tab-form .form-divider {
    margin: 24px 0;
    border-top: 1px solid var(--gray-200);
}

.tab-form .form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.tab-form .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

.code-block {
    position: relative;
    background: var(--gray-800);
    border-radius: var(--radius);
    padding: 16px;
    overflow: hidden;
}

.code-block pre {
    margin: 0;
    overflow-x: auto;
}

.code-block code {
    color: #e2e8f0;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: var(--radius);
    color: var(--gray-300);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.code-copy:hover {
    background: rgba(255,255,255,0.2);
    color: var(--white);
}

.embed-section-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.embed-section-header p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .master-panel {
        width: 260px;
        min-width: 240px;
    }
}

@media (max-width: 768px) {
    .master-detail-layout {
        flex-direction: column;
    }
    
    .master-panel {
        width: 100%;
        max-width: none;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .detail-panel {
        flex: 1;
    }
}

/* ===== Side Panel ===== */
.side-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 998;
}

.side-panel-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 440px;
    height: 100vh;
    background: var(--white);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.side-panel.active {
    transform: translateX(0);
}

.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--primary-lighter), var(--white));
}

.side-panel-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.side-panel-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.side-panel-title h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.side-panel-url {
    font-size: 13px;
    color: var(--gray-500);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-panel-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--white);
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.side-panel-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.side-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.panel-section {
    padding: 24px;
    border-bottom: 1px solid var(--gray-100);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 16px 0;
}

.panel-section-title svg {
    color: var(--gray-400);
}

.panel-section-header .panel-section-title {
    margin: 0;
}

.panel-hint {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.panel-hint code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Panel Stats Grid */
.panel-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.panel-stat {
    text-align: center;
    padding: 20px 8px;
    background: linear-gradient(135deg, var(--gray-50), var(--white));
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
}

.panel-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.panel-stat-label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Panel Actions */
.panel-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.panel-action-btn:hover {
    background: var(--primary-lighter);
    border-color: var(--primary-light);
    color: var(--primary);
}

.panel-action-btn svg {
    color: var(--gray-400);
}

.panel-action-btn:hover svg {
    color: var(--primary);
}

/* Documents List in Panel */
.side-panel .documents-list {
    max-height: 200px;
    overflow-y: auto;
}

.side-panel .empty-docs {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
    text-align: center;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--gray-200);
}

.side-panel .empty-docs svg {
    color: var(--gray-300);
    margin-bottom: 12px;
}

.side-panel .empty-docs p {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    margin: 0;
}

.side-panel .empty-docs span {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.side-panel .doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.side-panel .doc-item:hover {
    border-color: var(--gray-200);
}

.side-panel .doc-item:last-child {
    margin-bottom: 0;
}

.side-panel .doc-item .file-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.side-panel .doc-item .file-info {
    flex: 1;
    min-width: 0;
}

.side-panel .doc-item .file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-panel .doc-item .file-meta {
    font-size: 11px;
    color: var(--gray-500);
}

.doc-status {
    display: flex;
    align-items: center;
    justify-content: center;
}

.side-panel .doc-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.side-panel .doc-delete:hover {
    background: var(--danger);
    color: var(--white);
}

/* Code Block in Panel */
.side-panel .code-block {
    position: relative;
}

.side-panel .code-block pre {
    background: var(--gray-900);
    border-radius: var(--radius-lg);
    padding: 16px;
    overflow-x: auto;
    margin: 0;
}

.side-panel .code-block code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    color: #e5e7eb;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.side-panel .code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: var(--gray-400);
    cursor: pointer;
    transition: var(--transition);
}

.side-panel .code-copy:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

/* Panel Footer */
.side-panel-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.side-panel-footer .btn-danger {
    width: 100%;
    justify-content: center;
}

/* Status Badge in Panel */
.panel-stat-value .status-badge {
    font-size: 12px;
    padding: 4px 10px;
}

/* ===== Customization Panel ===== */
.customize-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius);
    position: relative;
    z-index: 1;
}

.customize-tab {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--gray-600);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.customize-tab:hover {
    color: var(--gray-800);
}

.customize-tab.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.customize-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.customize-content.hidden {
    display: none;
}

.customize-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-input,
.form-textarea,
.form-select {
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-800);
    transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-lighter);
}

.form-textarea {
    resize: vertical;
    min-height: 60px;
}

.form-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    appearance: none;
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-checkbox label {
    font-weight: 400;
}

.color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
}

.color-text-input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    font-family: monospace;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
}

/* ===== Widget Preview ===== */
.widget-preview-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.preview-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.widget-preview {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-200);
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.preview-header-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-header-icon svg {
    width: 16px;
    height: 16px;
}

.preview-header-text {
    display: flex;
    flex-direction: column;
}

.preview-title {
    font-size: 13px;
    font-weight: 600;
}

.preview-subtitle {
    font-size: 11px;
    opacity: 0.85;
}

.preview-messages {
    padding: 12px;
    min-height: 80px;
}

.preview-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.preview-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.preview-avatar svg {
    width: 12px;
    height: 12px;
    color: white;
}

.preview-bubble {
    background: white;
    padding: 10px 12px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--gray-800);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.preview-input {
    display: flex;
    gap: 6px;
    padding: 10px;
    background: white;
    border-top: 1px solid var(--gray-100);
}

.preview-input input {
    flex: 1;
    padding: 8px 10px;
    font-size: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
}

.preview-send {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.preview-send svg {
    width: 14px;
    height: 14px;
    color: white;
}

.preview-branding {
    padding: 6px 12px;
    text-align: center;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
    border-radius: 0 0 12px 12px;
}

.preview-branding a {
    font-size: 9px;
    color: #9ca3af;
    text-decoration: none;
}

.preview-branding strong {
    font-weight: 600;
}

.preview-branding.hidden {
    display: none;
}

/* ===== Analytics Dashboard ===== */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.analytics-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* 3-col bottom grid */
.analytics-bottom-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
}

.analytics-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 20px;
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.analytics-card-full {
    margin-bottom: 16px;
}

.analytics-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.analytics-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.analytics-card-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.analytics-card-icon.teal { background: var(--primary-lighter); color: var(--primary); }
.analytics-card-icon.blue { background: #dbeafe; color: #3b82f6; }
.analytics-card-icon.purple { background: #ede9fe; color: #8b5cf6; }

.analytics-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.analytics-period-select {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius);
}

.period-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--gray-600);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.period-btn:hover {
    color: var(--gray-800);
}

.period-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.chart-container {
    position: relative;
    height: 320px;
}

.chart-container.chart-sm {
    height: 200px;
}

.analytics-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-top: 14px;
    margin-top: 14px;
    border-top: 1px solid var(--gray-100);
    flex-wrap: wrap;
}

.summary-item {
    font-size: 13px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 6px;
}

.summary-item strong {
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.summary-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.summary-dot.teal { background: #0d9488; }
.summary-dot.teal-light { background: #14b8a6; border: 1.5px dashed #14b8a6; background: transparent; }

.summary-change {
    margin-left: auto;
    font-weight: 500;
    font-size: 13px;
}

.trend-up {
    color: var(--success) !important;
}

.trend-down {
    color: var(--danger) !important;
}

.popular-questions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.question-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-100);
    transition: border-color 0.15s;
}

.question-item:hover {
    border-color: var(--gray-200);
}

.question-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-lighter);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.question-content {
    flex: 1;
    min-width: 0;
}

.question-text {
    font-size: 14px;
    color: var(--gray-800);
    line-height: 1.4;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.question-count {
    font-size: 12px;
    color: var(--gray-500);
}

.recent-conversations-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.recent-conversations-list .empty-analytics {
    grid-column: 1 / -1;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.conversation-item:hover {
    background: var(--gray-100);
}

.conversation-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-lighter);
    color: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-preview {
    font-size: 14px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-500);
}

.empty-analytics {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--gray-400);
    font-size: 13px;
    gap: 4px;
    text-align: center;
    padding: 16px;
}

/* Conversations by Site */
.conversations-by-site-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
    max-height: 300px;
    overflow-y: auto;
}

.site-stat-row {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.site-stat-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.site-stat-bar-wrap {
    background: var(--gray-100);
    border-radius: 99px;
    height: 6px;
    overflow: hidden;
}

.site-stat-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.4s ease;
    min-width: 4px;
}

.site-stat-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
}

.site-stat-msgs {
    font-size: 11px;
    font-weight: 400;
    color: var(--gray-400);
    margin-left: 4px;
}

.analytics-view-all {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.analytics-view-all:hover {
    background: var(--primary-lighter);
}

.analytics-site-select {
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
    min-width: 140px;
}

.analytics-site-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Question frequency bars */
.question-bar-wrap {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    margin: 5px 0 3px;
    overflow: hidden;
}

.question-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Top Sources list */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 0;
    max-height: 300px;
    overflow-y: auto;
}

.source-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.source-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.source-title {
    font-size: 13px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.source-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.source-bar-wrap {
    height: 5px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
}

.source-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Recent conversations arrow */
.conv-item-arrow {
    color: var(--gray-300);
    flex-shrink: 0;
    transition: var(--transition);
}

.conversation-item:hover .conv-item-arrow {
    color: var(--primary);
}

/* ===== Conversations View ===== */
.conversations-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    height: 100%;
    min-height: 0;
    background: var(--gray-50);
}

.conversations-list-panel {
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.conversations-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--gray-200);
}

.conversations-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.conversations-count {
    font-size: 13px;
    color: var(--gray-500);
}

.conversations-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.search-box svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--gray-800);
}

.search-box input:focus {
    outline: none;
}

.search-box input::placeholder {
    color: var(--gray-400);
}

.conversations-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.conv-filters-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.conv-date-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    white-space: nowrap;
    flex-shrink: 0;
}

.conv-date-input {
    flex: 1;
    min-width: 0;
}

.filter-select {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--gray-700);
    background: white;
    cursor: pointer;
}

.filter-select-auto {
    flex: 1 1 0;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.conversations-bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--primary-lighter);
    border-bottom: 1px solid var(--gray-200);
}

.bulk-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--gray-700);
}

.bulk-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.bulk-buttons {
    display: flex;
    gap: 8px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversations-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    gap: 12px;
    color: var(--gray-500);
}

.conversations-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.conv-list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.conv-list-item:hover {
    background: var(--gray-50);
}

.conv-list-item.selected {
    background: var(--primary-lighter);
    border-color: var(--primary);
}

.conv-checkbox {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.conv-list-content {
    flex: 1;
    min-width: 0;
}

.conv-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conv-list-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-list-time {
    font-size: 11px;
    color: var(--gray-400);
    flex-shrink: 0;
}

.conv-list-preview {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.conv-list-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--gray-400);
}

.conv-meta-tag {
    display: flex;
    align-items: center;
    gap: 4px;
}

.conv-meta-tag svg {
    width: 12px;
    height: 12px;
}

.conv-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    text-align: center;
    color: var(--gray-400);
}

.conv-list-empty svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.conv-list-empty h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.conv-list-empty p {
    font-size: 13px;
}

.conversations-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    border-top: 1px solid var(--gray-200);
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: white;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 13px;
    color: var(--gray-600);
}

/* Conversation Detail Panel */
.conversation-detail-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.conversation-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--gray-400);
}

.conversation-detail-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.conversation-detail-empty h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.conversation-detail-empty p {
    font-size: 14px;
}

.conversation-detail-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.conversation-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.conversation-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.conversation-info .conversation-meta {
    font-size: 13px;
    color: var(--gray-500);
}

.conversation-actions {
    display: flex;
    gap: 8px;
}

.conversation-stats-bar {
    display: flex;
    gap: 24px;
    padding: 12px 24px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.conv-stat {
    text-align: center;
}

.conv-stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.conv-stat-label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
}

.conv-stat.positive .conv-stat-value {
    color: var(--success);
}

.conv-stat.negative .conv-stat-value {
    color: var(--danger);
}

.conversation-transcript {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--gray-50);
}

.transcript-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    max-width: 85%;
}

.transcript-message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.transcript-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.transcript-message.assistant .transcript-avatar {
    background: var(--primary);
    color: white;
}

.transcript-message.user .transcript-avatar {
    background: var(--gray-200);
    color: var(--gray-600);
}

.transcript-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.transcript-message.user .transcript-bubble {
    background: var(--primary);
    color: white;
}

.transcript-bubble-content {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.transcript-bubble-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--gray-400);
}

.transcript-message.user .transcript-bubble-meta {
    color: rgba(255,255,255,0.7);
}

.transcript-feedback {
    display: flex;
    align-items: center;
    gap: 4px;
}

.transcript-feedback.positive {
    color: var(--success);
}

.transcript-feedback.negative {
    color: var(--danger);
}

.transcript-sources {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}

.transcript-sources-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.transcript-source-item {
    display: block;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transcript-source-item:hover {
    text-decoration: underline;
}

/* Export Modal */
.modal-sm {
    max-width: 400px;
}

.modal-body {
    padding: 20px 24px;
}

.modal-body p {
    margin-bottom: 16px;
    color: var(--gray-600);
}

.export-options {
    display: flex;
    gap: 12px;
}

.export-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--primary-lighter);
}

.export-option svg {
    color: var(--primary);
}

.export-option span {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

/* ===== Proactive Chat Triggers ===== */

/* Triggers Tab Content */
.triggers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.triggers-description {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

.triggers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.triggers-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--gray-500);
    font-size: 13px;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.triggers-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    text-align: center;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 2px dashed var(--gray-200);
}

.triggers-empty svg {
    color: var(--gray-400);
    margin-bottom: 12px;
}

.triggers-empty p {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin: 0 0 4px 0;
}

.triggers-empty span {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

/* Trigger Item Card */
.trigger-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition);
}

.trigger-item:hover {
    border-color: var(--primary-lighter);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.trigger-item.disabled {
    opacity: 0.6;
    background: var(--gray-50);
}

.trigger-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--gray-300);
    border-radius: 11px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.trigger-toggle.active {
    background: var(--success);
}

.trigger-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.trigger-toggle.active::after {
    transform: translateX(18px);
}

.trigger-info {
    flex: 1;
    min-width: 0;
}

.trigger-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.trigger-summary {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trigger-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.trigger-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--gray-500);
    transition: var(--transition);
}

.trigger-action-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.trigger-action-btn.delete:hover {
    background: var(--danger-lighter);
    color: var(--danger);
}

/* Triggers Settings */
.triggers-settings {
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.triggers-settings .form-group {
    margin-bottom: 0;
}

.triggers-settings .form-hint {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}

.triggers-actions {
    display: flex;
    justify-content: flex-start;
}

/* Trigger Editor Modal */
#trigger-editor-modal .modal-form {
    padding: 0 24px 24px;
}

.conditions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 50px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px dashed var(--gray-200);
}

.condition-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.condition-type {
    width: 140px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
}

.condition-operator {
    width: 130px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
}

.condition-value {
    flex: 1;
    min-width: 80px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.condition-unit {
    font-size: 12px;
    color: var(--gray-500);
    min-width: 50px;
}

.remove-condition {
    padding: 4px;
    flex-shrink: 0;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-danger-ghost {
    color: var(--gray-400);
}

.btn-danger-ghost:hover {
    background: var(--danger-lighter);
    color: var(--danger);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-field {
    flex: 1;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-checkbox label {
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
}

/* Trigger Analytics Section */
.trigger-analytics-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}

.trigger-analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.trigger-analytics-header h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.trigger-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.trigger-stat {
    text-align: center;
    padding: 12px 8px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.trigger-stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.trigger-stat-label {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

.trigger-stat.success .trigger-stat-value {
    color: var(--success);
}

.trigger-stat.warning .trigger-stat-value {
    color: var(--warning);
}

/* Trigger Performance Row */
.trigger-perf-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.trigger-perf-row:last-child {
    border-bottom: none;
}

.trigger-perf-name {
    flex: 1;
    font-size: 13px;
    color: var(--gray-700);
}

.trigger-perf-bar {
    width: 100px;
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
}

.trigger-perf-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.trigger-perf-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    min-width: 40px;
    text-align: right;
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Human Handoffs ===== */
.handoffs-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100%;
    min-height: 0;
    background: var(--gray-50);
}

.handoffs-queue-panel {
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
}

.handoffs-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.handoffs-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 12px;
}

.handoffs-filters {
    display: flex;
    gap: 8px;
}

.handoffs-queue-hint {
    margin: 12px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--gray-600);
    max-width: 42rem;
}

.handoffs-stats {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.handoff-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    flex: 1;
}

.handoff-stat .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.handoff-stat .stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.handoff-stat.pending .stat-value {
    color: var(--warning-500, #f59e0b);
}

.handoff-stat.active .stat-value {
    color: var(--success-500, #10b981);
}

.handoffs-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

.handoffs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-400);
}

.handoffs-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.handoffs-empty p {
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.handoffs-empty span {
    font-size: 13px;
}

.handoffs-empty .handoffs-empty-hint {
    display: block;
    margin-top: 16px;
    max-width: 320px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--gray-600);
}

.handoff-item {
    position: relative;
    padding: 14px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 8px;
    border: 1px solid var(--gray-200);
    background: white;
}

.handoff-item:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.handoff-item.selected {
    border-color: #6ee7b7;
    background: linear-gradient(95deg, rgba(240, 253, 244, 0.95) 0%, #fff 100%);
    box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.28);
}

.handoff-item.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 10px 0 0 10px;
    background: linear-gradient(180deg, var(--green-500, #22c55e), var(--green-700, #15803d));
}

.handoff-item.selected .handoff-item-visitor {
    color: var(--gray-900);
}

.handoff-item-header-end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.handoff-item-open-pill {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 6px;
    background: var(--green-600, #16a34a);
    color: #fff;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(22, 101, 52, 0.25);
}

/* New handoff — visible for several minutes (see JS handoffHighlightExpiry); survives queue refresh.
   Blue accent: distinct from green Accept + yellow PENDING; uses :root --blue-* tokens. */
@keyframes handoff-new-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.1);
        border-color: #bfdbfe;
    }
    50% {
        box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.08);
        border-color: var(--blue-500);
    }
}

.handoff-item.handoff-item-new {
    border-left: 4px solid var(--blue-600);
    background: linear-gradient(90deg, var(--blue-50) 0%, #fff 20%);
    animation: handoff-new-pulse 2s ease-in-out infinite;
}

.handoff-item.handoff-item-new:hover {
    border-color: #93c5fd;
    background: linear-gradient(90deg, var(--blue-100) 0%, #fff 22%);
}

/* Open chat: selection wins over “new” styling (JS omits .handoff-item-new when selected). */
.handoff-item.handoff-item-new.selected {
    animation: none;
    border-left-width: 1px;
    background: linear-gradient(95deg, rgba(239, 246, 255, 0.96) 0%, #fff 100%);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.22);
}

.handoff-item-accept-hint {
    font-size: 12px;
    line-height: 1.45;
    color: var(--gray-700);
    background: var(--blue-50);
    border-radius: 8px;
    padding: 8px 10px 8px 12px;
    margin-bottom: 8px;
    border: 1px solid #bfdbfe;
    border-left: 3px solid var(--blue-500);
}

.handoff-item-accept-hint strong {
    font-weight: 700;
}

.handoff-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
    min-width: 0;
}

/* Pending: wait time + optional agent on the left, Accept on the right (inbox-style). */
.handoff-item-meta--pending {
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}

.handoff-item-meta-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.handoff-item-agent {
    font-size: 11px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.handoff-item-accept-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 0 0 auto;
    margin: 0;
    margin-left: auto;
    padding: 6px 11px;
    min-height: 32px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: var(--green-800, #166534);
    background: var(--green-50, #f0fdf4);
    border: 1px solid #bbf7d0;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, color 0.15s ease;
}

.handoff-item-accept-icon {
    flex-shrink: 0;
    color: var(--green-700, #15803d);
    opacity: 1;
}

.handoff-item-accept-btn:hover {
    background: var(--green-100, #dcfce7);
    border-color: var(--green-400, #4ade80);
    box-shadow: var(--shadow-sm);
}

.handoff-item-accept-btn:active {
    transform: scale(0.995);
}

.handoff-item-accept-btn:focus-visible {
    outline: 2px solid var(--green-600, #16a34a);
    outline-offset: 2px;
}

.handoff-item:hover .handoff-item-accept-btn:not(:disabled) {
    border-color: #86efac;
}

.handoff-item.selected .handoff-item-accept-btn:not(:disabled) {
    background: var(--green-100, #dcfce7);
    border-color: var(--green-500, #22c55e);
    color: var(--green-900, #14532d);
}

.handoff-item-accept-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.handoff-item-visitor {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.handoff-item-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
}

.handoff-item-status.pending {
    background: var(--warning-100, #fef3c7);
    color: var(--warning-700, #b45309);
}

.handoff-item-status.active {
    background: var(--success-100, #d1fae5);
    color: var(--success-700, #047857);
}

.handoff-item-status.resolved {
    background: var(--gray-100);
    color: var(--gray-600);
}

.handoff-item-preview {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.handoff-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--gray-500);
}

/* Very narrow queue: full-width Accept so it stays easy to tap. */
@media (max-width: 340px) {
    .handoff-item-meta--pending .handoff-item-accept-btn {
        flex: 1 1 100%;
        margin-left: 0;
        justify-content: center;
        min-height: 36px;
    }
}

/* ===== Handoff Detail Panel (redesigned) ===== */

.handoffs-layout.handoff-session-active .handoffs-queue-panel {
    border-right-color: #a7f3d0;
    box-shadow: inset -1px 0 0 rgba(5, 150, 105, 0.12);
}

.handoff-detail-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    background: var(--gray-50);
    overflow: hidden;
    transition: box-shadow 0.2s ease, background 0.2s ease;
}

.handoff-detail-panel.handoff-session-active {
    background: linear-gradient(180deg, rgba(240, 253, 244, 0.55) 0%, var(--gray-50) 72px);
    box-shadow:
        inset 0 3px 0 0 var(--green-600, #16a34a),
        0 0 0 1px rgba(5, 150, 105, 0.2),
        0 12px 40px -16px rgba(5, 150, 105, 0.12);
}

.handoff-detail-panel.handoff-session-active .hd-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, #fff 100%);
    border-bottom-color: #d1fae5;
}

.handoff-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-400);
    text-align: center;
    gap: 8px;
}

.handoff-detail-empty svg {
    margin-bottom: 8px;
    opacity: 0.35;
}

.handoff-detail-empty p {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-500);
    margin: 0;
}

.handoff-detail-empty span {
    font-size: 13px;
    color: var(--gray-400);
}

.handoff-detail-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Header */
.hd-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.hd-visitor-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.hd-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.hd-visitor-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.hd-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hd-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hd-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.hd-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.hd-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.hd-badge.resolved {
    background: var(--gray-100);
    color: var(--gray-500);
}

.hd-sub-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hd-assign-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 10px 20px;
    border-top: 1px solid var(--gray-200);
    background: #fff;
}

.hd-assign-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}

.hd-assign-select {
    flex: 1;
    min-width: 0;
    max-width: 280px;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    color: var(--gray-800);
}

.hd-email {
    font-size: 12px;
    color: var(--gray-500);
}

.hd-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--gray-500);
}

.hd-chip svg {
    opacity: 0.6;
    flex-shrink: 0;
}

.hd-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.hd-btn-accept,
.hd-btn-resolve {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.hd-btn-accept {
    background: var(--success-500, #10b981);
    color: white;
}

.hd-btn-accept:hover {
    background: var(--success-600, #059669);
    transform: translateY(-1px);
}

.hd-btn-accept:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.hd-btn-resolve {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.hd-btn-resolve:hover {
    background: var(--gray-200);
    transform: translateY(-1px);
}

/* AI Summary */
.hd-summary {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.hd-summary-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}

.hd-summary-toggle:hover {
    background: var(--gray-50);
}

.hd-summary-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
}

.hd-ai-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    letter-spacing: 0.04em;
}

.hd-chevron {
    color: var(--gray-400);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.hd-chevron.open {
    transform: rotate(180deg);
}

.hd-summary-body {
    padding: 0 20px 12px;
    max-height: 160px;
    overflow-y: auto;
}

.hd-summary-body pre {
    font-size: 12px;
    color: var(--gray-600);
    white-space: pre-wrap;
    font-family: inherit;
    margin: 0;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 10px 12px;
    line-height: 1.6;
}

/* Keep old class for JS compat */
.ai-summary-content { }

/* Messages */
.hd-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--gray-50);
}

/* Date separator */
.hd-date-separator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    color: var(--gray-400);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.hd-date-separator::before,
.hd-date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

/* Message bubbles */
.hd-msg {
    display: flex;
    flex-direction: column;
    max-width: 72%;
    gap: 2px;
}

.hd-msg.visitor {
    align-self: flex-start;
}

.hd-msg.agent {
    align-self: flex-end;
}

.hd-msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px;
}

.hd-msg.agent .hd-msg-meta {
    flex-direction: row-reverse;
}

.hd-msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
}

.hd-msg-time {
    font-size: 11px;
    color: var(--gray-400);
}

.hd-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.hd-msg.visitor .hd-msg-bubble {
    background: white;
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.hd-msg.agent .hd-msg-bubble {
    background: var(--primary-500, #6366f1);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(99,102,241,0.25);
}

/* Empty chat state */
.hd-messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 8px;
    color: var(--gray-400);
    font-size: 13px;
    text-align: center;
    padding: 32px;
}

.hd-messages-empty svg {
    opacity: 0.3;
    margin-bottom: 4px;
}

/* Input bar */
.hd-input-bar {
    padding: 12px 16px 14px;
    border-top: 1px solid var(--gray-200);
    background: white;
    flex-shrink: 0;
}

.hd-assign-row:not(.hidden) + .hd-input-bar {
    border-top: none;
}

.hd-input-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hd-input-inner {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: 12px;
    padding: 6px 8px 6px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hd-input-inner:focus-within {
    border-color: var(--primary-400, #818cf8);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
    background: white;
}

.hd-textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px 0;
    color: var(--gray-800);
    font-family: inherit;
}

.hd-textarea::placeholder {
    color: var(--gray-400);
}

.hd-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: var(--primary-500, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin-bottom: 1px;
}

.hd-send-btn:hover {
    background: var(--primary-600, #4f46e5);
    transform: translateY(-1px);
}

.hd-send-btn:active {
    transform: translateY(0);
}

.hd-input-hint {
    font-size: 11px;
    color: var(--gray-400);
    text-align: right;
    margin: 0;
}

/* hd-input-bar hidden state (JS toggles this) */
.hd-input-bar.hidden { display: none; }

/* Menu badge for handoffs */
.menu-badge {
    background: var(--warning-500, #f59e0b);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* ===== Handoff Settings Panel ===== */
.handoff-settings-header {
    margin-bottom: 20px;
}

.handoff-settings-header h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.handoff-settings-header p {
    font-size: 13px;
    color: var(--gray-500);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch {
    background: var(--primary-500);
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-input {
    flex: 1;
    height: 6px;
    appearance: none;
    background: var(--gray-200);
    border-radius: 3px;
    outline: none;
}

.range-input::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-500);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.range-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    min-width: 40px;
}

.form-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 24px 0;
}

.business-hours-schedule {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.schedule-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.day-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 70px;
    cursor: pointer;
}

.day-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-500);
}

.day-toggle span {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.schedule-start,
.schedule-end {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    width: 100px;
}

.schedule-start:focus,
.schedule-end:focus {
    border-color: var(--primary-500);
}

.schedule-start:disabled,
.schedule-end:disabled {
    background: var(--gray-100);
    color: var(--gray-400);
}

.schedule-to {
    font-size: 13px;
    color: var(--gray-500);
}

.form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.form-textarea:focus {
    border-color: var(--primary-500);
}

.form-actions {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* Button success variant */
.btn-success {
    background: linear-gradient(135deg, var(--success-500, #10b981), var(--success-600, #059669));
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--success-600, #059669), var(--success-700, #047857));
}

/* ===== Security Settings ===== */
.security-settings-header {
    margin-bottom: 20px;
}

.security-settings-header h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.security-settings-header p {
    font-size: 13px;
    color: var(--gray-500);
}

.domain-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.domain-input-wrapper {
    display: flex;
    gap: 8px;
}

.domain-input-wrapper .form-input {
    flex: 1;
}

.domain-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
    padding: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.domain-list:empty::before {
    content: 'No domains added';
    color: var(--gray-400);
    font-size: 13px;
}

.domain-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 12px;
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: 16px;
    font-size: 13px;
    color: var(--primary-700);
}

.domain-tag .remove-domain {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: var(--primary-100);
    border-radius: 50%;
    cursor: pointer;
    color: var(--primary-600);
    transition: all 0.2s ease;
}

.domain-tag .remove-domain:hover {
    background: var(--primary-200);
    color: var(--primary-800);
}

.domain-tag .remove-domain svg {
    width: 12px;
    height: 12px;
}

.security-info-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.security-info-section h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.security-info-section > p {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.embed-code-container {
    position: relative;
    margin-bottom: 12px;
}

.embed-code-preview {
    background: var(--gray-900);
    color: var(--gray-100);
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    margin: 0;
}

.copy-embed-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 12px;
}

.copy-embed-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.security-sri-info {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 12px;
}

.sri-label {
    display: block;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 12px;
    margin-bottom: 6px;
}

.security-sri-info code {
    display: block;
    background: var(--white);
    border: 1px solid var(--gray-200);
    padding: 8px 10px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.5;
    word-break: break-all;
    color: var(--gray-700);
    max-height: 80px;
    overflow-y: auto;
}

/* ===== Responsive ===== */
@media (max-width: 1280px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    .analytics-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .analytics-bottom-grid {
        grid-template-columns: 1fr 1fr;
    }
    .recent-conversations-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    .analytics-grid-3 {
        grid-template-columns: 1fr;
    }
    .analytics-bottom-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .conversations-layout {
        grid-template-columns: 1fr;
    }
    
    .conversation-detail-panel {
        display: none;
    }
    
    .conversations-layout.detail-open .conversations-list-panel {
        display: none;
    }
    
    .conversations-layout.detail-open .conversation-detail-panel {
        display: flex;
    }
    
    .handoffs-layout {
        grid-template-columns: 1fr;
    }
    
    .handoff-detail-panel {
        display: none;
    }
    
    .handoffs-layout.detail-open .handoffs-queue-panel {
        display: none;
    }
    
    .handoffs-layout.detail-open .handoff-detail-panel {
        display: flex;
    }
}

/* ===== Mobile Topbar ===== */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    align-items: center;
    padding: 0 10px;
    z-index: 200;
    gap: 4px;
}

.mobile-menu-btn {
    /* sizing handled by .mobile-nav-btn */
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-brand-icon {
    width: 30px;
    height: 30px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    flex-shrink: 0;
}

.mobile-brand span {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    font-family: var(--font-sans);
}

.mobile-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Mobile sidebar overlay backdrop */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

@media (max-width: 768px) {
    /* Sidebar becomes a slide-in overlay */
    .sidebar-toggle {
        display: none;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 220px;
        transition: transform 0.25s ease;
        z-index: 1001;
        box-shadow: none;
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .mobile-topbar {
        display: flex;
    }

    .mobile-sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    body.sidebar-mobile-open .mobile-sidebar-overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .main {
        margin-left: 0;
        padding-top: 56px;
    }

    .page-container {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        gap: 16px;
    }

    .sites-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        width: calc(100% - 32px);
        max-height: calc(100vh - 64px);
    }

    .side-panel {
        width: 100%;
    }

    .panel-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-period-select {
        display: none;
    }

    /* Full-height views must account for the 56px topbar */
    #handoffs-view.view.active {
        height: calc(100dvh - 56px);
    }
}

/* ==================== White-label Settings ==================== */

.section-desc {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 20px;
}


.settings-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 4px 0 8px;
}

.settings-hint {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: -8px;
}

.settings-error {
    font-size: 13px;
    color: var(--danger);
    padding: 10px 12px;
    background: var(--red-50);
    border-radius: var(--radius);
    border: 1px solid var(--red-100);
}

.settings-success {
    font-size: 13px;
    color: var(--success);
    padding: 10px 12px;
    background: var(--green-50);
    border-radius: var(--radius);
    border: 1px solid var(--green-100);
}

/* ===== Help Page ===== */
.help-page {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.help-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #0891b2 100%);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    color: white;
}

.help-hero-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.help-hero-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.help-hero-sub {
    font-size: 14px;
    opacity: 0.82;
}

.help-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-block-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

/* Step cards */
.help-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.help-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.help-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.help-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(13,148,136,0.1); /* fallback */
    background: color-mix(in srgb, var(--hc) 12%, transparent);
    color: var(--hc);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.help-card-step {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
}

.help-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-900);
}

.help-card-desc {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.55;
}

.help-card-desc strong {
    font-weight: 600;
    color: var(--gray-700);
}

.help-card-desc code {
    font-family: var(--font-mono);
    font-size: 11.5px;
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--gray-700);
}

/* Bottom two-column */
.help-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* FAQ */
.help-faq {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.faq-item {
    border-bottom: 1px solid var(--gray-100);
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-q {
    padding: 13px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--gray-800);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    transition: background 0.12s ease;
}

.faq-q:hover {
    background: var(--gray-50);
}

.faq-chevron {
    flex-shrink: 0;
    color: var(--primary);
    transition: transform 0.18s ease;
}

.faq-item[open] .faq-chevron {
    transform: rotate(90deg);
}

.faq-a {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.6;
    padding: 2px 16px 14px 40px;
}

.faq-a strong {
    font-weight: 600;
    color: var(--gray-700);
}

/* Shortcuts */
.help-shortcuts {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
}

.shortcut-row:last-child {
    border-bottom: none;
}

.shortcut-desc {
    font-size: 13.5px;
    color: var(--gray-700);
}

.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kbd-sep {
    font-size: 11px;
    color: var(--gray-400);
    padding: 0 2px;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    padding: 3px 7px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-bottom-width: 2px;
    border-radius: 5px;
    line-height: 1;
}

@media (max-width: 1100px) {
    .help-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .help-cards { grid-template-columns: 1fr; }
    .help-bottom { grid-template-columns: 1fr; }
    .help-hero { flex-direction: column; align-items: flex-start; gap: 14px; padding: 22px 20px; }
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .settings-form .form-row {
        grid-template-columns: 1fr;
    }
}

.settings-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input {
    width: 48px;
    height: 40px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 2px;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-text {
    flex: 1;
}


.whitelabel-preview {
    margin-top: 20px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px dashed var(--gray-300);
}

.whitelabel-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.whitelabel-preview-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.whitelabel-preview-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.whitelabel-preview-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 12px 0;
}

.form-help {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.whitelabel-fields {
    display: none;
}

/* ===== Crawling Tab Styles ===== */

.crawling-settings-header {
    margin-bottom: 24px;
}

.crawling-settings-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 4px 0;
}

.crawling-settings-header p {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

.crawl-status-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary-50) 0%, #e0f2fe 100%);
    border: 1px solid var(--primary-200);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.crawl-status-icon {
    color: var(--primary);
}

.crawl-status-icon .spinner {
    animation: spin 1s linear infinite;
}

.crawl-status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.crawl-status-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-700);
}

.crawl-status-detail {
    font-size: 12px;
    color: var(--primary-600);
}

.crawl-quick-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.crawl-quick-actions .btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.crawl-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.crawl-info-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crawl-info-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.crawl-schedule-options {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.crawl-schedule-options.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.crawl-history-table {
    margin-top: 12px;
    overflow-x: auto;
}

.crawl-history-table .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.crawl-history-table .data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crawl-history-table .data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.crawl-history-table .data-table tr:last-child td {
    border-bottom: none;
}

.crawl-history-table .empty-row td {
    text-align: center;
    color: var(--gray-400);
    padding: 24px;
}

.crawl-trigger-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.crawl-trigger-badge.manual {
    background: var(--blue-100);
    color: var(--blue-700);
}

.crawl-trigger-badge.scheduled {
    background: var(--purple-100);
    color: var(--purple-700);
}

.crawl-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.crawl-status-badge.running {
    background: var(--yellow-100);
    color: var(--yellow-700);
}

.crawl-status-badge.completed {
    background: var(--green-100);
    color: var(--green-700);
}

.crawl-status-badge.failed {
    background: var(--red-100);
    color: var(--red-700);
}

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    background: var(--white);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-section h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.form-section {
    margin-bottom: 24px;
}

/* ==========================================
   Widget Preview Styles
   ========================================== */

.appearance-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto auto;
    gap: 20px;
}

.appearance-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.appearance-preview {
    position: sticky;
    top: 16px;
    height: fit-content;
}

.preview-card {
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.preview-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-device {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.preview-device-screen {
    position: relative;
}

.widget-preview-mini {
    width: 100%;
    background: white;
    font-family: var(--font-sans);
}

.widget-preview-mini .preview-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.widget-preview-mini .preview-header-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-preview-mini .preview-header-icon svg {
    width: 14px;
    height: 14px;
    color: white;
}

.widget-preview-mini .preview-header-text {
    display: flex;
    flex-direction: column;
}

.widget-preview-mini .preview-title {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.widget-preview-mini .preview-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
}

.widget-preview-mini .preview-messages {
    padding: 12px;
    background: #f8f9fa;
    min-height: 80px;
}

.widget-preview-mini .preview-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.widget-preview-mini .preview-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.widget-preview-mini .preview-avatar svg {
    width: 12px;
    height: 12px;
    color: white;
}

.widget-preview-mini .preview-bubble {
    background: white;
    padding: 8px 12px;
    border-radius: 10px;
    border-top-left-radius: 4px;
    font-size: 11px;
    color: var(--gray-700);
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    max-width: 150px;
    word-wrap: break-word;
}

.widget-preview-mini .preview-input {
    padding: 10px;
    background: white;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 6px;
}

.widget-preview-mini .preview-input input {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 10px;
    outline: none;
    background: var(--gray-50);
}

.widget-preview-mini .preview-send {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: background-color 0.2s;
}

.widget-preview-mini .preview-send svg {
    width: 12px;
    height: 12px;
    color: white;
}

.widget-preview-mini .preview-branding {
    padding: 6px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    text-align: center;
}

.widget-preview-mini .preview-branding a {
    font-size: 9px;
    color: var(--gray-400);
    text-decoration: none;
}

.widget-preview-mini .preview-branding.hidden {
    display: none;
}

/* Appearance Embed Section */
.appearance-embed-section {
    grid-column: 1 / -1;
    margin-top: 4px;
}

.embed-card {
    background: linear-gradient(135deg, #f0f7f4 0%, #e8f4ec 100%);
    border: 1px solid var(--primary-200, #86efac);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.embed-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at center, var(--primary-100, #dcfce7) 0%, transparent 70%);
    opacity: 0.5;
    pointer-events: none;
}

.embed-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    position: relative;
}

.embed-card-icon {
    width: 40px;
    height: 40px;
    background: var(--primary, #0d9488);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.2);
}

.embed-card-icon svg {
    color: white;
}

.embed-card-title-wrapper {
    flex: 1;
}

.embed-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0 0 4px 0;
}

.embed-card-desc {
    font-size: 13px;
    color: var(--gray-600);
    margin: 0;
}

.embed-card-desc code {
    background: rgba(13, 148, 136, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--primary, #0d9488);
}

.embed-code-block {
    background: var(--gray-900);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.embed-code-block pre {
    margin: 0;
    padding: 16px;
    padding-right: 100px;
    overflow-x: auto;
    font-size: 11px;
    line-height: 1.5;
}

.embed-code-block code {
    color: #e2e8f0;
    font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.embed-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary, #0d9488);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.embed-copy-btn:hover {
    background: var(--primary-600, #166534);
    transform: translateY(-1px);
}

.embed-copy-btn.copied {
    background: var(--success, #22c55e);
}

.embed-options {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.embed-option-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.embed-option-btn:hover {
    background: white;
    border-color: var(--primary, #0d9488);
    color: var(--primary, #0d9488);
}

@media (max-width: 768px) {
    .appearance-layout {
        grid-template-columns: 1fr;
    }
    
    .appearance-preview {
        order: -1;
        position: relative;
        top: 0;
    }
    
    .appearance-embed-section {
        grid-column: 1;
    }
}

.widget-preview-container {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.preview-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.widget-preview-wrapper {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    min-height: 380px;
}

.widget-preview {
    width: 240px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    font-family: var(--font-sans);
}

.widget-preview-header {
    padding: 14px 16px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.widget-preview-title {
    font-weight: 600;
    font-size: 14px;
}

.widget-preview-controls {
    display: flex;
    gap: 8px;
    opacity: 0.8;
}

.widget-preview-controls span {
    cursor: default;
    font-size: 16px;
}

.widget-preview-body {
    padding: 16px;
    min-height: 120px;
    max-height: 180px;
    overflow-y: auto;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.widget-preview-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.widget-preview-message.bot .preview-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.preview-bubble {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    border-top-left-radius: 4px;
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    max-width: 180px;
    word-wrap: break-word;
}

.widget-preview-input {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.widget-preview-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
    outline: none;
}

.widget-preview-input button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: background-color 0.2s;
}

.widget-preview-fab {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;
}

.widget-preview-fab.left {
    right: auto;
    left: 20px;
}

.widget-preview-branding {
    padding: 6px 12px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 10px;
    color: #999;
}

.widget-preview-branding span {
    opacity: 0.8;
}

.widget-preview-branding.hidden {
    display: none;
}

/* Preview Header Row with Toggle */
.preview-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-header-row .preview-title {
    margin: 0;
}

.preview-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--gray-600);
}

.preview-mode-toggle input[type="checkbox"] {
    position: relative;
    width: 36px;
    height: 20px;
    appearance: none;
    background: var(--gray-300);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.preview-mode-toggle input[type="checkbox"]:checked {
    background: var(--primary);
}

.preview-mode-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.preview-mode-toggle input[type="checkbox"]:checked::before {
    transform: translateX(16px);
}

.toggle-label {
    font-weight: 500;
}

/* Interactive Mode Styles */
.widget-preview.interactive .widget-preview-input input:not(:disabled) {
    background: white;
    cursor: text;
}

.widget-preview.interactive .widget-preview-input button:not(:disabled) {
    cursor: pointer;
}

.widget-preview.interactive .widget-preview-input button:not(:disabled):hover {
    opacity: 0.9;
    transform: scale(1.05);
}

/* User message style */
.widget-preview-message.user {
    flex-direction: row-reverse;
}

.widget-preview-message.user .preview-bubble {
    background: var(--primary, #0d9488);
    color: white;
    border-radius: 12px;
    border-top-right-radius: 4px;
    border-top-left-radius: 12px;
}

.widget-preview-message.user .preview-avatar {
    background: var(--gray-400) !important;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Scrollable messages area */
.widget-preview-body::-webkit-scrollbar {
    width: 4px;
}

.widget-preview-body::-webkit-scrollbar-track {
    background: transparent;
}

.widget-preview-body::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

/* ===== Enhanced UI Improvements ===== */

/* Improved Range Slider */
.range-input::-webkit-slider-thumb {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

.range-input::-webkit-slider-thumb:active {
    transform: scale(1.1);
}

.range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.range-input::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

/* Enhanced Toggle Switch - subtle shadow */
.toggle-switch {
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

/* Hover states for unchecked toggles */
.toggle-label:hover .toggle-switch,
.toggle-row:hover .toggle-switch {
    background: var(--gray-400);
}

/* Checked state - must override hover */
.toggle-label input[type="checkbox"]:checked + .toggle-switch,
.toggle-row input[type="checkbox"]:checked + .toggle-switch {
    background: var(--primary);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08), 0 0 0 2px rgba(13, 148, 136, 0.1);
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch::after,
.toggle-row input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* Hover on checked toggle */
.toggle-label:hover input[type="checkbox"]:checked + .toggle-switch,
.toggle-row:hover input[type="checkbox"]:checked + .toggle-switch {
    background: var(--primary-dark);
}

/* Form Section Styling */
.form-section {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.form-section h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section h5::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
}

/* Enhanced Security Info Section */
.security-info-section {
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 20px;
    position: relative;
    overflow: hidden;
}

.security-info-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
}

.security-info-section h5 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.security-info-section h5::before {
    content: '🔒';
    font-size: 14px;
}

/* Enhanced Embed Code Block */
.embed-code-preview {
    background: linear-gradient(180deg, var(--gray-800) 0%, var(--gray-900) 100%);
    border: 1px solid var(--gray-700);
    position: relative;
}

.embed-code-preview::before {
    content: 'HTML';
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.embed-code-container .embed-code-preview {
    padding-top: 32px;
}

/* Enhanced Copy Button */
.copy-embed-btn {
    transition: var(--transition-fast);
    backdrop-filter: blur(4px);
}

.copy-embed-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.copy-embed-btn:active {
    transform: translateY(0);
}

/* Customize panel tabs (horizontal underline) */
.customize-tab {
    position: relative;
    transition: var(--transition);
}

.customize-tab::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: var(--transition);
    transform: translateX(-50%);
}

.customize-tab:hover::after {
    width: 50%;
}

.customize-tab.active::after {
    width: 100%;
}

/* Form Input Focus States */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Form Textarea Improvements */
.form-textarea {
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Crawl History Status Badges Animation */
.crawl-status-badge.running::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* Button Hover Lift Effect */
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Quick Actions Improvements */
.crawl-quick-actions {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
}

/* Form Hint Improvements */
.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.4;
    margin-top: 4px;
}

/* Toggle Row - For inline toggles with labels */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    padding: 8px 0;
}

.toggle-row input[type="checkbox"] {
    display: none;
}

.toggle-row .toggle-switch {
    flex-shrink: 0;
}

/* Settings Header Improvements */
.security-settings-header,
.crawling-settings-header,
.handoff-settings-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 24px;
}

.security-settings-header h4,
.crawling-settings-header h4,
.handoff-settings-header h4 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.security-settings-header h4::before {
    content: '🛡️';
}

.crawling-settings-header h4::before {
    content: '🔄';
}

.handoff-settings-header h4::before {
    content: '👤';
}

/* Domain Tag Improvements */
.domain-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--primary-lighter);
    border: 1px solid rgba(13, 148, 136, 0.2);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-dark);
    transition: var(--transition-fast);
}

.domain-tag:hover {
    background: rgba(13, 148, 136, 0.15);
}

.domain-tag .remove-domain {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 0;
}

.domain-tag .remove-domain:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Domain List Container */
.domain-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    min-height: 20px;
}

/* Smooth Page Transitions */
.tab-form {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Q&A Training Styles ===== */

/* Q&A Stats Cards */
.qa-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.qa-stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.qa-stat-card.primary {
    background: var(--primary-lighter);
    border-color: rgba(13, 148, 136, 0.2);
}

.qa-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.qa-stat-card.primary .qa-stat-value {
    color: var(--primary);
}

.qa-stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
}

/* Q&A Header Actions */
.qa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.qa-header h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

.qa-actions {
    display: flex;
    gap: 8px;
}

/* Q&A Search */
.qa-search-wrapper {
    margin-bottom: 16px;
}

.qa-search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    transition: var(--transition);
}

.qa-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Q&A List */
.qa-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qa-list-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.qa-list-empty svg {
    margin-bottom: 16px;
    color: var(--gray-300);
}

.qa-list-empty h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.qa-list-empty p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* Q&A Item */
.qa-item {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    transition: var(--transition);
}

.qa-item:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
}

.qa-item.disabled {
    opacity: 0.6;
}

.qa-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.qa-question {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
    line-height: 1.4;
}

.qa-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.qa-item-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
}

.qa-item-btn:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.qa-item-btn.edit:hover {
    color: var(--primary);
}

.qa-item-btn.delete:hover {
    background: var(--red-50);
    color: var(--danger);
}

.qa-answer {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
    margin-bottom: 12px;
    max-height: 60px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.qa-item-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--gray-500);
}

.qa-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qa-meta-item svg {
    width: 14px;
    height: 14px;
}

.qa-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.qa-status-badge.enabled {
    background: var(--green-100);
    color: var(--green-700);
}

.qa-status-badge.disabled {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* Q&A Modal */
.qa-modal-content {
    padding: 24px;
}

.qa-form-group {
    margin-bottom: 20px;
}

.qa-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.qa-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.qa-form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.qa-form-group textarea.question {
    min-height: 80px;
}

.qa-form-group textarea.answer {
    min-height: 150px;
}

.qa-char-count {
    font-size: 11px;
    color: var(--gray-400);
    text-align: right;
    margin-top: 4px;
}

.qa-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* Q&A Pagination */
.qa-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.qa-pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.qa-pagination-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.qa-pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.qa-pagination-info {
    font-size: 13px;
    color: var(--gray-600);
}

/* Create Q&A button in conversations */
.create-qa-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--purple-600);
    background: var(--purple-50);
    border: 1px solid var(--purple-200);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.create-qa-btn:hover {
    background: var(--purple-100);
    border-color: var(--purple-300);
}

.create-qa-btn svg {
    width: 12px;
    height: 12px;
}

/* Q&A badge on messages */
.qa-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--purple-700);
    background: var(--purple-100);
    border-radius: 10px;
}

/* Transcript message with Q&A actions */
.transcript-bubble-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--gray-200);
}

/* Most Used Q&A List */
.qa-most-used {
    margin-top: 16px;
}

.qa-most-used-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.qa-most-used-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.qa-most-used-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-lighter);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.qa-most-used-text {
    flex: 1;
    font-size: 13px;
    color: var(--gray-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qa-most-used-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
}

/* ===== Quick Prompts Management ===== */
.quick-prompts-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 20px;
}

.quick-prompts-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-prompts-header h4::before {
    content: '💬';
}

.quick-prompts-description {
    font-size: 13px;
    color: var(--gray-500);
}

.quick-prompts-content {
    transition: opacity 0.2s ease;
}

.quick-prompts-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.quick-prompts-list-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quick-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
}

.quick-prompts-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--gray-500);
    font-size: 14px;
}

.quick-prompts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--gray-50);
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    text-align: center;
}

.quick-prompts-empty svg {
    color: var(--gray-400);
    margin-bottom: 12px;
}

.quick-prompts-empty p {
    color: var(--gray-500);
    margin-bottom: 16px;
}

.quick-prompts-empty.hidden {
    display: none;
}

.quick-prompt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition-fast);
}

.quick-prompt-item:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
}

.quick-prompt-drag-handle {
    cursor: grab;
    color: var(--gray-400);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-prompt-drag-handle:active {
    cursor: grabbing;
}

.quick-prompt-drag-handle:hover {
    color: var(--gray-600);
}

.quick-prompt-icon-wrapper {
    flex-shrink: 0;
}

.quick-prompt-icon-input {
    width: 44px;
    height: 36px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-align: center;
    font-size: 18px;
    background: var(--gray-50);
    transition: var(--transition-fast);
}

.quick-prompt-icon-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
}

.quick-prompt-text-wrapper {
    flex: 1;
}

.quick-prompt-text-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    transition: var(--transition-fast);
}

.quick-prompt-text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.quick-prompt-text-input::placeholder {
    color: var(--gray-400);
}

.quick-prompt-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-prompt-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.quick-prompt-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.quick-prompt-toggle .toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 10px;
    transition: var(--transition-fast);
}

.quick-prompt-toggle .toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.quick-prompt-toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.quick-prompt-toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.quick-prompt-move-up,
.quick-prompt-move-down,
.quick-prompt-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-500);
    cursor: pointer;
    transition: var(--transition-fast);
}

.quick-prompt-move-up:hover,
.quick-prompt-move-down:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-lighter);
}

.quick-prompt-delete:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--red-50);
}

.quick-prompt-move-up:disabled,
.quick-prompt-move-down:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.quick-prompts-settings {
    padding-top: 16px;
}

/* Toggle Switch Label - for header toggles */
.toggle-switch-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.toggle-switch-label input {
    display: none;
}

.toggle-switch-label .toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    transition: var(--transition-fast);
}

.toggle-switch-label .toggle-switch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle-switch-label input:checked + .toggle-switch {
    background: var(--primary);
}

.toggle-switch-label input:checked + .toggle-switch::before {
    transform: translateX(20px);
}

/* Responsive Quick Prompts */
@media (max-width: 768px) {
    .quick-prompt-item {
        flex-wrap: wrap;
    }
    
    .quick-prompt-text-wrapper {
        flex-basis: 100%;
        order: 1;
        margin-top: 8px;
    }
    
    .quick-prompt-drag-handle {
        order: -1;
    }
}

/* ==================== Lead Management Styles ==================== */

.leads-tab-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.leads-config-section {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--gray-100);
}

.leads-config-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 16px;
}

.lead-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.leads-list-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.leads-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.leads-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.leads-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box-sm {
    width: 200px;
}

.search-box-sm input {
    padding: 6px 10px 6px 32px;
    font-size: 13px;
    height: 32px;
}

.search-box-sm svg {
    left: 10px;
    width: 14px;
    height: 14px;
}

.leads-table-container {
    overflow-x: auto;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
}

.leads-table th,
.leads-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.leads-table th {
    background: var(--gray-50);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.leads-table td {
    font-size: 13px;
    color: var(--gray-700);
}

.leads-table tr:last-child td {
    border-bottom: none;
}

.leads-table tr:hover td {
    background: var(--gray-50);
}

.leads-empty td,
.leads-loading td {
    text-align: center;
    padding: 40px 16px;
    color: var(--gray-500);
}

.leads-loading td {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =========================================================
   Mobile polish (dashboard)
   ========================================================= */
@media (max-width: 900px) {
    .page-container {
        padding: 16px;
    }

    .stats-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .conversations-layout,
    .handoffs-layout {
        grid-template-columns: 1fr;
    }

    .conversations-list-panel,
    .handoffs-queue-panel,
    .conversation-detail-panel,
    .handoff-detail-panel {
        min-height: 0;
        height: auto;
    }

    .detail-settings-layout {
        grid-template-columns: 1fr;
    }

    .detail-settings-nav {
        position: static;
        top: auto;
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 640px) {
    /* Small phones: sidebar becomes a bottom nav bar */
    .sidebar {
        transform: none;
        width: 100%;
        height: 64px;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-right: none;
        border-top: 1px solid var(--gray-200);
        flex-direction: row;
        align-items: center;
        z-index: 300;
        box-shadow: none;
    }

    /* Undo overlay open state on small phones */
    body.sidebar-mobile-open .sidebar {
        transform: none;
        box-shadow: none;
    }

    /* Hide overlay backdrop on small phones */
    .mobile-sidebar-overlay {
        display: none !important;
    }

    /* Hide mobile topbar — bottom nav is the nav chrome */
    .mobile-topbar {
        display: none;
    }

    .sidebar-brand,
    .sidebar-footer {
        display: none;
    }

    .sidebar-menu {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 0 8px;
        gap: 0;
    }

    .menu-item {
        flex: 1;
        height: 48px;
        min-width: 0;
        padding: 0;
        margin: 0 2px;
        border-radius: 10px;
        justify-content: center;
    }

    .menu-item span,
    .menu-badge {
        display: none !important;
    }

    .main {
        margin-left: 0 !important;
        padding-top: 0;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    .master-detail-layout {
        gap: 10px;
    }

    .master-panel {
        max-height: 35vh;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .detail-header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .detail-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .detail-stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .detail-quick-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .table-container,
    .leads-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Reset height override from 768px block — bottom nav, no topbar */
    #handoffs-view.view.active {
        height: 100dvh;
    }
}

.lead-source-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius);
    text-transform: capitalize;
}

.lead-source-badge.chat {
    background: var(--primary-lighter);
    color: var(--primary);
}

.lead-source-badge.handoff {
    background: var(--blue-50);
    color: var(--blue-600);
}

.lead-source-badge.proactive {
    background: var(--purple-50);
    color: var(--purple-600);
}

.leads-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger-ghost {
    color: var(--gray-400);
}

.btn-danger-ghost:hover {
    background: var(--red-50);
    color: var(--danger);
}

.text-muted {
    color: var(--gray-400);
}

/* ===== Conversation Feature Enhancements ===== */

/* Unread dot */
.conv-unread-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

/* Status badges */
.conv-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-open { background: var(--blue-100); color: var(--blue-700); }
.status-resolved { background: var(--green-100); color: var(--green-700); }
.status-closed { background: var(--gray-100); color: var(--gray-600); }

/* Priority badges */
.conv-priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 4px;
}
.priority-high { background: var(--red-100); color: var(--red-700); }
.priority-medium { background: var(--yellow-100); color: var(--yellow-700); }
.priority-low { background: var(--gray-100); color: var(--gray-500); }

/* List badges row */
.conv-list-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 3px 0;
    flex-wrap: wrap;
}
.conv-visitor-name {
    font-size: 11px;
    color: var(--gray-500);
}

/* Detail panel selects */
.conv-status-select, .conv-priority-select {
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
}

/* Visitor / side panels */
.conv-visitor-panel, .conv-notes-panel {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 16px;
}

.conv-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.conv-panel-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.conv-panel-label {
    font-size: 12px;
    color: var(--gray-500);
    min-width: 60px;
}

.conv-visitor-info {
    font-size: 13px;
    margin-bottom: 8px;
}
.visitor-field {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    color: var(--gray-700);
}
.visitor-field a { color: var(--primary); }
.visitor-empty { font-size: 12px; color: var(--gray-400); }

/* Tags */
.conv-tags-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.conv-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.conv-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary-lighter);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}
.tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-dark);
    padding: 0;
    line-height: 1;
    font-size: 14px;
}
.conv-add-tag {
    display: flex;
    align-items: center;
    gap: 4px;
}
.conv-add-tag input {
    width: 100px;
    padding: 2px 6px;
    font-size: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
}
.btn-icon-sm {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Star rating */
.conv-rating-row, .conv-sentiment-row, .conv-context-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
}
.star-rating {
    display: flex;
    gap: 2px;
}
.star {
    font-size: 20px;
    color: var(--gray-300);
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
}
.star:hover, .star.active { color: var(--warning); }
.conv-sentiment-label { font-size: 13px; color: var(--gray-700); }
.conv-page-url {
    font-size: 12px;
    color: var(--primary);
    word-break: break-all;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 200px;
}

/* Notes */
.conv-note-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
}
.conv-note-content {
    font-size: 13px;
    color: var(--gray-800);
    margin-bottom: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}
.conv-note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-400);
}
.conv-note-actions {
    display: flex;
    gap: 8px;
}
.btn-link {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    font-size: 11px;
    padding: 0;
}
.btn-link.danger { color: var(--danger); }

/* First-time admin: block dashboard until password is set */
body.admin-password-gate-active .app {
    filter: blur(2px);
    pointer-events: none;
    user-select: none;
}

#admin-password-gate {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
}

.admin-password-gate-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface, #fff);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
    padding: 28px 28px 24px;
    border: 1px solid var(--gray-200, #e5e7eb);
}

.admin-password-gate-card h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--gray-900, #111827);
}

.admin-password-gate-hint {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--gray-600, #4b5563);
    line-height: 1.45;
}

.admin-password-gate-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700, #374151);
    margin-bottom: 6px;
}

.admin-password-gate-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: var(--radius, 8px);
    font-size: 15px;
    margin-bottom: 14px;
}

.admin-password-gate-input:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.admin-password-gate-error {
    color: var(--danger, #dc2626);
    font-size: 13px;
    margin: 0 0 12px;
}

.admin-password-gate-submit {
    width: 100%;
    margin-top: 4px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius, 8px);
    background: var(--primary, #2563eb);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.admin-password-gate-submit:hover:not(:disabled) {
    filter: brightness(1.05);
}

.admin-password-gate-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Extra mobile-friendly overrides (dashboard) */
@media (max-width: 640px) {
    .page-container { padding: 12px; }
    .page-title { font-size: 22px; line-height: 1.2; }
    .detail-header-actions { grid-template-columns: 1fr !important; }
    .table-container, .leads-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Very small phones */
@media (max-width: 375px) {
    .page-container {
        padding: 10px;
    }

    .page-title {
        font-size: 20px;
    }

    .topbar {
        padding: 10px 12px;
    }

    .site-card,
    .stats-card,
    .card {
        padding: 12px;
    }

    .btn,
    .btn-primary,
    .btn-secondary {
        min-height: 40px;
        padding: 8px 12px;
    }
}

/* Tablet portrait pass */
@media (min-width: 768px) and (max-width: 1024px) {
    .page-container {
        padding: 16px;
    }

    .site-list-grid,
    .stats-grid,
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-header-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-container,
    .leads-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ================================================================
   MOBILE BEAUTIFUL — comprehensive polish for phones
   ================================================================ */

/* ── Mobile topbar: back button + page title ────────────────── */
.mobile-nav-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn:hover,
.mobile-nav-btn:active {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* Override old mobile-menu-btn sizing now it uses mobile-nav-btn */
.mobile-menu-btn {
    width: 40px;
    height: 40px;
    background: transparent;
}

.mobile-back-btn {
    display: none;
}

.mobile-topbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.mobile-topbar-title {
    display: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    font-family: var(--font-sans);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

/* Back-nav mode: hamburger → back arrow, brand → page title */
@media (max-width: 768px) {
    body.mobile-has-back .mobile-menu-btn {
        display: none;
    }
    body.mobile-has-back .mobile-back-btn {
        display: flex;
    }
    body.mobile-has-back .mobile-brand {
        display: none;
    }
    body.mobile-has-back .mobile-topbar-title {
        display: block;
    }
}

/* ── Sites: full-screen master → detail navigation on mobile ── */
@media (max-width: 768px) {
    #sites-view .master-detail-layout {
        flex-direction: column;
        overflow: visible;
    }

    /* Master panel fills the screen */
    #sites-view .master-panel {
        width: 100%;
        max-width: none;
        max-height: none;
        height: auto;
        flex: 1;
        min-height: 0;
        border-right: none;
        border-bottom: none;
        overflow-y: auto;
    }

    /* Detail panel hidden until a site is selected */
    #sites-view .detail-panel {
        display: none;
        flex: 1;
        min-height: 0;
        width: 100%;
    }

    /* When a site is tapped: hide list, show detail full-screen */
    #sites-view .master-detail-layout.mobile-detail-open .master-panel {
        display: none;
    }
    #sites-view .master-detail-layout.mobile-detail-open .detail-panel {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    /* Breadcrumb hidden on mobile (back button handles this) */
    .detail-breadcrumb {
        display: none;
    }
}

/* ── Conversations & Handoffs: extend detail-open to mobile ── */
@media (max-width: 1024px) {
    .conversations-layout.detail-open .conversations-list-panel {
        display: none;
    }
    .conversations-layout.detail-open .conversation-detail-panel {
        display: flex;
    }
    .handoffs-layout.detail-open .handoffs-queue-panel {
        display: none;
    }
    .handoffs-layout.detail-open .handoff-detail-panel {
        display: flex;
    }
}

/* ── Detail settings tabs: horizontal scroll on mobile ──────── */
@media (max-width: 900px) {
    .detail-settings-nav {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        padding: 10px 12px !important;
        gap: 6px !important;
        border-bottom: 1px solid var(--gray-200);
        border-right: none;
    }

    .detail-settings-nav::-webkit-scrollbar {
        display: none;
    }

    .detail-nav-group {
        display: contents;
    }

    .detail-nav-group-label {
        display: none !important;
    }

    .detail-settings-nav .detail-nav-item.detail-tab {
        flex: 0 0 auto;
        min-width: auto;
        white-space: nowrap;
        scroll-snap-align: start;
        border-radius: 20px;
        padding: 8px 16px;
        font-size: 13px;
        text-align: left;
        justify-content: flex-start;
        border: 1px solid var(--gray-200);
        background: var(--white);
        box-shadow: none !important;
        outline: none !important;
    }

    .detail-settings-nav .detail-nav-item.detail-tab.active {
        background: var(--primary);
        color: var(--white);
        border-color: var(--primary);
        outline: none !important;
        box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25) !important;
    }

    .detail-settings-layout {
        flex-direction: column;
    }
}

/* ── Stats row: horizontal scroll on phones ──────────────────── */
@media (max-width: 640px) {
    .stats-row {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        padding-bottom: 4px;
        gap: 10px;
    }

    .stats-row::-webkit-scrollbar { display: none; }

    .stat-card {
        min-width: 150px;
        flex: 0 0 auto;
        scroll-snap-align: start;
    }
}

/* ── Site list items: better touch targets ───────────────────── */
@media (max-width: 768px) {
    .site-list-item {
        padding: 14px 12px;
        gap: 14px;
    }

    .master-header {
        padding: 16px 14px;
    }

    .master-header h2 {
        font-size: 17px;
    }
}

/* ── Detail header: clean stack on mobile ────────────────────── */
@media (max-width: 768px) {
    .detail-header {
        padding: 16px 14px 12px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        border-bottom: 1px solid var(--gray-100);
    }

    .detail-header-info {
        gap: 10px;
    }

    .detail-header-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .detail-header-actions .btn {
        flex: 1;
        justify-content: center;
        min-height: 40px;
    }

    .detail-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px 14px;
    }

    .detail-stat {
        padding: 12px;
    }

    .detail-quick-actions {
        padding: 0 14px 12px;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .detail-action-btn {
        min-height: 44px;
        font-size: 13px;
        gap: 6px;
    }

    .detail-tab-content {
        padding: 0;
    }
}

/* ── Forms: prevent iOS zoom (font-size must be ≥ 16px) ──────── */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    input[type="number"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ── Buttons: proper touch targets ───────────────────────────── */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        padding: 10px 18px;
    }

    .btn-sm {
        min-height: 38px;
        padding: 8px 14px;
    }
}

/* ── Modal: bottom sheet style on mobile ─────────────────────── */
@media (max-width: 640px) {
    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 92dvh;
        margin: 0;
    }

    .modal-header {
        padding: 20px 20px 16px;
    }

    .modal::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--gray-300);
        border-radius: 2px;
        margin: 12px auto -4px;
    }
}

/* ── Bottom nav: active item shows label ─────────────────────── */
@media (max-width: 640px) {
    .sidebar-menu .menu-item {
        flex-direction: column;
        height: 56px;
        gap: 3px;
        border-radius: 10px;
        padding: 6px 4px 4px;
        position: relative;
    }

    .sidebar-menu .menu-item::after {
        content: attr(title);
        font-size: 9px;
        font-weight: 600;
        line-height: 1;
        color: var(--gray-400);
        font-family: var(--font-sans);
        letter-spacing: 0.01em;
        white-space: nowrap;
    }

    .sidebar-menu .menu-item.active::after {
        color: var(--white);
    }

    .sidebar-menu .menu-item svg {
        width: 22px;
        height: 22px;
    }

    /* Bottom nav bar taller to fit labels */
    .sidebar {
        height: 68px;
    }

    /* Adjust main padding to match */
    .main {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }
}

/* ── Page header: compact on mobile ─────────────────────────── */
@media (max-width: 768px) {
    .page-header {
        margin-bottom: 20px;
    }

    .page-title {
        font-size: 22px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn,
    .header-actions select {
        flex: 1;
    }
}

/* ── Cards: better padding & radius on mobile ────────────────── */
@media (max-width: 640px) {
    .stat-card {
        padding: 14px;
        border-radius: var(--radius-lg);
    }

    .stat-value {
        font-size: 26px;
    }

    .card {
        padding: 14px;
    }
}

/* ── Conversations: compact list items ───────────────────────── */
@media (max-width: 768px) {
    .conversations-header,
    .handoffs-queue-header {
        padding: 14px 16px;
    }

    .conv-list-item {
        padding: 12px 14px;
    }
}

/* ── Side panel: full-screen on mobile ───────────────────────── */
@media (max-width: 640px) {
    .side-panel {
        top: 0;
        border-radius: 0;
    }
}

/* ── Handoffs detail: add back button affordance ─────────────── */
@media (max-width: 1024px) {
    .hd-header {
        position: relative;
    }
}

/* ── Analytics page: period buttons compact ──────────────────── */
@media (max-width: 768px) {
    .analytics-period-buttons {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 4px;
    }

    .analytics-period-buttons::-webkit-scrollbar {
        display: none;
    }
}

/* ── Safe area bottom padding for iOS ────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 640px) {
        .sidebar {
            padding-bottom: env(safe-area-inset-bottom, 0px);
            height: calc(68px + env(safe-area-inset-bottom, 0px));
        }

        .main {
            padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        }
    }
}
