/* ============================================================================
   AI Advisor — extremely modern, animated showcase page.
   Layered animations, mesh gradients, glassmorphism, neural-net orb.
   ============================================================================ */

:root {
    --ai-ink:        #0b1020;
    --ai-ink-2:      #475569;
    --ai-ink-3:      #94a3b8;
    --ai-surface:    #ffffff;
    --ai-surface-2:  #f1f5f9;
    --ai-border:     rgb(15 23 42 / 0.08);
    --ai-violet:     #8b5cf6;
    --ai-cyan:       #22d3ee;
    --ai-emerald:    #10b981;
    --ai-amber:      #f59e0b;
    --ai-rose:       #f43f5e;
    --ai-blue:       #3b82f6;
    --ai-glow-1:     rgba(167, 139, 250, 0.5);
    --ai-glow-2:     rgba(34, 211, 238, 0.45);
    --ai-ease:       cubic-bezier(.175, .885, .32, 1.1);
    --ai-shadow-b:   inset 0 0 0 1px var(--ai-border);
    --ai-shadow-card:0 1px 3px 0 rgb(15 23 42 / 0.04), 0 1px 2px -1px rgb(15 23 42 / 0.05), inset 0 0 0 1px var(--ai-border);
    --ai-shadow-elev:0 28px 60px -20px rgb(15 23 42 / 0.35), 0 0 0 1px var(--ai-border);
}

.ai-advisor-page { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }
.ai-advisor-page * { box-sizing: border-box; }

/* ============================================================================
   HERO
   ============================================================================ */
.ai-hero {
    position: relative;
    overflow: hidden;
    color: #f5f3ff;
    isolation: isolate;
    margin: 16px 24px 24px;
    border-radius: 20px;
    background: linear-gradient(135deg, #0b1020 0%, #1e1b4b 45%, #0f172a 100%);
    box-shadow: 0 28px 60px -28px rgba(99, 102, 241, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ----- animated mesh + grid layers ----- */
.ai-hero-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.ai-hero-bg .mesh {
    position: absolute; inset: -20%;
    background:
        radial-gradient(40% 50% at 15% 30%, rgba(139, 92, 246, 0.55) 0%, transparent 60%),
        radial-gradient(45% 50% at 80% 20%, rgba(34, 211, 238, 0.42) 0%, transparent 60%),
        radial-gradient(50% 55% at 60% 90%, rgba(244, 114, 182, 0.30) 0%, transparent 60%),
        radial-gradient(35% 40% at 30% 80%, rgba(96, 165, 250, 0.30) 0%, transparent 60%);
    filter: blur(20px) saturate(1.05);
    animation: meshShift 14s ease-in-out infinite alternate;
}
.ai-hero-bg .grid-fade {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 70%);
}
@keyframes meshShift {
    0%   { transform: translate(0,0) scale(1); }
    50%  { transform: translate(-3%, -2%) scale(1.05); }
    100% { transform: translate(2%, 1%)   scale(1.02); }
}

/* ----- decorative floating accents ----- */
.floaty { position: absolute; border-radius: 999px; filter: blur(40px); opacity: 0.4; animation: floatY 9s ease-in-out infinite; }
.floaty.f1 { width: 220px; height: 220px; background: #8b5cf6; left: 8%;  top: 18%; }
.floaty.f2 { width: 180px; height: 180px; background: #22d3ee; right: 6%; top: 10%; animation-delay: -3s; }
.floaty.f3 { width: 160px; height: 160px; background: #ec4899; left: 28%; bottom: 8%; animation-delay: -5s; }
.floaty.f4 { width: 200px; height: 200px; background: #38bdf8; right: 18%; bottom: 16%; animation-delay: -7s; }
@keyframes floatY {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-22px); }
}

/* ----- hero inner grid ----- */
.ai-hero-inner {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 40px;
    align-items: center;
    padding: 36px 40px;
    min-height: 360px;
}
@media (max-width: 1024px) {
    .ai-hero-inner { grid-template-columns: 1fr; }
    .ai-orb-wrap   { justify-self: center; }
}

.hero-breadcrumb {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 11px; color: rgba(241, 245, 249, 0.65);
    margin-bottom: 8px;
}
.hero-breadcrumb-active { color: rgba(241, 245, 249, 1); font-weight: 500; }

.hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(139, 92, 246, 0.16);
    box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.35);
    color: #ddd6fe;
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    margin-bottom: 14px;
}
.hero-eyebrow .dot {
    width: 6px; height: 6px; border-radius: 999px; background: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.25);
    animation: pulseDot 1.4s ease-in-out infinite;
}
@keyframes pulseDot {
    0%, 100% { transform: scale(1);   opacity: 1;   box-shadow: 0 0 0 0    rgba(167, 139, 250, 0.4); }
    50%      { transform: scale(1.2); opacity: 0.7; box-shadow: 0 0 0 6px rgba(167, 139, 250, 0.0); }
}

.hero-title {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.025em;
    color: #f8fafc;
    margin: 0 0 12px;
}
.hero-gradient {
    background: linear-gradient(90deg, #a78bfa 0%, #22d3ee 50%, #f472b6 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradientShift 5s ease-in-out infinite alternate;
}
@keyframes gradientShift { from { background-position: 0% 0; } to { background-position: 100% 0; } }

.hero-sub {
    max-width: 540px;
    font-size: 14px;
    color: rgba(226, 232, 240, 0.75);
    line-height: 1.6;
    margin: 0 0 22px;
}

/* ----- CTA buttons ----- */
.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-cta {
    position: relative;
    display: inline-flex; align-items: center; gap: 12px;
    padding: 12px 18px 12px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #22d3ee 100%);
    background-size: 200% auto;
    color: #fff;
    font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
    box-shadow: 0 12px 28px -10px rgba(139, 92, 246, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    transition: background-position .5s var(--ai-ease), transform .15s var(--ai-ease), box-shadow .2s var(--ai-ease);
    overflow: hidden;
    isolation: isolate;
}
.hero-cta:hover  { background-position: 100% 0; transform: translateY(-1px); box-shadow: 0 18px 36px -10px rgba(139, 92, 246, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
.hero-cta:active { transform: translateY(0); }
.hero-cta:disabled, .hero-cta.is-running { opacity: 0.85; cursor: not-allowed; }
.hero-cta-glow {
    position: absolute; inset: -20%; z-index: -1;
    background: conic-gradient(from 0deg, #a78bfa, #22d3ee, #f472b6, #a78bfa);
    filter: blur(18px); opacity: 0.6;
    animation: cone 6s linear infinite;
}
@keyframes cone { to { transform: rotate(360deg); } }
.hero-cta-label   { display: inline-flex; align-items: center; gap: 8px; }
.hero-cta-arrow   { width: 22px; height: 22px; border-radius: 999px; background: rgba(255,255,255,0.18); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; transition: transform .2s var(--ai-ease), background-color .2s var(--ai-ease); }
.hero-cta:hover .hero-cta-arrow { transform: translateX(2px); background: rgba(255,255,255,0.28); }

.hero-secondary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    font-size: 13px; font-weight: 500;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    transition: background-color .15s var(--ai-ease), color .15s var(--ai-ease);
}
.hero-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); color: #fff; }
.hero-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.hero-meta {
    display: inline-flex; align-items: center; gap: 10px;
    margin-left: 6px;
    color: rgba(226, 232, 240, 0.55);
    font-size: 11.5px; font-weight: 500;
}
.hero-meta i { color: rgba(167, 139, 250, 0.7); margin-right: 4px; font-size: 10px; }
.dot-sep    { width: 3px; height: 3px; border-radius: 999px; background: rgba(226, 232, 240, 0.25); }

/* ============================================================================
   AI ORB
   ============================================================================ */
.ai-orb-wrap {
    position: relative;
    width: 320px;
    height: 320px;
    justify-self: end;
}

.ai-orbit { position: absolute; inset: 0; animation: orbitSpin 32s linear infinite; }
.ai-orbit .ring-r  { animation: orbitSpin 18s linear infinite reverse; transform-origin: 50% 50%; }
.ai-orbit .ring-r2 { animation: orbitSpin 9s  linear infinite;          transform-origin: 50% 50%; }
@keyframes orbitSpin { to { transform: rotate(360deg); } }

.ai-orb {
    position: absolute;
    left: 50%; top: 50%;
    width: 150px; height: 150px;
    transform: translate(-50%, -50%);
}
.orb-core {
    position: relative;
    width: 100%; height: 100%;
    border-radius: 999px;
    background:
        radial-gradient(circle at 35% 30%, #c4b5fd 0%, #8b5cf6 30%, #4338ca 65%, #1e1b4b 100%);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.18),
        0 0 60px 4px rgba(139, 92, 246, 0.55),
        inset 0 -20px 32px rgba(15, 23, 42, 0.5),
        inset 0 16px 24px rgba(255, 255, 255, 0.18);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 36px;
    animation: orbBreathe 4s ease-in-out infinite;
}
.orb-aura {
    position: absolute; inset: -6%;
    border-radius: 999px;
    background:
        radial-gradient(circle, rgba(167, 139, 250, 0.55) 0%, transparent 65%);
    filter: blur(10px);
    animation: orbBreathe 4s ease-in-out infinite;
}
.orb-core i { position: relative; z-index: 2; text-shadow: 0 4px 18px rgba(167, 139, 250, 0.6); }
@keyframes orbBreathe {
    0%, 100% { transform: scale(1);   filter: brightness(1); }
    50%      { transform: scale(1.05); filter: brightness(1.15); }
}

/* Expanding pulse rings */
.orb-pulse {
    position: absolute; inset: 0;
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.45);
    animation: pulseRing 3.4s ease-out infinite;
    pointer-events: none;
}
.orb-pulse.p2 { animation-delay: -1.1s; }
.orb-pulse.p3 { animation-delay: -2.3s; }
@keyframes pulseRing {
    0%   { transform: scale(0.8); opacity: 0.9; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* Orbiting satellite dots */
.orbit-dot {
    position: absolute;
    width: 8px; height: 8px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.65), 0 0 16px 4px var(--ai-glow-1);
    transform-origin: 160px 160px;
}
.ai-advisor-page .ai-orb-wrap .orbit-dot {
    left: 50%; top: 50%;
    margin-left: -4px; margin-top: -4px;
}
/* Position via translate + rotate, animate via revolve */
.orbit-dot.d1 { animation: revolve1 7s  linear infinite; }
.orbit-dot.d2 { animation: revolve2 11s linear infinite reverse; background: #67e8f9; box-shadow: 0 0 0 2px rgba(103, 232, 249, 0.65), 0 0 16px 4px var(--ai-glow-2); }
.orbit-dot.d3 { animation: revolve3 14s linear infinite; background: #f472b6; box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.55), 0 0 16px 4px rgba(244, 114, 182, 0.4); }
.orbit-dot.d4 { animation: revolve1 9s  linear infinite reverse; }
@keyframes revolve1 { from { transform: rotate(0deg)   translate(140px) rotate(0deg); } to { transform: rotate(360deg) translate(140px) rotate(-360deg); } }
@keyframes revolve2 { from { transform: rotate(60deg)  translate(110px) rotate(-60deg); } to { transform: rotate(420deg) translate(110px) rotate(-420deg); } }
@keyframes revolve3 { from { transform: rotate(120deg) translate(150px) rotate(-120deg); } to { transform: rotate(480deg) translate(150px) rotate(-480deg); } }

/* Intensified state when analysis is running */
.ai-advisor-page.is-running .orb-core { animation: orbBreathe 1.2s ease-in-out infinite, orbBoost 1.2s ease-in-out infinite; }
.ai-advisor-page.is-running .orb-pulse { animation-duration: 1.6s; }
@keyframes orbBoost { 50% { filter: brightness(1.3) saturate(1.3); box-shadow: 0 0 80px 14px rgba(139, 92, 246, 0.85), 0 0 0 1px rgba(255,255,255,0.18); } }

/* ============================================================================
   Sections, eyebrow, headings
   ============================================================================ */
.ai-section {
    margin: 24px 24px 0;
    padding: 22px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--ai-shadow-card);
}
.ai-section + .ai-section { margin-top: 16px; }

.ai-section-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.section-eyebrow {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--ai-surface-2);
    color: var(--ai-ink-2);
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    margin-bottom: 6px;
}
.section-eyebrow.on      { background: rgba(139, 92, 246, 0.12); color: #6d28d9; }
.section-eyebrow.success { background: rgba(16, 185, 129, 0.12); color: #047857; }
.section-title { font-size: 18px; font-weight: 600; color: var(--ai-ink); letter-spacing: -0.01em; margin: 0; }
.section-sub   { font-size: 12.5px; color: var(--ai-ink-2); margin-top: 4px; }

/* ============================================================================
   Data source cards
   ============================================================================ */
.ds-group { margin-bottom: 14px; }
.ds-group:last-child { margin-bottom: 0; }
.ds-group-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--ai-ink-3);
    margin: 14px 0 8px;
}
.ds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.ds-card {
    position: relative;
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: var(--ai-shadow-card);
    overflow: hidden;
    transition: box-shadow .2s var(--ai-ease), transform .15s var(--ai-ease);
}
.ds-card:hover { box-shadow: 0 6px 18px -10px rgb(15 23 42 / 0.2), inset 0 0 0 1px rgba(139, 92, 246, 0.25); transform: translateY(-1px); }
.ds-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ede9fe, #ffffff);
    box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.18);
    display: inline-flex; align-items: center; justify-content: center;
    color: #6d28d9; font-size: 13px;
    flex-shrink: 0;
}
.ds-body { flex: 1; min-width: 0; }
.ds-top  { display: flex; align-items: center; justify-content: space-between; }
.ds-label { font-size: 12.5px; font-weight: 600; color: var(--ai-ink); }
.ds-status { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #047857; }
.ds-status .dot { width: 6px; height: 6px; border-radius: 999px; background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.ds-count { font-size: 14px; color: var(--ai-ink); margin-top: 2px; font-family: 'JetBrains Mono', Consolas, monospace; }
.ds-count .num { font-weight: 600; }
.ds-count .unit { font-size: 11px; color: var(--ai-ink-3); margin-left: 2px; }
.ds-desc { font-size: 11px; color: var(--ai-ink-2); margin-top: 2px; }
.ds-spark {
    position: absolute;
    right: 10px; bottom: 8px;
    width: 70px; height: 22px;
    color: rgba(139, 92, 246, 0.55);
    opacity: 0.7;
}

/* Scanning highlight on each card during analysis */
.ds-card.is-scanning {
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.6), 0 12px 24px -10px rgba(139, 92, 246, 0.35);
}
.ds-card.is-scanning::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(167, 139, 250, 0.18) 50%, transparent 70%);
    animation: scanSheen 1.1s linear infinite;
    pointer-events: none;
}
@keyframes scanSheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ============================================================================
   Pipeline (analysis stages)
   ============================================================================ */
.pipeline-section { opacity: 0; max-height: 0; padding: 0; margin: 0 24px; overflow: hidden; transition: max-height .4s var(--ai-ease), opacity .4s var(--ai-ease), padding .3s var(--ai-ease), margin .3s var(--ai-ease); }
.pipeline-section.is-active { opacity: 1; max-height: 600px; padding: 22px; margin-top: 16px; background: #ffffff; border-radius: 16px; box-shadow: var(--ai-shadow-card); }

.pipeline-elapsed {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--ai-surface-2);
    color: var(--ai-ink-2);
    font-size: 11px;
    font-family: 'JetBrains Mono', Consolas, monospace;
}

.pipeline-track {
    position: relative;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 8px 0 18px;
    padding: 10px 0;
}
.pipeline-progress-line {
    position: absolute; left: 8%; right: 8%; top: 28px;
    height: 2px; background: var(--ai-surface-2); border-radius: 999px;
    z-index: 0;
}
.pipeline-progress-line .fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #a78bfa, #22d3ee);
    border-radius: 999px;
    transition: width .6s var(--ai-ease);
    position: relative;
}
.pipeline-progress-line .fill::after {
    content: '';
    position: absolute; right: -4px; top: 50%; transform: translateY(-50%);
    width: 10px; height: 10px;
    border-radius: 999px; background: #fff;
    box-shadow: 0 0 0 2px #22d3ee, 0 0 14px 4px rgba(34, 211, 238, 0.55);
}

.pipeline-stage {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    gap: 6px;
    z-index: 1;
}
.pipeline-pill {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1.5px rgba(15, 23, 42, 0.08);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ai-ink-3);
    font-size: 13px;
    transition: background-color .2s var(--ai-ease), color .2s var(--ai-ease), box-shadow .25s var(--ai-ease), transform .2s var(--ai-ease);
}
.pipeline-pill .pipeline-num   { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 999px; background: #fff; color: var(--ai-ink-3); font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--ai-shadow-b); }
.pipeline-pill .pipeline-icon  { display: inline-flex; }
.pipeline-pill .pipeline-check { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 14px; color: #fff; }

.pipeline-stage.is-active .pipeline-pill {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.18), 0 8px 22px -8px rgba(139, 92, 246, 0.5);
    transform: scale(1.06);
    animation: stagePulse 1.4s ease-in-out infinite;
}
.pipeline-stage.is-active .pipeline-num { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; box-shadow: none; }
@keyframes stagePulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.18), 0 8px 22px -8px rgba(139, 92, 246, 0.5); }
    50%      { box-shadow: 0 0 0 12px rgba(139, 92, 246, 0.05), 0 12px 28px -10px rgba(139, 92, 246, 0.6); }
}

.pipeline-stage.is-done .pipeline-pill {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
}
.pipeline-stage.is-done .pipeline-icon { display: none; }
.pipeline-stage.is-done .pipeline-check { display: inline-flex; }
.pipeline-stage.is-done .pipeline-num   { background: #10b981; color: #fff; }

.pipeline-label { font-size: 11.5px; font-weight: 600; color: var(--ai-ink); }
.pipeline-sub   { font-size: 10px; color: var(--ai-ink-3); text-align: center; max-width: 140px; line-height: 1.35; }

/* Thinking stream card */
.thinking-card {
    position: relative;
    background: linear-gradient(180deg, #0f172a, #1e1b4b);
    border-radius: 12px;
    padding: 14px 16px;
    color: #e2e8f0;
    overflow: hidden;
    box-shadow: 0 18px 36px -18px rgba(67, 56, 202, 0.6), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.thinking-card::before {
    content: '';
    position: absolute; inset: -1px;
    background: linear-gradient(120deg, transparent 30%, rgba(139, 92, 246, 0.25) 50%, transparent 70%);
    animation: scanSheen 3s linear infinite;
    pointer-events: none;
}
.thinking-head {
    display: flex; align-items: center; gap: 10px;
    font-size: 11px; color: rgba(226, 232, 240, 0.7);
    margin-bottom: 8px;
}
.thinking-dot {
    width: 8px; height: 8px; border-radius: 999px;
    background: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
    animation: pulseDot 1s ease-in-out infinite;
}
.thinking-label { font-family: 'JetBrains Mono', Consolas, monospace; color: rgba(196, 181, 253, 0.85); }
.thinking-tokens { margin-left: auto; font-family: 'JetBrains Mono', Consolas, monospace; color: rgba(186, 230, 253, 0.7); font-size: 10px; }

.thinking-stream {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.55;
    max-height: 96px;
    overflow: hidden;
    color: rgba(226, 232, 240, 0.6);
}
.thinking-stream .line { animation: streamIn .25s var(--ai-ease) both; }
.thinking-stream .line.done { color: rgba(226, 232, 240, 0.45); }
@keyframes streamIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.thinking-cursor {
    margin-top: 4px;
    display: flex; align-items: center; gap: 4px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12px; color: #f5f3ff;
}
.thinking-cursor .caret {
    width: 8px; height: 16px; background: #a78bfa;
    border-radius: 2px;
    animation: caretBlink .9s steps(2, end) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

/* ============================================================================
   Results — recommendation cards
   ============================================================================ */
.results-section { opacity: 0; transform: translateY(8px); transition: opacity .45s var(--ai-ease), transform .45s var(--ai-ease); }
.results-section.is-visible { opacity: 1; transform: translateY(0); }

.results-summary { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-blue, .chip-emerald, .chip-rose, .chip-amber, .chip-sky {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
}
.chip-blue    { background: #eff6ff; color: #1d4ed8; }
.chip-emerald { background: #ecfdf5; color: #047857; }
.chip-rose    { background: #fff1f2; color: #be123c; }
.chip-amber   { background: #fffbeb; color: #b45309; }
.chip-sky     { background: #ecfeff; color: #0369a1; }

.rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
}

.rec-card {
    position: relative;
    display: flex; flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--ai-shadow-card);
    overflow: hidden;
    isolation: isolate;
    animation: recIn .5s var(--ai-ease) both;
}
.rec-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--rec-bar, #a78bfa);
}
.rec-card[data-tone="emerald"] { --rec-bar: #10b981; }
.rec-card[data-tone="rose"]    { --rec-bar: #f43f5e; }
.rec-card[data-tone="blue"]    { --rec-bar: #3b82f6; }
.rec-card[data-tone="amber"]   { --rec-bar: #f59e0b; }
.rec-card[data-tone="sky"]     { --rec-bar: #0ea5e9; }
@keyframes recIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.rec-head { display: flex; gap: 10px; align-items: flex-start; }
.rec-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(139, 92, 246, 0.10);
    color: #6d28d9;
    font-size: 12px;
    flex-shrink: 0;
}
.rec-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--ai-ink); line-height: 1.35; }

.rec-desc  { font-size: 11.5px; color: var(--ai-ink-2); line-height: 1.5; }

.rec-tags  { display: flex; flex-wrap: wrap; gap: 4px; }
.rec-tag {
    display: inline-flex; align-items: center;
    padding: 1px 6px; border-radius: 999px;
    background: var(--ai-surface-2);
    color: var(--ai-ink-2);
    font-size: 9.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}

.rec-stats {
    display: flex; align-items: center; gap: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--ai-border);
    font-family: 'JetBrains Mono', Consolas, monospace;
}
.rec-stat { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.rec-stat .k { font-size: 9px; color: var(--ai-ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-family: 'Inter', sans-serif; font-weight: 600; }
.rec-stat .v { font-size: 13px; font-weight: 600; }
.rec-stat .v.pos { color: #047857; }
.rec-stat .v.neg { color: #be123c; }
.rec-stat .v.neu { color: var(--ai-ink); }

.rec-confidence {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 5px;
}
.rec-confidence .bar {
    width: 56px; height: 6px;
    border-radius: 999px;
    background: var(--ai-surface-2);
    overflow: hidden;
}
.rec-confidence .bar > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, #a78bfa, #22d3ee);
    border-radius: 999px;
    width: 0;
    transition: width .9s var(--ai-ease);
}
.rec-confidence .pct { font-size: 11px; color: var(--ai-ink-2); font-family: 'JetBrains Mono', Consolas, monospace; }

.rec-actions { display: flex; align-items: center; gap: 6px; padding-top: 6px; }
.rec-action {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11.5px; font-weight: 600;
    background: var(--ai-ink); color: #fff;
    transition: background-color .15s var(--ai-ease);
}
.rec-action:hover { background: #1e293b; }
.rec-action.ghost {
    background: #fff; color: var(--ai-ink-2);
    box-shadow: inset 0 0 0 1px var(--ai-border);
}
.rec-action.ghost:hover { background: var(--ai-surface-2); color: var(--ai-ink); }

/* ============================================================================
   Gauges (RAK / Credit / AI Score)
   ============================================================================ */
.gauge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.gauge-card {
    position: relative;
    background: linear-gradient(180deg, #f8fafc, #ffffff);
    border-radius: 14px;
    box-shadow: var(--ai-shadow-card);
    padding: 18px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.gauge-svg { width: 140px; height: 140px; transform: rotate(-90deg); }
.gauge-bg  { fill: none; stroke: var(--ai-surface-2); stroke-width: 10; }
.gauge-fg  {
    fill: none;
    stroke: url(#none);
    stroke: var(--ai-violet);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 0 999;
    transition: stroke-dasharray 1.2s var(--ai-ease);
    filter: drop-shadow(0 0 6px var(--ai-glow-1));
}
.gauge-fg[data-gauge="rak"]    { stroke: #8b5cf6; }
.gauge-fg[data-gauge="credit"] { stroke: #06b6d4; filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.4)); }
.gauge-fg[data-gauge="ai"]     { stroke: #10b981; filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4)); }

.gauge-overlay {
    position: absolute;
    inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
}
.gauge-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ai-ink-3); }
.gauge-value { font-size: 32px; font-weight: 700; color: var(--ai-ink); margin-top: 4px; line-height: 1; letter-spacing: -0.02em; }
.gauge-value .suffix { font-size: 16px; color: var(--ai-ink-3); margin-left: 2px; }
.gauge-foot { font-size: 11px; color: var(--ai-ink-2); margin-top: 4px; }
.gauge-foot .up { color: #047857; font-weight: 600; }

/* ============================================================================
   Loan projection + impact donuts
   ============================================================================ */
.proj-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 12px;
}
@media (max-width: 900px) { .proj-grid { grid-template-columns: 1fr; } }

.proj-card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--ai-shadow-card);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.proj-eyebrow { display: inline-flex; align-items: center; gap: 5px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ai-ink-3); margin-bottom: 12px; }
.proj-eyebrow i { color: var(--ai-violet); }

.loan-headline {
    display: flex; align-items: baseline; gap: 8px;
    margin: 4px 0 14px;
}
.loan-headline .currency { font-size: 14px; font-weight: 600; color: var(--ai-ink-3); letter-spacing: 0.04em; }
.loan-headline .amount {
    font-size: 44px;
    font-weight: 700;
    color: var(--ai-ink);
    letter-spacing: -0.025em;
    line-height: 1;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.loan-confidence { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.conf-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ai-ink-3); }
.conf-bar { flex: 1; height: 6px; background: var(--ai-surface-2); border-radius: 999px; overflow: hidden; }
.conf-fill { height: 100%; width: 0; background: linear-gradient(90deg, #a78bfa, #22d3ee); border-radius: 999px; transition: width 1.1s var(--ai-ease); }
.conf-value { font-size: 12px; color: var(--ai-ink); font-family: 'JetBrains Mono', Consolas, monospace; min-width: 36px; text-align: right; }

.loan-range {
    margin-top: 6px;
}
.range-track {
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(167, 139, 250, 0.4), rgba(34, 211, 238, 0.4));
}
.range-marker {
    position: absolute;
    top: 50%;
    width: 14px; height: 14px;
    margin-left: -7px; margin-top: -7px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 0 0 2px #8b5cf6, 0 0 12px 4px rgba(139, 92, 246, 0.45);
    transition: left 1.1s var(--ai-ease);
}
.range-labels {
    display: flex; justify-content: space-between;
    margin-top: 8px;
    font-size: 10.5px; color: var(--ai-ink-3);
}
.range-labels strong { color: var(--ai-ink); font-weight: 600; }
.loan-foot { font-size: 11px; color: var(--ai-ink-3); margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--ai-border); }

/* Impact donuts */
.impact-row {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin: 6px 0 14px;
}
.impact-donut { position: relative; width: 120px; height: 120px; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-bg { fill: none; stroke: var(--ai-surface-2); stroke-width: 12; }
.donut-fg {
    fill: none;
    stroke: #8b5cf6;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 0 999;
    transition: stroke-dasharray 1.1s var(--ai-ease);
    filter: drop-shadow(0 0 6px var(--ai-glow-1));
}
.donut-fg.projected { stroke: #10b981; filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4)); }
.donut-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ai-ink-3); }
.donut-value { font-size: 22px; font-weight: 700; color: var(--ai-ink); margin-top: 2px; }
.impact-arrow { color: var(--ai-ink-3); font-size: 18px; }
.impact-foot {
    font-size: 12px; color: var(--ai-ink-2);
    padding-top: 12px; border-top: 1px dashed var(--ai-border);
}
.impact-foot i { color: #047857; margin-right: 4px; }
.impact-foot [data-counter] { color: #047857; font-weight: 600; font-family: 'JetBrains Mono', Consolas, monospace; }

/* ============================================================================
   Cohort pill (live indicator)
   ============================================================================ */
.cohort-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--ai-surface-2);
    color: var(--ai-ink-2);
    font-size: 10.5px; font-weight: 600;
}
.cohort-pill .dot.live { width: 7px; height: 7px; border-radius: 999px; background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); animation: pulseDot 1.4s ease-in-out infinite; }

/* ============================================================================
   Toasts (matches rule-engine/rule-flow style)
   ============================================================================ */
.toast {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 16px 36px -10px rgb(15 23 42 / 0.18), 0 0 0 1px var(--ai-border);
    color: var(--ai-ink);
    font-size: 12px; font-weight: 500;
    opacity: 0;
    transform: translateY(8px) scale(.98);
    transition: opacity .22s var(--ai-ease), transform .22s var(--ai-ease);
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast .ico { width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.toast.toast-success .ico { background: #d1fae5; color: #059669; }
.toast.toast-error   .ico { background: #fee2e2; color: #dc2626; }
.toast.toast-info    .ico { background: #ede9fe; color: #6d28d9; }

/* ============================================================================
   IMPACT MODAL — extreme animated cause-and-effect preview
   ============================================================================ */
.impact-modal {
    position: fixed; inset: 0;
    z-index: 250;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s var(--ai-ease);
}
.impact-modal.is-open { opacity: 1; pointer-events: auto; }

.impact-backdrop {
    position: absolute; inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(30, 27, 75, 0.42) 0%, rgba(11, 16, 32, 0.78) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.impact-panel {
    position: relative;
    width: min(1100px, calc(100vw - 48px));
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    border-radius: 22px;
    box-shadow:
        0 50px 100px -30px rgba(15, 23, 42, 0.6),
        0 0 0 1px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    transition: transform .42s var(--ai-ease), opacity .35s ease;
    isolation: isolate;
}
.impact-modal.is-open .impact-panel { transform: translateY(0) scale(1); opacity: 1; }

/* Animated mesh on the modal background */
.impact-panel::before {
    content: '';
    position: absolute; inset: 0; z-index: -1;
    border-radius: 22px;
    background:
        radial-gradient(35% 35% at 0% 0%, rgba(167, 139, 250, 0.20) 0%, transparent 60%),
        radial-gradient(35% 35% at 100% 0%, rgba(34, 211, 238, 0.18) 0%, transparent 60%),
        radial-gradient(40% 40% at 100% 100%, rgba(244, 114, 182, 0.12) 0%, transparent 65%);
    pointer-events: none;
    animation: meshShift 16s ease-in-out infinite alternate;
}

/* Header */
.impact-header {
    position: relative;
    display: flex; align-items: flex-start; gap: 14px;
    padding: 22px 26px 18px;
    border-bottom: 1px solid var(--ai-border);
}
.impact-icon {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 16px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    box-shadow: 0 12px 24px -10px rgba(139, 92, 246, 0.5);
    position: relative;
}
.impact-icon::after {
    content: '';
    position: absolute; inset: -3px;
    border-radius: 14px;
    background: inherit;
    opacity: 0.35;
    filter: blur(8px);
    z-index: -1;
}
.impact-icon[data-tone="emerald"] { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 12px 24px -10px rgba(16, 185, 129, 0.5); }
.impact-icon[data-tone="rose"]    { background: linear-gradient(135deg, #fb7185, #e11d48); box-shadow: 0 12px 24px -10px rgba(244, 63, 94, 0.5); }
.impact-icon[data-tone="blue"]    { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 12px 24px -10px rgba(59, 130, 246, 0.5); }
.impact-icon[data-tone="amber"]   { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 12px 24px -10px rgba(245, 158, 11, 0.5); }
.impact-icon[data-tone="sky"]     { background: linear-gradient(135deg, #38bdf8, #0284c7); box-shadow: 0 12px 24px -10px rgba(14, 165, 233, 0.5); }

.impact-head-text { flex: 1; min-width: 0; }
.impact-eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.10);
    color: #6d28d9;
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    margin-bottom: 6px;
}
.impact-eyebrow .dot {
    width: 6px; height: 6px; border-radius: 999px; background: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
    animation: pulseDot 1.4s ease-in-out infinite;
}
.impact-title { font-size: 17px; font-weight: 600; color: var(--ai-ink); letter-spacing: -0.01em; line-height: 1.35; margin: 0 0 4px; }
.impact-sub   { font-size: 12.5px; color: var(--ai-ink-2); margin: 0; line-height: 1.5; }

.impact-close {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: var(--ai-surface-2);
    color: var(--ai-ink-2);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: background-color .15s var(--ai-ease), color .15s var(--ai-ease), transform .15s var(--ai-ease);
}
.impact-close:hover { background: #fff1f2; color: #be123c; transform: rotate(90deg); }

/* Linear progress under header during compute */
.impact-progress {
    position: relative;
    height: 3px;
    background: var(--ai-surface-2);
    overflow: hidden;
}
.impact-progress-bar {
    position: absolute; inset: 0 100% 0 0;
    background: linear-gradient(90deg, #8b5cf6, #22d3ee, #f472b6);
    background-size: 200% 100%;
    animation: progressBar 1.1s var(--ai-ease) forwards, progressShift 2s linear infinite;
    transform-origin: left center;
}
@keyframes progressBar  { from { right: 100%; } to { right: 0%; } }
@keyframes progressShift { from { background-position: 0% 0; } to { background-position: 200% 0; } }
.impact-modal.compute-done .impact-progress { display: none; }

/* Loading state */
.impact-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px;
    padding: 70px 0 90px;
    transition: opacity .3s ease, max-height .3s ease;
    overflow: hidden;
}
.impact-loading.is-out { opacity: 0; max-height: 0; padding: 0; }

.impact-loader {
    position: relative;
    width: 76px; height: 76px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px;
    background: radial-gradient(circle at 35% 30%, #c4b5fd 0%, #8b5cf6 40%, #4338ca 100%);
    color: #fff;
    font-size: 24px;
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.45), inset 0 0 0 1px rgba(255,255,255,0.18);
    animation: orbBreathe 1.6s ease-in-out infinite;
}
.impact-loader .ring {
    position: absolute; inset: 0;
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.55);
    animation: pulseRing 2.2s ease-out infinite;
}
.impact-loader .ring.r2 { animation-delay: -0.7s; }
.impact-loader .ring.r3 { animation-delay: -1.4s; }
.loader-text {
    font-size: 12.5px; color: var(--ai-ink-2);
    font-family: 'JetBrains Mono', Consolas, monospace;
    letter-spacing: 0.02em;
}
.loader-text::after { content: '▌'; margin-left: 4px; animation: caretBlink .9s steps(2,end) infinite; color: #8b5cf6; }

/* Body */
.impact-body { padding: 22px 26px 26px; display: none; }
.impact-body.is-in { display: block; animation: bodyIn .35s var(--ai-ease) both; }
@keyframes bodyIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --------- KPI strip --------- */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
@media (max-width: 900px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
    position: relative;
    display: flex; gap: 10px; align-items: flex-start;
    padding: 14px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--ai-shadow-card);
    overflow: hidden;
    transform: translateY(8px);
    opacity: 0;
    animation: kpiIn .42s var(--ai-ease) forwards;
}
.kpi-card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 60%, var(--kpi-tone, rgba(139,92,246,0.08)) 100%);
    pointer-events: none;
}
.kpi-card[data-tone="emerald"] { --kpi-tone: rgba(16, 185, 129, 0.10); }
.kpi-card[data-tone="rose"]    { --kpi-tone: rgba(244, 63, 94, 0.10); }
.kpi-card[data-tone="blue"]    { --kpi-tone: rgba(59, 130, 246, 0.10); }
.kpi-card[data-tone="amber"]   { --kpi-tone: rgba(245, 158, 11, 0.12); }
@keyframes kpiIn { to { opacity: 1; transform: translateY(0); } }

.kpi-icon-mini {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 12px;
    flex-shrink: 0;
    background: var(--kpi-bg, linear-gradient(135deg, #8b5cf6, #6366f1));
    box-shadow: 0 6px 14px -6px rgba(99, 102, 241, 0.5);
}
.kpi-card[data-tone="emerald"] .kpi-icon-mini { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 6px 14px -6px rgba(16, 185, 129, 0.5); }
.kpi-card[data-tone="rose"]    .kpi-icon-mini { background: linear-gradient(135deg, #fb7185, #e11d48); box-shadow: 0 6px 14px -6px rgba(244, 63, 94, 0.5); }
.kpi-card[data-tone="blue"]    .kpi-icon-mini { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 6px 14px -6px rgba(59, 130, 246, 0.5); }
.kpi-card[data-tone="amber"]   .kpi-icon-mini { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 6px 14px -6px rgba(245, 158, 11, 0.5); }

.kpi-meta { flex: 1; min-width: 0; }
.kpi-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ai-ink-3); margin-bottom: 4px; }
.kpi-row { display: flex; align-items: baseline; gap: 6px; line-height: 1; flex-wrap: wrap; }
.kpi-from { font-size: 13px; color: var(--ai-ink-3); font-family: 'JetBrains Mono', Consolas, monospace; text-decoration: line-through; text-decoration-color: rgba(15, 23, 42, 0.25); }
.kpi-arrow { font-size: 9px; color: var(--ai-ink-3); }
.kpi-to { font-size: 22px; font-weight: 700; color: var(--ai-ink); letter-spacing: -0.015em; font-family: 'JetBrains Mono', Consolas, monospace; }
.kpi-suffix { font-size: 12px; color: var(--ai-ink-3); margin-left: -3px; }
.kpi-foot { font-size: 10.5px; font-weight: 600; margin-top: 5px; display: inline-flex; align-items: center; gap: 3px; }
.kpi-foot.pos { color: #047857; }
.kpi-foot.neg { color: #be123c; }
.kpi-foot.neu { color: var(--ai-ink-2); }
.kpi-foot i { font-size: 9px; }

/* --------- Cohort flow viz (the centerpiece) --------- */
.cohort-viz {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 140px 1fr;
    gap: 14px;
    padding: 22px 18px 18px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-radius: 16px;
    box-shadow: var(--ai-shadow-card);
    margin-bottom: 18px;
    overflow: hidden;
}
@media (max-width: 820px) {
    .cohort-viz { grid-template-columns: 1fr; }
    .cohort-delta { order: 2; flex-direction: row; padding: 8px 0; }
}

.cohort-side {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 0 6px;
    transform: translateY(8px);
    opacity: 0;
    animation: cohortIn .55s var(--ai-ease) .1s forwards;
}
.cohort-side.projected { animation-delay: .25s; }
@keyframes cohortIn { to { opacity: 1; transform: translateY(0); } }

.cohort-cap {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--ai-surface-2);
    color: var(--ai-ink-2);
    font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.cohort-side.projected .cohort-cap { background: rgba(139, 92, 246, 0.12); color: #6d28d9; }
.cohort-side.projected .cohort-cap::after { content: 'AI'; margin-left: 4px; padding: 1px 5px; border-radius: 4px; background: #8b5cf6; color: #fff; font-size: 8.5px; }

.cohort-pool {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 16px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--ai-shadow-card);
    min-width: 120px;
    text-align: center;
}
.cohort-pool .num { font-size: 20px; font-weight: 700; color: var(--ai-ink); letter-spacing: -0.015em; line-height: 1.1; font-family: 'JetBrains Mono', Consolas, monospace; }
.cohort-pool .lbl { font-size: 10.5px; color: var(--ai-ink-3); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-top: 2px; }
.cohort-pool.top  { background: linear-gradient(180deg, #fff, #f1f5f9); }

.cohort-tube {
    position: relative;
    width: 100%;
    max-width: 220px;
    height: 200px;
    border-radius: 12px;
    background:
        radial-gradient(ellipse at top, rgba(139, 92, 246, 0.08), transparent 60%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.03), rgba(15, 23, 42, 0.05));
    box-shadow: inset 0 0 0 1px var(--ai-border);
    overflow: hidden;
}
.cohort-tube::before {
    content: '';
    position: absolute; left: 50%; top: 0; bottom: 0;
    width: 2px; margin-left: -1px;
    background: linear-gradient(180deg, transparent 0%, rgba(139, 92, 246, 0.45) 20%, rgba(34, 211, 238, 0.45) 80%, transparent 100%);
}
.cohort-tube .rule-tag {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    padding: 3px 8px;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 4px 10px -4px rgba(15, 23, 42, 0.15), 0 0 0 1px var(--ai-border);
    font-size: 10px; color: var(--ai-ink); font-weight: 600;
    font-family: 'JetBrains Mono', Consolas, monospace;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
}
.cohort-side.projected .cohort-tube .rule-tag {
    background: linear-gradient(135deg, #ede9fe, #ffffff);
    box-shadow: 0 4px 10px -4px rgba(139, 92, 246, 0.4), 0 0 0 1px rgba(139, 92, 246, 0.3);
    color: #6d28d9;
}

/* The flowing dots */
.flow-dot {
    position: absolute;
    width: 8px; height: 8px;
    border-radius: 999px;
    top: -10px;
    left: 50%;
    margin-left: -4px;
    opacity: 0;
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.55), 0 0 0 1px rgba(255,255,255,0.6);
    will-change: top, transform, opacity;
}
.flow-dot.rejected { background: #f43f5e; box-shadow: 0 0 8px rgba(244, 63, 94, 0.55), 0 0 0 1px rgba(255,255,255,0.6); }
.flow-dot.approved { animation: flowApproved 2.6s linear infinite; }
.flow-dot.rejected { animation: flowRejected 2.6s linear infinite; }
@keyframes flowApproved {
    0%   { top: -10px; opacity: 0; transform: translateX(0) scale(0.6); }
    6%   { opacity: 1; transform: translateX(0) scale(1); }
    52%  { transform: translateX(0); }
    78%  { top: 170px; transform: translateX(-46px); opacity: 1; }
    100% { top: 198px; transform: translateX(-46px) scale(0.5); opacity: 0; }
}
@keyframes flowRejected {
    0%   { top: -10px; opacity: 0; transform: translateX(0) scale(0.6); }
    6%   { opacity: 1; transform: translateX(0) scale(1); }
    52%  { transform: translateX(0); }
    78%  { top: 170px; transform: translateX(46px); opacity: 1; }
    100% { top: 198px; transform: translateX(46px) scale(0.5); opacity: 0; }
}

.cohort-bottom {
    display: flex; gap: 8px; width: 100%; max-width: 220px;
}
.cohort-pool.approved, .cohort-pool.rejected { flex: 1; min-width: 0; padding: 8px; }
.cohort-pool.approved { background: linear-gradient(180deg, #ecfdf5, #d1fae5); box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.22); }
.cohort-pool.rejected { background: linear-gradient(180deg, #fff1f2, #ffe4e6); box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.22); }
.cohort-pool.approved .num { color: #047857; }
.cohort-pool.rejected .num { color: #be123c; }
.cohort-pool.approved i, .cohort-pool.rejected i { font-size: 10px; opacity: 0.7; margin-bottom: 1px; }
.cohort-pool.approved i { color: #047857; }
.cohort-pool.rejected i { color: #be123c; }

/* Center delta */
.cohort-delta {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px;
    padding: 0 4px;
    position: relative;
    opacity: 0;
    animation: cohortIn .55s var(--ai-ease) .55s forwards;
}
.delta-arrow {
    width: 38px; height: 38px;
    border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #8b5cf6, #22d3ee);
    color: #fff;
    font-size: 14px;
    box-shadow: 0 10px 20px -8px rgba(139, 92, 246, 0.6);
    animation: deltaPulse 1.8s ease-in-out infinite;
}
@keyframes deltaPulse {
    0%, 100% { box-shadow: 0 10px 20px -8px rgba(139, 92, 246, 0.6), 0 0 0 0 rgba(139, 92, 246, 0.5); transform: scale(1); }
    50%      { box-shadow: 0 10px 20px -8px rgba(139, 92, 246, 0.6), 0 0 0 12px rgba(139, 92, 246, 0); transform: scale(1.06); }
}
.delta-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: 11px; font-weight: 600;
    text-align: center;
    white-space: nowrap;
}
.delta-pill strong { font-weight: 700; }
.delta-pill.warn { background: #fff7ed; color: #c2410c; }
.delta-pill.neutral { background: var(--ai-surface-2); color: var(--ai-ink-2); }

/* --------- Bottom row: projection chart + risk shift histogram --------- */
.impact-chart-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}
@media (max-width: 820px) { .impact-chart-row { grid-template-columns: 1fr; } }

.impact-chart, .risk-shift {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--ai-shadow-card);
    padding: 16px;
    position: relative;
    opacity: 0;
    transform: translateY(8px);
    animation: kpiIn .5s var(--ai-ease) .5s forwards;
}
.risk-shift { animation-delay: .65s; }

.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chart-title { font-size: 12.5px; font-weight: 600; color: var(--ai-ink); letter-spacing: -0.005em; }
.chart-legend { display: inline-flex; align-items: center; gap: 10px; }
.leg { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--ai-ink-3); font-weight: 600; }
.leg::before {
    content: '';
    width: 14px; height: 2px;
    border-radius: 999px;
    background: var(--ai-ink-3);
}
.leg.leg-curr::before { background: #94a3b8; background: repeating-linear-gradient(90deg, #94a3b8 0 3px, transparent 3px 5px); }
.leg.leg-proj::before { background: linear-gradient(90deg, #8b5cf6, #22d3ee); height: 3px; }

.proj-chart { width: 100%; height: 200px; display: block; }
.proj-chart .grid-line       { stroke: rgba(15, 23, 42, 0.06); stroke-width: 1; stroke-dasharray: 4 4; }
.proj-chart .axis-label      { fill: var(--ai-ink-3); font-size: 9px; font-family: 'Inter', sans-serif; }
.proj-chart .today-line      { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 2 3; }
.proj-chart .today-label     { fill: var(--ai-ink-3); font-size: 9px; font-weight: 600; font-family: 'Inter', sans-serif; }
.proj-chart .area-fill       { fill: url(#proj-area-grad); opacity: 0; animation: areaIn 1s var(--ai-ease) 1.4s forwards; }
@keyframes areaIn { to { opacity: 1; } }
.proj-chart .line-curr {
    fill: none;
    stroke: #94a3b8;
    stroke-width: 2;
    stroke-dasharray: 5 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.proj-chart .line-proj {
    fill: none;
    stroke: url(#proj-line-grad);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 4px 6px rgba(139, 92, 246, 0.25));
}
.proj-chart .line-reveal-curr {
    stroke-dasharray: var(--len) var(--len);
    stroke-dashoffset: var(--len);
    animation: drawLine 1.2s var(--ai-ease) .9s forwards;
}
.proj-chart .line-reveal-proj {
    stroke-dasharray: var(--len) var(--len);
    stroke-dashoffset: var(--len);
    animation: drawLine 1.4s var(--ai-ease) 1.3s forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.proj-chart .dot-curr, .proj-chart .dot-proj { opacity: 0; animation: dotPop .35s var(--ai-ease) forwards; }
.proj-chart .dot-curr { fill: #94a3b8; }
.proj-chart .dot-proj { fill: #8b5cf6; filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.45)); }
@keyframes dotPop { 0% { opacity: 0; transform: scale(0); } 60% { transform: scale(1.4); } 100% { opacity: 1; transform: scale(1); } }
.proj-chart .endpoint-label {
    fill: var(--ai-ink);
    font-size: 10px;
    font-weight: 700;
    font-family: 'JetBrains Mono', Consolas, monospace;
    opacity: 0;
    animation: dotPop .35s ease 2.5s forwards;
}
.proj-chart .endpoint-label.curr-end { fill: #64748b; font-weight: 500; }

/* Histogram */
.histo {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    align-items: end;
    height: 200px;
    padding-bottom: 24px;
    position: relative;
}
.histo::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 22px;
    height: 1px;
    background: rgba(15, 23, 42, 0.08);
}
.histo-band {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px;
    position: relative;
    height: 100%;
    justify-content: flex-end;
}
.histo-bars {
    display: flex; align-items: flex-end; gap: 3px;
    height: calc(100% - 22px);
    width: 100%;
    justify-content: center;
}
.histo-bar {
    width: 26%;
    min-width: 12px;
    max-width: 18px;
    background: var(--ai-surface-2);
    border-radius: 4px 4px 0 0;
    position: relative;
    transform-origin: bottom;
    transform: scaleY(0);
    animation: histoUp .7s var(--ai-ease) forwards;
    box-shadow: inset 0 0 0 1px var(--ai-border);
}
.histo-bar.curr  { background: linear-gradient(180deg, #cbd5e1, #94a3b8); }
.histo-bar.proj  { background: linear-gradient(180deg, #a78bfa, #6d28d9); box-shadow: 0 0 12px rgba(139, 92, 246, 0.25); }
.histo-bar .v {
    position: absolute;
    top: -16px; left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 600;
    color: var(--ai-ink-2);
    font-family: 'JetBrains Mono', Consolas, monospace;
    opacity: 0;
    animation: dotPop .35s ease 1s forwards;
    white-space: nowrap;
}
.histo-bar.proj .v { color: #6d28d9; }
@keyframes histoUp { to { transform: scaleY(1); } }
.histo-label {
    position: absolute;
    bottom: 0;
    font-size: 10px;
    font-weight: 700;
    color: var(--ai-ink-3);
    letter-spacing: 0.04em;
}

/* --------- Footer --------- */
.impact-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid var(--ai-border);
    opacity: 0;
    transform: translateY(6px);
    animation: kpiIn .45s var(--ai-ease) 1s forwards;
}
.impact-confidence { display: inline-flex; align-items: center; gap: 8px; }
.conf-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f5f3ff, #ecfeff);
    box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.25);
    color: #6d28d9;
    font-size: 12px;
}
.conf-pill strong { font-family: 'JetBrains Mono', Consolas, monospace; font-weight: 700; }
.conf-foot { font-size: 10.5px; color: var(--ai-ink-3); }

.impact-actions { display: flex; align-items: center; gap: 8px; }
.impact-cancel {
    padding: 8px 14px;
    border-radius: 9px;
    background: #fff;
    color: var(--ai-ink-2);
    font-size: 13px; font-weight: 500;
    box-shadow: inset 0 0 0 1px var(--ai-border);
    transition: background-color .15s var(--ai-ease);
}
.impact-cancel:hover { background: var(--ai-surface-2); }
.impact-apply {
    position: relative;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px;
    border-radius: 9px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    font-size: 13px; font-weight: 600;
    box-shadow: 0 10px 22px -8px rgba(99, 102, 241, 0.55), inset 0 0 0 1px rgba(255,255,255,0.15);
    overflow: hidden;
    transition: transform .15s var(--ai-ease), box-shadow .2s var(--ai-ease);
}
.impact-apply:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -8px rgba(99, 102, 241, 0.7); }
.impact-apply::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.25) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform .6s var(--ai-ease);
}
.impact-apply:hover::before { transform: translateX(100%); }

/* --------- Confetti (after apply) --------- */
.confetti-burst { position: fixed; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 260; }
.confetti-piece {
    position: absolute;
    width: 8px; height: 12px;
    top: 0; left: 0;
    transform: translate(-50%, -50%) rotate(0deg);
    animation: confettiFly 1.2s ease-out forwards;
    border-radius: 1px;
}
@keyframes confettiFly {
    0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(var(--cx), var(--cy)) rotate(var(--cr)) scale(0.6); opacity: 0; }
}

/* ============================================================================
   Reduced motion respect
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .ai-orbit, .ai-orb, .orb-pulse, .orbit-dot, .floaty, .ai-hero-bg .mesh,
    .hero-gradient, .hero-cta-glow, .ai-orb .orb-core, .pipeline-stage.is-active .pipeline-pill,
    .thinking-dot, .thinking-card::before, .ds-card.is-scanning::after,
    .flow-dot, .impact-panel::before, .impact-loader, .impact-loader .ring,
    .delta-arrow, .impact-progress-bar, .histo-bar, .proj-chart .line-reveal-curr,
    .proj-chart .line-reveal-proj, .proj-chart .dot-curr, .proj-chart .dot-proj,
    .confetti-piece, .kpi-card, .cohort-side, .cohort-delta, .impact-chart, .risk-shift,
    .impact-footer, .loader-text::after { animation: none !important; transition: none !important; }
}
