<style>
        /* =============================================
           APP SHELL STYLES (from Job Costing 2.2)
           ============================================= */
        :root {
            --swept-blue: #3592FF;
            --swept-dark-blue: #2e72d9;
            --swept-light-blue: #e5f0ff;
            --swept-green: #00C79F;
            --swept-dark: #37383F;
            --swept-light-gray: #F5F5F7;
            --swept-gray: #E0E0E0;
            --swept-red: #FF647C;
            --swept-orange: #FFA26B;
            --swept-purple: #6B66FF;

            --topbar-height: 64px;

            /* Stage colors */
            --stage-prospect: #94a3b8;
            --stage-bidding: #f59e0b;
            --stage-won: #10b981;
            --stage-onboarding: #3b82f6;
            --stage-active: #8b5cf6;
            --stage-expand: #ec4899;
        }

        .lead-pipeline-tool-embed * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .lead-pipeline-tool-embed {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: #f5f7fa;
            color: #1e293b;
            line-height: 1.5;
        }

        /* App Layout */
        .app-layout {
            display: flex;
            min-height: 100vh;
        }

        /* Main Content — full width (kanban board benefits from the space) */
        .app-main {
            flex: 1;
            margin-left: 0;
            /* min-width: 0 keeps the wide kanban board from blowing out the flex
               layout — horizontal scroll stays inside the board, not the page */
            min-width: 0;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        /* Topbar */
        .app-topbar {
            height: var(--topbar-height);
            background: white;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 1.5rem;
            position: sticky;
            top: 0;
            z-index: 50;
            transition: transform 0.2s ease;
        }

        /* Reveal-on-scroll-up: hidden while scrolling down, revealed on scroll up */
        .app-topbar.topbar-hidden {
            transform: translateY(-100%);
        }

        .topbar-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--swept-dark);
        }

        .topbar-subtitle {
            font-size: 0.8rem;
            color: #64748b;
            margin-top: 0.1rem;
        }

        .topbar-actions {
            display: flex;
            gap: 0.75rem;
        }

        /* Buttons */
        .btn {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            border: none;
            transition: all 0.15s;
            min-height: 40px;
        }

        .btn-icon {
            width: 16px;
            height: 16px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
        }

        .btn-ghost {
            background: transparent;
            color: #475569;
        }

        .btn-ghost:hover {
            background: #f1f5f9;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--swept-blue), var(--swept-dark-blue));
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(53, 146, 255, 0.3);
        }

        .btn-secondary {
            background: #f1f5f9;
            color: #475569;
        }

        .btn-secondary:hover {
            background: #e2e8f0;
        }

        /* App Content */
        .app-content {
            flex: 1;
            padding: 1.5rem;
            overflow-x: auto;
        }

        /* Feedback section (below the board) */
        .feedback-section {
            background: #eef2f7;
            padding: 3rem 1.5rem;
            text-align: center;
        }
        .feedback-section__inner { max-width: 800px; margin: 0 auto; }

        /* =============================================
           PIPELINE STATS BAR
           ============================================= */
        .pipeline-stats {
            display: flex;
            gap: 1.5rem;
            margin-bottom: 1.5rem;
            flex-wrap: wrap;
        }

        .stat-card {
            background: white;
            padding: 1rem 1.5rem;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            min-width: 150px;
        }

        .stat-card .stat-label {
            font-size: 0.75rem;
            font-weight: 500;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .stat-card .stat-value {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--swept-dark);
            margin-top: 0.25rem;
        }

        .stat-card .stat-value.green {
            color: var(--swept-green);
        }

        .stat-card .stat-value.blue {
            color: var(--swept-blue);
        }

        /* =============================================
           KANBAN BOARD STYLES
           ============================================= */
        .kanban-board {
            display: flex;
            gap: 1rem;
            min-height: 480px;
            overflow-x: auto;
            padding-bottom: 1rem;
        }

        .kanban-column {
            flex: 0 0 280px;
            background: #f1f5f9;
            border-radius: 12px;
            display: flex;
            flex-direction: column;
            min-height: 200px;
        }

        .kanban-column-header {
            padding: 1rem;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .kanban-column-title {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .kanban-column-title .stage-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }

        .kanban-column-title h3 {
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--swept-dark);
            text-transform: capitalize;
        }

        .kanban-column-count {
            background: white;
            padding: 0.25rem 0.5rem;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 600;
            color: #64748b;
        }

        .kanban-column-body {
            flex: 1;
            padding: 0.5rem;
        }

        .kanban-column-body.drag-over {
            background: rgba(53, 146, 255, 0.1);
        }

        /* Kanban Cards */
        .kanban-card {
            background: white;
            border-radius: 8px;
            padding: 1rem;
            margin-bottom: 0.5rem;
            cursor: grab;
            border: 1px solid #e2e8f0;
            transition: all 0.15s;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }

        .kanban-card:hover {
            border-color: var(--swept-blue);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        }

        .kanban-card.dragging {
            opacity: 0.5;
            transform: rotate(3deg);
        }

        .kanban-card-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 0.5rem;
        }

        .kanban-card-name {
            font-weight: 600;
            font-size: 0.9rem;
            color: var(--swept-dark);
        }

        .kanban-card-value {
            font-weight: 700;
            font-size: 0.85rem;
            color: var(--swept-green);
        }

        .kanban-card-financials {
            display: flex;
            gap: 0.75rem;
            font-size: 0.75rem;
            margin-bottom: 0.5rem;
            padding: 0.4rem 0.5rem;
            background: #f8fafc;
            border-radius: 4px;
        }

        .kanban-card-financials span {
            color: #64748b;
        }

        .kanban-card-financials .margin {
            font-weight: 600;
            color: var(--swept-green);
        }

        .kanban-card-financials .margin.low {
            color: var(--swept-orange);
        }

        .kanban-card-financials .margin.negative {
            color: var(--swept-red);
        }

        .kanban-card-address {
            font-size: 0.75rem;
            color: #64748b;
            margin-bottom: 0.5rem;
        }

        .kanban-card-meta {
            display: flex;
            gap: 0.75rem;
            flex-wrap: wrap;
        }

        .kanban-card-tag {
            font-size: 0.7rem;
            padding: 0.15rem 0.5rem;
            border-radius: 4px;
            background: #f1f5f9;
            color: #475569;
        }

        .kanban-card-tag.sqft {
            background: #e0f2fe;
            color: #0369a1;
        }

        .kanban-card-tag.linked {
            background: #dcfce7;
            color: #166534;
        }

        .kanban-card-actions {
            display: flex;
            gap: 0.5rem;
            margin-top: 0.75rem;
            padding-top: 0.75rem;
            border-top: 1px solid #f1f5f9;
        }

        .kanban-card-actions button {
            flex: 1;
            padding: 0.4rem;
            border: none;
            border-radius: 4px;
            font-size: 0.7rem;
            cursor: pointer;
            background: #f1f5f9;
            color: #475569;
            transition: all 0.15s;
        }

        .kanban-card-actions button:hover {
            background: #e2e8f0;
        }

        .kanban-card-actions button.delete:hover {
            background: #fee2e2;
            color: #dc2626;
        }

        /* Ensure buttons are clickable above the card's click handler */
        .kanban-card-actions {
            position: relative;
            z-index: 10;
            pointer-events: auto;
        }

        .kanban-card-actions button {
            pointer-events: auto;
            position: relative;
            z-index: 11;
        }

        /* Add Card Button */
        .add-card-btn {
            width: 100%;
            padding: 0.75rem;
            border: 1px dashed #cbd5e1;
            border-radius: 8px;
            background: transparent;
            color: #64748b;
            cursor: pointer;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            transition: all 0.15s;
        }

        .add-card-btn:hover {
            background: white;
            border-color: var(--swept-blue);
            color: var(--swept-blue);
        }

        /* Stage Colors */
        [data-stage="prospect"] .stage-dot { background: var(--stage-prospect); }
        [data-stage="bidding"] .stage-dot { background: var(--stage-bidding); }
        [data-stage="won"] .stage-dot { background: var(--stage-won); }
        [data-stage="onboarding"] .stage-dot { background: var(--stage-onboarding); }
        [data-stage="active"] .stage-dot { background: var(--stage-active); }
        [data-stage="expand"] .stage-dot { background: var(--stage-expand); }

        /* =============================================
           MODAL STYLES
           ============================================= */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1.5rem 1rem;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s;
        }

        .modal-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .modal {
            background: white;
            border-radius: 16px;
            width: 100%;
            max-width: 500px;
            max-height: calc(100vh - 3rem);
            overflow-y: auto;
            transform: translateY(20px);
            transition: transform 0.2s;
        }

        .modal-overlay.show .modal {
            transform: translateY(0);
        }

        .modal-header {
            padding: 1.5rem;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h2 {
            font-size: 1.1rem;
            font-weight: 600;
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: #64748b;
            line-height: 1;
        }

        .modal-body {
            padding: 1.5rem;
        }

        .form-group {
            margin-bottom: 1rem;
        }

        .form-group label {
            display: block;
            font-size: 0.85rem;
            font-weight: 500;
            color: #475569;
            margin-bottom: 0.4rem;
        }

        .form-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.75rem;
        }

        .lead-pipeline-tool-embed :is(input, textarea, select) {
            width: 100%;
            padding: 0.6rem 0.75rem;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.9rem;
            font-family: inherit;
            transition: all 0.2s;
        }

        .lead-pipeline-tool-embed :is(input, textarea, select):focus {
            outline: none;
            border-color: var(--swept-blue);
            box-shadow: 0 0 0 3px rgba(53, 146, 255, 0.1);
        }

        .lead-pipeline-tool-embed textarea {
            resize: vertical;
            min-height: 80px;
        }

        /* "Also save as location" default checkbox */
        .lead-loc-autosave {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-top: 0.5rem;
            font-size: 0.8125rem;
            font-weight: 500;
            color: #475569;
            cursor: pointer;
        }

        .lead-loc-autosave input {
            width: auto;
            margin: 0;
            accent-color: var(--swept-blue, #3592FF);
        }

        /* Inline "Add new location" mini-form */
        .lead-loc-inline-form {
            display: none;
            margin-top: 0.75rem;
            padding: 0.75rem;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
        }

        .lead-loc-inline-form.show {
            display: block;
        }

        .lead-loc-inline-form .form-group {
            margin-bottom: 0.75rem;
        }

        .lead-loc-inline-actions {
            display: flex;
            justify-content: flex-end;
            gap: 0.5rem;
        }

        .modal-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid #e2e8f0;
            display: flex;
            justify-content: flex-end;
            gap: 0.75rem;
        }

        /* Toast */
        .toast {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            background: #1e293b;
            color: white;
            padding: 1rem 1.5rem;
            border-radius: 8px;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
            transform: translateY(100px);
            opacity: 0;
            transition: all 0.3s;
            z-index: 1000;
        }

        .toast.show {
            transform: translateY(0);
            opacity: 1;
        }

        .toast.success {
            background: var(--swept-green);
        }

        .toast.error {
            background: var(--swept-red);
        }

        /* =============================================
           LEAD DETAIL PANEL (Slide-out)
           ============================================= */
        .lead-detail-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.4);
            z-index: 900;
            opacity: 0;
            visibility: hidden;
            transition: all 0.25s ease;
        }

        .lead-detail-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .lead-detail-panel {
            position: fixed;
            top: 0;
            right: 0;
            width: 480px;
            max-width: 100%;
            height: 100vh;
            background: white;
            z-index: 950;
            transform: translateX(100%);
            transition: transform 0.3s ease;
            display: flex;
            flex-direction: column;
            box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
        }

        .lead-detail-panel.show {
            transform: translateX(0);
        }

        .lead-detail-header {
            padding: 1.25rem 1.5rem;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #fafbfc;
        }

        .lead-detail-header h2 {
            font-size: 1.1rem;
            font-weight: 600;
            color: var(--swept-dark);
            margin: 0;
        }

        .lead-detail-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: #64748b;
            line-height: 1;
            padding: 0.25rem;
            border-radius: 4px;
            transition: all 0.15s;
        }

        .lead-detail-close:hover {
            background: #f1f5f9;
            color: #1e293b;
        }

        .lead-detail-body {
            flex: 1;
            overflow-y: auto;
            padding: 1.5rem;
        }

        .lead-detail-section {
            margin-bottom: 1.5rem;
        }

        .lead-detail-section-title {
            font-size: 0.7rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: #94a3b8;
            margin-bottom: 0.75rem;
        }

        .lead-detail-field {
            margin-bottom: 1rem;
        }

        .lead-detail-label {
            font-size: 0.75rem;
            color: #64748b;
            margin-bottom: 0.25rem;
        }

        .lead-detail-value {
            font-size: 0.95rem;
            color: #1e293b;
            font-weight: 500;
        }

        .lead-detail-value.empty {
            color: #94a3b8;
            font-style: italic;
            font-weight: 400;
        }

        .lead-detail-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1rem;
        }

        .lead-detail-financials {
            background: linear-gradient(135deg, #f8fafc, #f1f5f9);
            border-radius: 12px;
            padding: 1.25rem;
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 1rem;
            text-align: center;
        }

        .lead-financial-item {
            padding: 0.5rem;
        }

        .lead-financial-label {
            font-size: 0.7rem;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 0.25rem;
        }

        .lead-financial-value {
            font-size: 1.25rem;
            font-weight: 700;
        }

        .lead-financial-value.revenue {
            color: var(--swept-blue);
        }

        .lead-financial-value.cost {
            color: #64748b;
        }

        .lead-financial-value.margin {
            color: var(--swept-green);
        }

        .lead-financial-value.margin.low {
            color: var(--swept-orange);
        }

        .lead-financial-value.margin.negative {
            color: var(--swept-red);
        }

        .lead-detail-stage {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 500;
        }

        .lead-detail-stage[data-stage="prospect"] { background: #f1f5f9; color: #64748b; }
        .lead-detail-stage[data-stage="bidding"] { background: #fef3c7; color: #b45309; }
        .lead-detail-stage[data-stage="won"] { background: #d1fae5; color: #059669; }
        .lead-detail-stage[data-stage="onboarding"] { background: #dbeafe; color: #2563eb; }
        .lead-detail-stage[data-stage="active"] { background: #ede9fe; color: #7c3aed; }
        .lead-detail-stage[data-stage="expand"] { background: #fce7f3; color: #db2777; }

        .lead-detail-stage .stage-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }

        .lead-detail-badges {
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
            margin-top: 0.75rem;
        }

        .lead-detail-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.35rem 0.75rem;
            border-radius: 6px;
            font-size: 0.75rem;
            font-weight: 500;
            background: #dcfce7;
            color: #166534;
        }

        .lead-detail-notes {
            background: #fffbeb;
            border: 1px solid #fde68a;
            border-radius: 8px;
            padding: 1rem;
            font-size: 0.9rem;
            color: #78350f;
            white-space: pre-wrap;
        }

        .lead-detail-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid #e2e8f0;
            background: #fafbfc;
            display: flex;
            gap: 0.75rem;
            flex-wrap: wrap;
        }

        .lead-detail-footer .btn {
            flex: 1;
            min-width: 120px;
            justify-content: center;
        }

        /* =============================================
           CONFIRM MODAL (Custom - VSCode blocks window.confirm)
           ============================================= */
        .confirm-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
        }

        .confirm-modal-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .confirm-modal {
            background: white;
            border-radius: 12px;
            padding: 1.5rem;
            width: 100%;
            max-width: 400px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
            transform: scale(0.9);
            transition: transform 0.2s ease;
        }

        .confirm-modal-overlay.show .confirm-modal {
            transform: scale(1);
        }

        .confirm-modal-icon {
            width: 48px;
            height: 48px;
            background: #fee2e2;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 1rem;
        }

        .confirm-modal-icon svg {
            width: 24px;
            height: 24px;
            stroke: #dc2626;
            fill: none;
            stroke-width: 2;
        }

        .confirm-modal-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: #1e293b;
            text-align: center;
            margin-bottom: 0.5rem;
        }

        .confirm-modal-message {
            font-size: 0.9rem;
            color: #64748b;
            text-align: center;
            margin-bottom: 1.5rem;
        }

        .confirm-modal-actions {
            display: flex;
            gap: 0.75rem;
        }

        .confirm-modal-actions .btn {
            flex: 1;
            justify-content: center;
        }

        .btn-danger {
            background: #dc2626;
            color: white;
            border: none;
        }

        .btn-danger:hover {
            background: #b91c1c;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .app-main {
                margin-left: 0;
            }

            .kanban-board {
                padding-right: 1rem;
            }

            /* Stack pipeline stats on mobile */
            .pipeline-stats {
                flex-wrap: wrap;
                gap: 0.5rem;
            }

            .pipeline-stat {
                flex: 1 1 45%;
            }

            /* Adjust topbar on mobile (height: auto so stacked content doesn't overflow) */
            .app-topbar {
                flex-direction: column;
                align-items: flex-start;
                gap: 1rem;
                height: auto;
                padding: 1rem;
            }

            .topbar-actions {
                width: 100%;
                justify-content: flex-start;
            }

            /* Lead detail panel full width on mobile */
            .lead-detail-panel {
                width: 100%;
            }
        }
    </style>

/* ===== WORKBENCH FRAME OVERRIDES (embedded, not a standalone page) ===== */
.lead-pipeline-tool-embed .app-topbar { position: static; top: auto; z-index: auto; border-radius: 0; min-height: 0; padding: 0.75rem 1rem; }
.lead-pipeline-tool-embed .app-main { min-height: 0; }
.lead-pipeline-tool-embed .app-content { padding-top: 1.25rem; }
.lead-pipeline-tool-embed .app-topbar .topbar-title, .lead-pipeline-tool-embed .app-topbar .topbar-subtitle { display: none; }
.lead-pipeline-tool-embed .topbar-left:empty { display: none; }

/* ===== LIFTED-TO-BODY OVERLAYS (moved outside the scoped wrapper at runtime) ===== */
.modal-overlay, .modal-overlay *, .confirm-modal-overlay, .confirm-modal-overlay *,
.lead-detail-overlay, .lead-detail-panel, .lead-detail-panel * { box-sizing: border-box; }
.modal-overlay, .confirm-modal-overlay, .lead-detail-panel { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }