        /* ── Reset scope ── */
        #aivt-settings-wrap *,
        #aivt-settings-wrap *::before,
        #aivt-settings-wrap *::after { box-sizing: border-box; }

        /* ── Layout ── */
        #aivt-settings-wrap {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            color: #1e293b;
            max-width: 900px;
            margin: 20px 0 40px;
        }

        /* ── Header ── */
        #aivt-settings-wrap .aivt-header {
            display: flex;
            align-items: center;
            gap: 14px;
            margin-bottom: 28px;
            padding-bottom: 20px;
            border-bottom: 1px solid #e2e8f0;
        }
        #aivt-settings-wrap .aivt-logo {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #e8601c 0%, #f59e0b 100%);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        #aivt-settings-wrap .aivt-logo svg { width: 22px; height: 22px; fill: #fff; }
        #aivt-settings-wrap .aivt-header-text h1 {
            margin: 0;
            font-size: 22px;
            font-weight: 700;
            color: #0f172a;
            padding: 0;
        }
        #aivt-settings-wrap .aivt-header-text p {
            margin: 2px 0 0;
            font-size: 13px;
            color: #64748b;
        }
        #aivt-settings-wrap .aivt-status-badge {
            margin-left: auto;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
        }
        #aivt-settings-wrap .aivt-status-badge.connected {
            background: #dcfce7;
            color: #166534;
        }
        #aivt-settings-wrap .aivt-status-badge.disconnected {
            background: #fef3c7;
            color: #92400e;
        }
        #aivt-settings-wrap .aivt-status-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
        }
        #aivt-settings-wrap .connected .aivt-status-dot { background: #16a34a; }
        #aivt-settings-wrap .disconnected .aivt-status-dot { background: #d97706; }

        /* ── Cards ── */
        #aivt-settings-wrap .aivt-card {
            background: #fff;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            margin-bottom: 20px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
            /* overflow:visible so absolute dropdowns inside aren't clipped */
        }
        #aivt-settings-wrap .aivt-card-header {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 16px 20px;
            border-bottom: 1px solid #f1f5f9;
            background: #f8fafc;
            border-radius: 12px 12px 0 0; /* clip header bg at card corners */
        }
        #aivt-settings-wrap .aivt-card-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        #aivt-settings-wrap .aivt-card-icon svg { width: 16px; height: 16px; }
        #aivt-settings-wrap .aivt-icon-api   { background: #eff6ff; }
        #aivt-settings-wrap .aivt-icon-api svg { stroke: #3b82f6; }
        #aivt-settings-wrap .aivt-icon-appearance { background: #fdf4ff; }
        #aivt-settings-wrap .aivt-icon-appearance svg { stroke: #a855f7; }
        #aivt-settings-wrap .aivt-icon-categories { background: #f0fdf4; }
        #aivt-settings-wrap .aivt-icon-categories svg { stroke: #22c55e; }
        #aivt-settings-wrap .aivt-icon-advanced { background: #fff7ed; }
        #aivt-settings-wrap .aivt-icon-advanced svg { stroke: #f97316; }
        #aivt-settings-wrap .aivt-icon-legal { background: #f8fafc; }
        #aivt-settings-wrap .aivt-icon-legal svg { stroke: #64748b; }
        #aivt-settings-wrap .aivt-card-header h2 {
            margin: 0;
            font-size: 14px;
            font-weight: 600;
            color: #0f172a;
            padding: 0;
            border: none;
        }
        #aivt-settings-wrap .aivt-card-header p {
            margin: 1px 0 0;
            font-size: 12px;
            color: #94a3b8;
        }
        #aivt-settings-wrap .aivt-card-body { padding: 20px; }

        /* ── Form rows ── */
        #aivt-settings-wrap .aivt-field {
            display: grid;
            grid-template-columns: 180px 1fr;
            gap: 12px 20px;
            align-items: start;
            padding: 14px 0;
            border-bottom: 1px solid #f1f5f9;
        }
        #aivt-settings-wrap .aivt-field:last-child { border-bottom: none; padding-bottom: 0; }
        #aivt-settings-wrap .aivt-field:first-child { padding-top: 0; }
        #aivt-settings-wrap .aivt-label {
            font-size: 13px;
            font-weight: 600;
            color: #374151;
            padding-top: 8px;
        }
        #aivt-settings-wrap .aivt-label em {
            display: block;
            font-style: normal;
            font-weight: 400;
            font-size: 11px;
            color: #9ca3af;
            margin-top: 2px;
        }
        #aivt-settings-wrap .aivt-control {}

        /* ── Inputs ── */
        #aivt-settings-wrap .aivt-input {
            width: 100%;
            max-width: 420px;
            padding: 8px 12px;
            border: 1.5px solid #e2e8f0;
            border-radius: 8px;
            font-size: 13px;
            color: #1e293b;
            background: #fff;
            transition: border-color 0.15s, box-shadow 0.15s;
            outline: none;
            line-height: 1.5;
        }
        #aivt-settings-wrap .aivt-input:focus {
            border-color: #e8601c;
            box-shadow: 0 0 0 3px rgba(232,96,28,0.1);
        }
        #aivt-settings-wrap .aivt-input-group {
            display: flex;
            gap: 8px;
            align-items: center;
            max-width: 420px;
        }
        #aivt-settings-wrap .aivt-input-group .aivt-input { flex: 1; max-width: none; }

        /* ── Select ── */
        #aivt-settings-wrap .aivt-select {
            padding: 8px 32px 8px 12px;
            border: 1.5px solid #e2e8f0;
            border-radius: 8px;
            font-size: 13px;
            color: #1e293b;
            background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
            appearance: none;
            cursor: pointer;
            outline: none;
            transition: border-color 0.15s;
        }
        #aivt-settings-wrap .aivt-select:focus { border-color: #e8601c; box-shadow: 0 0 0 3px rgba(232,96,28,0.1); }

        /* ── Buttons ── */
        #aivt-settings-wrap .aivt-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            border: none;
            transition: all 0.15s;
            text-decoration: none;
            line-height: 1.4;
        }
        #aivt-settings-wrap .aivt-btn-primary {
            background: #e8601c;
            color: #fff;
        }
        #aivt-settings-wrap .aivt-btn-primary:hover { background: #c94f16; color: #fff; }
        #aivt-settings-wrap .aivt-btn-secondary {
            background: #f1f5f9;
            color: #374151;
            border: 1.5px solid #e2e8f0;
        }
        #aivt-settings-wrap .aivt-btn-secondary:hover { background: #e2e8f0; }
        #aivt-settings-wrap .aivt-btn-ghost {
            background: transparent;
            color: #64748b;
            border: 1.5px solid #e2e8f0;
            padding: 7px 12px;
        }
        #aivt-settings-wrap .aivt-btn-ghost:hover { background: #f8fafc; }
        #aivt-settings-wrap .aivt-btn svg { width: 14px; height: 14px; }

        /* ── Description ── */
        #aivt-settings-wrap .aivt-description {
            font-size: 12px;
            color: #64748b;
            margin: 6px 0 0;
            line-height: 1.5;
        }

        /* ── Color picker preview ── */
        #aivt-settings-wrap .aivt-color-row {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
        }
        #aivt-settings-wrap .aivt-color-input-wrap {
            display: flex;
            align-items: center;
            gap: 8px;
            border: 1.5px solid #e2e8f0;
            border-radius: 8px;
            padding: 6px 10px;
            background: #fff;
            cursor: pointer;
        }
        #aivt-settings-wrap input[type="color"]#aivt_theme_color {
            width: 28px;
            height: 28px;
            border: none;
            border-radius: 6px;
            padding: 0;
            cursor: pointer;
            background: none;
        }
        #aivt-settings-wrap .aivt-color-hex {
            font-size: 13px;
            font-family: monospace;
            color: #374151;
            min-width: 64px;
        }

        /* ── Button preview ── */
        #aivt-settings-wrap .aivt-preview-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 9px 18px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 600;
            color: #fff;
            border: none;
            cursor: default;
            transition: background 0.2s;
        }
        #aivt-settings-wrap .aivt-preview-label {
            font-size: 11px;
            color: #94a3b8;
            margin-bottom: 6px;
        }

        /* ── Toggle / Checkbox ── */
        #aivt-settings-wrap .aivt-toggle-wrap {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        #aivt-settings-wrap .aivt-toggle {
            position: relative;
            width: 40px;
            height: 22px;
            flex-shrink: 0;
        }
        #aivt-settings-wrap .aivt-toggle input { opacity: 0; width: 0; height: 0; }
        #aivt-settings-wrap .aivt-toggle-slider {
            position: absolute;
            inset: 0;
            background: #cbd5e1;
            border-radius: 22px;
            cursor: pointer;
            transition: background 0.2s;
        }
        #aivt-settings-wrap .aivt-toggle-slider::before {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            left: 3px;
            top: 3px;
            background: #fff;
            border-radius: 50%;
            transition: transform 0.2s;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }
        #aivt-settings-wrap .aivt-toggle input:checked + .aivt-toggle-slider { background: #e8601c; }
        #aivt-settings-wrap .aivt-toggle input:checked + .aivt-toggle-slider::before { transform: translateX(18px); }
        #aivt-settings-wrap .aivt-toggle-text { font-size: 13px; color: #374151; }

        /* ── Categories list ── */
        #aivt-settings-wrap .aivt-cat-list {
            max-height: 220px;
            overflow-y: auto;
            border: 1.5px solid #e2e8f0;
            border-radius: 8px;
            background: #fff;
        }
        #aivt-settings-wrap .aivt-cat-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 14px;
            cursor: pointer;
            font-size: 13px;
            color: #374151;
            transition: background 0.1s;
            border-bottom: 1px solid #f1f5f9;
        }
        #aivt-settings-wrap .aivt-cat-item:last-child { border-bottom: none; }
        #aivt-settings-wrap .aivt-cat-item:hover { background: #f8fafc; }
        #aivt-settings-wrap .aivt-cat-select-all {
            background: #f8fafc;
            font-weight: 600;
            color: #0f172a;
            position: sticky;
            top: 0;
            z-index: 1;
            border-bottom: 1.5px solid #e2e8f0 !important;
        }
        #aivt-settings-wrap .aivt-cat-item em { color: #94a3b8; font-style: normal; }
        #aivt-settings-wrap .aivt-cat-item input[type="checkbox"] {
            width: 15px;
            height: 15px;
            accent-color: #e8601c;
            flex-shrink: 0;
        }

        /* ── Individual product search ── */
        #aivt-settings-wrap .aivt-product-search-wrap { position: relative; max-width: 480px; }
        #aivt-settings-wrap .aivt-product-search-box {
            display: flex;
            align-items: center;
            gap: 8px;
            border: 1.5px solid #e2e8f0;
            border-radius: 8px;
            padding: 8px 12px;
            background: #fff;
            transition: border-color 0.15s, box-shadow 0.15s;
        }
        #aivt-settings-wrap .aivt-product-search-box:focus-within {
            border-color: #e8601c;
            box-shadow: 0 0 0 3px rgba(232,96,28,0.1);
        }
        #aivt-settings-wrap .aivt-product-search-box svg { flex-shrink: 0; color: #94a3b8; }
        #aivt-settings-wrap .aivt-product-search-box input {
            border: none;
            outline: none;
            font-size: 13px;
            color: #1e293b;
            width: 100%;
            background: transparent;
        }
        /* Dropdown is appended to <body> by JS — not scoped under card */
        #aivt-product-results-portal {
            position: fixed;
            background: #fff;
            border: 1.5px solid #e2e8f0;
            border-radius: 8px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.13);
            z-index: 999999;
            max-height: 280px;
            overflow-y: auto;
            display: none;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        }
        #aivt-product-results-portal.open { display: block; }
        #aivt-settings-wrap .aivt-product-result-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 12px;
            cursor: pointer;
            border-bottom: 1px solid #f1f5f9;
            transition: background 0.1s;
        }
        #aivt-settings-wrap .aivt-product-result-item:last-child { border-bottom: none; }
        #aivt-settings-wrap .aivt-product-result-item:hover { background: #f0f9ff; }
        #aivt-settings-wrap .aivt-product-result-thumb {
            width: 40px;
            height: 40px;
            border-radius: 6px;
            object-fit: cover;
            background: #f1f5f9;
            flex-shrink: 0;
            border: 1px solid #e2e8f0;
        }
        #aivt-settings-wrap .aivt-product-result-info { flex: 1; min-width: 0; }
        #aivt-settings-wrap .aivt-product-result-title {
            font-size: 13px;
            font-weight: 600;
            color: #0f172a;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        #aivt-settings-wrap .aivt-product-result-price {
            font-size: 11px;
            color: #64748b;
            margin-top: 1px;
        }
        #aivt-settings-wrap .aivt-product-result-add {
            font-size: 11px;
            font-weight: 600;
            color: #e8601c;
            flex-shrink: 0;
        }
        #aivt-settings-wrap .aivt-product-result-empty {
            padding: 14px 16px;
            font-size: 13px;
            color: #94a3b8;
            text-align: center;
        }
        #aivt-settings-wrap .aivt-product-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 12px;
        }
        #aivt-settings-wrap .aivt-product-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: #eff6ff;
            border: 1px solid #bfdbfe;
            border-radius: 20px;
            padding: 5px 10px 5px 12px;
            font-size: 12px;
            font-weight: 500;
            color: #1e40af;
            max-width: 240px;
        }
        #aivt-settings-wrap .aivt-product-chip span {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        #aivt-settings-wrap .aivt-product-chip-remove {
            background: none;
            border: none;
            cursor: pointer;
            padding: 0;
            color: #93c5fd;
            font-size: 16px;
            line-height: 1;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            transition: color 0.15s;
        }
        #aivt-settings-wrap .aivt-product-chip-remove:hover { color: #1e40af; }
        #aivt-settings-wrap .aivt-product-search-loading {
            display: none;
            padding: 8px 0 0;
            font-size: 12px;
            color: #64748b;
        }

        /* Portal styles — outside #aivt-settings-wrap because portal is on <body> */
        #aivt-product-results-portal .aivt-product-result-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 14px;
            border-bottom: 1px solid #f1f5f9;
            transition: background 0.1s;
        }
        #aivt-product-results-portal .aivt-product-result-item:last-child { border-bottom: none; }
        #aivt-product-results-portal .aivt-product-result-item:not(.aivt-result-added):hover { background: #f0f9ff; }
        #aivt-product-results-portal .aivt-product-result-thumb {
            width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
            background: #f1f5f9; flex-shrink: 0; border: 1px solid #e2e8f0;
        }
        #aivt-product-results-portal .aivt-product-result-info { flex: 1; min-width: 0; }
        #aivt-product-results-portal .aivt-product-result-title {
            font-size: 13px; font-weight: 600; color: #0f172a;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        #aivt-product-results-portal .aivt-product-result-price { font-size: 11px; color: #64748b; margin-top: 1px; }
        #aivt-product-results-portal .aivt-product-result-add { font-size: 11px; font-weight: 600; color: #e8601c; flex-shrink: 0; }
        #aivt-product-results-portal .aivt-product-result-empty { padding: 14px 16px; font-size: 13px; color: #94a3b8; text-align: center; }

        /* ── Connection test result ── */
        #aivt-settings-wrap .aivt-test-result {
            margin-top: 12px;
            padding: 10px 14px;
            border-radius: 8px;
            font-size: 13px;
            display: none;
        }
        #aivt-settings-wrap .aivt-test-result.success {
            background: #dcfce7;
            color: #166534;
            border: 1px solid #bbf7d0;
        }
        #aivt-settings-wrap .aivt-test-result.error {
            background: #fef2f2;
            color: #991b1b;
            border: 1px solid #fecaca;
        }
        #aivt-settings-wrap .aivt-test-result.testing {
            background: #eff6ff;
            color: #1e40af;
            border: 1px solid #bfdbfe;
        }

        /* ── Save bar ── */
        #aivt-settings-wrap .aivt-card > .aivt-save-bar:last-child {
            border-radius: 0 0 12px 12px;
        }
        #aivt-settings-wrap .aivt-save-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 20px;
            background: #f8fafc;
            border-top: 1px solid #e2e8f0;
            margin-top: 0;
        }
        #aivt-settings-wrap .aivt-save-bar p {
            margin: 0;
            font-size: 12px;
            color: #94a3b8;
        }

        /* ── Setup guide ── */
        #aivt-settings-wrap .aivt-guide-steps {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 12px;
            margin: 0;
            padding: 0;
            list-style: none;
        }
        #aivt-settings-wrap .aivt-guide-steps li {
            display: flex;
            gap: 10px;
            align-items: flex-start;
            font-size: 13px;
            color: #475569;
            line-height: 1.5;
        }
        #aivt-settings-wrap .aivt-guide-step-num {
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background: #e8601c;
            color: #fff;
            font-size: 11px;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            margin-top: 1px;
        }

        /* ── Responsive ── */
        @media (max-width: 640px) {
            #aivt-settings-wrap .aivt-field { grid-template-columns: 1fr; gap: 6px; }
            #aivt-settings-wrap .aivt-label { padding-top: 0; }
        }
        
