/* =========================================================
   SCALE AI ENGINE — Frontend styles
   Brand: #FF5B8D (pink) · #732654 (maroon) · #142030 (navy)
   Inspired by the Scale Dashboard design system but built
   fresh for the AI setup wizard + live ops dashboard.
   ========================================================= */

.scaleai * { box-sizing: border-box; }
.scaleai a { color: inherit; }

/* Break out of constrained theme containers */
.scaleai {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    min-height: 100vh;
    padding: 28px 32px 80px;

    /* Brand tokens */
    --c-pink: #FF5B8D;
    --c-pink-2: #ff7ba5;
    --c-pink-soft: rgba(255, 91, 141, 0.12);
    --c-maroon: #732654;
    --c-cream: #E9D8C7;
    --c-slate: #85A3B3;
    --c-navy: #142030;
    --c-navy-2: #0F1A28;
    --c-navy-3: #1A2A3D;
    --c-navy-4: #1F3048;

    --c-green: #22c55e;
    --c-amber: #f59e0b;
    --c-red:   #ef4444;

    --c-text:        #ffffff;
    --c-text-2:      rgba(255, 255, 255, 0.78);
    --c-text-muted:  rgba(255, 255, 255, 0.55);
    --c-text-faint:  rgba(255, 255, 255, 0.38);

    --c-border:        rgba(255, 255, 255, 0.08);
    --c-border-strong: rgba(255, 255, 255, 0.16);

    --grad-brand:  linear-gradient(135deg, #FF5B8D 0%, #732654 100%);
    --grad-card:   linear-gradient(180deg, rgba(30, 46, 70, 0.55) 0%, rgba(20, 32, 48, 0.55) 100%);
    --grad-glow:   radial-gradient(900px 400px at 12% -10%, rgba(255, 91, 141, 0.14), transparent 60%);

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;

    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.32);
    --shadow-glow: 0 0 0 1px rgba(255, 91, 141, 0.28), 0 8px 28px rgba(255, 91, 141, 0.18);

    background: var(--c-navy);
    background-image: var(--grad-glow);
    color: var(--c-text);

    font-family: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.scaleai[dir="rtl"] {
    font-family: 'Cairo', 'Inter', -apple-system, sans-serif;
}

.scaleai h1, .scaleai h2, .scaleai h3 {
    font-family: 'Inter', 'Cairo', sans-serif;
    color: var(--c-text);
    margin: 0;
    letter-spacing: -0.015em;
}
.scaleai[dir="rtl"] h1, .scaleai[dir="rtl"] h2, .scaleai[dir="rtl"] h3 {
    font-family: 'Cairo', 'Inter', sans-serif;
}
.scaleai h1 { font-size: 32px; font-weight: 800; line-height: 1.18; }
.scaleai h2 { font-size: 20px; font-weight: 700; }
.scaleai h3 { font-size: 16px; font-weight: 700; }
.scaleai p  { color: var(--c-text-2); margin: 6px 0 0; }
.scaleai code {
    background: rgba(255,255,255,0.06);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    color: var(--c-cream);
}

/* ==================== TOPBAR ==================== */
.scaleai-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    margin-bottom: 28px;
    backdrop-filter: blur(8px);
}
.scaleai-brand { display: flex; align-items: center; gap: 14px; }
.scaleai-brand-logo {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: rgba(255, 91, 141, 0.10);
    display: grid; place-items: center;
    box-shadow: inset 0 0 0 1px rgba(255, 91, 141, 0.22);
}
.scaleai-brand-title { font-weight: 800; font-size: 16px; letter-spacing: 0.2px; }
.scaleai-brand-sub   { font-size: 12px; color: var(--c-text-muted); margin-top: 2px; }

.scaleai-topbar-right { display: flex; gap: 10px; align-items: center; }
.scaleai-user-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-border);
    color: var(--c-text-2);
    font-size: 13px;
    font-weight: 500;
}
.scaleai-user-dot, .scaleai-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--c-green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.scaleai-status-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.28);
    color: #b9f2cd;
    font-size: 12px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.scaleai-status-chip.is-off {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.28);
    color: #f9b6b6;
}
.scaleai-status-chip.is-off .scaleai-status-dot { background: var(--c-red); box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }

/* ==================== HERO (setup) ==================== */
.scaleai-hero {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 28px;
    margin-bottom: 32px;
}
@media (max-width: 900px) { .scaleai-hero { grid-template-columns: 1fr; } }

.scaleai-eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 700;
    color: var(--c-pink);
    background: var(--c-pink-soft);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 14px;
}
.scaleai-hero-text h1 { max-width: 580px; }
.scaleai-hero-text p { max-width: 540px; color: var(--c-text-2); margin-top: 12px; font-size: 15px; }

.scaleai-hero-card {
    background: var(--grad-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: grid;
    align-content: start;
    gap: 12px;
}
.scaleai-hero-card .scaleai-hero-stat {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--c-border);
}
.scaleai-hero-card .scaleai-hero-stat:last-child { border-bottom: 0; }
.scaleai-hero-card .scaleai-hero-stat-label { color: var(--c-text-muted); font-size: 13px; }
.scaleai-hero-card .scaleai-hero-stat-val   { font-weight: 700; }

.scaleai-skel {
    background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    background-size: 200% 100%;
    animation: scaleai-skel 1.4s ease-in-out infinite;
    border-radius: var(--r-sm);
}
@keyframes scaleai-skel { 0% { background-position: 0 0; } 100% { background-position: -200% 0; } }

/* ==================== STEPPER ==================== */
.scaleai-stepper {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 32px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 8px;
}
@media (max-width: 800px) {
    .scaleai-stepper { grid-template-columns: repeat(2, 1fr); }
}
.scaleai-step {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: start;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
}
.scaleai-step:hover { background: rgba(255,255,255,0.03); color: var(--c-text-2); }
.scaleai-step.is-active {
    background: var(--c-pink-soft);
    border-color: rgba(255, 91, 141, 0.35);
    color: var(--c-text);
}
.scaleai-step.is-done { color: var(--c-text-2); }
.scaleai-step.is-done .scaleai-step-num { background: var(--c-green); border-color: var(--c-green); color: #fff; }

.scaleai-step-num {
    width: 28px; height: 28px; flex: 0 0 28px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--c-border);
    font-weight: 700; font-size: 13px;
}
.scaleai-step.is-active .scaleai-step-num {
    background: var(--grad-brand);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(255,91,141,0.30);
}
.scaleai-step-label { font-weight: 600; }

/* ==================== PANELS ==================== */
.scaleai-main { display: grid; gap: 24px; }
.scaleai-panel { display: none; animation: scaleai-fade 0.3s ease; }
.scaleai-panel.is-active { display: block; }
@keyframes scaleai-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== CARDS ==================== */
.scaleai-card {
    background: var(--grad-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(6px);
    position: relative;
    overflow: hidden;
}
.scaleai-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 91, 141, 0.4), transparent);
    opacity: 0.6;
}
.scaleai-card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}
.scaleai-card-head p { font-size: 14px; }
.scaleai-card-celebrate {
    background: linear-gradient(180deg, rgba(255, 91, 141, 0.10) 0%, rgba(20, 32, 48, 0.55) 80%);
    border-color: rgba(255, 91, 141, 0.28);
}
.scaleai-card-faq { margin-top: 16px; }

/* ==================== PILLS ==================== */
.scaleai-pill {
    display: inline-flex; align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--c-border);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-2);
    white-space: nowrap;
}
.scaleai-pill-pink {
    background: var(--c-pink-soft);
    border-color: rgba(255, 91, 141, 0.32);
    color: var(--c-pink-2);
}
.scaleai-pill-hot   { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.32); color: #fca5a5; }
.scaleai-pill-warm  { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.32); color: #fcd34d; }
.scaleai-pill-cold  { background: rgba(133, 163, 179, 0.14); border-color: rgba(133, 163, 179, 0.30); color: #cbd5e1; }
.scaleai-pill-unknown { background: rgba(255, 255, 255, 0.04); color: var(--c-text-muted); }

/* ==================== FORMS ==================== */
.scaleai-form { display: grid; gap: 18px; }
.scaleai-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 720px) { .scaleai-grid-2 { grid-template-columns: 1fr; } }

.scaleai-field { display: grid; gap: 8px; }
.scaleai-field > span {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-2);
}
.scaleai-field input,
.scaleai-field select,
.scaleai-field textarea {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    color: var(--c-text);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.18s ease;
}
.scaleai-field input::placeholder,
.scaleai-field textarea::placeholder { color: var(--c-text-faint); }
.scaleai-field input:focus,
.scaleai-field select:focus,
.scaleai-field textarea:focus {
    outline: none;
    border-color: var(--c-pink);
    background: rgba(255, 91, 141, 0.06);
    box-shadow: 0 0 0 3px rgba(255, 91, 141, 0.14);
}
.scaleai-field select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23ffffff80' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.scaleai[dir="rtl"] .scaleai-field select { background-position: left 14px center; padding-right: 14px; padding-left: 36px; }

.scaleai-field textarea { resize: vertical; min-height: 80px; }

.scaleai-hint { font-size: 12px; color: var(--c-text-muted); }
.scaleai-hint.is-success { color: #86efac; }
.scaleai-hint.is-error   { color: #fca5a5; }

/* ==================== BUTTONS ==================== */
.scaleai-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 6px;
    flex-wrap: wrap;
}
.scaleai-actions-finish { justify-content: space-between; }
.scaleai[dir="rtl"] .scaleai-actions { justify-content: flex-start; }

.scaleai-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 22px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    white-space: nowrap;
}
.scaleai-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.scaleai-btn-primary {
    background: var(--grad-brand);
    color: #fff;
    box-shadow: 0 6px 18px rgba(255, 91, 141, 0.28);
}
.scaleai-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(255, 91, 141, 0.36);
}
.scaleai-btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--c-border);
    color: var(--c-text-2);
}
.scaleai-btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--c-border-strong);
    color: var(--c-text);
}
.scaleai-btn-launch {
    padding: 14px 28px;
    font-size: 15px;
    box-shadow: 0 0 0 1px rgba(255, 91, 141, 0.32), 0 14px 36px rgba(255, 91, 141, 0.32);
}

/* ==================== INFO BOX ==================== */
.scaleai-info-box {
    display: flex; gap: 14px;
    padding: 18px;
    background: rgba(255, 91, 141, 0.06);
    border: 1px dashed rgba(255, 91, 141, 0.28);
    border-radius: var(--r-md);
    margin-bottom: 22px;
    font-size: 14px;
    color: var(--c-text-2);
}
.scaleai-info-icon {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--grad-brand);
    color: #fff;
    font-weight: 700;
    display: grid; place-items: center;
    flex-shrink: 0;
    font-size: 13px;
}
.scaleai-info-box strong { color: var(--c-text); }

.scaleai-copy-row {
    display: flex; gap: 8px;
    margin-top: 8px;
}
.scaleai-copy-row input {
    flex: 1;
    padding: 9px 12px;
    background: rgba(0, 0, 0, 0.30);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    color: var(--c-cream);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 12.5px;
}
.scaleai-copy {
    padding: 9px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    color: var(--c-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: all 0.15s ease;
}
.scaleai-copy:hover { background: rgba(255, 91, 141, 0.18); border-color: var(--c-pink); }
.scaleai-copy.is-copied { background: var(--c-green); border-color: var(--c-green); color: #fff; }

.scaleai-test-result {
    padding: 14px 16px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 500;
    display: none;
}
.scaleai-test-result.is-success {
    display: block;
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.28);
    color: #b9f2cd;
}
.scaleai-test-result.is-error {
    display: block;
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.28);
    color: #fca5a5;
}

/* ==================== SUMMARY (finish step) ==================== */
.scaleai-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    margin-bottom: 22px;
}
.scaleai-summary-item { display: grid; gap: 4px; }
.scaleai-summary-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-muted); font-weight: 600; }
.scaleai-summary-value { font-weight: 700; font-size: 14px; word-break: break-all; }
.scaleai-summary-value .ok  { color: #86efac; }
.scaleai-summary-value .bad { color: #fca5a5; }

/* ==================== LIST (FAQ) ==================== */
.scaleai-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 12px; }
.scaleai-list li {
    display: flex; gap: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    color: var(--c-text-2);
    font-size: 14px;
}
.scaleai-bullet {
    width: 26px; height: 26px;
    flex: 0 0 26px;
    border-radius: 8px;
    background: var(--grad-brand);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: grid; place-items: center;
}

/* ==================== DASHBOARD KPIs ==================== */
.scaleai-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}
@media (max-width: 1100px) { .scaleai-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .scaleai-kpis { grid-template-columns: repeat(2, 1fr); } }

.scaleai-kpi {
    padding: 18px 20px;
    background: var(--grad-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    transition: all 0.2s ease;
}
.scaleai-kpi:hover {
    border-color: rgba(255, 91, 141, 0.32);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.scaleai-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-muted);
    font-weight: 600;
}
.scaleai-kpi-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: 6px;
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
}

/* ==================== DASHBOARD GRID ==================== */
.scaleai-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 1000px) { .scaleai-grid { grid-template-columns: 1fr; } }
.scaleai-card-wide { grid-column: 1 / -1; }

/* ==================== LEAD BARS ==================== */
.scaleai-leadbar { display: grid; gap: 16px; }
.scaleai-leadbar-row {
    display: grid;
    grid-template-columns: 90px 1fr 60px;
    align-items: center;
    gap: 14px;
    font-size: 14px;
}
.scaleai-leadbar-label { font-weight: 600; color: var(--c-text-2); }
.scaleai-leadbar-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.scaleai-leadbar-fill {
    display: block;
    height: 100%;
    background: var(--grad-brand);
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.scaleai-leadbar-row[data-status="hot"]    .scaleai-leadbar-fill { background: linear-gradient(90deg, #ef4444, #FF5B8D); }
.scaleai-leadbar-row[data-status="warm"]   .scaleai-leadbar-fill { background: linear-gradient(90deg, #f59e0b, #FF5B8D); }
.scaleai-leadbar-row[data-status="cold"]   .scaleai-leadbar-fill { background: linear-gradient(90deg, #85A3B3, #6b8a9b); }
.scaleai-leadbar-row[data-status="unknown"].scaleai-leadbar-fill { background: rgba(255,255,255,0.18); }
.scaleai-leadbar-num { font-weight: 700; text-align: end; font-size: 14px; }

/* ==================== CHART ==================== */
.scaleai-chart {
    height: 180px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 14px 0;
}
.scaleai-chart-bar {
    flex: 1;
    background: var(--grad-brand);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    opacity: 0.85;
    transition: all 0.18s ease;
    position: relative;
}
.scaleai-chart-bar:hover { opacity: 1; transform: scaleY(1.04); transform-origin: bottom; }
.scaleai-chart-bar[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%; transform: translateX(-50%);
    background: var(--c-navy-2);
    border: 1px solid var(--c-border-strong);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

/* ==================== TABLE ==================== */
.scaleai-table-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.scaleai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.scaleai-table th, .scaleai-table td {
    padding: 14px 16px;
    text-align: start;
    border-bottom: 1px solid var(--c-border);
}
.scaleai-table th {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    color: var(--c-text-muted);
    font-weight: 700;
    background: rgba(255,255,255,0.02);
}
.scaleai-table tbody tr { transition: background 0.15s ease; }
.scaleai-table tbody tr:hover { background: rgba(255,255,255,0.025); cursor: pointer; }
.scaleai-table tbody tr:last-child td { border-bottom: 0; }
.scaleai-empty {
    text-align: center;
    color: var(--c-text-muted);
    padding: 30px !important;
    font-size: 13.5px;
}
.scaleai-table .col-name {
    display: flex; flex-direction: column; gap: 2px;
}
.scaleai-table .col-name strong { font-weight: 600; color: var(--c-text); }
.scaleai-table .col-name small  { color: var(--c-text-muted); font-size: 12px; }
.scaleai-table .col-msg { color: var(--c-text-2); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scaleai-table .col-when { color: var(--c-text-muted); font-size: 12.5px; white-space: nowrap; }

.scaleai-link {
    color: var(--c-pink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.scaleai-link:hover { color: var(--c-pink-2); }

/* ==================== DRAWER ==================== */
.scaleai-drawer { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }
.scaleai-drawer[aria-hidden="false"] { pointer-events: auto; }
.scaleai-drawer-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
}
.scaleai-drawer[aria-hidden="false"] .scaleai-drawer-overlay { opacity: 1; }
.scaleai-drawer-panel {
    position: absolute;
    top: 0; bottom: 0; right: 0;
    width: min(560px, 100vw);
    background: var(--c-navy-2);
    border-left: 1px solid var(--c-border);
    transform: translateX(100%);
    transition: transform 0.30s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.scaleai[dir="rtl"] .scaleai-drawer-panel {
    right: auto; left: 0;
    border-left: 0;
    border-right: 1px solid var(--c-border);
    transform: translateX(-100%);
}
.scaleai-drawer[aria-hidden="false"] .scaleai-drawer-panel { transform: translateX(0); }
.scaleai-drawer-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 22px 24px;
    border-bottom: 1px solid var(--c-border);
}
.scaleai-drawer-head h3 { font-size: 17px; font-weight: 700; }
.scaleai-drawer-head p  { font-size: 13px; color: var(--c-text-muted); margin-top: 2px; }
.scaleai-drawer-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    border-radius: 50%;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    cursor: pointer;
    font-size: 22px; line-height: 1;
}
.scaleai-drawer-close:hover { background: rgba(255, 91, 141, 0.20); }
.scaleai-bubble-time { font-size: 11px; color: var(--c-text-faint); margin-top: 4px; display: block; }

/* drawer-body base — overridden by v1.4 block below */
.scaleai-drawer-body-PLACEHOLDER { display: none; }

/* ==================== UTIL ==================== */
.scaleai-login-required {
    text-align: center;
    padding: 60px 20px;
    background: var(--grad-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    color: var(--c-text);
}

.scaleai-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.30);
    border-top-color: #fff;
    border-radius: 50%;
    animation: scaleai-spin 0.7s linear infinite;
    margin-inline-end: 8px;
}
@keyframes scaleai-spin { to { transform: rotate(360deg); } }

/* ==================== TOAST ==================== */
.scaleai-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    background: var(--c-navy-2);
    border: 1px solid var(--c-border-strong);
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    font-family: var(--ff-sans);
    font-size: 14px;
    font-weight: 500;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 360px;
    pointer-events: none;
}
.scaleai[dir="rtl"] ~ .scaleai-toast,
[dir="rtl"] .scaleai-toast { right: auto; left: 24px; }
.scaleai-toast.show { transform: translateY(0); opacity: 1; }
.scaleai-toast.success { border-color: #22c55e; box-shadow: 0 10px 30px rgba(34,197,94,0.20); }
.scaleai-toast.error   { border-color: #ef4444; box-shadow: 0 10px 30px rgba(239,68,68,0.20); }
.scaleai-toast.success::before { content: "✓ "; color: #86efac; font-weight: 700; }
.scaleai-toast.error::before   { content: "✗ "; color: #fca5a5; font-weight: 700; }

/* Summary rows on finish step */
.scaleai-sum-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
    font-size: 14px;
}
.scaleai-sum-row:last-child { border-bottom: none; }
.scaleai-sum-row .label { color: var(--c-text-muted); }
.scaleai-sum-row .value { color: #fff; font-weight: 600; }

/* Refresh spin animation */
.scaleai-link.is-spinning { animation: scaleai-spin 0.6s linear; }

/* Drawer message timestamp */
.scaleai-bubble-empty {
    text-align: center;
    color: var(--c-text-muted);
    padding: 60px 20px;
    font-size: 14px;
}

/* ==================== UTILITIES (added) ==================== */
.scaleai-num    { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.scaleai-small  { font-size: 12px; }
.scaleai-muted  { color: var(--c-text-muted); }
.scaleai-truncate {
    max-width: 280px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Hero status card content */
.scaleai-hero-status-list {
    display: flex; flex-direction: column; gap: 10px;
}
.scaleai-hero-status-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--c-border);
    border-radius: 10px;
    font-size: 13px;
    transition: all 0.2s ease;
}
.scaleai-hero-status-row.is-ok {
    background: linear-gradient(90deg, rgba(255, 91, 141, 0.06), rgba(115, 38, 84, 0.04));
    border-color: rgba(255, 91, 141, 0.25);
}
.scaleai-hero-status-label {
    color: var(--c-text-muted); font-weight: 600; font-size: 12px;
    letter-spacing: 0.04em; text-transform: uppercase;
}
.scaleai-hero-status-val {
    color: #fff; font-weight: 600; font-size: 13px;
}
.scaleai-hero-wallet {
    margin-top: 14px; padding: 12px 14px;
    background: var(--grad-brand);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: space-between;
    color: #fff;
}
.scaleai-hero-wallet strong {
    color: #fff; font-size: 18px; font-weight: 800;
}
.scaleai-hero-wallet .scaleai-hero-status-label {
    color: rgba(255, 255, 255, 0.85);
}

/* Card / drawer action button group */
.scaleai-card-actions,
.scaleai-drawer-actions {
    display: flex; align-items: center; gap: 14px;
}
.scaleai-drawer-actions { gap: 10px; }
.scaleai-drawer-actions .scaleai-link {
    font-size: 13px; padding: 6px 10px;
    background: rgba(255, 91, 141, 0.12);
    border: 1px solid rgba(255, 91, 141, 0.25);
    border-radius: 8px;
    transition: all 0.18s ease;
}
.scaleai-drawer-actions .scaleai-link:hover {
    background: rgba(255, 91, 141, 0.22);
    border-color: rgba(255, 91, 141, 0.45);
}

/* =====================================================================
   GLASSMORPHISM SURFACES (v1.2)
   Used by .scaleai-glass and .scaleai-glass-strong on cards, drawer,
   notice banner, KPI tiles. Falls back gracefully on browsers without
   backdrop-filter (Firefox <103) by using a slightly more opaque bg.
   ===================================================================== */
.scaleai-glass {
    background: rgba(20, 32, 48, 0.55);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255,255,255,0.05);
}
.scaleai-glass-strong {
    background: rgba(15, 24, 38, 0.72);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
            backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.06);
}
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
    .scaleai-glass         { background: rgba(20, 32, 48, 0.92); }
    .scaleai-glass-strong  { background: rgba(15, 24, 38, 0.96); }
}

/* Privacy notice banner */
.scaleai-notice {
    margin: 18px 0 22px;
    padding: 14px 18px;
    border-radius: 14px;
    display: flex; align-items: center; gap: 12px;
    font-size: 14px; color: var(--c-text);
    border-left: 3px solid var(--c-pink-1);
}
.scaleai[dir="rtl"] .scaleai-notice {
    border-left: none; border-right: 3px solid var(--c-pink-1);
}
.scaleai-notice-icon { font-size: 18px; }
.scaleai-notice-text strong { color: var(--c-pink-1); font-weight: 700; }

/* =====================================================================
   CHAT BUBBLES — WhatsApp-like, white background, dark text, rounded
   ===================================================================== */
/* Drawer body — full-flex chat area: fixed header, scrollable messages, fixed composer */
.scaleai-drawer-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding: 20px 20px 12px;
    scroll-behavior: smooth;
}

/* =====================================================================
   MODE CHIP (AI active / Manual)
   ===================================================================== */
.scaleai-mode-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px;
    font-size: 12px; font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
    user-select: none;
}
.scaleai-mode-chip.is-ai {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.32);
    color: #86efac;
}
.scaleai-mode-chip.is-manual {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.32);
    color: #fcd34d;
}
.scaleai-mode-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
    animation: scaleai-pulse-dot 2s ease-in-out infinite;
}
@keyframes scaleai-pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

/* =====================================================================
   DRAWER TOOLBAR + KEBAB MENU
   ===================================================================== */
.scaleai-drawer-toolbar {
    display: flex; align-items: center; gap: 8px;
}
.scaleai-btn-ghost {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}
.scaleai-btn-ghost:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,91,141,0.35);
}
.scaleai-drawer-menu {
    position: relative;
}
.scaleai-drawer-menu-pop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: rgba(20, 32, 48, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    padding: 6px;
    display: none;
    z-index: 10;
}
.scaleai[dir="rtl"] .scaleai-drawer-menu-pop { right: auto; left: 0; }
.scaleai-drawer-menu.is-open .scaleai-drawer-menu-pop { display: block; }
.scaleai-drawer-menu-pop a {
    display: block;
    padding: 8px 12px;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.15s;
}
.scaleai-drawer-menu-pop a:hover { background: rgba(255, 91, 141, 0.14); }
.scaleai-drawer-menu-pop a.scaleai-link-danger:hover { background: rgba(239, 68, 68, 0.18); }

/* =====================================================================
   COMPOSER (manual reply input)
   ===================================================================== */
.scaleai-composer {
    display: flex; align-items: flex-end; gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(20, 32, 48, 0.40);
    -webkit-backdrop-filter: blur(10px);
            backdrop-filter: blur(10px);
}
.scaleai-composer textarea {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 140px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.18s ease, background 0.18s ease;
}
.scaleai-composer textarea:focus {
    outline: none;
    border-color: rgba(255, 91, 141, 0.50);
    background: rgba(255,255,255,0.10);
    box-shadow: 0 0 0 3px rgba(255, 91, 141, 0.14);
}
.scaleai-composer textarea::placeholder { color: rgba(255,255,255,0.45); }
.scaleai-btn-primary {
    background: var(--grad-brand);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}
.scaleai-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(255, 91, 141, 0.30);
}
.scaleai-btn-primary:disabled { opacity: 0.6; cursor: wait; }

/* Danger link variant */
.scaleai-link-danger { color: #fca5a5 !important; }
.scaleai-link-danger:hover { color: #fecaca !important; }

/* Drawer panel layout: fixed header, scrollable body, fixed composer */
.scaleai-drawer-panel {
    display: flex; flex-direction: column;
    height: 100vh;
}
.scaleai-drawer-head { flex: 0 0 auto; }
.scaleai-drawer-body { flex: 1 1 auto; }
.scaleai-composer    { flex: 0 0 auto; }

/* Responsive tweaks */
@media (max-width: 640px) {
    .scaleai-bubble { max-width: 88%; font-size: 13.5px; }
    .scaleai-drawer-toolbar { gap: 4px; }
    .scaleai-drawer-toolbar .scaleai-mode-chip { display: none; }
    .scaleai-composer { padding: 10px 12px; }
}

/* =====================================================================
   ROUTING CHOICE — radio cards on the WhatsApp setup step
   ===================================================================== */
.scaleai-routing-choice {
    border: none; padding: 0; margin: 0 0 22px 0;
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.scaleai-routing-choice legend {
    color: var(--c-text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding: 0;
}
.scaleai-radio-card {
    position: relative;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
}
.scaleai-radio-card:hover {
    border-color: rgba(255, 91, 141, 0.45);
    background: rgba(255, 91, 141, 0.05);
}
.scaleai-radio-card input[type="radio"] {
    width: 18px; height: 18px;
    accent-color: var(--c-pink-1);
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}
.scaleai-radio-card input[type="radio"]:checked + .scaleai-radio-card-body strong { color: var(--c-pink-1); }
.scaleai-radio-card:has(input[type="radio"]:checked) {
    border-color: var(--c-pink-1);
    background: linear-gradient(135deg, rgba(255, 91, 141, 0.08), rgba(115, 38, 84, 0.04));
    box-shadow: 0 4px 16px rgba(255, 91, 141, 0.12);
}
.scaleai-radio-card-body {
    display: flex; flex-direction: column; gap: 4px;
    flex: 1;
}
.scaleai-radio-card-body strong {
    font-size: 14px;
    color: #fff;
    font-weight: 700;
}
.scaleai-radio-card-body small {
    font-size: 12px;
    color: var(--c-text-muted);
    line-height: 1.45;
}
.scaleai-routing-section {
    margin-top: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--c-border);
    border-radius: 10px;
    margin-bottom: 18px;
}

@media (max-width: 640px) {
    .scaleai-routing-choice { grid-template-columns: 1fr; }
}

/* =====================================================================
   KNOWLEDGE BASE — dropzone + file list (v1.3)
   ===================================================================== */
.scaleai-dropzone {
    border: 2px dashed rgba(255, 91, 141, 0.30);
    border-radius: 14px;
    padding: 30px 20px;
    text-align: center;
    background: rgba(255, 91, 141, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 14px 0 18px;
}
.scaleai-dropzone:hover, .scaleai-dropzone.is-dragover {
    border-color: var(--c-pink-1);
    background: rgba(255, 91, 141, 0.10);
    transform: translateY(-1px);
}
.scaleai-dropzone-inner {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.scaleai-dropzone-icon { font-size: 32px; }
.scaleai-dropzone strong {
    color: #fff; font-size: 15px;
}
.scaleai-dropzone small { color: var(--c-text-muted); font-size: 12px; }

.scaleai-kb-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 18px;
}
.scaleai-kb-item {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-border);
    border-radius: 10px;
    transition: all 0.18s ease;
}
.scaleai-kb-item:hover { background: rgba(255, 255, 255, 0.06); }
.scaleai-kb-icon {
    font-size: 22px; width: 36px; text-align: center;
}
.scaleai-kb-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scaleai-kb-meta strong { color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scaleai-kb-meta small { color: var(--c-text-muted); font-size: 12px; }
.scaleai-kb-item.is-processing .scaleai-kb-meta small { color: #fcd34d; }
.scaleai-kb-item.is-failed     .scaleai-kb-meta small { color: #fca5a5; }
.scaleai-kb-item.is-ready      .scaleai-kb-meta small { color: #86efac; }
.scaleai-kb-del {
    background: transparent; color: var(--c-text-muted);
    border: none; font-size: 22px; line-height: 1;
    cursor: pointer; padding: 4px 10px; border-radius: 6px;
    transition: all 0.15s;
}
.scaleai-kb-del:hover { color: #fca5a5; background: rgba(239, 68, 68, 0.10); }

/* =====================================================================
   CONNECT WHATSAPP button (FB-style) + connected card
   ===================================================================== */
.scaleai-connect-area { text-align: center; padding: 20px 0; }
.scaleai-btn-connect {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 14px 28px;
    background: #1877F2;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.30);
    transition: all 0.2s ease;
}
.scaleai-btn-connect:hover:not(:disabled) {
    background: #166FE5;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(24, 119, 242, 0.40);
}
.scaleai-btn-connect:disabled { opacity: 0.55; cursor: not-allowed; }
.scaleai-fb-icon {
    width: 22px; height: 22px;
    background: #fff;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z'/></svg>") center/contain no-repeat;
}

.scaleai-connected-card {
    margin-top: 18px;
    padding: 18px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.02));
    border: 1px solid rgba(34, 197, 94, 0.30);
    border-radius: 12px;
}
.scaleai-connected-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 14px;
}
.scaleai-connected-row:last-of-type { border-bottom: none; margin-bottom: 14px; }
.scaleai-connected-label { color: var(--c-text-muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.scaleai-connected-row strong, .scaleai-connected-row code { color: #fff; font-weight: 600; }
.scaleai-connected-row code { font-family: ui-monospace, monospace; font-size: 12px; padding: 2px 6px; background: rgba(255,255,255,0.06); border-radius: 4px; }

/* Warning info box variant */
.scaleai-info-warn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02)) !important;
    border-color: rgba(245, 158, 11, 0.32) !important;
}
.scaleai-info-warn .scaleai-info-icon { color: #fcd34d; }

/* =====================================================================
   MASTER AI TOGGLE (dashboard topbar) — iOS-style switch
   ===================================================================== */
.scaleai-master-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--c-border);
    transition: all 0.18s ease;
}
.scaleai-master-toggle:hover { background: rgba(255,255,255,0.07); }
.scaleai-master-toggle input { display: none; }
.scaleai-master-track {
    position: relative;
    width: 36px; height: 20px;
    background: rgba(34, 197, 94, 0.45);
    border-radius: 999px;
    transition: background 0.2s ease;
}
.scaleai-master-thumb {
    position: absolute; top: 2px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.20);
}
.scaleai-master-toggle.is-off .scaleai-master-track { background: rgba(239, 68, 68, 0.55); }
/* checked state — drive thumb position from input */
.scaleai-master-toggle input:checked + .scaleai-master-track .scaleai-master-thumb { left: 18px; }
.scaleai-master-toggle input:not(:checked) + .scaleai-master-track .scaleai-master-thumb { left: 2px; }
.scaleai-master-label {
    font-size: 12px; font-weight: 700;
    color: #86efac;
    letter-spacing: 0.04em;
}
.scaleai-master-toggle.is-off .scaleai-master-label { color: #fca5a5; }

/* =====================================================================
   GENERIC MODAL (used for KB + Prompt editors on the dashboard)
   ===================================================================== */
.scaleai-modal {
    position: fixed; inset: 0;
    z-index: 9999;
    display: none;
}
.scaleai-modal.is-open { display: block; }
.scaleai-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.scaleai-modal-panel {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(640px, 92vw);
    max-height: 88vh;
    border-radius: 14px;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: scaleai-modal-in 0.2s ease-out;
}
@keyframes scaleai-modal-in {
    from { opacity: 0; transform: translate(-50%, -48%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}
.scaleai-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}
.scaleai-modal-head h3 { color: #fff; font-size: 16px; margin: 0; font-weight: 700; }
.scaleai-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ====================================================================
   ===                                                              ===
   ===   v1.4 — DESIGN OVERHAUL                                     ===
   ===   This block sits at the END of the stylesheet and overrides ===
   ===   anything earlier when there's a conflict. The earlier rules ===
   ===   stay so the codebase keeps working; this section makes the ===
   ===   final look. Treat it as "the design system."               ===
   ===                                                              ===
   ==================================================================== */

.scaleai {
    /* Reset our local color palette to a more sophisticated dark theme */
    --c-bg-1:        #0A0E1A;
    --c-bg-2:        #0F1626;
    --c-surface-0:   rgba(255, 255, 255, 0.025);
    --c-surface-1:   rgba(255, 255, 255, 0.045);
    --c-surface-2:   rgba(255, 255, 255, 0.075);
    --c-surface-hi:  rgba(255, 255, 255, 0.10);
    --c-border-1:    rgba(255, 255, 255, 0.06);
    --c-border-2:    rgba(255, 255, 255, 0.10);
    --c-border-3:    rgba(255, 255, 255, 0.16);
    --c-text:        rgba(255, 255, 255, 0.92);
    --c-text-2:      rgba(255, 255, 255, 0.66);
    --c-text-3:      rgba(255, 255, 255, 0.45);
    --c-pink:        #FF5B8D;
    --c-pink-2:      #FF7BA8;
    --c-pink-deep:   #C73265;
    --c-maroon:      #732654;
    --c-emerald:     #10B981;
    --c-amber:       #F59E0B;
    --c-red:         #EF4444;
    --c-blue:        #3B82F6;

    /* Typography */
    --ff-ui:    'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ff-mono:  ui-monospace, 'SF Mono', Menlo, Monaco, monospace;

    /* Spacing scale */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

    /* Radii */
    --r-sm: 6px;  --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

    /* Shadows */
    --sh-1: 0 1px 2px rgba(0,0,0,0.10);
    --sh-2: 0 4px 12px rgba(0,0,0,0.18);
    --sh-3: 0 12px 32px rgba(0,0,0,0.32);
    --sh-glow: 0 0 0 1px rgba(255,91,141,0.20), 0 8px 24px rgba(255,91,141,0.18);

    /* Background — refined gradient w/ subtle ambient orbs */
    background:
        radial-gradient(900px 600px at 88% -10%,  rgba(255, 91, 141, 0.12), transparent 60%),
        radial-gradient(800px 600px at -10% 90%, rgba(115, 38, 84, 0.18), transparent 60%),
        linear-gradient(180deg, var(--c-bg-1) 0%, var(--c-bg-2) 100%);
    color: var(--c-text);
    font-family: var(--ff-ui);
    font-feature-settings: "ss01", "cv01", "cv11";
    min-height: 100vh;
    padding: var(--s-6);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----- Topbar ----- */
.scaleai-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-4) var(--s-5);
    margin-bottom: var(--s-6);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--c-border-1);
    border-radius: var(--r-lg);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
            backdrop-filter: blur(20px) saturate(140%);
}
.scaleai-brand { display: flex; align-items: center; gap: var(--s-3); }
.scaleai-brand-logo {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, rgba(255,91,141,0.18), rgba(115,38,84,0.14));
    border: 1px solid rgba(255,91,141,0.25);
}
.scaleai-brand-title {
    font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
    color: #fff;
}
.scaleai-brand-sub {
    font-size: 12px; color: var(--c-text-3);
    margin-top: 1px;
}
.scaleai-topbar-right {
    display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
}

/* ----- Status chip ----- */
.scaleai-status-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: rgba(16, 185, 129, 0.10);
    border: 1px solid rgba(16, 185, 129, 0.30);
    color: #6EE7B7;
}
.scaleai-status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: scaleai-pulse 2s ease-in-out infinite;
}
@keyframes scaleai-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.9); }
}
.scaleai-status-chip.scaleai-status-off {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.30);
    color: #FCA5A5;
}

/* ----- Topbar links ----- */
.scaleai-topbar-right .scaleai-link {
    color: var(--c-text-2);
    font-size: 13px; font-weight: 500;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    transition: all 0.15s ease;
}
.scaleai-topbar-right .scaleai-link:hover {
    background: var(--c-surface-2);
    color: #fff;
}

/* ----- Master toggle (refined) ----- */
.scaleai-master-toggle {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.30);
    padding: 5px 12px 5px 8px;
}
.scaleai-master-toggle.is-off {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.30);
}
.scaleai-master-track   { background: rgba(16, 185, 129, 0.55); }
.scaleai-master-toggle.is-off .scaleai-master-track { background: rgba(239, 68, 68, 0.55); }
.scaleai-master-thumb   { box-shadow: 0 1px 3px rgba(0,0,0,0.30), 0 0 0 1px rgba(0,0,0,0.05); }
.scaleai-master-label   { color: #6EE7B7; }
.scaleai-master-toggle.is-off .scaleai-master-label { color: #FCA5A5; }

/* ----- Privacy notice (refined) ----- */
.scaleai-notice {
    margin: 0 0 var(--s-6);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-left-width: 3px;
    font-size: 13px; color: var(--c-text-2);
    display: flex; align-items: center; gap: var(--s-3);
}
.scaleai[dir="rtl"] .scaleai-notice {
    border-left-width: 1px; border-right-width: 3px;
    border-right-color: rgba(59, 130, 246, 0.30);
}
.scaleai-notice-text strong { color: #93C5FD; font-weight: 700; }

/* ===========================  KPI ROW  =========================== */
.scaleai-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--s-3);
    margin-bottom: var(--s-6);
}
.scaleai-kpi {
    padding: var(--s-4) var(--s-5);
    border-radius: var(--r-lg);
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-1);
    position: relative;
    overflow: hidden;
    transition: all 0.18s ease;
}
.scaleai-kpi:hover {
    background: var(--c-surface-2);
    border-color: var(--c-border-2);
    transform: translateY(-1px);
}
.scaleai-kpi::before {
    content: '';
    position: absolute; inset: 0; bottom: auto;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,91,141,0.45), transparent);
    opacity: 0; transition: opacity 0.2s;
}
.scaleai-kpi:hover::before { opacity: 1; }
.scaleai-kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: var(--s-2);
}
.scaleai-kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    font-feature-settings: "tnum" 1;
}
.scaleai-kpi.hot .scaleai-kpi-value { color: #FCA5A5; }

@media (max-width: 1100px) { .scaleai-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .scaleai-kpis { grid-template-columns: repeat(2, 1fr); } }

/* ===========================  GRID  =========================== */
.scaleai-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4);
}
.scaleai-card-wide { grid-column: 1 / -1; }

@media (max-width: 900px) {
    .scaleai-grid { grid-template-columns: 1fr; }
}

/* ----- Cards ----- */
.scaleai-card {
    padding: var(--s-5);
    border-radius: var(--r-lg);
    background: var(--c-surface-0);
    border: 1px solid var(--c-border-1);
}
.scaleai-card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--s-4); gap: var(--s-3);
}
.scaleai-card-head h2 {
    font-size: 15px; font-weight: 700;
    margin: 0; color: #fff;
    letter-spacing: -0.01em;
}
.scaleai-card-head .scaleai-pill {
    font-size: 11px; font-weight: 600;
    padding: 3px 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--c-border-1);
    color: var(--c-text-3);
}
.scaleai-card-actions { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.scaleai-card-actions .scaleai-link {
    font-size: 12px; font-weight: 500;
    color: var(--c-text-2);
    padding: 5px 10px; border-radius: var(--r-sm);
    text-decoration: none;
    transition: all 0.15s ease;
}
.scaleai-card-actions .scaleai-link:hover { background: var(--c-surface-2); color: #fff; }
.scaleai-card-actions .scaleai-link-danger { color: #FCA5A5; }
.scaleai-card-actions .scaleai-link-danger:hover { background: rgba(239,68,68,0.12); color: #FECACA; }

/* ----- Lead breakdown ----- */
.scaleai-leadbar { display: flex; flex-direction: column; gap: var(--s-3); }
.scaleai-leadbar-row {
    display: grid;
    grid-template-columns: 80px 1fr 50px;
    align-items: center;
    gap: var(--s-3);
}
.scaleai-leadbar-label {
    font-size: 12px; font-weight: 600;
    color: var(--c-text-2);
}
.scaleai-leadbar-track {
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 999px;
    overflow: hidden;
}
.scaleai-leadbar-fill {
    height: 100%; border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.scaleai-leadbar-row[data-status="hot"]     .scaleai-leadbar-fill { background: linear-gradient(90deg, #EF4444, #F87171); }
.scaleai-leadbar-row[data-status="warm"]    .scaleai-leadbar-fill { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.scaleai-leadbar-row[data-status="cold"]    .scaleai-leadbar-fill { background: linear-gradient(90deg, #6B7280, #9CA3AF); }
.scaleai-leadbar-row[data-status="unknown"] .scaleai-leadbar-fill { background: linear-gradient(90deg, #4B5563, #6B7280); }
.scaleai-leadbar-num {
    font-size: 13px; font-weight: 700; color: #fff;
    text-align: right;
    font-feature-settings: "tnum" 1;
}

/* ----- Replies/day chart ----- */
.scaleai-chart {
    display: flex; align-items: flex-end;
    gap: 4px; height: 130px;
    padding: var(--s-2) 0;
}
.scaleai-chart-bar {
    flex: 1;
    min-width: 6px;
    background: linear-gradient(180deg, var(--c-pink) 0%, var(--c-maroon) 100%);
    border-radius: 4px 4px 0 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    opacity: 0.85;
    position: relative;
}
.scaleai-chart-bar:hover {
    opacity: 1;
    transform: scaleY(1.05);
    transform-origin: bottom;
}
.scaleai-chart-bar[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%; left: 50%; transform: translateX(-50%) translateY(-4px);
    padding: 4px 8px;
    background: #fff; color: #0F1626;
    border-radius: 4px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--sh-2);
    pointer-events: none;
    z-index: 10;
}

/* ----- Tables ----- */
.scaleai-table-wrap { overflow-x: auto; margin: 0 -8px; }
.scaleai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.scaleai-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px; font-weight: 600;
    color: var(--c-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--c-border-1);
}
.scaleai[dir="rtl"] .scaleai-table th { text-align: right; }
.scaleai-table td {
    padding: 12px;
    border-bottom: 1px solid var(--c-border-1);
    vertical-align: middle;
    color: var(--c-text);
}
.scaleai-table tbody tr {
    transition: background 0.12s ease;
}
.scaleai-table tbody tr:hover { background: var(--c-surface-1); }
.scaleai-table tbody tr.row-click { cursor: pointer; }
.scaleai-table strong { color: #fff; font-weight: 600; }
.scaleai-table .scaleai-num { text-align: right; font-feature-settings: "tnum" 1; }
.scaleai-table tr:last-child td { border-bottom: none; }

/* Pills */
.scaleai-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    border: 1px solid;
    line-height: 1;
}
.scaleai-pill-hot     { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.32); color: #FCA5A5; }
.scaleai-pill-warm    { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.32); color: #FCD34D; }
.scaleai-pill-cold    { background: rgba(107, 114, 128, 0.14); border-color: rgba(107, 114, 128, 0.30); color: #CBD5E1; }
.scaleai-pill-unknown { background: rgba(255,255,255,0.04); border-color: var(--c-border-1); color: var(--c-text-3); }

/* ----- Empty state ----- */
.scaleai-empty {
    text-align: center;
    padding: var(--s-7) var(--s-4);
    color: var(--c-text-3);
    font-size: 13px;
}

/* ----- Drawer (refined) ----- */
.scaleai-drawer {
    position: fixed; inset: 0;
    z-index: 99999;
    pointer-events: none;
    visibility: hidden;
    /* Stay visible for the full slide-out (0.34s) before snapping to hidden,
       otherwise visibility flips instantly and the close animation never plays. */
    transition: visibility 0s linear 0.34s;
}
.scaleai-drawer.is-open {
    pointer-events: auto;
    visibility: visible;
    transition: visibility 0s linear 0s; /* become visible immediately on open */
}
.scaleai-drawer-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0; transition: opacity 0.3s ease;
}
.scaleai-drawer.is-open .scaleai-drawer-overlay { opacity: 1; }
.scaleai-drawer-panel {
    position: absolute; top: 0; bottom: 0;
    inset-inline-end: 0;
    width: min(560px, 100vw);
    background: rgba(15, 22, 38, 0.94);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
            backdrop-filter: blur(28px) saturate(150%);
    border-inline-start: 1px solid var(--c-border-2);
    box-shadow: -16px 0 48px rgba(0, 0, 0, 0.35);
    transform: translateX(100%);
    opacity: 0;
    will-change: transform, opacity;
    /* Slide + a touch of fade, with a slightly slower, eased close for a premium feel. */
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1),
                opacity   0.26s ease;
    display: flex; flex-direction: column;
}
.scaleai[dir="rtl"] .scaleai-drawer-panel {
    inset-inline-end: 0; inset-inline-start: 0; right: auto; left: 0;
    transform: translateX(-100%);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.35);
}
.scaleai-drawer.is-open .scaleai-drawer-panel {
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1),
                opacity   0.3s ease;
}

.scaleai-drawer-head {
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--c-border-1);
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--s-3);
}
.scaleai-drawer-title h3 {
    margin: 0;
    font-size: 15px; font-weight: 700; color: #fff;
}
.scaleai-drawer-title p {
    margin: 2px 0 0; font-size: 12px;
    color: var(--c-text-3);
}
.scaleai-drawer-close {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border: 1px solid var(--c-border-1);
    background: var(--c-surface-1);
    color: var(--c-text-2);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 18px; line-height: 1;
    transition: all 0.15s ease;
}
.scaleai-drawer-close:hover {
    background: var(--c-surface-2);
    color: #fff;
}

/* Drawer body — chat area visual override (layout comes from earlier flex definition) */
.scaleai-drawer-body {
    background:
        radial-gradient(ellipse 80% 40% at 50% 0%, rgba(255, 91, 141, 0.05), transparent 70%),
        linear-gradient(180deg, rgba(10,14,26,0.6) 0%, rgba(15,22,38,0.4) 100%);
}

/* ===== CHAT BUBBLES (definitive v1.4) ===== */
.scaleai-bubble {
    max-width: 80%;
    padding: 10px 14px 8px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: transform 0.15s ease;
}
.scaleai-bubble:hover { transform: translateY(-1px); }

/* User bubble = person chatting via WhatsApp (LTR: left side) */
.scaleai-bubble-user {
    background: #fff;
    color: #1a2030;
    align-self: flex-start;
    border-radius: 18px 18px 18px 4px;
    margin-right: auto;
    border: none;
}
/* AI/assistant bubble (LTR: right side, branded) */
.scaleai-bubble-assistant {
    background: linear-gradient(135deg, #FF5B8D 0%, #C73265 100%);
    color: #fff;
    align-self: flex-end;
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
    box-shadow: 0 3px 10px rgba(255, 91, 141, 0.30);
}
.scaleai-bubble-assistant .scaleai-bubble-time { color: rgba(255,255,255,0.65); }
.scaleai-bubble-user .scaleai-bubble-time { color: #9CA3AF; }
.scaleai-bubble-time {
    display: block; margin-top: 3px;
    font-size: 10.5px; opacity: 1;
}
/* RTL flip */
.scaleai[dir="rtl"] .scaleai-bubble-user {
    align-self: flex-end; border-radius: 18px 18px 4px 18px;
    margin-right: 0; margin-left: auto;
}
.scaleai[dir="rtl"] .scaleai-bubble-assistant {
    align-self: flex-start; border-radius: 18px 18px 18px 4px;
    margin-left: 0; margin-right: auto;
}

/* Date separator */
.scaleai-chat-date {
    text-align: center;
    font-size: 11px; font-weight: 600;
    color: var(--c-text-3);
    padding: 4px 0 8px;
    letter-spacing: 0.04em;
}

/* Composer */
.scaleai-composer {
    background: rgba(15, 22, 38, 0.86);
    -webkit-backdrop-filter: blur(20px);
            backdrop-filter: blur(20px);
    border-top: 1px solid var(--c-border-1);
    padding: var(--s-3) var(--s-4);
    gap: var(--s-3);
}
.scaleai-composer textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-border-2);
    color: #fff;
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 14px;
    transition: all 0.15s ease;
}
.scaleai-composer textarea:focus {
    outline: none;
    border-color: rgba(255, 91, 141, 0.50);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(255, 91, 141, 0.14);
}
.scaleai-btn-primary {
    background: linear-gradient(135deg, var(--c-pink) 0%, var(--c-pink-deep) 100%);
    color: #fff; border: none;
    padding: 10px 18px;
    border-radius: var(--r-md);
    font-size: 13px; font-weight: 700;
    letter-spacing: -0.005em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(199, 50, 101, 0.35);
    transition: all 0.18s ease;
}
.scaleai-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(199, 50, 101, 0.45);
}
.scaleai-btn-primary:disabled {
    opacity: 0.5; cursor: wait;
    transform: none; box-shadow: none;
}
.scaleai-btn-ghost {
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-2);
    color: var(--c-text);
    padding: 10px 18px;
    border-radius: var(--r-md);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.scaleai-btn-ghost:hover {
    background: var(--c-surface-2);
    border-color: var(--c-border-3);
}

/* ===========================  SETUP WIZARD  =========================== */
.scaleai-hero {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: var(--s-6);
    margin-bottom: var(--s-6);
    align-items: center;
}
.scaleai-hero-text h1 {
    font-size: 32px; font-weight: 800;
    color: #fff;
    margin: 0 0 var(--s-3);
    letter-spacing: -0.025em;
    line-height: 1.15;
    background: linear-gradient(135deg, #fff 0%, #FFC0D6 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}
.scaleai-hero-sub {
    font-size: 15px;
    color: var(--c-text-2);
    margin: 0;
    max-width: 540px;
    line-height: 1.6;
}
@media (max-width: 900px) {
    .scaleai-hero { grid-template-columns: 1fr; }
    .scaleai-hero-text h1 { font-size: 26px; }
}

/* Hero status card */
#scaleai-hero-status {
    padding: var(--s-4);
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-2);
    border-radius: var(--r-lg);
}
.scaleai-hero-status-list { display: flex; flex-direction: column; gap: var(--s-2); }
.scaleai-hero-status-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.025);
    border-radius: var(--r-sm);
    border: 1px solid var(--c-border-1);
    transition: all 0.18s ease;
}
.scaleai-hero-status-row.is-ok {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.06), transparent);
    border-color: rgba(16, 185, 129, 0.20);
}
.scaleai-hero-status-label {
    font-size: 11px; font-weight: 600;
    color: var(--c-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.scaleai-hero-status-val {
    font-size: 13px; font-weight: 600;
    color: #fff;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

/* ----- Stepper ----- */
.scaleai-stepper {
    list-style: none;
    margin: 0 0 var(--s-6);
    padding: var(--s-2);
    background: var(--c-surface-0);
    border: 1px solid var(--c-border-1);
    border-radius: var(--r-xl);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}
.scaleai-step {
    display: flex; align-items: center; gap: var(--s-2);
    padding: 10px var(--s-3);
    border-radius: var(--r-md);
    cursor: pointer;
    color: var(--c-text-3);
    transition: all 0.18s ease;
    overflow: hidden;
}
.scaleai-step:hover { background: var(--c-surface-1); color: var(--c-text); }
.scaleai-step.is-active {
    background: linear-gradient(135deg, var(--c-pink) 0%, var(--c-pink-deep) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 91, 141, 0.30);
}
.scaleai-step.is-done {
    color: var(--c-text);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.24);
}
.scaleai-step-num {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    font-size: 11px; font-weight: 700;
    flex-shrink: 0;
}
.scaleai-step.is-active .scaleai-step-num { background: rgba(255,255,255,0.30); }
.scaleai-step.is-done   .scaleai-step-num { background: var(--c-emerald); color: #fff; }
.scaleai-step.is-done   .scaleai-step-num::before { content: '✓'; }
.scaleai-step.is-done   .scaleai-step-num span { display: none; }
.scaleai-step-label {
    font-size: 13px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 700px) {
    .scaleai-stepper { grid-template-columns: 1fr; }
    .scaleai-step.is-active { box-shadow: none; }
    .scaleai-step:not(.is-active) .scaleai-step-label { display: none; }
}

/* ----- Panel (each step body) ----- */
.scaleai-panel { display: none; }
.scaleai-panel.is-active {
    display: block;
    animation: scaleai-fade-up 0.3s ease;
}
@keyframes scaleai-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Card description text under headers */
.scaleai-card-desc {
    color: var(--c-text-2);
    font-size: 14px;
    line-height: 1.65;
    margin: 0 0 var(--s-5);
    max-width: 640px;
}

/* ----- Forms ----- */
.scaleai-form { display: flex; flex-direction: column; gap: var(--s-4); }
.scaleai-grid-2 {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4);
}
@media (max-width: 600px) { .scaleai-grid-2 { grid-template-columns: 1fr; } }
.scaleai-field {
    display: flex; flex-direction: column; gap: 6px;
}
.scaleai-field > span {
    font-size: 12px; font-weight: 600;
    color: var(--c-text-2);
    letter-spacing: -0.005em;
}
.scaleai-field input[type="text"],
.scaleai-field input[type="password"],
.scaleai-field input[type="email"],
.scaleai-field input[type="number"],
.scaleai-field textarea,
.scaleai-field select {
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-2);
    color: #fff;
    padding: 11px 14px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.15s ease;
    width: 100%;
}
.scaleai-field input:focus,
.scaleai-field textarea:focus,
.scaleai-field select:focus {
    outline: none;
    border-color: rgba(255, 91, 141, 0.50);
    background: var(--c-surface-2);
    box-shadow: 0 0 0 3px rgba(255, 91, 141, 0.14);
}
.scaleai-field input::placeholder,
.scaleai-field textarea::placeholder { color: var(--c-text-3); }
.scaleai-field textarea { font-family: var(--ff-mono); font-size: 13px; }
.scaleai-field select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}
.scaleai[dir="rtl"] .scaleai-field select {
    background-position: left 14px center;
    padding-right: 14px; padding-left: 38px;
}
.scaleai-hint { font-size: 12px; color: var(--c-text-3); }
.scaleai-hint.is-success { color: #6EE7B7; }
.scaleai-hint.is-error   { color: #FCA5A5; }

.scaleai-actions {
    display: flex; align-items: center; gap: var(--s-3);
    padding-top: var(--s-3);
    flex-wrap: wrap;
}

/* ----- Test result inline ----- */
.scaleai-test-result {
    margin-top: var(--s-3);
    padding: 10px 14px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    display: none;
}
.scaleai-test-result:not(:empty) { display: block; }
.scaleai-test-result.is-success {
    background: rgba(16, 185, 129, 0.10);
    border: 1px solid rgba(16, 185, 129, 0.30);
    color: #6EE7B7;
}
.scaleai-test-result.is-error {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.30);
    color: #FCA5A5;
}
.scaleai-test-result.is-pending { background: var(--c-surface-1); color: var(--c-text-2); }

/* ----- Info box ----- */
.scaleai-info-box {
    display: flex; gap: var(--s-3);
    padding: var(--s-4);
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-2);
    border-radius: var(--r-md);
    margin: var(--s-3) 0;
}
.scaleai-info-icon { font-size: 22px; flex-shrink: 0; }
.scaleai-info-box strong { display: block; font-weight: 700; color: #fff; margin-bottom: 4px; font-size: 14px; }
.scaleai-info-box small { color: var(--c-text-2); font-size: 13px; line-height: 1.6; }
.scaleai-info-warn {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.28);
}
.scaleai-info-warn .scaleai-info-icon { color: #FCD34D; }

/* ----- Connect WhatsApp button (refined) ----- */
.scaleai-connect-area {
    text-align: center;
    padding: var(--s-6);
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-2);
    border-radius: var(--r-md);
}
.scaleai-btn-connect {
    display: inline-flex; align-items: center; gap: 10px;
    background: #1877F2;
    color: #fff;
    padding: 13px 28px;
    border-radius: var(--r-md);
    border: none;
    font-size: 14px; font-weight: 700;
    letter-spacing: -0.005em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.30);
    transition: all 0.18s ease;
    font-family: inherit;
}
.scaleai-btn-connect:hover:not(:disabled) {
    background: #166FE5;
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(24, 119, 242, 0.42);
}
.scaleai-btn-connect:disabled { opacity: 0.55; cursor: not-allowed; }

/* ----- Connected card ----- */
.scaleai-connected-card {
    margin-top: var(--s-4);
    padding: var(--s-5);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, transparent 100%);
    border: 1px solid rgba(16, 185, 129, 0.28);
    border-radius: var(--r-md);
}
.scaleai-connected-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--s-3) 0;
    border-bottom: 1px solid var(--c-border-1);
    font-size: 13px;
}
.scaleai-connected-row:last-of-type { border-bottom: none; margin-bottom: var(--s-3); }
.scaleai-connected-label {
    font-size: 11px; font-weight: 600;
    color: var(--c-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.scaleai-connected-row strong { color: #fff; font-weight: 600; }
.scaleai-connected-row code {
    font-family: var(--ff-mono); font-size: 12px;
    color: #fff;
    padding: 3px 7px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--c-border-1);
    border-radius: 4px;
}

/* ----- Knowledge Base dropzone (refined) ----- */
.scaleai-dropzone {
    border: 2px dashed rgba(255, 91, 141, 0.30);
    border-radius: var(--r-lg);
    padding: var(--s-7) var(--s-5);
    text-align: center;
    background: linear-gradient(180deg, rgba(255, 91, 141, 0.04) 0%, transparent 100%);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: var(--s-4) 0;
}
.scaleai-dropzone:hover, .scaleai-dropzone.is-dragover {
    border-color: var(--c-pink);
    background: linear-gradient(180deg, rgba(255, 91, 141, 0.10) 0%, transparent 100%);
    transform: translateY(-1px);
}
.scaleai-dropzone-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: var(--s-2);
}
.scaleai-dropzone-icon { font-size: 36px; opacity: 0.85; }
.scaleai-dropzone strong {
    color: #fff; font-size: 15px; font-weight: 700;
}
.scaleai-dropzone small { color: var(--c-text-3); font-size: 12px; }

.scaleai-kb-list { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.scaleai-kb-item {
    display: flex; align-items: center; gap: var(--s-3);
    padding: 12px var(--s-4);
    background: var(--c-surface-1);
    border: 1px solid var(--c-border-1);
    border-radius: var(--r-md);
    transition: all 0.15s ease;
}
.scaleai-kb-item:hover { background: var(--c-surface-2); border-color: var(--c-border-2); }
.scaleai-kb-icon { font-size: 22px; width: 32px; text-align: center; }
.scaleai-kb-meta { flex: 1; min-width: 0; }
.scaleai-kb-meta strong {
    display: block; color: #fff; font-weight: 600; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scaleai-kb-meta small { color: var(--c-text-3); font-size: 12px; }
.scaleai-kb-item.is-processing .scaleai-kb-meta small { color: #FCD34D; }
.scaleai-kb-item.is-failed     .scaleai-kb-meta small { color: #FCA5A5; }
.scaleai-kb-item.is-ready      .scaleai-kb-meta small { color: #6EE7B7; }
.scaleai-kb-del {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    background: transparent;
    border: 1px solid var(--c-border-1);
    color: var(--c-text-3);
    border-radius: var(--r-sm);
    cursor: pointer; font-size: 16px; line-height: 1;
    transition: all 0.15s;
}
.scaleai-kb-del:hover {
    color: #FCA5A5; background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.30);
}

/* ----- Summary rows (final step) ----- */
.scaleai-summary {
    margin-bottom: var(--s-5);
    border: 1px solid var(--c-border-2);
    border-radius: var(--r-md);
    overflow: hidden;
}
.scaleai-sum-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px var(--s-4);
    border-bottom: 1px solid var(--c-border-1);
    font-size: 13px;
    background: var(--c-surface-0);
}
.scaleai-sum-row:last-child { border-bottom: none; }
.scaleai-sum-row .label { color: var(--c-text-3); font-weight: 600; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.scaleai-sum-row .value { color: #fff; font-weight: 600; }

/* ----- Mode chip in drawer (refined) ----- */
.scaleai-mode-chip { padding: 4px 10px; }

/* ----- Toast (refined) ----- */
.scaleai-toast {
    background: rgba(15, 22, 38, 0.96);
    border: 1px solid var(--c-border-2);
    -webkit-backdrop-filter: blur(20px);
            backdrop-filter: blur(20px);
    box-shadow: var(--sh-3);
}
.scaleai-toast.success { border-color: rgba(16, 185, 129, 0.42); }
.scaleai-toast.error   { border-color: rgba(239, 68, 68, 0.42); }

/* ----- Modals (refined) ----- */
.scaleai-modal-overlay { background: rgba(0, 0, 0, 0.58); }
.scaleai-modal-panel {
    background: rgba(15, 22, 38, 0.96);
    -webkit-backdrop-filter: blur(28px);
            backdrop-filter: blur(28px);
    border: 1px solid var(--c-border-2);
    box-shadow: var(--sh-3);
}
.scaleai-modal-head h3 { font-size: 15px; }

/* Polish tiny details */
.scaleai-truncate { max-width: 320px; }
.scaleai-muted    { color: var(--c-text-3); }
.scaleai-small    { font-size: 12px; }

/* =====================================================================
   v1.5 — FINAL POLISH: Drawer layout guarantee + UX improvements
   ===================================================================== */

/* Guarantee the drawer panel is a true full-height flex column */
.scaleai-drawer-panel {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
}
.scaleai-drawer-head { flex: 0 0 auto !important; }
.scaleai-drawer-body { flex: 1 1 auto !important; overflow-y: auto !important; min-height: 0; }
.scaleai-composer    { flex: 0 0 auto !important; }

/* Smooth auto-scroll to bottom on open */
.scaleai-drawer.is-open .scaleai-drawer-body {
    scroll-behavior: smooth;
}

/* Composer send button */
.scaleai-composer .scaleai-btn-primary {
    min-width: 72px;
    height: 42px;
    padding: 0 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    align-self: flex-end;
    flex-shrink: 0;
}

/* Drawer header: avatar-style contact initial */
.scaleai-drawer-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-pink) 0%, var(--c-maroon) 100%);
    display: grid; place-items: center;
    font-weight: 700; font-size: 15px;
    color: #fff;
    flex-shrink: 0;
}

/* Contact table rows: unread indicator */
.scaleai-table tbody tr.has-unread td:first-child {
    position: relative;
}
.scaleai-table tbody tr.has-unread td:first-child::before {
    content: '';
    position: absolute;
    left: 4px; top: 50%; transform: translateY(-50%);
    width: 6px; height: 6px;
    background: var(--c-pink);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 91, 141, 0.6);
}

/* Active row highlight in table */
.scaleai-table tbody tr.row-click:hover td {
    background: rgba(255, 91, 141, 0.04);
}

/* Empty chat state  */
.scaleai-bubble-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    flex: 1;
    text-align: center;
    padding: 40px 20px;
    color: var(--c-text-3);
    font-size: 14px;
    gap: 8px;
}
.scaleai-bubble-empty::before {
    content: '💬';
    font-size: 36px;
    opacity: 0.5;
}

/* Scroll-to-bottom button */
.scaleai-scroll-btn {
    position: absolute;
    bottom: 80px; right: 20px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,91,141,0.85);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 4px 12px rgba(255,91,141,0.35);
    transition: all 0.2s ease;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}
.scaleai-scroll-btn.show { opacity: 1; pointer-events: auto; }
.scaleai-scroll-btn:hover { transform: translateY(-2px); background: var(--c-pink); }

/* Composer textarea auto-grow feel */
.scaleai-composer textarea {
    overflow-y: hidden;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
}

/* KPI shimmer loading */
.scaleai-kpi-value.is-loading {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.04) 25%,
        rgba(255,255,255,0.10) 50%,
        rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: scaleai-skel 1.4s ease-in-out infinite;
    -webkit-background-clip: text;
    background-clip: unset;
    border-radius: 4px;
    color: transparent !important;
    display: inline-block;
    min-width: 40px;
}

/* Drawer toolbar refinement */
.scaleai-drawer-toolbar {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.scaleai-drawer-toolbar .scaleai-btn-ghost {
    padding: 6px 12px;
    font-size: 12px;
}

/* Mobile: drawer full-width */
@media (max-width: 600px) {
    .scaleai-drawer-panel { width: 100vw !important; }
    .scaleai-bubble { max-width: 90%; }
    .scaleai-composer { padding: 10px 12px; gap: 8px; }
}

/* Contact row phone sub-line */
.scaleai-table td .scaleai-muted.scaleai-small {
    display: block;
    margin-top: 2px;
    line-height: 1.3;
}

/* Bubble pop-in animation */
.scaleai-bubble {
    animation: bubble-in 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes bubble-in {
    from { opacity: 0; transform: scale(0.88) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Drawer container needs position: relative for scroll button */
.scaleai-drawer-panel { position: relative; }

/* =====================================================================
   v1.6 — NAV BUTTONS + KPI 5-column layout
   ===================================================================== */

/* Topbar nav */
.scaleai-topbar-nav {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.scaleai-nav-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    border-radius: var(--r-md);
    font-size: 12px; font-weight: 600;
    color: var(--c-text-2);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    cursor: pointer;
    background: transparent;
}
.scaleai-nav-btn:hover {
    background: var(--c-surface-2);
    border-color: var(--c-border-2);
    color: #fff;
}
.scaleai-nav-btn svg {
    opacity: 0.7;
    flex-shrink: 0;
}
.scaleai-nav-btn:hover svg { opacity: 1; }

.scaleai-nav-btn-danger {
    color: #FCA5A5;
}
.scaleai-nav-btn-danger:hover {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.28);
    color: #FECACA;
}
.scaleai-nav-btn-ghost {
    color: var(--c-text-3);
}
.scaleai-nav-btn.has-attention {
    color: #FCD34D;
    border-color: rgba(245, 158, 11, 0.30);
    background: rgba(245, 158, 11, 0.08);
}

/* Engine badge */
.scaleai-engine-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: rgba(16, 185, 129, 0.10);
    border: 1px solid rgba(16, 185, 129, 0.30);
    color: #6EE7B7;
    white-space: nowrap;
}
.scaleai-engine-badge .scaleai-status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: scaleai-pulse 2s ease-in-out infinite;
}

/* KPI 5 columns */
.scaleai-kpis {
    grid-template-columns: repeat(5, 1fr) !important;
}
@media (max-width: 1100px) { .scaleai-kpis { grid-template-columns: repeat(3, 1fr) !important; } }
@media (max-width: 600px)  { .scaleai-kpis { grid-template-columns: repeat(2, 1fr) !important; } }

/* KPI with icon */
.scaleai-kpi {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 18px 20px !important;
}
.scaleai-kpi-icon {
    font-size: 24px;
    width: 44px; height: 44px;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-border-1);
    border-radius: var(--r-md);
    flex-shrink: 0;
}
.scaleai-kpi-body {
    display: flex; flex-direction: column; gap: 2px;
}
.scaleai-kpi-body .scaleai-kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
    margin-top: 0 !important;
}
.scaleai-kpi-body .scaleai-kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0 !important;
}
.scaleai-kpi.scaleai-kpi-hot .scaleai-kpi-icon {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.25);
}
.scaleai-kpi.scaleai-kpi-hot .scaleai-kpi-body .scaleai-kpi-value {
    color: #FCA5A5;
}

/* Pipeline table refinements */
.scaleai-pipeline-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.scaleai-pipeline-table th {
    text-align: left; padding: 10px 12px;
    font-size: 11px; font-weight: 600;
    color: var(--c-text-3);
    letter-spacing: 0.06em; text-transform: uppercase;
    border-bottom: 1px solid var(--c-border-1);
}
.scaleai[dir="rtl"] .scaleai-pipeline-table th { text-align: right; }
.scaleai-pipeline-table td {
    padding: 12px; border-bottom: 1px solid var(--c-border-1);
    vertical-align: middle; color: var(--c-text);
}
.scaleai-pipeline-table tbody tr { transition: background 0.12s ease; cursor: pointer; }
.scaleai-pipeline-table tbody tr:hover { background: var(--c-surface-1); }
.scaleai-pipeline-table tr:last-child td { border-bottom: none; }
.scaleai-pipeline-empty {
    text-align: center; padding: 30px !important;
    color: var(--c-text-3); font-size: 13px;
}
.scaleai-pipeline-name { font-weight: 600; color: #fff; }
.scaleai-pipeline-phone { font-size: 12px; color: var(--c-text-3); margin-top: 2px; }
.scaleai-pipeline-summary {
    font-size: 12px; color: var(--c-text-2);
    max-width: 320px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.scaleai-pipeline-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.scaleai-pipeline-time { font-size: 12px; color: var(--c-text-3); white-space: nowrap; }
.scaleai-tag {
    display: inline-flex; align-items: center;
    padding: 2px 7px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--c-border-1);
    color: var(--c-text-2);
}
.scaleai-tag[data-tag="meeting"]  { background: rgba(59,130,246,0.10); border-color: rgba(59,130,246,0.28); color: #93C5FD; }
.scaleai-tag[data-tag="followup"] { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.28); color: #FCD34D; }
.scaleai-tag[data-tag="purchase"] { background: rgba(16,185,129,0.10); border-color: rgba(16,185,129,0.28); color: #6EE7B7; }
.scaleai-lead-status {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; border: 1px solid;
}
.scaleai-lead-status[data-status="hot"]     { background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.32); color: #FCA5A5; }
.scaleai-lead-status[data-status="warm"]    { background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.32); color: #FCD34D; }
.scaleai-lead-status[data-status="cold"]    { background: rgba(107,114,128,0.14); border-color: rgba(107,114,128,0.30); color: #CBD5E1; }
.scaleai-lead-status[data-status="unknown"] { background: rgba(255,255,255,0.04); border-color: var(--c-border-1); color: var(--c-text-3); }

@media (max-width: 900px) {
    .scaleai-topbar { flex-wrap: wrap; gap: 12px; }
    .scaleai-topbar-nav { gap: 2px; }
    .scaleai-nav-btn { padding: 6px 8px; font-size: 11px; }
    .scaleai-nav-btn span { display: none; }
    .scaleai-nav-btn svg { opacity: 1; }
}
/* ==========================================================================
   LIGHT MODE — Scale AI Engine
   Applied via: body.scale-light  (toggled by the floating theme button)
   All surfaces, text, borders, and gradients re-mapped for a clean light UI.
   ========================================================================== */

body.scale-light .scaleai,
body.scale-light .scaleai.scaleai {
    /* ── Background ── */
    --c-navy:   #f0f4f8;
    --c-navy-2: #e4eaf1;
    --c-navy-3: #dde4ee;
    --c-navy-4: #d3dce9;

    /* ── Text ── */
    --c-text:        #0f1a28;
    --c-text-2:      rgba(15, 26, 40, 0.78);
    --c-text-muted:  rgba(15, 26, 40, 0.55);
    --c-text-faint:  rgba(15, 26, 40, 0.38);

    /* ── Borders ── */
    --c-border:        rgba(15, 26, 40, 0.10);
    --c-border-strong: rgba(15, 26, 40, 0.20);

    /* ── Cards / surfaces ── */
    --grad-card:   linear-gradient(180deg, rgba(255,255,255,0.85) 0%, rgba(240,244,248,0.85) 100%);
    --grad-glow:   radial-gradient(900px 400px at 12% -10%, rgba(255, 91, 141, 0.08), transparent 60%);

    /* ── Shadows ── */
    --shadow-sm: 0 4px 14px rgba(15, 26, 40, 0.08);
    --shadow-md: 0 12px 32px rgba(15, 26, 40, 0.14);
    --shadow-glow: 0 0 0 1px rgba(255, 91, 141, 0.22), 0 8px 28px rgba(255, 91, 141, 0.12);

    background: var(--c-navy);
    color: var(--c-text);
}

/* Cards */
body.scale-light .scaleai-card,
body.scale-light .scaleai-glass {
    background: rgba(255,255,255,0.82) !important;
    border-color: rgba(15, 26, 40, 0.10) !important;
    box-shadow: 0 4px 20px rgba(15, 26, 40, 0.08) !important;
}

/* Hero stat cards */
body.scale-light .scaleai-hero-card {
    background: rgba(255,255,255,0.75) !important;
    border-color: rgba(15, 26, 40, 0.10) !important;
}
body.scale-light .scaleai-hero-stat-value {
    color: #0f1a28 !important;
}

/* Topbar / secondary toolbar */
body.scale-light .scaleai-topbar {
    background: rgba(255,255,255,0.78) !important;
    border-color: rgba(15, 26, 40, 0.10) !important;
    backdrop-filter: blur(16px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(140%) !important;
}
body.scale-light .scaleai-topbar-btn {
    color: rgba(15,26,40,0.75) !important;
    border-color: rgba(15,26,40,0.12) !important;
    background: rgba(255,255,255,0.6) !important;
}
body.scale-light .scaleai-topbar-btn:hover {
    background: rgba(255,255,255,0.95) !important;
    color: #0f1a28 !important;
    border-color: rgba(15,26,40,0.22) !important;
}

/* Steps */
body.scale-light .scaleai-step {
    border-color: rgba(15,26,40,0.10) !important;
    background: rgba(255,255,255,0.6) !important;
}
body.scale-light .scaleai-step:hover {
    background: rgba(255,255,255,0.92) !important;
}

/* Fields / inputs */
body.scale-light .scaleai-field input,
body.scale-light .scaleai-field textarea,
body.scale-light .scaleai-field select {
    background: rgba(255,255,255,0.9) !important;
    border-color: rgba(15,26,40,0.18) !important;
    color: #0f1a28 !important;
}
body.scale-light .scaleai-field input::placeholder,
body.scale-light .scaleai-field textarea::placeholder {
    color: rgba(15,26,40,0.38) !important;
}
body.scale-light .scaleai-field input:focus,
body.scale-light .scaleai-field textarea:focus {
    background: #fff !important;
    border-color: #FF5B8D !important;
}

/* Table */
body.scale-light .scaleai-table {
    background: rgba(255,255,255,0.8) !important;
    border-color: rgba(15,26,40,0.10) !important;
}
body.scale-light .scaleai-table th {
    background: rgba(240,244,248,0.9) !important;
    color: rgba(15,26,40,0.55) !important;
    border-color: rgba(15,26,40,0.08) !important;
}
body.scale-light .scaleai-table td {
    border-color: rgba(15,26,40,0.06) !important;
}
body.scale-light .scaleai-table tr:hover td {
    background: rgba(255,91,141,0.04) !important;
}
body.scale-light .scaleai-table .col-msg {
    color: rgba(15,26,40,0.65) !important;
}
body.scale-light .scaleai-table .col-when {
    color: rgba(15,26,40,0.45) !important;
}
body.scale-light .scaleai-table .col-name strong {
    color: #0f1a28 !important;
}
body.scale-light .scaleai-table .col-name small {
    color: rgba(15,26,40,0.5) !important;
}

/* Pipeline table */
body.scale-light .scaleai-pipeline-table {
    background: rgba(255,255,255,0.8) !important;
    color: #0f1a28 !important;
    border-color: rgba(15,26,40,0.10) !important;
}
body.scale-light .scaleai-pipeline-table th {
    background: rgba(240,244,248,0.9) !important;
    color: rgba(15,26,40,0.55) !important;
    border-color: rgba(15,26,40,0.08) !important;
}
body.scale-light .scaleai-pipeline-table td {
    border-color: rgba(15,26,40,0.06) !important;
}
body.scale-light .scaleai-pipeline-table tr:hover td {
    background: rgba(255,91,141,0.04) !important;
}

/* Drawer */
body.scale-light .scaleai-drawer {
    background: rgba(248,250,252,0.97) !important;
    border-color: rgba(15,26,40,0.12) !important;
    box-shadow: -12px 0 48px rgba(15,26,40,0.12) !important;
}
body.scale-light .scaleai-drawer-head {
    border-color: rgba(15,26,40,0.10) !important;
    background: rgba(255,255,255,0.85) !important;
}
body.scale-light .scaleai-drawer-head h3,
body.scale-light .scaleai-drawer-head p {
    color: #0f1a28 !important;
}
body.scale-light .scaleai-drawer-body {
    background: #f5f7fa !important;
}

/* Chat bubbles */
body.scale-light .scaleai-bubble-user {
    background: #ffffff !important;
    color: #1a2030 !important;
    box-shadow: 0 2px 8px rgba(15,26,40,0.10) !important;
}
body.scale-light .scaleai-bubble-user .scaleai-bubble-time {
    color: #9CA3AF !important;
}
body.scale-light .scaleai-drawer-composer {
    background: rgba(255,255,255,0.9) !important;
    border-color: rgba(15,26,40,0.10) !important;
}
body.scale-light .scaleai-composer-input {
    background: rgba(240,244,248,0.8) !important;
    color: #0f1a28 !important;
    border-color: rgba(15,26,40,0.12) !important;
}
body.scale-light .scaleai-composer-input:focus {
    background: #fff !important;
    border-color: #FF5B8D !important;
}
body.scale-light .scaleai-composer-input::placeholder {
    color: rgba(15,26,40,0.38) !important;
}

/* Leadbar */
body.scale-light .scaleai-leadbar-item {
    background: rgba(255,255,255,0.75) !important;
    border-color: rgba(15,26,40,0.10) !important;
}
body.scale-light .scaleai-leadbar-label {
    color: #0f1a28 !important;
}
body.scale-light .scaleai-leadbar-phone {
    color: rgba(15,26,40,0.55) !important;
}

/* Section headings */
body.scale-light .scaleai-section-title {
    color: #0f1a28 !important;
}
body.scale-light .scaleai-section-meta {
    color: rgba(15,26,40,0.55) !important;
}

/* Tabs */
body.scale-light .scaleai-tab {
    color: rgba(15,26,40,0.55) !important;
}
body.scale-light .scaleai-tab.is-active {
    color: #0f1a28 !important;
    border-color: #FF5B8D !important;
}

/* Misc pills / badges */
body.scale-light .scaleai-pill-unknown {
    background: rgba(15,26,40,0.06) !important;
    color: rgba(15,26,40,0.55) !important;
}

/* Toast */
body.scale-light .scaleai-toast {
    background: rgba(255,255,255,0.95) !important;
    color: #0f1a28 !important;
    border-color: rgba(15,26,40,0.12) !important;
    box-shadow: 0 8px 28px rgba(15,26,40,0.14) !important;
}

/* Scroll bar */
body.scale-light .scaleai-drawer-body::-webkit-scrollbar-track {
    background: #f0f4f8 !important;
}
body.scale-light .scaleai-drawer-body::-webkit-scrollbar-thumb {
    background: rgba(15,26,40,0.18) !important;
}

/* ── Header in light mode ── */
body.scale-light .s-header {
    background: rgba(255,255,255,0.72) !important;
    border-color: rgba(15,26,40,0.12) !important;
    box-shadow: 0 8px 32px rgba(15,26,40,0.10),
                inset 0 1px 0 rgba(255,255,255,0.9) !important;
}
body.scale-light .s-header.is-scrolled {
    background: rgba(255,255,255,0.90) !important;
    border-color: rgba(15,26,40,0.16) !important;
}
body.scale-light .s-header__menu a {
    color: #0f1a28 !important;
}
body.scale-light .s-header__menu a::before {
    background: rgba(15,26,40,0.06) !important;
}
body.scale-light .s-header__toggle span {
    background: #0f1a28 !important;
}
body.scale-light .s-mobile {
    background: rgba(240,244,248,0.97) !important;
}
body.scale-light .s-mobile__list a {
    color: #0f1a28 !important;
}

/* ── Auth shell (login/signup pages) in light mode ── */
body.scale-light .sa-shell {
    background: linear-gradient(135deg, #f0f4f8 0%, #e8eef5 50%, #f5f0f8 100%) !important;
}
body.scale-light .sa-card {
    background: rgba(255,255,255,0.88) !important;
    border-color: rgba(15,26,40,0.10) !important;
    box-shadow: 0 12px 40px rgba(15,26,40,0.10) !important;
}
body.scale-light .sa-label,
body.scale-light .sa-title,
body.scale-light .sa-subtitle {
    color: #0f1a28 !important;
}
body.scale-light .sa-input {
    background: rgba(240,244,248,0.8) !important;
    border-color: rgba(15,26,40,0.15) !important;
    color: #0f1a28 !important;
}
body.scale-light .sa-input:focus {
    background: #fff !important;
    border-color: #FF5B8D !important;
}
body.scale-light .sa-input::placeholder {
    color: rgba(15,26,40,0.38) !important;
}
body.scale-light .sa-link {
    color: #FF5B8D !important;
}

/* ── Floating theme toggle button ── */
.scale-theme-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FF5B8D 0%, #732654 100%);
    box-shadow: 0 4px 18px rgba(255, 91, 141, 0.40), 0 2px 8px rgba(0,0,0,0.18);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                background 0.4s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
.scale-theme-fab:hover {
    transform: scale(1.12) translateY(-2px);
    box-shadow: 0 8px 28px rgba(255, 91, 141, 0.55), 0 4px 14px rgba(0,0,0,0.20);
}
.scale-theme-fab:active {
    transform: scale(0.94);
}
body.scale-light .scale-theme-fab {
    background: linear-gradient(135deg, #0f1a28 0%, #1e3050 100%);
    box-shadow: 0 4px 18px rgba(15,26,40,0.28), 0 2px 8px rgba(0,0,0,0.12);
}
body.scale-light .scale-theme-fab:hover {
    box-shadow: 0 8px 28px rgba(15,26,40,0.38), 0 4px 14px rgba(0,0,0,0.18);
}

/* Icon inside FAB — sun & moon via SVG/CSS */
.scale-theme-fab__icon {
    width: 22px;
    height: 22px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scale-theme-fab__sun,
.scale-theme-fab__moon {
    position: absolute;
    width: 22px;
    height: 22px;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
/* Dark mode: show moon, hide sun */
.scale-theme-fab__sun  { opacity: 0; transform: scale(0.5) rotate(-90deg); }
.scale-theme-fab__moon { opacity: 1; transform: scale(1) rotate(0deg); }
/* Light mode: show sun, hide moon */
body.scale-light .scale-theme-fab__sun  { opacity: 1; transform: scale(1) rotate(0deg); }
body.scale-light .scale-theme-fab__moon { opacity: 0; transform: scale(0.5) rotate(90deg); }

/* Tooltip */
.scale-theme-fab::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 56px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15,26,40,0.88);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-family: 'Inter Tight', system-ui, sans-serif;
}
.scale-theme-fab:hover::after {
    opacity: 1;
}

@media (max-width: 768px) {
    .scale-theme-fab {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
    }
}

/* Smooth color transition on the whole page */
body {
    transition: background-color 0.4s ease, color 0.4s ease;
}
/* ==================== AUTO-LEARNED KNOWLEDGE (KB modal) ==================== */
.scaleai-learned {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(255, 91, 141, 0.08), transparent 60%),
        rgba(255, 255, 255, 0.02);
}
.scaleai-learned-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scaleai-learned-title { display: flex; align-items: center; gap: 12px; }
.scaleai-learned-icon {
    width: 38px; height: 38px; flex: 0 0 auto;
    display: grid; place-items: center;
    font-size: 19px;
    border-radius: var(--r-sm);
    background: var(--c-pink-soft);
    border: 1px solid rgba(255, 91, 141, 0.25);
}
.scaleai-learned-title strong { display: block; font-size: 14px; font-weight: 700; color: var(--c-text); }
.scaleai-learned-title small  { display: block; margin-top: 2px; font-size: 12px; color: var(--c-text-muted); }
.scaleai-learned .scaleai-card-desc { margin: 12px 0; font-size: 12.5px; line-height: 1.7; color: var(--c-text-2); }
.scaleai-learned-body {
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: rgba(0, 0, 0, 0.18);
    padding: 12px 14px;
}
.scaleai-learned-preview { font-size: 12.5px; line-height: 1.75; color: var(--c-text-2); white-space: normal; }
.scaleai-learned-more { color: var(--c-pink-2); }
.scaleai-learned-empty { font-size: 12.5px; color: var(--c-text-muted); padding: 6px 2px; }
.scaleai-learned-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.scaleai-learned-actions .scaleai-btn-ghost { font-size: 13px; }
.scaleai-learned-actions .scaleai-btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
