/* ═══════════════════════════════════════════════════════════
   PRIQO Design System — CSS Custom Properties
   Converted from theme.ts (architecture §18)
   ═══════════════════════════════════════════════════════════ */

:root {
    /* ── Gradient (outer page bg) ── */
    --gradient-start: #6C3CE1;
    --gradient-mid: #C850C0;
    --gradient-end: #FF6B6B;

    /* ── Container & Cards ── */
    --container-bg: #F4F7FA;
    --card-bg: #FFFFFF;
    --card-dark: #0A0A0A;
    --bg-input: #FFFFFF;
    --bg-card-hover: #F9FAFB;
    --bg-drawer: #FFFFFF;
    --bg-modal: #FFFFFF;

    /* ── Toast backgrounds ── */
    --bg-toast: #1F2937;
    --bg-toast-error: #FEE2E2;
    --bg-toast-success: #DCFCE7;
    --bg-toast-info: #DBEAFE;
    --bg-toast-warning: #FEF3C7;

    /* ── Text ── */
    --text-primary: #101828;
    --text-muted: #6B7280;
    --text-subtle: #9CA3AF;

    /* ── Accents ── */
    --accent-purple: #6C3CE1;
    --accent-pink: #C850C0;
    --accent-red: #FF6B6B;
    --accent-blue: #4158D0;
    --accent-green: #22C55E;

    /* ── Semantic ── */
    --color-critical: #EF4444;
    --color-warning: #F59E0B;
    --color-info: #3B82F6;
    --color-success: #22C55E;

    /* ── Borders ── */
    --border-default: #E5E7EB;
    --border-light: #F3F4F6;
    --border-focus: #6C3CE1;

    /* ── Typography ── */
    --font-heading: 'Outfit', 'DM Sans', system-ui, sans-serif;
    --font-body: 'DM Sans', 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --text-xs: 0.75rem;
    /* 12px */
    --text-sm: 0.875rem;
    /* 14px */
    --text-base: 1rem;
    /* 16px */
    --text-lg: 1.125rem;
    /* 18px */
    --text-xl: 1.25rem;
    /* 20px */
    --text-2xl: 1.5rem;
    /* 24px */
    --text-3xl: 1.875rem;
    /* 30px */
    --text-4xl: 2.25rem;
    /* 36px */

    /* ── Spacing ── */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* ── Border Radius ── */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;
    --radius-pill: 9999px;

    /* ── Shadows ── */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
    --shadow-glow-purple: 0 0 20px rgba(108, 60, 225, 0.3);
    --shadow-container: 0 20px 80px rgba(0, 0, 0, 0.15);

    /* ── Transitions ── */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* ── Z-Index ── */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 300;
    --z-modal: 400;
    --z-toast: 500;

    /* ── Layout ── */
    --sidebar-width: 280px;
    --navbar-height: 60px;
    --container-max-width: 1400px;
    --shell-padding: 6px;
}


/* ═══════════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════════ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background: #F4F7FA;
}


/* ═══════════════════════════════════════════════════════════
   Gradient Background  —  outer wrapper (6px gradient frame)
   ═══════════════════════════════════════════════════════════ */

.gradient-bg {
    min-height: 100vh;
    padding: var(--shell-padding);
    background: linear-gradient(135deg,
            var(--gradient-start) 0%,
            var(--gradient-mid) 50%,
            var(--gradient-end) 100%);
}

/* Auth pages — standalone fixed gradient background */
.gradient-bg-auth {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg,
            var(--gradient-start) 0%,
            var(--gradient-mid) 50%,
            var(--gradient-end) 100%);
}

/* ─── Floating Shell (navbar + content live inside) ─── */

.floating-shell {
    background: var(--container-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-container);
    display: flex;
    flex-direction: column;
    height: calc(100vh - calc(var(--shell-padding) * 2));
    overflow: hidden;
    position: relative;
}


/* ═══════════════════════════════════════════════════════════
   App Container  —  scrollable content area inside shell
   ═══════════════════════════════════════════════════════════ */

.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: 24px 32px 32px;
}


/* ═══════════════════════════════════════════════════════════
   Typography
   ═══════════════════════════════════════════════════════════ */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: var(--text-3xl);
    font-weight: 700;
}

h2 {
    font-size: var(--text-2xl);
}

h3 {
    font-size: var(--text-xl);
}

h4 {
    font-size: var(--text-lg);
}

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

.text-subtle {
    color: var(--text-subtle);
}

code,
pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}


/* ═══════════════════════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════════════════════ */

.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition-base);
}

.empty-state-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 0;
    box-shadow: none;
    border: 1px solid #EAECF0;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-dark {
    background: var(--card-dark);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-dark .text-muted {
    color: rgba(255, 255, 255, 0.6);
}


/* ═══════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background: var(--accent-purple);
    color: #ffffff;
}

.btn-primary:hover {
    background: #5B2FD1;
    box-shadow: var(--shadow-glow-purple);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-purple);
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
    border-radius: var(--radius-md);
}


/* ═══════════════════════════════════════════════════════════
   Pills & Badges
   ═══════════════════════════════════════════════════════════ */

.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 500;
    background: var(--bg-card-hover);
    color: var(--text-muted);
}

.pill-active {
    background: var(--accent-purple);
    color: #ffffff;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.badge-critical {
    background: var(--color-critical);
    color: #ffffff;
}

.badge-warning {
    background: var(--color-warning);
    color: #ffffff;
}

.badge-info {
    background: var(--color-info);
    color: #ffffff;
}

.badge-success {
    background: var(--color-success);
    color: #ffffff;
}


/* ═══════════════════════════════════════════════════════════
   Form Inputs
   ═══════════════════════════════════════════════════════════ */

.input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
    outline: none;
}

.input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.1);
}

.input::placeholder {
    color: var(--text-subtle);
}

.input-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}


/* ═══════════════════════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════════════════════ */

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: var(--space-1);
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.w-full {
    width: 100%;
}

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

/* Status indicators */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot-active {
    background: var(--color-success);
}

.status-dot-warning {
    background: var(--color-warning);
}

.status-dot-error {
    background: var(--color-critical);
}


/* ═══════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════ */

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

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes blink {

    0%,
    80%,
    100% {
        opacity: 0.3;
    }

    40% {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-slow) ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg,
            var(--border-light) 25%,
            var(--bg-card-hover) 50%,
            var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}


/* ═══════════════════════════════════════════════════════════
   TopNavbar  —  matches design-system.html §27 & TopNavbar.tsx
   ═══════════════════════════════════════════════════════════ */

.top-navbar {
    background: #FFFFFF;
    border-bottom: 1px solid #EAECF0;
    flex-shrink: 0;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--navbar-height);
    padding: 0 24px;
}


/* ── Left group ── */

.navbar-left {
    display: flex;
    align-items: center;
    height: 100%;
}


/* ── Logo ── */

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    min-width: 262px;
}




.logo-text {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: #101828;
    letter-spacing: -0.02em;
}


/* ── Vertical divider ── */

.navbar-divider {
    width: 1px;
    height: 28px;
    background: #E5E7EB;
    margin-right: 16px;
    flex-shrink: 0;
}


/* ── Project Switcher ── */

#project-switcher {
    position: relative;
    margin-right: 16px;
}

.project-switcher-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid #E5E7EB;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    width: 210px;
}

.project-switcher-trigger:hover {
    border-color: rgba(108, 60, 225, 0.4);
    background: rgba(108, 60, 225, 0.03);
}

.project-icon-block {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.project-info {
    text-align: left;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.project-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #101828;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-meta {
    display: block;
    font-size: 10px;
    color: #667085;
    line-height: 1.2;
}

.project-chevron {
    margin-left: 4px;
    flex-shrink: 0;
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Project dropdown items */
.project-item {
    gap: 12px !important;
    padding: 10px 12px !important;
}

.project-item-info {
    flex: 1;
    min-width: 0;
}

.project-item-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #101828;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-item-meta {
    display: block;
    font-size: 11px;
    color: #667085;
}

.dropdown-item-active .project-item-name {
    font-weight: 600;
    color: var(--accent-purple);
}

.project-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-purple);
    flex-shrink: 0;
}

.project-new-item {
    gap: 12px !important;
    padding: 10px 12px !important;
}

.project-new-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1.5px dashed #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #667085;
    flex-shrink: 0;
}


/* ── Nav Items (underline-active) ── */

.nav-items {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.nav-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
    color: #475467;
    text-decoration: none;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
}

.nav-item:hover {
    color: #101828;
}

.nav-item-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.nav-item-active {
    color: var(--accent-purple);
    font-weight: 600;
}

/* Active underline bar */
.nav-item-active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--accent-purple);
}


/* ── Right group ── */

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}


/* ── Notification Bell (pill style, matches reference) ── */

.notif-bell-btn {
    position: relative;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #475467;
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-body);
}

.notif-bell-btn:hover {
    border-color: rgba(108, 60, 225, 0.4);
    background: rgba(108, 60, 225, 0.03);
}

.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: var(--accent-purple);
    border-radius: 50%;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FFFFFF;
}


/* ── User Pill ── */

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px 5px 5px;
    background: transparent;
    border: 1px solid #E5E7EB;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.user-pill:hover {
    border-color: rgba(108, 60, 225, 0.4);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-avatar-initials {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
}

.user-email {
    font-size: 13px;
    font-weight: 500;
    color: #475467;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chevron {
    color: #667085;
    flex-shrink: 0;
}


/* ── Shared Dropdown ── */

.dropdown {
    position: relative;
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: #FFFFFF;
    border: 1px solid #EAECF0;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.dropdown-panel.dropdown-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #E5E7EB;
}

.dropdown-title {
    font-size: 14px;
    font-weight: 600;
    color: #101828;
    font-family: var(--font-heading);
}

.dropdown-body {
    padding: 6px;
    max-height: 360px;
    overflow-y: auto;
}

.dropdown-footer {
    padding: 8px;
    border-top: 1px solid #E5E7EB;
}

.dropdown-link-btn {
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-purple);
    cursor: pointer;
    font-family: var(--font-body);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 150ms cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.dropdown-link-btn:hover {
    background: rgba(108, 60, 225, 0.06);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: #475467;
    text-decoration: none;
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    background: none;
    font-family: var(--font-body);
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: #F0F2F6;
    color: #101828;
}

.dropdown-item svg,
.dropdown-item i {
    width: 15px;
    height: 15px;
    color: inherit;
    flex-shrink: 0;
}

.dropdown-item-active {
    background: rgba(108, 60, 225, 0.03);
    border: 1.5px solid rgba(108, 60, 225, 0.19);
}

.dropdown-item-active:hover {
    background: rgba(108, 60, 225, 0.06);
}

.dropdown-item-danger {
    color: #ef4444;
}

.dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}

.dropdown-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 4px 0;
}

.dropdown-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    color: #667085;
    font-size: 14px;
}

.dropdown-empty-icon {
    width: 24px;
    height: 24px;
}


/* ── User Header in Dropdown ── */

.user-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 12px;
    margin-bottom: 4px;
}

.user-header-name {
    font-size: 14px;
    font-weight: 600;
    color: #101828;
    font-family: var(--font-heading);
}

.user-header-email {
    font-size: 11px;
    color: #667085;
    margin-top: 2px;
}


/* ── Notification Items ── */

.notification-item {
    align-items: flex-start;
    gap: 12px;
}

.notification-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-icon svg,
.notification-icon i {
    width: 14px;
    height: 14px;
}

.notification-icon-alert {
    background: rgba(239, 68, 68, 0.07);
    color: var(--color-critical);
}

.notification-icon-anomaly {
    background: rgba(245, 158, 11, 0.07);
    color: var(--color-warning);
}

.notification-icon-system {
    background: rgba(34, 197, 94, 0.07);
    color: var(--color-success);
}

.notification-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.notification-text {
    font-size: 13px;
    font-weight: 600;
    color: #101828;
    font-family: var(--font-heading);
    line-height: 1.4;
}

.notification-time {
    font-size: 11px;
    color: #667085;
    opacity: 0.7;
    margin-top: 4px;
}


/* ── Panel Widths ── */

.project-panel {
    min-width: 280px;
    left: 0;
    right: auto;
}

.notifications-panel {
    min-width: 380px;
    right: 0;
}

.user-panel {
    min-width: 220px;
    right: 0;
}


/* ── Responsive: Compact on small screens ── */

@media (max-width: 768px) {
    .nav-item .nav-item-label {
        display: none;
    }

    .nav-item {
        padding: 0 8px;
    }

    .project-info,
    .user-email {
        display: none;
    }

    .project-switcher-trigger {
        width: auto;
        padding: 6px;
    }

    .user-pill {
        padding: 4px;
        border-radius: 50%;
    }

    .navbar-divider {
        margin: 0 8px;
    }
}


/* ═══════════════════════════════════════════════════════════
   Page Content Shell
   ═══════════════════════════════════════════════════════════ */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto var(--space-2) auto;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: #667085;
}

/* ═══════════════════════════════════════════
   Modal — Create Project  (design-system #67)
   ═══════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: modal-fade-in 0.15s ease-out;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modal-slide-in {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.97);
    }

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

/* ── Card ── */

.modal-card {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-default);
    width: 480px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    scrollbar-width: none;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: modal-slide-in 0.2s ease-out;
    font-family: var(--font-body);
}

.modal-card::-webkit-scrollbar {
    display: none;
}

/* ── Header ── */

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 28px 0;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 30px;
    margin: 0;
}

.modal-subtitle {
    font-size: 13px;
    color: #667085;
    margin: 4px 0 0;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card-hover);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: var(--border-default);
    color: var(--text-primary);
}

/* ── Body ── */

.modal-body {
    padding: 16px 28px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-field {}

.modal-step-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Loading Spinner ── */

.modal-sources-loading {
    padding: 24px 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.modal-sources-loading p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.modal-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border-default);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: modal-spin 0.7s linear infinite;
}

@keyframes modal-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Source Group Headers ── */

.modal-source-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.modal-source-group-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.modal-source-group-name {
    flex: 1;
}

.modal-source-group-count {
    font-size: 13px;
    font-weight: 600;
}

.modal-source-group-chevron {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.modal-source-group-chevron.collapsed {
    transform: rotate(-90deg);
}

/* ── Source Items (stacked name + ID) ── */

.modal-source-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px 12px 36px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.04));
}

.modal-source-item:last-of-type {
    border-bottom: none;
}

.modal-source-item:hover {
    background: rgba(75, 123, 245, 0.04);
}

.modal-source-check {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-default);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    color: transparent;
    transition: all 0.15s;
    margin-top: 2px;
}

.modal-source-check-on {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #fff;
}

.modal-source-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.modal-source-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-source-id {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Sources Footer ── */

.modal-sources-footer {
    padding: 10px 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.06));
}

/* ── Labels (uppercase) ── */

.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475467;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Input ── */

.modal-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid #E5E7EB;
    background: #F0F2F6;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-body);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.modal-input:focus {
    border-color: var(--accent-purple);
    box-shadow: none;
    background: #fff;
}

.modal-input::placeholder {
    color: var(--text-subtle);
}

/* ── Color Swatches (36px filled circles) ── */

.modal-color-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-swatch {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1.5px solid #E5E7EB;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    position: relative;
}

.modal-swatch:hover {
    transform: scale(1.08);
}

.modal-swatch-active {
    border: 2.5px solid var(--accent-purple);
}

.modal-swatch-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: block;
    pointer-events: none;
}

/* ── Data Sources Panel ── */

.modal-sources-panel {
    background: var(--bg-card-hover);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    overflow: hidden;
}

.modal-sources-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}

.modal-search-wrap {
    position: relative;
}

.modal-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.modal-search-input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-card-hover);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-body);
    outline: none;
    box-sizing: border-box;
}

.modal-search-input:focus {
    border-color: var(--border-focus);
}

.modal-search-input::placeholder {
    color: var(--text-subtle);
}

/* ── Source Filter Tabs ── */

.modal-source-tabs {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}

.modal-tab {
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s;
}

.modal-tab:hover {
    background: rgba(108, 60, 225, 0.04);
}

.modal-tab-active {
    border: 1.5px solid var(--accent-purple);
    background: rgba(108, 60, 225, 0.06);
    color: var(--accent-purple);
    font-weight: 600;
}

.modal-tab-count {
    font-size: 10px;
    opacity: 0.6;
}

/* ── Source List ── */

.modal-sources-list {
    max-height: 200px;
    overflow-y: auto;
}

.modal-sources-empty {
    padding: 20px 14px;
    text-align: center;
}

.modal-sources-empty p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.modal-sources-empty-hint {
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 4px !important;
}

/* Source group header */
.modal-source-group-header {
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.modal-source-group-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.modal-source-group-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-source-group-count {
    font-size: 11px;
    font-weight: 600;
}

/* Source item row */
.modal-source-item {
    padding: 6px 14px 6px 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.1s;
}

.modal-source-item:hover {
    background: rgba(108, 60, 225, 0.03);
}

.modal-source-check {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--border-default);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    transition: all 0.15s;
}

.modal-source-check-on {
    border-color: var(--accent-purple);
    background: rgba(108, 60, 225, 0.08);
    color: var(--accent-purple);
}

.modal-source-name {
    font-size: 13px;
    color: var(--text-primary);
}

.modal-source-id {
    font-size: 10px;
    color: var(--text-muted);
}

/* ── Connector Directory (Step 2) ── */

.connector-directory {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 520px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.connector-directory::-webkit-scrollbar {
    display: none;
}

/* Category */
.connector-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.connector-category-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #667085);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.connector-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
}

.connector-badge-oauth {
    color: var(--accent-purple, #4158D0);
    background: rgba(65, 88, 208, 0.08);
}

.connector-badge-apikey {
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.08);
}

.connector-badge-oauth-social {
    color: #6C3CE1;
    background: rgba(108, 60, 225, 0.08);
}

.connector-badge-soon {
    color: #98A2B3;
    background: rgba(152, 162, 179, 0.1);
}

.connector-badge-apikey-warehouse {
    color: #22C55E;
    background: rgba(34, 197, 94, 0.08);
}

/* Service list */
.connector-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Service row */
.connector-row {
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.connector-row.connector-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.connector-coming-soon {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #8B8FA3);
    background: var(--bg-inset, #E8EAF0);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.connector-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #F0F2F6;
    border: 1px solid #EAECF0;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

/* Hover only on the Connect button, not the full row */

.connector-row.expanded .connector-row-main {
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid var(--border-subtle, #e4e7ec);
}

/* Icon box */
.connector-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle, #eaecf0);
}

/* Service name */
.connector-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Connect / Add Key buttons */
.connector-btn {
    padding: 6px 16px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body);
    white-space: nowrap;
}

.connector-btn-connect {
    border: 1px solid #e5e7eb;
    color: #374151;
    background: transparent;
    transition: all 0.15s;
}

.connector-btn-connect:hover {
    border-color: var(--accent-purple, #4158D0);
    background: rgba(65, 88, 208, 0.03);
    color: var(--accent-purple, #4158D0);
}

.connector-btn-addkey {
    border: 1px solid #e5e7eb;
    color: #374151;
    background: transparent;
}

.connector-btn-addkey:hover {
    background: #e5e7eb;
}

/* Cancel state (when expanded) */
.connector-btn-cancel {
    border: 1px solid var(--accent-purple, #4158D0) !important;
    color: var(--accent-purple, #4158D0) !important;
    background: rgba(65, 88, 208, 0.03) !important;
}

.connector-btn-cancel:hover {
    background: rgba(65, 88, 208, 0.08) !important;
}

/* Connected state */
.connector-connected {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #22C55E;
    white-space: nowrap;
    cursor: pointer;
}

.connector-row.connected .connector-row-main {
    background: rgba(34, 197, 94, 0.04);
    border-color: rgba(34, 197, 94, 0.15);
    cursor: pointer;
}

/* Expandable area — OAuth accounts */
.connector-expand {
    background: var(--bg-input, #f0f2f6);
    border: 1px solid var(--border-card, #eaecf0);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 10px 14px 12px;
}

.connector-row.expanded .connector-row-main {
    border-bottom: none;
}

.connector-search-wrap {
    position: relative;
    margin-bottom: 8px;
}

.connector-search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.connector-search {
    width: 100%;
    padding: 7px 10px 7px 32px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-default, #d0d5dd);
    background: #fff;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-body);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.connector-search:focus {
    border-color: var(--accent-purple, #4158D0);
}

/* Account list */
.connector-account-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.connector-account-list::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Account row (custom checkbox) */
.connector-account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-body);
}

.connector-account:hover {
    background: rgba(0, 0, 0, 0.03);
}

.connector-account input[type="checkbox"] {
    display: none;
}

.connector-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--border-default, #d0d5dd);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.connector-account input[type="checkbox"]:checked~.connector-check {
    border-color: var(--accent-purple, #4158D0);
    background: var(--accent-purple, #4158D0);
    border-width: 2px;
}

.connector-account input[type="checkbox"]:checked~.connector-check::after {
    content: '';
    display: block;
    width: 8px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

.connector-account-info {
    flex: 1;
    min-width: 0;
}

.connector-account-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.connector-account-id {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Expand footer */
.connector-expand-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle, #e4e7ec);
}

.connector-account-count {
    font-size: 11px;
    color: var(--text-muted);
}

.connector-btn-confirm {
    padding: 5px 14px;
    border-radius: 9999px;
    border: none;
    background: var(--bg-elevated, #F0F2F6);
    color: var(--text-muted, #667085);
    font-size: 12px;
    font-weight: 600;
    cursor: default;
    font-family: var(--font-body);
    transition: all 0.15s;
    opacity: 0.5;
}

.connector-btn-confirm.active {
    background: var(--accent-purple, #4158D0);
    color: #fff;
    cursor: pointer;
    opacity: 1;
}

.connector-btn-confirm.active:hover {
    filter: brightness(1.1);
}

/* MCC / MCA Group Headers */
.connector-mcc-header {
    padding: 10px 16px 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-top: 1px solid var(--border-subtle, #e4e7ec);
    margin-top: 4px;
}

.connector-mcc-header .connector-check {
    margin: 0;
}

.connector-mcc-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.connector-mcc-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card-hover, #f5f6f8);
}

.connector-mcc-icon--ads {
    background: #e8f0fe;
}

.connector-mcc-icon--merchant {
    background: #e6f4ea;
}

.connector-mcc-icon--ga4 {
    background: #fef3e0;
}

.connector-mcc-info {
    flex: 1;
    min-width: 0;
}

.connector-mcc-name {
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.connector-mcc-subtitle {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.7;
}

.connector-mcc-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.15s;
    flex-shrink: 0;
}

.connector-mcc-header.collapsed .connector-mcc-chevron {
    transform: rotate(-90deg);
}

.connector-mcc-children {
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.connector-mcc-children.collapsed {
    max-height: 0 !important;
    overflow: hidden;
}

.connector-mcc-children .connector-account {
    padding-left: 40px;
}

/* Connector type badges (360 / MCC / MCA) */

/* ── Linked Google Accounts display ── */
.connector-linked-accounts {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-light, #e5e5e5);
}

.connector-linked-pill {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #F0F1F6;
    color: var(--text-muted, #667085);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.connector-linked-pill:hover {
    background: #E0E2EB;
}

.connector-linked-pill--active {
    background: var(--accent, #7C5CFC);
    color: #fff;
}

.connector-linked-pill--active:hover {
    background: var(--accent-dark, #6A4CE0);
}

/* ── Add Another Google Account link ── */
.connector-add-account {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--accent-purple);
    cursor: pointer;
    border-top: 1px solid var(--border-light, #e5e5e5);
    transition: background 0.15s;
}

.connector-add-account:hover {
    background: rgba(124, 92, 252, 0.06);
}

.connector-add-account svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.connector-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 9999px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 16px;
    flex-shrink: 0;
    white-space: nowrap;
}

.connector-type-badge--360 {
    color: #E37400;
    background: rgba(227, 116, 0, 0.07);
    border: 1px solid rgba(227, 116, 0, 0.145);
}

.connector-type-badge--mcc {
    color: #4285F4;
    background: rgba(66, 133, 244, 0.07);
    border: 1px solid rgba(66, 133, 244, 0.145);
}

.connector-type-badge--mca {
    color: #34A853;
    background: rgba(52, 168, 83, 0.07);
    border: 1px solid rgba(52, 168, 83, 0.145);
}

.connector-type-badge--account {
    color: var(--text-muted, #667085);
    background: #F0F1F6;
    border: none;
}

/* Step 3 confirm source icon */
.modal-confirm-source-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.03);
}

.modal-confirm-source-icon svg {
    width: 16px;
    height: 16px;
}

/* Account list scroll */
.connector-account-list {
    max-height: 260px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
}

/* Expandable — API Key */
.connector-expand-apikey {
    padding: 12px 14px 14px;
}

.connector-key-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: block;
}

.connector-key-input {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-default, #d0d5dd);
    background: #fff;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-body);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.connector-key-input:focus {
    border-color: var(--accent-purple, #4158D0);
}

.connector-key-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.connector-btn-verify {
    padding: 6px 20px;
    border-radius: 9999px;
    border: none;
    background: #22C55E;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: opacity 0.15s;
}

.connector-btn-verify:hover {
    opacity: 0.9;
}

.connector-key-help {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #3B82F6;
    text-decoration: none;
    transition: color 0.15s;
}

.connector-key-help:hover {
    color: #2563EB;
}





/* ── Footer ── */

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 16px 28px 24px;
    border-top: none;
}

.modal-btn-cancel {
    padding: 10px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.modal-btn-cancel:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-btn-create {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 28px;
    border-radius: 9999px;
    border: none;
    background: linear-gradient(135deg, var(--accent-purple, #6C3CE1), #C850C0);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(108, 60, 225, 0.3);
    transition: opacity 0.15s;
}

/* Back button */
.modal-btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 9999px;
    border: 1px solid #e5e7eb;
    background: transparent;
    color: #475467;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s;
}

.modal-btn-back:hover {
    background: #f9fafb;
}

.modal-btn-create:hover {
    opacity: 0.92;
}

.modal-btn-create:disabled,
.modal-btn-create.modal-btn-disabled {
    background: #F0F2F6;
    background-image: none;
    color: #667085;
    opacity: 0.7;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
}

/* Skip button */
.modal-btn-skip {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-body);
    padding: 8px 4px;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s;
}

.modal-btn-skip:hover {
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════
   3-Step Wizard — Stepper
   ═══════════════════════════════════════════ */

.modal-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 24px 28px 8px;
}

.modal-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 60px;
}

.modal-step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-body);
    border: 1.5px solid var(--border-default);
    color: var(--text-muted);
    background: transparent;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.modal-step-dot-active {
    border-color: var(--accent-purple);
    background: var(--accent-purple);
    color: #fff;
    box-shadow: 0 0 16px rgba(108, 60, 225, 0.31), 0 0 40px rgba(108, 60, 225, 0.12);
}

.modal-step-dot-done {
    border-color: #22C55E;
    background: #22C55E;
    color: #fff;
    font-size: 13px;
}

.modal-step-dot-inactive {
    border-color: var(--border-default);
    color: var(--text-subtle, #B0B7C3);
    background: #F0F2F6;
}

.modal-step-label {
    font-size: 11px;
    font-weight: 500;
    color: #667085;
    font-family: var(--font-body);
    transition: color 0.2s;
}

.modal-step-label-active {
    color: var(--accent-purple, #6C3CE1);
    font-weight: 600;
}

.modal-step-label-done {
    color: #22C55E;
    font-weight: 600;
}

.modal-step-line {
    flex: 1;
    height: 2px;
    background: var(--border-default);
    margin: 0 8px;
    margin-bottom: 22px;
    border-radius: 1px;
    transition: background 0.3s;
    max-width: 100px;
}

.modal-step-line-done {
    background: #22C55E;
}


/* ═══════════════════════════════════════════
   Step 1 — Icon Grid
   ═══════════════════════════════════════════ */

.modal-icon-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.modal-icon-btn {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
}

.modal-icon-btn svg,
.modal-icon-btn i {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color 0.15s;
}

.modal-icon-btn:hover {
    border-color: var(--border-default);
    background: rgba(0, 0, 0, 0.02);
}

.modal-icon-btn-active {
    border-color: var(--accent-purple);
    background: rgba(108, 60, 225, 0.06);
}

.modal-icon-btn-active svg,
.modal-icon-btn-active i {
    color: var(--accent-purple);
}


/* ═══════════════════════════════════════════
   Step 1 — Live Preview
   ═══════════════════════════════════════════ */

.modal-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #F0F2F6;
    border: 1px solid #EAECF0;
    border-radius: var(--radius-md);
    margin-top: 4px;
    position: relative;
}

.modal-preview-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-preview-info {
    flex: 1;
    min-width: 0;
}

.modal-preview-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-preview-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.modal-preview-badge {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    background: transparent;
    padding: 0;
    border-radius: 0;
}


/* ═══════════════════════════════════════════
   Step 1 — Name Counter & Error
   ═══════════════════════════════════════════ */

.modal-name-counter {
    font-size: 11px;
    font-weight: 500;
    color: #667085;
    font-family: 'JetBrains Mono', monospace;
    transition: color 0.2s;
}

.modal-name-error {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #EF4444;
    margin-top: 6px;
}

.modal-name-error i,
.modal-name-error svg {
    flex-shrink: 0;
    color: #EF4444;
}


/* ═══════════════════════════════════════════
   Step 1 — Color Swatch Check
   ═══════════════════════════════════════════ */

.modal-swatch-check {
    display: none;
    font-size: 11px;
    color: #fff;
    font-weight: 700;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.modal-swatch-active .modal-swatch-check {
    display: block;
}


/* ═══════════════════════════════════════════
   Step 3 — Confirm Card
   ═══════════════════════════════════════════ */

.modal-confirm-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: hidden;
}

.modal-confirm-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
}

.modal-confirm-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-confirm-info {
    flex: 1;
    min-width: 0;
}

.modal-confirm-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

.modal-confirm-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.modal-confirm-divider {
    height: 1px;
    background: var(--border-default);
}

.modal-confirm-sources-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 14px 20px 8px;
}

.modal-confirm-source {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.04));
}

.modal-confirm-source:last-of-type {
    border-bottom: none;
}

.modal-confirm-source-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.modal-confirm-source-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-confirm-source-id {
    font-size: 11px;
    color: var(--text-muted);
}

.modal-confirm-source-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.modal-confirm-empty {
    padding: 20px;
    text-align: center;
}

.modal-confirm-empty-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.modal-confirm-empty-hint {
    font-size: 12px;
    color: var(--text-subtle, #94A3B8);
    margin-top: 4px;
}


/* ═══════════════════════════════════════════
   Step 3 — AI Info Block
   ═══════════════════════════════════════════ */

.modal-ai-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    background: rgba(108, 60, 225, 0.04);
    border: 1px solid rgba(108, 60, 225, 0.12);
    border-radius: var(--radius-md);
}

.modal-ai-info-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-purple);
    font-family: var(--font-heading);
    margin-bottom: 4px;
}

.modal-ai-info-text {
    font-size: 12px;
    color: var(--text-secondary, #475467);
    line-height: 1.5;
}


/* ═══════════════════════════════════════════════════════════
   Settings Page
   ═══════════════════════════════════════════════════════════ */

/* ── Tab Bar (underline style) ── */

.settings-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: var(--space-6);
}

.settings-tab,
.settings-tab:hover,
.settings-tab:visited,
.settings-tab:active {
    text-decoration: none !important;
}

.settings-tab {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-secondary);
    border: 1.5px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.settings-tab:hover {
    color: var(--text-primary);
    background: var(--surface-tertiary);
}

.settings-tab-active {
    color: var(--text-primary);
    font-weight: 600;
    background: var(--bg-primary);
    border-color: var(--text-secondary);
}

/* ── Tab Panels ── */

.settings-panel {
    display: none;
}

.settings-panel-active {
    display: block;
    animation: fadeIn var(--transition-slow) ease-out;
}

/* ── Section Cards ── */

.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    padding: var(--space-6);
    margin-bottom: var(--space-4);
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-header {
    margin-bottom: var(--space-5);
}

.settings-section-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
    margin: 0;
}

.settings-section-subtitle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Field Row ── */

.settings-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.settings-field-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-field-row:first-child {
    padding-top: 0;
}

.settings-field-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.settings-field-sublabel {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 1px;
}

/* ── Toggle Switch ── */

.settings-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: var(--radius-pill);
    border: none;
    background: #D1D5DB;
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.settings-toggle.active {
    background: var(--accent-purple);
}

.settings-toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-pill);
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: left var(--transition-fast);
}

.settings-toggle.active .settings-toggle-knob {
    left: 23px;
}

/* ── Input fields for settings ── */

.settings-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.settings-input-group label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.settings-input-group .input {
    background: var(--bg-card-hover);
}

/* ── Text Link ── */

.settings-link {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--accent-purple);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
}

.settings-link:hover {
    text-decoration: underline;
}

/* ── Danger Zone ── */

.settings-danger {
    border-color: rgba(239, 68, 68, 0.2);
}

.settings-danger .settings-section-title {
    color: var(--color-critical);
}

.btn-danger {
    background: transparent;
    color: var(--color-critical);
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: var(--text-sm);
    font-weight: 500;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    transition: all var(--transition-fast);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.06);
    border-color: var(--color-critical);
}

/* ═══════════════════════════════════════════
   Settings — Projects Tab
   ═══════════════════════════════════════════ */

.settings-projects-layout {
    display: flex;
    gap: var(--space-4);
    align-items: flex-start;
}

/* ── Sidebar ── */

.settings-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    padding: var(--space-4);
}

.settings-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.settings-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.settings-sidebar-add {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    font-size: 16px;
}

.settings-sidebar-add:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: rgba(108, 60, 225, 0.04);
}

/* ── Project List Items ── */

.settings-project-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.settings-project-item:hover {
    background: var(--bg-card-hover);
}

.settings-project-item-active {
    background: rgba(108, 60, 225, 0.04);
    border-color: rgba(108, 60, 225, 0.15);
}

.settings-project-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.settings-project-info {
    flex: 1;
    min-width: 0;
}

.settings-project-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-project-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.settings-project-dots {
    display: flex;
    gap: 3px;
}

.settings-project-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.settings-project-source-count {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Detail Panel ── */

.settings-detail-panel {
    flex: 1;
    min-width: 0;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    padding: var(--space-6);
}

.settings-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-5);
}

.settings-detail-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.settings-detail-info {
    flex: 1;
    min-width: 0;
}

.settings-detail-name {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
    margin: 0;
}

.settings-detail-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.settings-project-id-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--surface-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.settings-project-id-pill:hover {
    background: var(--surface-tertiary);
}

.btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--card-bg);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-body);
    transition: all var(--transition-fast);
}

.btn-edit:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* ── Data Sources Section ── */

.settings-sources-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.settings-sources-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.settings-source-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.settings-source-row:last-of-type {
    border-bottom: none;
}

.settings-source-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-source-info {
    flex: 1;
    min-width: 0;
}

.settings-source-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.settings-source-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 1px;
}

.settings-source-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-success);
    margin-right: 4px;
}

.settings-source-delete {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    transition: all var(--transition-fast);
}

.settings-source-delete:hover {
    color: var(--color-critical);
    background: rgba(239, 68, 68, 0.06);
}

/* ── Delete Project Bar ── */

.settings-delete-project {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    margin-top: var(--space-5);
    background: rgba(239, 68, 68, 0.03);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-md);
}

.settings-delete-project-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-critical);
}

.settings-delete-project-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ═══════════════════════════════════════════
   Confirm Modal — overrides
   ═══════════════════════════════════════════ */

.confirm-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #EF4444, #F97066);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    box-shadow: 0 6px 24px rgba(239, 68, 68, 0.25);
}

.confirm-btn-delete {
    background: linear-gradient(135deg, #EF4444, #DC2626) !important;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3) !important;
}

.confirm-btn-delete:hover {
    background: linear-gradient(135deg, #DC2626, #B91C1C) !important;
}

/* ═══════════════════════════════════════════
   Settings — Select / Radio controls
   ═══════════════════════════════════════════ */

.settings-select {
    padding: var(--space-2) var(--space-3);
    padding-right: var(--space-8);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition-fast);
}

.settings-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.1);
}

.settings-radio-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.settings-radio-option {
    padding: 6px 16px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-default);
    cursor: pointer;
    font-family: var(--font-body);
    transition: all var(--transition-fast);
}

.settings-radio-option:last-child {
    border-right: none;
}

.settings-radio-option:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.settings-radio-option-active {
    background: var(--accent-purple);
    color: #fff;
}

.settings-radio-option-active:hover {
    background: #5B2FD1;
    color: #fff;
}

/* ── Slider ── */

.settings-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 4px;
    border-radius: 2px;
    background: #E5E7EB;
    outline: none;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(108, 60, 225, 0.3);
}

.settings-slider-value {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    min-width: 32px;
}


/* ═══════════════════════════════════════════════════════════
   Chat Page — Layout
   ═══════════════════════════════════════════════════════════ */

.chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    position: relative;
}

/* When chat is active, prevent parent from scrolling */
.app-container:has(.chat-layout) {
    overflow: hidden;
}

.main-content:has(.chat-layout) {
    min-height: 0;
    padding: 0;
}

/* ─── Sidebar ─── */

.chat-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    overflow-y: auto;
    flex-shrink: 0;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.chat-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
}

.chat-sidebar.collapsed>* {
    opacity: 0;
    pointer-events: none;
}

/* Sidebar collapse button (inside footer) */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-left: auto;
}

.sidebar-collapse-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

/* Sidebar reopen button (floating, visible when collapsed) */
.sidebar-open-btn {
    position: absolute;
    top: 12px;
    left: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.sidebar-open-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.chat-new-btn-wrap {
    padding: 20px 16px 12px;
}

.chat-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-pill);
    border: none;
    background: linear-gradient(135deg, #6C3CE1, #C850C0);
    color: #fff;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 21px;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px rgba(108, 60, 225, 0.3);
}

.chat-new-btn:hover {
    box-shadow: 0 6px 24px rgba(108, 60, 225, 0.4);
    transform: translateY(-1px);
}

.chat-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px 9px 36px;
    margin: 8px 12px 12px;
    background: #F4F7FA;
    border: 1.5px solid #E2E5EA;
    border-radius: var(--radius-md);
    position: relative;
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-search-wrap:focus-within {
    background: #fff;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.1);
}

.chat-search-wrap>i,
.chat-search-wrap>svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.chat-search {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-primary);
}

.chat-search::placeholder {
    color: var(--text-subtle);
}

/* Session groups */

.chat-session-groups {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: none;
}

.chat-session-groups::-webkit-scrollbar {
    display: none;
}

.chat-session-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-session-group-label {
    padding: 14px 8px 6px;
    font-size: 10px;
    font-weight: 600;
    color: #667085;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: var(--font-body);
}

.chat-session-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
    width: 100%;
    position: relative;
    overflow: hidden;
    font-family: var(--font-body);
}

/* Gradient overlay on hover */
.chat-session-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(108, 60, 225, 0.06), rgba(236, 72, 153, 0.04));
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
    border-radius: inherit;
}

.chat-session-item:hover::before {
    opacity: 1;
}

.chat-session-item:hover {
    background: #F4F5F9;
}

.chat-session-item.active {
    background: rgba(108, 60, 225, 0.06);
    border-color: rgba(108, 60, 225, 0.18);
    border-left: 2px solid var(--accent-purple);
}

.chat-session-item.active .chat-session-title {
    color: var(--accent-purple);
    font-weight: 600;
}

.chat-session-item.active::before {
    opacity: 1;
}

/* Background processing states — override .active */
.chat-session-item.bg-processing {
    border-color: rgba(139, 92, 246, 0.45) !important;
    box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.45);
}
.chat-session-item.bg-processing .chat-session-snippet {
    color: var(--accent-purple) !important;
    font-style: italic;
}
.chat-session-item.bg-ready {
    border-color: rgba(245, 158, 11, 0.45) !important;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.45);
}
.chat-session-item.bg-ready .chat-session-snippet {
    color: var(--text-subtle) !important;
    font-style: italic;
    font-weight: 400;
}

/* Session header row — title + timestamp side by side */
.chat-session-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.chat-session-title {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: #101828;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.chat-session-time-wrap {
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.chat-session-time {
    font-size: 11px;
    color: #667085;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.chat-session-snippet {
    font-family: var(--font-body);
    font-size: 12px;
    color: #667085;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    z-index: 1;
}

.chat-session-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #667085;
    position: relative;
    z-index: 1;
    margin-top: 2px;
}

.chat-session-source {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-purple);
    font-weight: 500;
    font-size: 10px;
    background: rgba(108, 60, 225, 0.06);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    align-self: flex-start;
    margin-top: 2px;
}

/* Delete button — revealed on hover */
/* Time label hides on hover, delete icon appears */
.chat-session-item:hover .chat-session-time {
    opacity: 0;
    pointer-events: none;
}

.chat-session-delete {
    position: absolute;
    right: 0;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #667085;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
    pointer-events: none;
    z-index: 5;
}

.chat-session-item:hover .chat-session-delete {
    opacity: 1;
    pointer-events: auto;
}

.chat-session-delete:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

/* ─── Sidebar Empty State ─── */

.chat-session-groups {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-session-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 24px 16px;
    gap: 10px;
}

.chat-empty-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(108, 60, 225, 0.08), rgba(216, 82, 204, 0.08));
    border: 1px solid rgba(108, 60, 225, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
    margin-bottom: 4px;
}

.chat-empty-title {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.chat-empty-hint {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-subtle);
    line-height: 1.4;
    max-width: 160px;
}

/* Sidebar footer */
.chat-sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: var(--text-xs);
    color: var(--text-subtle);
    font-family: var(--font-body);
}

.chat-sidebar-footer .sidebar-collapse-btn {
    position: absolute;
    right: 8px;
}

/* ─── Main Chat Area ─── */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--container-bg);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

.chat-messages-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    width: 100%;
}

/* ─── Message Rows ─── */

/* ─── Welcome State ─── */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 24px;
    gap: 32px;
    animation: chat-welcome-in 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hero section */
.chat-welcome-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.chat-welcome-glow {
    display: none;
}

.chat-welcome-icon-wrap {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: welcome-logo-spin 15s linear infinite;
}

.chat-welcome-icon-wrap img {
    width: 48px;
    height: 48px;
}

@keyframes welcome-logo-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.chat-welcome-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-welcome-subtitle {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-muted);
    max-width: 420px;
    text-align: center;
    line-height: 1.5;
}

/* 2×2 Suggestion Grid */
.chat-welcome-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    max-width: 580px;
    width: 100%;
}

.chat-welcome-card {
    all: unset;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 22px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(108, 60, 225, 0.08);
    opacity: 0;
    animation: welcome-card-in 0.4s ease forwards;
    background: linear-gradient(135deg, rgba(108, 60, 225, 0.015), rgba(255, 255, 255, 0.8));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03), 0 0 0 0.5px rgba(108, 60, 225, 0.04);
    transition: all 0.2s ease;
    text-align: left;
}

.chat-welcome-card:hover {
    border-color: rgba(108, 60, 225, 0.2);
    background: linear-gradient(135deg, rgba(108, 60, 225, 0.04), rgba(216, 82, 204, 0.02));
    box-shadow: 0 4px 16px rgba(108, 60, 225, 0.08);
    transform: translateY(-2px);
}

.chat-welcome-card:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 4px rgba(108, 60, 225, 0.06);
    transition: all 0.1s ease;
}

/* Ripple effect */
.chat-welcome-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(108, 60, 225, 0.12) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.chat-welcome-card:active::after {
    opacity: 1;
    transition: opacity 0.05s ease;
}

.chat-welcome-card-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-welcome-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.chat-welcome-card-title {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-welcome-card-desc {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-subtle);
    line-height: 1.4;
}

@keyframes chat-welcome-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes welcome-glow-pulse {

    0%,
    100% {
        opacity: 0.6;
        transform: translateX(-50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.15);
    }
}

@keyframes welcome-icon-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

@keyframes welcome-card-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.chat-welcome-card:nth-child(1) {
    animation-delay: 0.15s;
}

.chat-welcome-card:nth-child(2) {
    animation-delay: 0.25s;
}

.chat-welcome-card:nth-child(3) {
    animation-delay: 0.35s;
}

.chat-welcome-card:nth-child(4) {
    animation-delay: 0.45s;
}


.chat-msg-row {
    display: flex;
    flex-direction: column;
}

.chat-msg-user {
    align-items: flex-end;
}

.chat-msg-user .chat-msg-wrap {
    align-items: flex-end;
}

.chat-msg-assistant .chat-msg-wrap {
    align-items: flex-start;
    width: 100%;
}

.chat-msg-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 100%;
}

.chat-msg-blocks {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.chat-msg-role {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-subtle);
    padding: 0 4px;
}

.chat-msg-role-ai {
    color: var(--accent-purple);
}

/* ─── Bubbles ─── */

.chat-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-primary);
}

.chat-bubble p {
    margin: 0 0 10px;
}

.chat-bubble p:last-of-type {
    margin-bottom: 0;
}

.chat-bubble code {
    background: rgba(108, 60, 225, 0.08);
    color: var(--accent-purple);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.chat-bubble-user {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 2px 8px rgba(108, 60, 225, 0.2);
}

.chat-bubble-user code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.chat-bubble-assistant {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 16px 16px 16px 4px;
    box-shadow: var(--shadow-sm);
}

.chat-msg-time {
    font-size: 10px;
    color: var(--text-subtle);
    padding: 0 6px;
}

.chat-msg-time-right {
    text-align: right;
}

.chat-msg-time-left {
    text-align: left;
}

/* ─── Block Base ─── */

.chat-block {
    margin: 0;
}

.chat-block+.chat-block {
    margin-top: 12px;
}

.chat-block-text+.chat-meta {
    margin-top: 8px;
}

/* ─── Text Block — typography ─── */

.chat-block-text {
    font-family: var(--font-body), sans-serif;
    font-size: 16px;
    color: #101828;
    line-height: 1.6;
}

.chat-block-text h1,
.chat-block-text h2,
.chat-block-text h3,
.chat-block-text h4 {
    font-family: var(--font-heading), sans-serif;
    font-weight: 700;
    color: #101828;
    line-height: 1.3;
    margin: 20px 0 8px;
}

.chat-block-text h1:first-child,
.chat-block-text h2:first-child,
.chat-block-text h3:first-child,
.chat-block-text h4:first-child {
    margin-top: 0;
}

.chat-block-text h1 {
    font-size: 23px;
    letter-spacing: -0.02em;
}

.chat-block-text h2 {
    font-size: 19px;
    letter-spacing: -0.01em;
}

.chat-block-text h3 {
    font-size: 17px;
}

.chat-block-text h4 {
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475467;
}

.chat-block-text p {
    margin: 8px 0;
    line-height: 1.6;
}

/* Spacing: heading immediately followed by a list */
.chat-block-text h2+ul,
.chat-block-text h2+ol,
.chat-block-text h3+ul,
.chat-block-text h3+ol {
    margin-top: 4px;
}

.chat-block-text ul,
.chat-block-text ol {
    margin: 10px 0;
    padding-left: 22px;
}

.chat-block-text ul {
    list-style-type: disc;
}

.chat-block-text ol {
    list-style-type: decimal;
}

.chat-block-text li {
    margin: 5px 0;
    line-height: 1.55;
    padding-left: 4px;
}

.chat-block-text li::marker {
    color: var(--accent-purple);
}

.chat-block-text strong {
    color: var(--accent-purple);
    font-weight: 700;
}

/* ─── Text Formatter (tf-*) ─── */

.tf-metric {
    color: var(--accent-purple);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: rgba(108, 60, 225, 0.07);
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

.tf-trend {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

.tf-trend-up {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.08);
}

.tf-trend-down {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.08);
}

.tf-path {
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--accent-purple);
    background: rgba(108, 60, 225, 0.06);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(108, 60, 225, 0.12);
    white-space: nowrap;
}

.tf-callout {
    margin: 12px 0;
    padding: 14px 16px;
    border-left: 3px solid var(--accent-purple);
    background: rgba(108, 60, 225, 0.04);
    border-radius: 0 8px 8px 0;
}

.tf-callout-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--accent-purple);
    margin-bottom: 8px;
}

.tf-callout-header svg {
    flex-shrink: 0;
}

.tf-callout-content {
    font-size: var(--text-sm);
    color: var(--text-primary);
    line-height: 1.65;
}

.tf-callout-content p {
    margin: 0 0 6px;
}

.tf-callout-content p:last-child {
    margin-bottom: 0;
}

.tf-callout-content ul,
.tf-callout-content ol {
    margin: 4px 0 0;
    padding-left: 20px;
}

.tf-callout-content li {
    margin-bottom: 4px;
}

/* ─── Priority Badges (SVG icons replacing emoji circles) ─── */

.priority-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 4px;
    position: relative;
    top: -1px;
}

.priority-badge svg {
    flex-shrink: 0;
}

.priority-critical {
    color: #dc2626;
}

.priority-important {
    color: #d97706;
}

.priority-monitor {
    color: #16a34a;
}

/* ─── Date Range Badge ─── */

.tf-meta-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 2px 0 18px;
}

.tf-date-range {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-elevated, #F9FAFB);
    border: 1px solid var(--border-card, #E8ECF1);
    border-radius: 9999px;
    font-family: var(--font-body), 'DM Sans', sans-serif;
}

.tf-date-range-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #667085;
}

.tf-date-range-label svg {
    flex-shrink: 0;
    color: #667085;
}

.tf-date-range-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #101828);
    font-family: var(--font-mono, 'JetBrains Mono'), monospace;
}

/* ─── Source Badge ─── */

.tf-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: var(--bg-elevated, #F9FAFB);
    border: 1px solid var(--border-card, #E8ECF1);
    border-radius: 9999px;
}

.tf-source-badge svg {
    flex-shrink: 0;
}

.tf-source-badge-text {
    font-size: 11px;
    font-weight: 500;
    color: #667085;
    font-family: var(--font-body), 'DM Sans', sans-serif;
}

/* ─── Chart Block ─── */

.chat-block-chart {
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 20px;
}

.chat-block-chart-title {
    font-size: 15px;
    font-weight: 600;
    color: #101828;
    margin-bottom: 14px;
    padding: 0 2px;
    font-family: var(--font-heading);
}

.chat-block-chart-title:empty {
    display: none;
}

/* ─── Table Block ─── */

.chat-block-table-title {
    font-size: 15px;
    font-weight: 600;
    color: #101828;
    margin-bottom: 14px;
    padding: 0 2px;
    font-family: var(--font-heading);
}

.chat-block-table-title:empty {
    display: none;
}

/* ─── Action Buttons ─── */

.chat-block-action {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--accent-purple);
    background: rgba(124, 92, 252, 0.06);
    color: var(--accent-purple);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chat-action-btn:hover {
    background: var(--accent-purple);
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 92, 252, 0.25);
    transform: translateY(-1px);
}

.chat-action-btn:active {
    transform: translateY(0);
}

/* ─── Quiz / Clarification Block ─── */

.chat-block-quiz {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
}

.chat-quiz-question {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.chat-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.chat-quiz-option:hover {
    border-color: var(--accent-purple);
    background: rgba(124, 92, 252, 0.04);
}

.chat-quiz-option.selected {
    border-color: var(--accent-purple);
    background: rgba(124, 92, 252, 0.08);
    color: var(--accent-purple);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--accent-purple);
}

/* ─── Charts ─── */

.chat-chart-container {
    width: 100%;
    margin: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    padding: 0;
}

/* ─── Scorecards ─── */

.chat-scorecard-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.chat-scorecard-grid>.chat-scorecard {
    flex: 1 1 140px;
    min-width: 0;
    max-width: 200px;
}

.chat-scorecard {
    background: #FAFBFC;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-scorecard-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
    min-height: 26px;
}

.chat-scorecard-label {
    font-size: 10px;
    font-weight: 600;
    color: #344054;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 1;
    min-width: 0;
    line-height: 1.35;
    word-break: break-word;
}

.chat-scorecard-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #101828);
    font-family: var(--font-heading, 'Outfit', system-ui, sans-serif);
    line-height: 1.2;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.chat-scorecard-change,
.chat-scorecard-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 5px;
    flex-shrink: 0;
    white-space: nowrap;
    line-height: 1.3;
}

.chat-scorecard-positive {
    color: #22C55E;
    background: rgba(34, 197, 94, 0.08);
}

.chat-scorecard-negative {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.08);
}

.chat-scorecard-sub {
    font-size: 10px;
    font-weight: 500;
    color: #475467;
    margin-top: 2px;
}

/* ─── Pivot Table ─── */

.chat-pivot-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-card, #E8ECF1);
    border-radius: 10px;
    overflow: hidden;
    margin: 12px 0;
    font-size: 12px;
    font-family: var(--font-body), sans-serif;
    background: var(--card-bg, #fff);
}

.chat-pivot-table th {
    background: var(--bg-elevated, #F9FAFB);
    color: #667085;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-card, #E8ECF1);
    white-space: nowrap;
}

.chat-pivot-table th:not(:first-child) {
    text-align: right;
}

.chat-pivot-table td {
    padding: 9px 14px;
    color: #101828;
    border-bottom: 1px solid var(--border-card, #E8ECF1);
    font-variant-numeric: tabular-nums;
}

.chat-pivot-table td:not(:first-child) {
    text-align: right;
    font-family: monospace;
    font-size: 11px;
    font-weight: 500;
}

.chat-pivot-table td:first-child {
    color: #101828;
}

.chat-pivot-table tr:last-child td {
    border-bottom: none;
}

.chat-pivot-table tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.015);
}

.chat-pivot-table tr:hover td {
    background: var(--bg-elevated, #F9FAFB);
}

.chat-pivot-table .pivot-total-row td {
    font-weight: 700;
    background: var(--bg-elevated, #F9FAFB);
    color: #101828;
    border-top: 2px solid var(--border-card, #E8ECF1);
}

/* ─── Cross-Tab Pivot ─── */

.chat-pivot-crosstab .pivot-corner {
    background: var(--bg-elevated, #F9FAFB);
    color: #667085;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
}

.chat-pivot-crosstab .pivot-row-header {
    font-weight: 600;
    color: #101828;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    left: 0;
    background: var(--card-bg, #fff);
    z-index: 1;
}

.chat-pivot-crosstab tr:nth-child(even) .pivot-row-header {
    background: rgba(0, 0, 0, 0.015);
}

.chat-pivot-crosstab tr:hover .pivot-row-header {
    background: var(--bg-elevated, #F9FAFB);
}

/* ─── Follow-up Chips ─── */

.chat-block-follow-ups {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.chat-followups {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(108, 60, 225, 0.04);
    border: 1px solid rgba(108, 60, 225, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
}

.chat-followups-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.chat-followups-label i,
.chat-followups-label svg {
    color: var(--accent-purple);
    opacity: 0.7;
}

.chat-followups-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-chip {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(108, 60, 225, 0.15);
    background: rgba(108, 60, 225, 0.06);
    color: var(--accent-purple);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chat-chip:hover {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--accent-purple), #e040a0);
    box-shadow: 0 2px 8px rgba(108, 60, 225, 0.25);
    transform: translateY(-1px);
}

/* ─── Metadata Footer ─── */

.chat-meta,
.chat-meta span {
    font-family: var(--font-mono) !important;
}

.chat-meta {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px dashed var(--border-light);
    font-size: 11px;
    color: var(--text-subtle);
    letter-spacing: -0.01em;
    cursor: default;
}

.chat-meta-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-rating-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-rating-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-rating-btn.active {
    color: var(--accent-purple);
    background: rgba(108, 60, 225, 0.1);
}

.chat-meta-dot {
    opacity: 0.4;
}

/* Custom tooltip on hover */
.chat-meta-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(108, 60, 225, 0.06);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    z-index: 100;
    pointer-events: none;
}

.chat-meta:hover .chat-meta-tooltip {
    display: block;
}

.chat-meta-tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 3px 0;
}

.chat-meta-tooltip-row:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
}

.chat-meta-tooltip-label {
    color: var(--text-subtle);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.chat-meta-tooltip-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
}

/* ─── Typing Indicator ─── */

/* ─── AI Typing Indicator ─── */

.chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0 2px 4px;
    border-radius: var(--radius-pill);
}

.chat-typing-icon {
    width: 14px;
    height: 14px;
    color: var(--accent-purple);
}

.chat-typing-text {
    font-size: 13px;
    color: var(--accent-purple);
    font-weight: 500;
    font-family: var(--font-mono);

    /* Typewriter effect */
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    animation: chat-typewriter calc(var(--typing-length) * 0.05s) steps(var(--typing-length), end) forwards;
}

.chat-ellipsis {
    font-size: 13px;
    color: var(--accent-purple);
    font-weight: 500;
    font-family: var(--font-mono);
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    vertical-align: bottom;
    animation: chat-ellipsis-anim 1.5s infinite steps(4, end);
}

.chat-ellipsis::after {
    content: '...';
}

@keyframes chat-typewriter {
    from {
        width: 0
    }

    to {
        width: 100%
    }
}

@keyframes chat-ellipsis-anim {
    0% {
        width: 0ch;
    }

    100% {
        width: 4ch;
    }
}

@keyframes chat-think-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}

/* ─── Markdown content in chat responses ─── */
.chat-response-content h1,
.chat-response-content h2,
.chat-response-content h3 {
    margin-bottom: 6px;
    font-family: var(--font-heading, 'Outfit', system-ui, sans-serif);
    line-height: 1.3;
}

.chat-response-content h2 {
    font-size: 23px;
    font-weight: 800;
    color: var(--text-primary, #101828);
    margin-top: 16px;
    letter-spacing: -0.02em;
}

.chat-response-content h2:first-child {
    margin-top: 0;
}

.chat-response-content h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-secondary, #344054);
    margin-top: 18px;
    text-transform: none;
}

.chat-response-content ul,
.chat-response-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.chat-response-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-card, #E8ECF1);
    border-radius: 10px;
    overflow: hidden;
    margin: 12px 0;
    font-size: 12px;
    font-family: var(--font-body), sans-serif;
    background: var(--card-bg, #fff);
}

.chat-response-content th {
    background: var(--bg-elevated, #F9FAFB);
    color: #667085;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-card, #E8ECF1);
    white-space: nowrap;
}

.chat-response-content th:not(:first-child) {
    text-align: right;
}

.chat-response-content td {
    padding: 9px 14px;
    color: #101828;
    border-bottom: 1px solid var(--border-card, #E8ECF1);
    font-variant-numeric: tabular-nums;
    border-left: none;
    border-right: none;
}

.chat-response-content td:not(:first-child) {
    text-align: right;
    font-size: 11px;
    font-weight: 500;
}

.chat-response-content td:first-child {
    font-weight: 500;
    color: #101828;
}

.chat-response-content tr:last-child td {
    border-bottom: none;
}

.chat-response-content tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.015);
}

.chat-response-content tr:hover td {
    background: var(--bg-elevated, #F9FAFB);
}

.chat-response-content code {
    background: var(--bg-elevated);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 13px;
    font-family: var(--font-mono) !important;
}

.chat-response-content pre {
    background: var(--bg-elevated);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: var(--font-mono) !important;
    font-size: 13px;
}

.chat-response-content strong {
    font-weight: 700;
    color: var(--accent-purple);
}

.chat-response-content blockquote {
    border-left: 3px solid var(--accent-purple);
    margin: 8px 0;
    padding: 4px 12px;
    color: var(--text-muted);
}

.chat-response-content hr {
    display: none;
}

/* ─── Input Bar ─── */

.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 20px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

/* ── Plus button (outside input) ── */
.chat-plus-wrapper {
    position: relative;
    flex-shrink: 0;
    align-self: flex-end;
}

.chat-plus-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    margin-bottom: 7px;
}

.chat-plus-btn:hover {
    background: #f5f3ff;
    color: var(--text-primary);
    border-color: rgba(108, 60, 225, 0.3);
}

.chat-plus-btn.active {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
    transform: rotate(45deg);
    box-shadow: 0 2px 12px rgba(108, 60, 225, 0.3);
}

/* ── Popup tool panel ── */
.chat-tools-popup {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border-default);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 100;
}

.chat-tools-popup.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.chat-tool-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chat-tool-item:hover {
    background: rgba(108, 60, 225, 0.06);
    color: var(--accent-purple);
}

.chat-tool-item .chat-slash-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono, monospace);
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    transition: all var(--transition-fast);
}

.chat-tool-item:hover .chat-slash-kbd {
    border-color: rgba(108, 60, 225, 0.3);
    color: var(--accent-purple);
    background: rgba(108, 60, 225, 0.06);
}

/* ── Input wrap (simplified — textarea + send) ── */
.chat-input-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    border-radius: 22px;
    padding: 8px 10px 8px 22px;
    border: 1px solid var(--border-default);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-wrap:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 2px 16px rgba(108, 60, 225, 0.1);
}

.chat-input {
    flex: 1;
    width: 100%;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    outline: none;
    padding: 6px 0;
    resize: none;
    line-height: 1.5;
    min-height: 28px;
    max-height: 200px;
    overflow: hidden;
    scrollbar-width: none;
}

.chat-input::-webkit-scrollbar {
    display: none;
}

.chat-input::placeholder {
    color: var(--text-subtle);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    border: none;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(108, 60, 225, 0.3);
    transition: all var(--transition-fast);
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(108, 60, 225, 0.4);
}

.chat-stop-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    border: none;
    background: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-fast);
    animation: chat-stop-pulse 2s ease-in-out infinite;
}

.chat-stop-btn:hover {
    background: #1f2937;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

@keyframes chat-stop-pulse {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    50% {
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
    }
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
    .chat-sidebar {
        display: none;
    }

    .chat-layout {
        margin: -16px -16px -16px;
    }

    .chat-messages-inner {
        padding: 0 12px;
    }

    .chat-input-area {
        padding: 8px 12px 12px;
    }

    .chat-scorecard-grid>.chat-scorecard {
        flex: 1 1 100%;
    }
}