@keyframes animateUp {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    50% {
        opacity: 1;
        transform: translateY(-3px);
    }
    100% {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes animateDown {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    50% {
        opacity: 1;
        transform: translateY(-4px);
    }
    100% {
        opacity: 0;
        transform: translateY(6px);
    }
}

.arrowUp {
    display: inline-block;
    margin-left: 0.25rem;
    animation: animateUp 1.5s ease-in-out infinite;
}

.arrowDown {
    display: inline-block;
    margin-left: 0.25rem;
    animation: animateDown 1.5s ease-in-out infinite;
}

.funnelChips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.funnelChip {
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
}

.funnelChipActive {
    background: #eff6ff;
    color: #1d4ed8;
}

.funnelChipInactive {
    background: #f3f4f6;
    color: #9ca3af;
}

:global(.dark) .funnelChipActive {
    background: #1e3a5f;
    color: #93c5fd;
}

:global(.dark) .funnelChipInactive {
    background: #1b2e4b;
    color: #64748b;
}

.timeline {
    border-left: 2px solid #e5e7eb;
    padding-left: 1rem;
    margin-left: 0.5rem;
}

:global(.dark) .timeline {
    border-left-color: #334155;
}

.timelineItem {
    position: relative;
    padding-bottom: 1.1rem;
}

.timelineItem::before {
    content: '';
    position: absolute;
    left: -1.35rem;
    top: 0.45rem;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 9999px;
    background: #3b82f6;
}

.timelineGroup::before {
    background: #94a3b8;
}

.timelineBoundary {
    position: relative;
    margin: 0.25rem 0 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: #f3f4f6;
}

:global(.dark) .timelineBoundary {
    background: #1b2e4b;
}

.timelineBoundaryLabel {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #4b5563;
}

:global(.dark) .timelineBoundaryLabel {
    color: #cbd5e1;
}

.eventBadge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
}

:global(.dark) .eventBadge {
    background: #1e3a5f;
    color: #93c5fd;
}

.eventAction {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    color: #111827;
}

:global(.dark) .eventAction {
    color: #f1f5f9;
}

.eventPath {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-all;
    color: #111827;
}

:global(.dark) .eventPath {
    color: #e5e7eb;
}

.eventPathSecondary {
    font-size: 0.8rem;
    line-height: 1.35;
    word-break: break-all;
    color: #6b7280;
    margin-top: 0.15rem;
}

:global(.dark) .eventPathSecondary {
    color: #94a3b8;
}

.metaChips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.metaChip {
    font-size: 0.7rem;
    line-height: 1.2;
    padding: 0.15rem 0.4rem;
    border-radius: 0.35rem;
    background: #f3f4f6;
    color: #4b5563;
}

:global(.dark) .metaChip {
    background: #243b55;
    color: #cbd5e1;
}

.groupToggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.groupCount {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

:global(.dark) .groupCount {
    color: #e2e8f0;
}

.groupChevron {
    font-size: 0.75rem;
    color: #9ca3af;
}

.groupList {
    margin-top: 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding-left: 0.15rem;
}

.groupListItem {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

/* GA4-style funnel (ApexCharts + overlay) */
.funnelApexWrap {
    width: 100%;
    --funnel-steps: 5;
}

.funnelStepHeadRow {
    display: grid;
    grid-template-columns: repeat(var(--funnel-steps), minmax(0, 1fr));
    gap: 0.5rem;
    padding-left: var(--funnel-plot-left, 3.5rem);
    padding-right: var(--funnel-plot-right, 2.5rem);
}

.funnelAbandonRow {
    position: relative;
    width: 100%;
    min-height: 4.75rem;
}

.funnelAbandonSlot {
    position: absolute;
    top: 0.55rem;
    transform: translateX(-50%);
    text-align: center;
    color: #6b7280;
    min-width: 4.5rem;
    pointer-events: none;
}

.funnelChartArea {
    position: relative;
    width: 100%;
}

.funnelZoomControls {
    position: absolute;
    right: 0.75rem;
    bottom: 5.5rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    border-radius: 0.35rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.funnelZoomBtn {
    width: 1.85rem;
    height: 1.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: #fff;
    color: #374151;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
}

.funnelZoomBtn + .funnelZoomBtn {
    border-top: 1px solid #e5e7eb;
}

.funnelZoomBtn:hover:not(:disabled) {
    background: #f3f4f6;
}

.funnelZoomBtn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.funnelZoomLevel {
    font-size: 0.6rem;
    font-weight: 600;
    color: #6b7280;
    padding: 0.15rem 0.25rem 0.35rem;
    line-height: 1;
}

:global(.dark) .funnelZoomControls {
    background: #1b2e4b;
    border-color: #334155;
}

:global(.dark) .funnelZoomBtn {
    background: #1b2e4b;
    color: #e2e8f0;
}

:global(.dark) .funnelZoomBtn + .funnelZoomBtn {
    border-top-color: #334155;
}

:global(.dark) .funnelZoomBtn:hover:not(:disabled) {
    background: #243b55;
}

:global(.dark) .funnelZoomLevel {
    color: #94a3b8;
}

.funnelChart {
    width: 100%;
    overflow-x: auto;
    position: relative;
}

.funnelChartInner {
    display: flex;
    gap: 0.75rem;
    min-width: 640px;
}

.funnelYAxis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    width: 2.5rem;
    padding-top: 3.25rem;
    padding-bottom: 4.75rem;
    font-size: 0.7rem;
    color: #9ca3af;
    flex-shrink: 0;
}

.funnelPlot {
    position: relative;
    flex: 1;
    min-height: 280px;
    height: 100%;
}

.funnelGridLine {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed #e5e7eb;
    pointer-events: none;
}

.funnelPlot .funnelGridLine:nth-child(1) {
    top: 3.25rem;
}

.funnelPlot .funnelGridLine:nth-child(2) {
    top: calc(3.25rem + (100% - 3.25rem - 4.75rem) * 0.5);
}

.funnelPlot .funnelGridLine:nth-child(3) {
    top: calc(100% - 4.75rem);
}

.funnelBars {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(var(--funnel-steps, 5), minmax(0, 1fr));
    gap: 0.5rem;
    height: 100%;
    min-height: 280px;
}

.funnelDropSvg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

.funnelDropPolygon {
    fill: rgba(66, 133, 244, 0.22);
}

:global(.dark) .funnelDropPolygon {
    fill: rgba(96, 165, 250, 0.22);
}

.funnelCol {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.funnelStepHead {
    height: 3.25rem;
    text-align: center;
    padding: 0 0.15rem;
}

.funnelAbandon {
    min-height: 4.75rem;
    text-align: center;
    padding-top: 0.55rem;
    color: #6b7280;
}

.funnelStepLabel {
    font-size: 0.72rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.25;
}

:global(.dark) .funnelStepLabel {
    color: #e2e8f0;
}

.funnelStepRate {
    font-size: 0.7rem;
    color: #6b7280;
    margin-top: 0.15rem;
}

.funnelBarTrack {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 140px;
}

.funnelBarWrap {
    position: relative;
    z-index: 2;
    width: 42%;
    min-width: 28px;
    max-width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: default;
}

.funnelBar {
    width: 100%;
    flex: 1;
    min-height: 4px;
    background: #4285f4;
    border-radius: 2px 2px 0 0;
    transition: filter 0.15s ease;
}

.funnelBarWrap:hover .funnelBar {
    filter: brightness(1.08);
}

.funnelBarValueOutside {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -4px);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    color: #1f2937;
    white-space: nowrap;
    pointer-events: none;
}

:global(.dark) .funnelBarValueOutside {
    color: #f1f5f9;
}

.funnelAbandonCount {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
}

:global(.dark) .funnelAbandonCount {
    color: #cbd5e1;
}

.funnelAbandonRate {
    font-size: 0.7rem;
}

.funnelAbandonLabel {
    font-size: 0.65rem;
    margin-top: 0.15rem;
    color: #9ca3af;
}

.funnelAbandonEmpty {
    font-size: 0.75rem;
    color: #d1d5db;
    padding-top: 0.5rem;
}

:global(.dark) .funnelGridLine {
    border-top-color: #334155;
}

:global(.dark) .funnelStepRate,
:global(.dark) .funnelAbandon,
:global(.dark) .funnelAbandonSlot {
    color: #94a3b8;
}
