/* ── Flows module theme ───────────────────────────────── */

/* ── rFlows color tokens (dark defaults) ─────────────── */
/* Use :host so vars apply inside shadow DOM (flows.css is loaded via <link> in shadow root) */
:host {
	/* Source node */
	--rflows-source-bg: #064e3b;
	--rflows-source-border: #10b981;
	--rflows-source-rate: #6ee7b7;

	/* Edge colors */
	--rflows-edge-inflow: #10b981;
	--rflows-edge-spending: #3b82f6;
	--rflows-edge-overflow: #f59e0b;

	/* Funnel zones */
	--rflows-zone-drain: #ef4444;
	--rflows-zone-drain-opacity: 0.08;
	--rflows-zone-healthy: #0ea5e9;
	--rflows-zone-healthy-opacity: 0.10;
	--rflows-zone-overflow: #f59e0b;
	--rflows-zone-overflow-opacity: 0.12;
	--rflows-fill-opacity: 0.45;

	/* Funnel labels */
	--rflows-label-inflow: #10b981;
	--rflows-label-spending: #3b82f6;
	--rflows-label-overflow: #f59e0b;

	/* Status colors */
	--rflows-status-critical: #ef4444;
	--rflows-status-sustained: #f59e0b;
	--rflows-status-overflow: #10b981;
	--rflows-status-thriving: #10b981;
	--rflows-sat-bar: #10b981;
	--rflows-sat-border: #fbbf24;

	/* Outcome / progress */
	--rflows-status-completed: #10b981;
	--rflows-status-blocked: #ef4444;
	--rflows-status-inprogress: #3b82f6;
	--rflows-status-notstarted: #64748b;
	--rflows-phase-unlocked: #10b981;

	/* Score badge */
	--rflows-score-gold: #fbbf24;
	--rflows-score-green: #10b981;
	--rflows-score-amber: #f59e0b;
	--rflows-score-red: #ef4444;

	/* Card value */
	--rflows-card-value: #0ea5e9;

	/* Selection */
	--rflows-selected: #6366f1;

	/* Inline edit buttons */
	--rflows-btn-done: #10b981;
	--rflows-btn-delete: #ef4444;
	--rflows-btn-fund: #6366f1;
	--rflows-btn-save: #10b981;

	/* Sufficiency tooltip highlight */
	--rflows-sufficiency-highlight: #fbbf24;

	/* Edge drag handle */
	--rflows-drag-handle-fill: #475569;
	--rflows-drag-handle-stroke: #94a3b8;

	/* Modal border accent */
	--rflows-modal-border: #334155;
}

/* ── Base ────────────────────────────────────────────── */
.flows-landing, .flows-detail {
	font-family: system-ui, -apple-system, sans-serif;
}

/* Thin scrollbars (rApp convention) */
.flows-detail, .flows-landing { scrollbar-width: thin; scrollbar-color: var(--rs-bg-surface-raised) transparent; }
.flows-detail ::-webkit-scrollbar,
.flows-landing ::-webkit-scrollbar { width: 6px; height: 6px; }
.flows-detail ::-webkit-scrollbar-track,
.flows-landing ::-webkit-scrollbar-track { background: transparent; }
.flows-detail ::-webkit-scrollbar-thumb,
.flows-landing ::-webkit-scrollbar-thumb { background: var(--rs-bg-surface-raised); border-radius: 3px; }

/* ── Shared utility classes ──────────────────────────── */
.flows-loading { text-align: center; color: var(--rs-text-muted); padding: 48px 16px; font-size: 14px; }
.flows-error { text-align: center; color: var(--rs-error); padding: 20px 16px; font-size: 14px; }

/* ── Landing page ────────────────────────────────────── */
.flows-landing { max-width: 960px; margin: 0 auto; padding: 24px 20px 64px; }

/* Features grid */
.flows-features { margin-bottom: 48px; }
.flows-features__grid {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px;
}
.flows-features__card {
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px; padding: 20px;
	transition: border-color 0.2s;
}
.flows-features__card:hover { border-color: var(--rs-bg-surface-raised); }
.flows-features__icon { font-size: 24px; margin-bottom: 8px; }
.flows-features__card h3 { font-size: 14px; font-weight: 600; color: var(--rs-text-primary); margin: 0 0 6px; }
.flows-features__card p { font-size: 12px; color: var(--rs-text-secondary); line-height: 1.6; margin: 0; }

/* Flow list */
.flows-flows { margin-bottom: 48px; }
.flows-flows__header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.flows-flows__heading { font-size: 18px; font-weight: 600; color: var(--rs-text-primary); margin: 0; }
.flows-flows__user { font-size: 12px; color: var(--rs-text-muted); }
.flows-flows__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.flows-flows__empty {
	text-align: center; color: var(--rs-text-muted); padding: 32px 16px; font-size: 14px;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px;
}
.flows-flows__empty a { color: var(--rs-primary-hover); text-decoration: none; }
.flows-flows__empty a:hover { text-decoration: underline; }

.flows-flow-card {
	display: block; text-decoration: none;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px;
	padding: 16px; cursor: pointer; transition: border-color 0.2s, transform 0.15s;
}
.flows-flow-card:hover { border-color: var(--rs-primary-hover); transform: translateY(-1px); }
.flows-flow-card__name { font-size: 15px; font-weight: 600; color: var(--rs-text-primary); margin-bottom: 4px; }
.flows-flow-card__value { font-size: 20px; font-weight: 700; color: var(--rflows-card-value, #0ea5e9); margin-bottom: 4px; }
.flows-flow-card__meta { font-size: 12px; color: var(--rs-text-muted); }

/* About / how-it-works section */
.flows-about { margin-bottom: 48px; }
.flows-about__heading { font-size: 18px; font-weight: 600; color: var(--rs-text-primary); margin: 0 0 20px; }

/* Steps layout (replaces the old card grid for "how it works") */
.flows-about__steps { display: flex; flex-direction: column; gap: 16px; }
.flows-about__step {
	display: flex; gap: 16px; align-items: flex-start;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px; padding: 20px;
}
.flows-about__step-num {
	width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
	background: var(--rs-primary); color: #fff; font-weight: 700; font-size: 14px;
	display: flex; align-items: center; justify-content: center;
}
.flows-about__step h3 { font-size: 14px; font-weight: 600; color: var(--rs-text-primary); margin: 0 0 4px; }
.flows-about__step p { font-size: 13px; color: var(--rs-text-secondary); line-height: 1.6; margin: 0; }

/* Legacy about grid (kept for compat) */
.flows-about__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.flows-about__card {
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px; padding: 20px;
}
.flows-about__icon { font-size: 28px; margin-bottom: 8px; }
.flows-about__card h3 { font-size: 15px; font-weight: 600; color: var(--rs-text-primary); margin: 0 0 8px; }
.flows-about__card p { font-size: 13px; color: var(--rs-text-secondary); line-height: 1.6; margin: 0; }

/* ── Detail view ─────────────────────────────────────── */
.flows-detail { max-width: 1100px; margin: 0 auto; padding: 16px 20px 64px; }
.flows-detail--fullpage { padding: 0; max-width: none; height: 100vh; }

/* ── Table tab — card grid ───────────────────────────── */
.flows-table { }
.flows-section { margin-bottom: 28px; }
.flows-section__title { font-size: 14px; font-weight: 600; color: var(--rs-text-secondary); margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.flows-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

.flows-card {
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px; padding: 16px;
}
.flows-card__header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.flows-card__icon { font-size: 18px; }
.flows-card__label { font-size: 14px; font-weight: 600; color: var(--rs-text-primary); flex: 1; }
.flows-card__type { font-size: 11px; color: var(--rs-text-muted); text-transform: uppercase; }
.flows-card__status { font-size: 11px; font-weight: 600; text-transform: capitalize; }
.flows-card__desc { font-size: 12px; color: var(--rs-text-secondary); margin-bottom: 10px; line-height: 1.5; }

.flows-card__stat { margin-bottom: 10px; }
.flows-card__stat-value { font-size: 18px; font-weight: 700; color: var(--rs-text-primary); }
.flows-card__stat-label { font-size: 12px; color: var(--rs-text-muted); margin-left: 4px; }
.flows-card__stats { display: flex; justify-content: space-between; margin-bottom: 8px; }

/* Progress bar */
.flows-card__bar-container {
	position: relative; height: 6px; background: var(--rs-border-strong); border-radius: 3px;
	margin-bottom: 10px; overflow: visible;
}
.flows-card__bar {
	height: 100%; border-radius: 3px; background: #0ea5e9;
	transition: width 0.3s ease;
}
.flows-card__bar--outcome { opacity: 0.8; }
.flows-card__bar-threshold {
	position: absolute; top: -3px; width: 2px; height: 12px;
	background: var(--rs-warning); border-radius: 1px;
}

.flows-card__thresholds {
	display: flex; gap: 12px; font-size: 11px; color: var(--rs-text-muted); margin-bottom: 8px;
}

/* Allocation lists */
.flows-card__allocs { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rs-border-strong); }
.flows-card__alloc-title { font-size: 11px; color: var(--rs-text-muted); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; }
.flows-card__alloc { font-size: 12px; color: var(--rs-text-secondary); display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.flows-card__alloc-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* Status colors */
.flows-status--abundant { color: var(--rs-warning); }
.flows-status--sufficient { color: var(--rs-success); }
.flows-status--seeking { color: #0ea5e9; }
.flows-status--critical { color: var(--rs-error); }

/* ── Interactive canvas (Diagram tab) ───────────────── */
.flows-canvas-container {
	position: relative; height: 70vh; min-height: 400px;
	background: var(--rs-bg-page); border-radius: 12px; border: 1px solid var(--rs-border-strong);
	overflow: hidden; user-select: none; touch-action: none;
}
.flows-canvas-container--fullpage {
	height: 100%; border-radius: 0; border: none; min-height: unset;
}

/* Compact nav overlay inside full-page canvas */
.flows-nav-overlay {
	position: absolute; top: 0; left: 0; right: 0; z-index: 15;
	height: 44px; display: flex; align-items: center; padding: 0 16px; gap: 12px;
	background: linear-gradient(to bottom, var(--rs-bg-overlay) 0%, transparent 100%);
	pointer-events: none;
}
.flows-nav-overlay > * { pointer-events: auto; }
.flows-nav-overlay .rapp-nav__back { color: var(--rs-text-secondary); text-decoration: none; font-size: 13px; }
.flows-nav-overlay .rapp-nav__back:hover { color: var(--rs-text-primary); }
.flows-nav-overlay .rapp-nav__title { color: var(--rs-text-primary); font-size: 14px; font-weight: 600; }
.flows-nav-overlay .rapp-nav__badge { font-size: 10px; color: var(--rs-warning); background: rgba(251,191,36,0.15); padding: 2px 8px; border-radius: 4px; }

/* Toolbar offset when nav overlay present */
.flows-canvas-container--fullpage .flows-canvas-toolbar { top: 54px; }

.flows-canvas-svg {
	width: 100%; height: 100%; display: block;
	cursor: grab;
	background-color: var(--rs-canvas-bg);
	background-image: var(--rs-canvas-bg-image);
	background-size: var(--rs-canvas-bg-size);
}
.flows-canvas-svg.panning { cursor: grabbing; }
.flows-canvas-svg.dragging { cursor: move; }

/* Toolbar — left-side vertical panel */
.flows-canvas-toolbar {
	position: absolute; top: 10px; left: 10px; z-index: 10;
	display: flex; flex-direction: column; gap: 4px; align-items: stretch;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border);
	border-radius: 10px; padding: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
	width: 150px;
}
.flows-toolbar-btn {
	padding: 7px 10px; border: 1px solid transparent; border-radius: 6px;
	background: transparent; color: var(--rs-text-primary); font-size: 12px; font-weight: 600;
	cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
	text-align: left;
}
.flows-toolbar-btn:hover { background: var(--rs-bg-hover); }
.flows-toolbar-btn--fund { background: var(--rs-primary); color: #fff; border-color: var(--rs-primary); text-align: center; }
.flows-toolbar-btn--fund:hover { background: var(--rs-primary-hover); }
.flows-toolbar-btn--source { color: var(--rflows-source-text, #6ee7b7); }
.flows-toolbar-btn--source:hover { background: var(--rflows-source-hover-bg, #064e3b); }
.flows-toolbar-btn--funnel { color: var(--rflows-funnel-text, #93c5fd); }
.flows-toolbar-btn--funnel:hover { background: var(--rflows-funnel-hover-bg, #1e3a5f); }
.flows-toolbar-btn--outcome { color: var(--rflows-outcome-text, #f9a8d4); }
.flows-toolbar-btn--outcome:hover { background: var(--rflows-outcome-hover-bg, #4a1942); }
.flows-toolbar-btn--active { background: var(--rs-primary); border-color: var(--rs-primary-hover); color: #fff; }
.flows-toolbar-sep {
	height: 1px; background: var(--rs-border); margin: 2px 0;
}

/* SVG node styles */
.flow-node { cursor: pointer; }
.flow-node:hover .node-bg { filter: brightness(1.05); }
.flow-node.selected .node-bg { stroke: var(--rs-primary-hover); stroke-width: 3; }
.node-glow { filter: drop-shadow(0 0 6px rgba(251,191,36,0.5)); }

/* Funnel drag handles — hidden by default, visible on hover */
.funnel-drain-knob, .funnel-height-handle { opacity: 0; transition: opacity 0.2s; }
.flow-node:hover .funnel-drain-knob,
.flow-node:hover .funnel-height-handle { opacity: 0.85; }
.funnel-drain-knob:hover { opacity: 1 !important; }
.funnel-height-handle:hover { opacity: 1 !important; }
.drain-knob { cursor: ew-resize; transition: filter 0.15s; }
.drain-knob:hover { filter: brightness(1.15); }
.drain-handle-group { transition: transform 0.2s ease; }

/* HTML card nodes (foreignObject) */
.node-card {
	background: var(--rs-bg-surface, #fff); color: var(--rs-text-primary, #1e293b); border-radius: 12px; overflow: hidden;
	font-family: system-ui, -apple-system, sans-serif;
	height: 100%; box-sizing: border-box;
}
.source-card { }
.outcome-card { }
.funnel-overlay { pointer-events: none; }

/* Editor panel — right side slide-in */
.flows-editor-panel {
	position: absolute; top: 0; right: 0; bottom: 0; width: 320px; z-index: 20;
	background: var(--rs-bg-surface); border-left: 1px solid var(--rs-border-strong);
	transform: translateX(100%); transition: transform 0.25s ease;
	overflow-y: auto; padding: 16px;
	display: flex; flex-direction: column; gap: 12px;
}
.flows-editor-panel.open { transform: translateX(0); }

.editor-header {
	display: flex; align-items: center; justify-content: space-between;
}
.editor-title { font-size: 14px; font-weight: 600; color: var(--rs-text-primary); }
.editor-close {
	background: none; border: none; color: var(--rs-text-secondary); font-size: 18px; cursor: pointer; padding: 2px 6px;
}
.editor-close:hover { color: var(--rs-text-primary); }

/* Analytics popout panel (left side) */
.flows-analytics-panel {
	position: absolute; top: 0; left: 0; bottom: 0; width: 380px; z-index: 20;
	background: var(--rs-bg-surface); border-right: 1px solid var(--rs-border-strong);
	transform: translateX(-100%); transition: transform 0.25s ease;
	overflow-y: auto; display: flex; flex-direction: column;
}
.flows-analytics-panel.open { transform: translateX(0); }

.analytics-header {
	display: flex; align-items: center; gap: 8px; padding: 12px 16px;
	border-bottom: 1px solid var(--rs-border-strong); flex-shrink: 0;
}
.analytics-title { font-size: 14px; font-weight: 600; color: var(--rs-text-primary); flex: 1; }
.analytics-close {
	background: none; border: none; color: var(--rs-text-secondary); font-size: 18px; cursor: pointer;
}
.analytics-close:hover { color: var(--rs-text-primary); }
.analytics-tabs { display: flex; gap: 4px; }
.analytics-tab {
	padding: 4px 10px; border: 1px solid var(--rs-border-strong); border-radius: 4px;
	background: transparent; color: var(--rs-text-secondary); font-size: 11px; cursor: pointer;
}
.analytics-tab:hover { background: var(--rs-border-strong); color: var(--rs-text-primary); }
.analytics-tab--active { background: var(--rs-border-strong); color: var(--rs-text-primary); }
.analytics-content { padding: 16px; flex: 1; overflow-y: auto; }

.editor-field { display: flex; flex-direction: column; gap: 4px; }
.editor-label { font-size: 11px; color: var(--rs-text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.editor-input {
	padding: 6px 10px; border: 1px solid var(--rs-border-strong); border-radius: 6px;
	background: var(--rs-bg-page); color: var(--rs-text-primary); font-size: 13px;
}
.editor-input:focus { outline: none; border-color: var(--rs-primary-hover); }
.editor-select {
	padding: 6px 10px; border: 1px solid var(--rs-border-strong); border-radius: 6px;
	background: var(--rs-bg-page); color: var(--rs-text-primary); font-size: 13px;
}
.editor-alloc-row {
	display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--rs-text-secondary);
}
.editor-alloc-row .editor-input { width: 60px; text-align: right; }
.editor-alloc-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.editor-section {
	padding-top: 8px; border-top: 1px solid var(--rs-border-strong);
}
.editor-section-title { font-size: 12px; font-weight: 600; color: var(--rs-text-muted); margin-bottom: 6px; }
.editor-btn {
	padding: 6px 14px; border: 1px solid var(--rs-bg-surface-raised); border-radius: 6px;
	background: var(--rs-border-strong); color: var(--rs-text-primary); font-size: 12px; cursor: pointer;
	transition: background 0.15s;
}
.editor-btn:hover { background: var(--rs-bg-surface-raised); }
.editor-btn--danger { border-color: var(--rs-error); color: var(--rflows-danger-text, #fca5a5); }
.editor-btn--danger:hover { background: var(--rflows-danger-hover-bg, #7f1d1d); }

/* Edge +/- controls */
.edge-controls {
	display: flex; align-items: center; gap: 2px; font-size: 11px;
}
.edge-btn {
	width: 18px; height: 18px; border: 1px solid var(--rs-bg-surface-raised); border-radius: 4px;
	background: var(--rs-bg-surface); color: var(--rs-text-primary); font-size: 12px; cursor: pointer;
	display: flex; align-items: center; justify-content: center; padding: 0;
}
.edge-btn:hover { background: var(--rs-border-strong); }
.edge-pct { color: var(--rs-text-primary); font-weight: 600; min-width: 30px; text-align: center; }

/* Legend — bottom-left */
.flows-canvas-legend {
	position: absolute; bottom: 10px; left: 10px; z-index: 10;
	display: flex; flex-wrap: wrap; gap: 12px;
	font-size: 11px; color: var(--rs-text-secondary); background: var(--rs-glass-bg);
	padding: 6px 10px; border-radius: 8px;
}
.flows-canvas-legend-item { display: flex; align-items: center; gap: 4px; }
.flows-canvas-legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* Zoom controls — bottom-right pill */
.flows-canvas-zoom {
	position: absolute; bottom: 14px; right: 14px; z-index: 10;
	display: flex; align-items: center; gap: 0;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border);
	border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
	overflow: hidden;
}
.flows-zoom-btn {
	display: flex; align-items: center; justify-content: center;
	width: 32px; height: 32px; border: none; background: transparent;
	color: var(--rs-text-primary); cursor: pointer; transition: background 0.15s;
}
.flows-zoom-btn:hover { background: var(--rs-bg-hover); }
.flows-zoom-level {
	font-size: 11px; font-weight: 600; color: var(--rs-text-secondary);
	min-width: 40px; text-align: center; user-select: none;
}
.flows-zoom-sep {
	width: 1px; height: 18px; background: var(--rs-border); margin: 0 2px;
}

/* Legacy diagram (kept for compat) */
.flows-diagram { overflow-x: auto; }
.flows-diagram svg { display: block; margin: 0 auto; }
.flows-diagram__legend {
	display: flex; flex-wrap: wrap; gap: 16px; justify-content: center;
	margin-top: 12px; font-size: 12px; color: var(--rs-text-secondary);
}
.flows-diagram__legend-item { display: flex; align-items: center; gap: 5px; }
.flows-diagram__dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ── River tab ───────────────────────────────────────── */
.flows-river-container { min-height: 500px; }

/* ── Transactions tab ────────────────────────────────── */
.flows-tx-list { display: flex; flex-direction: column; gap: 4px; }
.flows-tx-empty { text-align: center; color: var(--rs-text-muted); padding: 48px 16px; font-size: 14px; }

.flows-tx {
	display: flex; align-items: center; gap: 12px; padding: 12px 16px;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong); border-radius: 8px;
}
.flows-tx__icon { font-size: 16px; flex-shrink: 0; }
.flows-tx__body { flex: 1; min-width: 0; }
.flows-tx__desc { font-size: 13px; color: var(--rs-text-primary); font-weight: 500; }
.flows-tx__meta { font-size: 11px; color: var(--rs-text-muted); margin-top: 2px; }
.flows-tx__amount { font-size: 14px; font-weight: 600; white-space: nowrap; }
.flows-tx__amount--positive { color: var(--rs-success); }
.flows-tx__amount--negative { color: var(--rs-error); }
.flows-tx__time { font-size: 11px; color: var(--rs-text-muted); white-space: nowrap; }

/* ── Port & wiring ──────────────────────────────────── */
.port-group { pointer-events: all; }
.port-hit { cursor: crosshair; }
.port-dot { transition: r 0.15s, filter 0.15s; r: 7; stroke: white; stroke-width: 2; }
.port-group:hover .port-dot { r: 9; filter: drop-shadow(0 0 4px currentColor); }

.port-group--wiring-source .port-dot { animation: port-glow 0.8s ease-in-out infinite; }
.port-group--wiring-target .port-dot { animation: port-breathe 1s ease-in-out infinite; }
.port-group--wiring-dimmed { opacity: 0.15; pointer-events: none; }

.wiring-temp-path {
	fill: none; stroke: var(--rs-text-secondary); stroke-width: 2; stroke-dasharray: 8 4;
	stroke-linecap: round; animation: wire-dash 0.6s linear infinite;
}

.flows-canvas-svg.wiring { cursor: crosshair; }

@keyframes port-glow {
	0%, 100% { filter: drop-shadow(0 0 4px currentColor); }
	50% { filter: drop-shadow(0 0 10px currentColor); }
}
@keyframes port-breathe {
	0%, 100% { opacity: 0.6; r: 5; }
	50% { opacity: 1; r: 7; }
}
@keyframes wire-dash {
	to { stroke-dashoffset: -12; }
}

/* ── Edge flow animation ──────────────────────────────── */
@keyframes streamFlow { to { stroke-dashoffset: -24; } }
.edge-path-animated { stroke-dasharray: 8 4; animation: streamFlow 1s linear infinite; }
.edge-path-overflow { stroke-dasharray: 6 3; animation: streamFlow 0.5s linear infinite; stroke-linecap: round; }
.edge-glow { pointer-events: none; }
.edge-group--highlight path:not(.edge-glow) { stroke-opacity: 1 !important; filter: brightness(1.4); }
.edge-group--highlight .edge-glow { stroke-opacity: 0.25 !important; }

/* Selected edge */
.edge-group--selected path:not(.edge-glow):not(.edge-hit-area) {
	stroke: #6366f1 !important;
	stroke-opacity: 1 !important;
	filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.5));
}
.edge-group--selected .edge-glow {
	stroke: #6366f1 !important;
	stroke-opacity: 0.25 !important;
}
.edge-group--selected .edge-ctrl-group rect:first-child {
	stroke: #6366f1;
}

/* Drag handle on edge midpoint */
.edge-drag-handle {
	fill: var(--rflows-drag-handle-fill, #475569);
	stroke: var(--rflows-drag-handle-stroke, #94a3b8);
	stroke-width: 1.5;
	cursor: grab;
	transition: fill 0.15s;
}
.edge-drag-handle:hover {
	fill: #6366f1;
	stroke: #818cf8;
}
.edge-group--selected .edge-drag-handle {
	fill: #6366f1;
	stroke: #a5b4fc;
}

/* Invisible hit area for edge click targeting */
.edge-hit-area { pointer-events: stroke; cursor: pointer; }

/* Ghost edge (zero-flow potential paths) */
.edge-ghost { pointer-events: none; }

/* Satisfaction bar (inflow bar on funnels & outcomes) */
.satisfaction-bar-bg { opacity: 0.3; }
.satisfaction-bar-fill { transition: width 0.3s ease; }


/* ── Node detail modals ──────────────────────────────── */
.flows-modal-backdrop {
	position: fixed; inset: 0; z-index: 50;
	background: var(--rs-bg-overlay); display: flex;
	align-items: center; justify-content: center;
	animation: modalFadeIn 0.15s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.flows-modal {
	background: var(--rs-bg-surface); border-radius: 16px; padding: 24px;
	width: 440px; max-height: 85vh; overflow-y: auto;
	border: 1px solid var(--rs-border-strong); box-shadow: var(--rs-shadow-lg);
	animation: modalSlideIn 0.2s ease-out;
}
@keyframes modalSlideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.flows-modal { scrollbar-width: thin; scrollbar-color: var(--rs-bg-surface-raised) transparent; }
.flows-modal::-webkit-scrollbar { width: 6px; }
.flows-modal::-webkit-scrollbar-track { background: transparent; }
.flows-modal::-webkit-scrollbar-thumb { background: var(--rs-bg-surface-raised); border-radius: 3px; }
.flows-modal__header {
	display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.flows-modal__close {
	background: none; border: none; color: var(--rs-text-secondary); font-size: 24px; cursor: pointer;
	padding: 2px 8px; border-radius: 4px; transition: color 0.15s;
}
.flows-modal__close:hover { color: var(--rs-text-primary); }
.flows-modal__progress-bar {
	height: 8px; background: var(--rs-border-strong); border-radius: 4px; overflow: hidden; margin-top: 8px;
}
.flows-modal__progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }

/* Phase accordion */
.phase-tier-bar { display: flex; gap: 1px; height: 8px; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.phase-tier-segment { flex: 1; transition: background 0.3s; }
.phase-card { border: 1px solid var(--rs-border-strong); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.phase-card--locked { opacity: 0.5; }
.phase-header {
	padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px;
	background: var(--rs-bg-page); transition: background 0.15s;
}
.phase-header:hover { background: var(--rs-bg-surface); }
.phase-content { padding: 8px 14px 14px; border-top: 1px solid var(--rs-border-strong); }
.phase-task {
	display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--rs-text-secondary); padding: 4px 0;
}
.phase-task input[type="checkbox"] { accent-color: #10b981; cursor: pointer; }
.phase-task--done { color: var(--rs-text-muted); text-decoration: line-through; }
.phase-add-btn {
	display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--rs-text-muted);
	background: none; border: 1px dashed var(--rs-border-strong); border-radius: 6px;
	padding: 4px 10px; cursor: pointer; margin-top: 6px; transition: all 0.15s;
}
.phase-add-btn:hover { color: var(--rs-text-secondary); border-color: var(--rs-bg-surface-raised); }

/* Source type picker */
.source-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.source-type-btn {
	display: flex; flex-direction: column; align-items: center; gap: 6px;
	padding: 14px 8px; border-radius: 8px; border: 2px solid var(--rs-border-strong);
	background: var(--rs-bg-page); color: var(--rs-text-secondary); cursor: pointer; transition: all 0.15s;
	font-size: 12px; font-weight: 500;
}
.source-type-btn:hover { border-color: var(--rs-bg-surface-raised); background: var(--rs-bg-surface); }
.source-type-btn--active { border-color: #10b981; background: var(--rflows-source-hover-bg, #064e3b); color: var(--rflows-source-text, #6ee7b7); }

/* Pay-by button grid (ICP - compact) */
.icp-pay-by { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 4px; }
.icp-pay-btn {
	display: flex; align-items: center; justify-content: center; gap: 4px;
	padding: 6px 4px; border-radius: 6px; border: 1.5px solid var(--rs-border-strong);
	background: var(--rs-bg-page); color: var(--rs-text-secondary); cursor: pointer;
	transition: all 0.15s; font-size: 10px; font-weight: 500;
	font-family: system-ui, -apple-system, sans-serif;
}
.icp-pay-btn:hover { border-color: var(--rs-bg-surface-raised); background: var(--rs-bg-surface); }
.icp-pay-btn--active { border-color: #10b981; background: var(--rflows-source-hover-bg, #064e3b); color: var(--rflows-source-text, #6ee7b7); }

/* Pay-by button grid (editor panel - larger) */
.editor-pay-by { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.editor-pay-btn {
	display: flex; flex-direction: column; align-items: center; gap: 4px;
	padding: 10px 6px; border-radius: 8px; border: 2px solid var(--rs-border-strong);
	background: var(--rs-bg-page); color: var(--rs-text-secondary); cursor: pointer;
	transition: all 0.15s; font-size: 11px; font-weight: 500;
	font-family: system-ui, -apple-system, sans-serif;
}
.editor-pay-btn:hover { border-color: var(--rs-bg-surface-raised); background: var(--rs-bg-surface); }
.editor-pay-btn--active { border-color: #10b981; background: var(--rflows-source-hover-bg, #064e3b); color: var(--rflows-source-text, #6ee7b7); }

/* Node hover tooltip */
.flows-node-tooltip {
	position: absolute; z-index: 30; pointer-events: none;
	background: var(--rs-glass-bg); border: 1px solid var(--rs-bg-surface-raised); border-radius: 8px;
	padding: 8px 12px; font-size: 12px; color: var(--rs-text-primary);
	box-shadow: var(--rs-shadow-md); white-space: nowrap;
}
.flows-node-tooltip__label { font-weight: 600; margin-bottom: 2px; }
.flows-node-tooltip__stat { color: var(--rs-text-secondary); font-size: 11px; }

/* Sufficiency glow on funnel status text */
@keyframes sufficiencyPulse {
	0%, 100% { fill-opacity: 1; }
	50% { fill-opacity: 0.6; }
}
.sufficiency-glow { animation: sufficiencyPulse 2s ease-in-out infinite; }

/* ── Funnel shape & inline editing ─────────────────── */

/* Threshold markers in edit mode */
.threshold-marker { pointer-events: none; }
.threshold-handle { cursor: ns-resize; transition: opacity 0.15s; }
.threshold-handle:hover { opacity: 0.8; }

/* Inline edit inputs (foreignObject) */
.inline-edit-input {
	background: transparent; border: none; border-bottom: 1px solid var(--rs-primary-hover);
	color: var(--rs-text-primary); font-size: 13px; font-weight: 600; width: 100%;
	outline: none; padding: 2px 4px; box-sizing: border-box;
	font-family: system-ui, -apple-system, sans-serif;
}
.inline-edit-input:focus { border-bottom-color: #818cf8; }

/* Edit mode toolbar */
.inline-edit-toolbar {
	display: flex; gap: 4px; justify-content: center; margin-top: 2px;
}
.inline-edit-toolbar button {
	padding: 3px 8px; border-radius: 4px; border: none;
	font-size: 10px; cursor: pointer; font-weight: 600;
	font-family: system-ui, -apple-system, sans-serif;
	transition: opacity 0.15s;
}
.inline-edit-toolbar button:hover { opacity: 0.85; }

/* Inline edit overlay container */
.inline-edit-overlay { pointer-events: all; }

/* Funnel overflow pipe (vessel metaphor) — fixed height, animate opacity + fill */
.funnel-pipe { transition: opacity 0.2s ease, fill 0.2s ease; }
.funnel-pipe--active { fill: #10b981; }

/* Threshold lines inside tank */
.threshold-line { pointer-events: none; }

/* Basin fill animation */
.basin-fill-rect { transition: y 120ms ease-out, height 120ms ease-out; }

/* Status badge in outcome inline edit */
.inline-status-badge { cursor: pointer; transition: opacity 0.15s; }
.inline-status-badge:hover { opacity: 0.8; }

/* ── Inline config panel (ICP) ─────────────────────── */
.inline-config-panel {
	display: flex; flex-direction: column;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong);
	border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,0.35);
	overflow: hidden; font-family: system-ui, -apple-system, sans-serif;
	color: var(--rs-text-primary); font-size: 12px;
}
.icp-tabs {
	display: flex; border-bottom: 1px solid var(--rs-border-strong);
	background: var(--rs-bg-surface-sunken);
}
.icp-tab {
	flex: 1; padding: 6px 8px; text-align: center;
	font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
	color: var(--rs-text-muted); cursor: pointer; border: none; background: none;
	border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.icp-tab:hover { color: var(--rs-text-secondary); }
.icp-tab--active {
	color: var(--rs-primary); border-bottom-color: var(--rs-primary);
}
.icp-body {
	flex: 1; overflow-y: auto; padding: 8px 10px;
	max-height: 180px; min-height: 60px;
}
.icp-body { scrollbar-width: thin; scrollbar-color: var(--rs-border-strong) transparent; }
.icp-body::-webkit-scrollbar { width: 4px; }
.icp-body::-webkit-scrollbar-thumb { background: var(--rs-border-strong); border-radius: 2px; }
.icp-toolbar {
	display: flex; gap: 4px; justify-content: center;
	padding: 6px 10px; border-top: 1px solid var(--rs-border-strong);
	background: var(--rs-bg-surface-sunken);
}
.icp-toolbar button {
	padding: 4px 10px; border-radius: 5px; border: none;
	font-size: 10px; cursor: pointer; font-weight: 600;
	font-family: system-ui, -apple-system, sans-serif;
	transition: opacity 0.15s;
}
.icp-toolbar button:hover { opacity: 0.85; }

/* Form fields */
.icp-field { margin-bottom: 6px; }
.icp-label {
	display: block; font-size: 10px; font-weight: 600;
	color: var(--rs-text-muted); text-transform: uppercase; letter-spacing: 0.03em;
	margin-bottom: 2px;
}
.icp-input, .icp-select {
	width: 100%; padding: 4px 6px; border-radius: 4px;
	border: 1px solid var(--rs-border-strong); background: var(--rs-bg-surface-sunken);
	color: var(--rs-text-primary); font-size: 12px;
	font-family: system-ui, -apple-system, sans-serif;
	outline: none; box-sizing: border-box;
}
.icp-input:focus, .icp-select:focus { border-color: var(--rs-primary); }

/* Range sliders */
.icp-range-group {
	display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.icp-range-label {
	font-size: 10px; font-weight: 600; color: var(--rs-text-muted);
	min-width: 28px; text-transform: uppercase;
}
.icp-range {
	flex: 1; height: 4px; cursor: pointer;
	accent-color: var(--rs-primary);
	-webkit-appearance: none; appearance: none;
	background: var(--rs-border-strong); border-radius: 2px;
}
.icp-range::-webkit-slider-thumb {
	-webkit-appearance: none; width: 12px; height: 12px;
	border-radius: 50%; background: var(--rs-primary); cursor: pointer;
}
.icp-range::-moz-range-thumb {
	width: 12px; height: 12px; border: none;
	border-radius: 50%; background: var(--rs-primary); cursor: pointer;
}
.icp-range::-moz-range-track {
	background: var(--rs-border-strong); border-radius: 2px; height: 4px;
}
.icp-range-value {
	font-size: 11px; font-weight: 600; color: var(--rs-text-primary);
	min-width: 40px; text-align: right;
}

/* Threshold color bar */
.icp-threshold-bar-wrap { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--rs-border-subtle); }
.icp-threshold-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 1px; }
.icp-threshold-seg--red { background: var(--rflows-status-critical, #ef4444); }
.icp-threshold-seg--yellow { background: var(--rflows-status-sustained, #eab308); }
.icp-threshold-seg--green { background: var(--rflows-status-thriving, #10b981); }
.icp-threshold-labels { display: flex; justify-content: space-between; font-size: 9px; color: var(--rs-text-muted); margin-top: 2px; }

/* Analytics bars */
.icp-analytics-row {
	margin-bottom: 8px;
}
.icp-analytics-label {
	display: flex; justify-content: space-between; font-size: 10px;
	color: var(--rs-text-muted); margin-bottom: 2px;
}
.icp-analytics-bar {
	height: 6px; background: var(--rs-border-strong); border-radius: 3px;
	overflow: hidden;
}
.icp-analytics-fill {
	height: 100%; border-radius: 3px; transition: width 120ms ease-out;
}

/* Conic-gradient donut for proportions */
.icp-proportion {
	display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.icp-proportion-ring {
	width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
}
.icp-proportion-legend {
	display: flex; flex-direction: column; gap: 3px; font-size: 10px;
}
.icp-proportion-item {
	display: flex; align-items: center; gap: 4px;
}
.icp-proportion-dot {
	width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* Stat pairs */
.icp-stat-row {
	display: flex; justify-content: space-between; font-size: 11px;
	padding: 2px 0; color: var(--rs-text-secondary);
}
.icp-stat-value { font-weight: 600; color: var(--rs-text-primary); }

/* Allocation rows */
.icp-alloc-row {
	display: flex; align-items: center; gap: 6px; padding: 3px 0;
	font-size: 11px; color: var(--rs-text-secondary);
}
.icp-alloc-dot {
	width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* Fund Now button */
.icp-fund-btn {
	width: 100%; padding: 6px; margin-top: 6px;
	background: var(--rflows-btn-fund); color: white; border: none;
	border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 11px;
	font-family: system-ui, -apple-system, sans-serif;
	transition: opacity 0.15s;
}
.icp-fund-btn:hover { opacity: 0.85; }

/* Sufficiency state label */
.icp-suf-badge {
	display: inline-block; padding: 2px 8px; border-radius: 4px;
	font-size: 10px; font-weight: 600; text-transform: uppercase;
}
.icp-suf-badge--seeking { background: rgba(59,130,246,0.15); color: #3b82f6; }
.icp-suf-badge--sufficient { background: rgba(16,185,129,0.15); color: #10b981; }
.icp-suf-badge--abundant { background: rgba(245,158,11,0.15); color: #f59e0b; }

/* Empty state */
.icp-empty {
	text-align: center; color: var(--rs-text-muted);
	padding: 12px 8px; font-size: 11px; font-style: italic;
}

/* Side port arrows */
.port-group[data-port-side="left"] .port-arrow { /* horizontal arrow left handled inline */ }
.port-group[data-port-side="right"] .port-arrow { /* horizontal arrow right handled inline */ }

/* ── Vessel fill animation (tapered path) ──────────── */
.funnel-fill-path { transition: d 120ms ease-out; }

/* ── Water surface shimmer ──────────────────────────── */
.water-surface-line { animation: water-shimmer 4s ease-in-out infinite; }
@keyframes water-shimmer {
	0%, 100% { opacity: 0.3; }
	50% { opacity: 0.6; }
}

/* ── Overflow spill pulse ──────────────────────────── */
.overflow-spill-left { animation: overflow-pulse 1.5s ease-in-out infinite; }
.overflow-spill-right { animation: overflow-pulse 1.5s ease-in-out infinite 0.3s; }
@keyframes overflow-pulse {
	0%, 100% { ry: 6; opacity: 0.4; }
	50% { ry: 10; opacity: 0.7; }
}

/* ── Basin water fill transition ───────────────────── */
.basin-water-fill { transition: y 200ms ease-out, height 200ms ease-out; }
.basin-receiving .basin-water-fill { animation: basin-pulse 2s ease-in-out infinite; }
@keyframes basin-pulse {
	0%, 100% { opacity: 0.8; }
	50% { opacity: 1; }
}

/* ── Basin ripple wave ─────────────────────────────── */
.basin-ripple { opacity: 0.7; }

/* ── Approaching overflow glow ───────────────────── */
.approaching-glow { animation: approachingPulse 1.5s ease-in-out infinite; }
@keyframes approachingPulse {
	0%, 100% { opacity: 0.15; }
	50% { opacity: 0.45; }
}

/* ── Approaching status badge ────────────────────── */
.flows-status--approaching { color: #f59e0b; }
.icp-suf-badge--approaching {
	background: rgba(245, 158, 11, 0.15);
	color: #f59e0b;
}

/* ── Simulation speed slider ──────────────────────── */
.flows-sim-speed {
	position: absolute; bottom: 50px; right: 10px; z-index: 10;
	flex-direction: column; align-items: center; gap: 4px;
	background: var(--rs-glass-bg); border-radius: 8px; padding: 8px 6px;
}
.flows-speed-slider {
	writing-mode: vertical-lr; direction: rtl;
	width: 24px; height: 100px; cursor: pointer;
	accent-color: var(--rs-primary);
}
.flows-speed-label {
	font-size: 9px; color: var(--rs-text-muted); white-space: nowrap;
}

/* ── Timeline bar ─────────────────────────────────── */
.flows-timeline {
	position: absolute; bottom: 36px; left: 10px; right: 80px; z-index: 10;
	align-items: center; gap: 8px;
	background: var(--rs-glass-bg); border-radius: 6px; padding: 4px 10px;
	transition: all 0.25s ease;
}
.flows-timeline__label {
	font-size: 10px; font-weight: 600; color: var(--rs-text-secondary); white-space: nowrap;
}
.flows-timeline__minimize {
	background: none; border: none; color: var(--rs-text-secondary); cursor: pointer;
	font-size: 12px; padding: 0 4px; line-height: 1;
}
.flows-timeline__minimize:hover { color: var(--rs-text-primary); }
.flows-timeline__track {
	flex: 1; height: 4px; background: var(--rs-border-strong); border-radius: 2px; overflow: hidden;
}
.flows-timeline__fill {
	height: 100%; background: var(--rs-primary); border-radius: 2px;
	transition: width 80ms linear;
}
.flows-timeline__tick {
	font-size: 10px; color: var(--rs-text-secondary); white-space: nowrap; min-width: 50px;
}
.flows-timeline.minimized {
	right: auto; width: auto; padding: 4px 8px; gap: 4px;
}
.flows-timeline.minimized .flows-timeline__label,
.flows-timeline.minimized .flows-timeline__track,
.flows-timeline.minimized .flows-timeline__tick {
	display: none;
}

/* Overflow splash animation */
.edge-splash { pointer-events: none; }

/* ── Light theme overrides ──────────────────────────── */
:host([data-theme="light"]) {
	--rflows-source-text: #059669;
	--rflows-source-hover-bg: #d1fae5;
	--rflows-funnel-text: #2563eb;
	--rflows-funnel-hover-bg: #dbeafe;
	--rflows-outcome-text: #db2777;
	--rflows-outcome-hover-bg: #fce7f3;
	--rflows-danger-text: #dc2626;
	--rflows-danger-hover-bg: #fee2e2;

	/* Source node */
	--rflows-source-bg: #d1fae5;
	--rflows-source-border: #059669;
	--rflows-source-rate: #047857;

	/* Edge colors */
	--rflows-edge-inflow: #059669;
	--rflows-edge-spending: #2563eb;
	--rflows-edge-overflow: #d97706;

	/* Funnel zones */
	--rflows-zone-drain-opacity: 0.15;
	--rflows-zone-healthy-opacity: 0.14;
	--rflows-zone-overflow-opacity: 0.14;
	--rflows-fill-opacity: 0.45;

	/* Funnel labels */
	--rflows-label-inflow: #047857;
	--rflows-label-spending: #2563eb;
	--rflows-label-overflow: #d97706;

	/* Status colors (darken for light bg) */
	--rflows-status-overflow: #059669;
	--rflows-status-thriving: #059669;
	--rflows-sat-bar: #059669;

	/* Outcome */
	--rflows-status-completed: #059669;
	--rflows-phase-unlocked: #059669;

	/* Card value */
	--rflows-card-value: #0369a1;

	/* Score badge */
	--rflows-score-green: #059669;

	/* Edge drag handle */
	--rflows-drag-handle-fill: #94a3b8;
	--rflows-drag-handle-stroke: #64748b;

	/* Modal border accent */
	--rflows-modal-border: #e2e8f0;
}
@media (prefers-color-scheme: light) {
	:host:not([data-theme]) {
		--rflows-source-text: #059669;
		--rflows-source-hover-bg: #d1fae5;
		--rflows-funnel-text: #2563eb;
		--rflows-funnel-hover-bg: #dbeafe;
		--rflows-outcome-text: #db2777;
		--rflows-outcome-hover-bg: #fce7f3;
		--rflows-danger-text: #dc2626;
		--rflows-danger-hover-bg: #fee2e2;

		--rflows-source-bg: #d1fae5;
		--rflows-source-border: #059669;
		--rflows-source-rate: #047857;

		--rflows-edge-inflow: #059669;
		--rflows-edge-spending: #2563eb;
		--rflows-edge-overflow: #d97706;

		--rflows-zone-drain-opacity: 0.15;
		--rflows-zone-healthy-opacity: 0.14;
		--rflows-zone-overflow-opacity: 0.14;
		--rflows-fill-opacity: 0.45;

		--rflows-label-inflow: #047857;
		--rflows-label-spending: #2563eb;
		--rflows-label-overflow: #d97706;

		--rflows-status-overflow: #059669;
		--rflows-status-thriving: #059669;
		--rflows-sat-bar: #059669;

		--rflows-status-completed: #059669;
		--rflows-phase-unlocked: #059669;

		--rflows-card-value: #0369a1;
		--rflows-score-green: #059669;

		--rflows-drag-handle-fill: #94a3b8;
		--rflows-drag-handle-stroke: #64748b;
		--rflows-modal-border: #e2e8f0;
	}
}

/* ── Flow dropdown (toolbar) ──────────────────────── */
.flows-dropdown {
	position: relative; display: block;
}
.flows-dropdown__trigger {
	display: flex; align-items: center; gap: 4px; width: 100%;
	max-width: none;
}
.flows-dropdown__name {
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flows-dropdown__chevron {
	font-size: 9px; flex-shrink: 0; opacity: 0.7;
}
.flows-dropdown__menu {
	position: absolute; top: 100%; left: 0; z-index: 25;
	min-width: 200px; max-height: 300px; overflow-y: auto;
	background: var(--rs-bg-surface); border: 1px solid var(--rs-border-strong);
	border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
	padding: 4px 0; margin-top: 4px;
}
.flows-dropdown__item {
	display: block; width: 100%; text-align: left;
	padding: 7px 12px; border: none; background: none;
	color: var(--rs-text-primary); font-size: 12px; cursor: pointer;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	transition: background 0.1s;
}
.flows-dropdown__item:hover { background: var(--rs-border-strong); }
.flows-dropdown__item--active {
	border-left: 3px solid var(--rs-primary); padding-left: 9px;
	color: var(--rs-primary);
}
.flows-dropdown__item--new { color: var(--rs-primary); font-weight: 600; }
.flows-dropdown__sep {
	height: 1px; background: var(--rs-border-strong); margin: 4px 0;
}

/* ── Flow management modal ───────────────────────── */
.flows-mgmt-overlay {
	position: fixed; inset: 0; z-index: 100;
	background: var(--rs-bg-overlay); display: flex;
	align-items: center; justify-content: center;
	animation: modalFadeIn 0.15s ease-out;
}
.flows-mgmt-modal {
	background: var(--rs-bg-surface); border-radius: 16px;
	width: 520px; max-width: 95vw; max-height: 85vh;
	border: 1px solid var(--rs-border-strong); box-shadow: var(--rs-shadow-lg);
	display: flex; flex-direction: column;
	animation: modalSlideIn 0.2s ease-out;
}
.flows-mgmt__header {
	display: flex; align-items: center; justify-content: space-between;
	padding: 16px 20px; border-bottom: 1px solid var(--rs-border-strong);
}
.flows-mgmt__header h2 { font-size: 16px; font-weight: 600; margin: 0; }
.flows-mgmt__close {
	background: none; border: none; color: var(--rs-text-secondary);
	font-size: 22px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.flows-mgmt__close:hover { color: var(--rs-text-primary); }
.flows-mgmt__body {
	flex: 1; overflow-y: auto; padding: 8px 0;
	max-height: 400px;
}
.flows-mgmt__body { scrollbar-width: thin; scrollbar-color: var(--rs-bg-surface-raised) transparent; }
.flows-mgmt__body::-webkit-scrollbar { width: 6px; }
.flows-mgmt__body::-webkit-scrollbar-thumb { background: var(--rs-bg-surface-raised); border-radius: 3px; }
.flows-mgmt__row {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 20px; transition: background 0.1s;
	border-bottom: 1px solid var(--rs-border-strong);
}
.flows-mgmt__row:hover { background: var(--rs-bg-page); }
.flows-mgmt__row-name {
	flex: 1; font-size: 13px; font-weight: 500; color: var(--rs-text-primary);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flows-mgmt__row-name input {
	background: var(--rs-bg-page); border: 1px solid var(--rs-primary);
	border-radius: 4px; padding: 2px 6px; color: var(--rs-text-primary);
	font-size: 13px; width: 100%; outline: none;
}
.flows-mgmt__row-meta {
	font-size: 11px; color: var(--rs-text-muted); white-space: nowrap;
}
.flows-mgmt__row-actions {
	display: flex; gap: 4px; flex-shrink: 0;
}
.flows-mgmt__row-btn {
	padding: 3px 6px; border: 1px solid var(--rs-border-strong);
	border-radius: 4px; background: none; color: var(--rs-text-secondary);
	font-size: 11px; cursor: pointer; transition: all 0.1s;
}
.flows-mgmt__row-btn:hover { background: var(--rs-border-strong); color: var(--rs-text-primary); }
.flows-mgmt__row-btn--danger { border-color: var(--rs-error); color: var(--rs-error); }
.flows-mgmt__row-btn--danger:hover { background: rgba(239,68,68,0.15); }
.flows-mgmt__footer {
	display: flex; justify-content: flex-end; gap: 8px;
	padding: 12px 20px; border-top: 1px solid var(--rs-border-strong);
}
.flows-mgmt__footer button {
	padding: 6px 14px; border-radius: 6px; border: 1px solid var(--rs-border-strong);
	background: var(--rs-bg-surface); color: var(--rs-text-primary);
	font-size: 12px; cursor: pointer; font-weight: 500;
	transition: background 0.15s;
}
.flows-mgmt__footer button:hover { background: var(--rs-border-strong); }
.flows-mgmt__footer button.primary {
	background: var(--rs-primary); border-color: var(--rs-primary-hover); color: #fff;
}
.flows-mgmt__footer button.primary:hover { opacity: 0.85; }
.flows-mgmt__empty {
	text-align: center; color: var(--rs-text-muted); padding: 32px 20px;
	font-size: 13px;
}

/* ── Drips import modal ──────────────────────────────── */
.flows-drips-overlay {
	position: fixed; inset: 0; z-index: 100;
	background: var(--rs-bg-overlay); display: flex;
	align-items: center; justify-content: center;
	animation: modalFadeIn 0.15s ease-out;
}
.flows-drips-modal {
	background: var(--rs-bg-surface); border-radius: 16px;
	width: 480px; max-width: 95vw; max-height: 85vh;
	border: 1px solid var(--rs-border-strong); box-shadow: var(--rs-shadow-lg);
	display: flex; flex-direction: column;
	animation: modalSlideIn 0.2s ease-out;
}
.flows-drips__field {
	display: flex; flex-direction: column; gap: 4px;
	padding: 8px 20px;
}
.flows-drips__field label {
	font-size: 11px; font-weight: 600; color: var(--rs-text-secondary);
	text-transform: uppercase; letter-spacing: 0.5px;
}
.flows-drips__field input, .flows-drips__field select {
	padding: 8px 10px; border-radius: 6px; border: 1px solid var(--rs-border-strong);
	background: var(--rs-bg-surface-raised); color: var(--rs-text-primary);
	font-size: 13px; font-family: ui-monospace, monospace;
}
.flows-drips__field input:focus, .flows-drips__field select:focus {
	outline: none; border-color: var(--rs-primary);
}
.flows-drips__loading, .flows-drips__error {
	padding: 12px 20px; font-size: 13px;
}
.flows-drips__loading { color: var(--rs-text-muted); }
.flows-drips__error { color: #ef4444; }
.flows-drips__preview {
	padding: 8px 20px; display: flex; flex-direction: column; gap: 8px;
}
.flows-drips__preview-group {
	display: flex; flex-direction: column; gap: 4px;
}
.flows-drips__preview-title {
	font-size: 11px; font-weight: 600; color: var(--rs-text-secondary);
	text-transform: uppercase; letter-spacing: 0.5px;
}
.flows-drips__node {
	display: flex; align-items: center; justify-content: space-between;
	padding: 6px 10px; border-radius: 6px; font-size: 12px;
	border-left: 3px solid transparent;
}
.flows-drips__node--source { border-left-color: #10b981; background: #064e3b20; }
.flows-drips__node--funnel { border-left-color: #3b82f6; background: #1e3a5f20; }
.flows-drips__node--outcome { border-left-color: #ec4899; background: #4a194220; }
.flows-drips__node-label {
	color: var(--rs-text-primary); font-family: ui-monospace, monospace;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px;
}
.flows-drips__node-rate {
	color: var(--rs-text-muted); font-size: 11px; white-space: nowrap; margin-left: 8px;
}
.flows-toolbar-btn--drips { color: #818cf8; }
.flows-toolbar-btn--drips:hover { background: #312e8120; }
.flows-drips-sync-badge {
	color: #818cf8; font-size: 11px !important;
	border: 1px solid #4f46e5 !important;
	animation: dripsPulse 2s ease-in-out infinite;
}
@keyframes dripsPulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.7; }
}
.flows-drips-badge rect { transition: opacity 0.2s; }

/* ── Faucet source node ──────────────────────────────── */
.faucet-pipe { transition: stroke 0.2s; }
.faucet-valve { transition: fill 0.2s; cursor: pointer; }
.faucet-valve:hover { filter: brightness(1.15); }
.faucet-handle { transition: transform 0.3s ease; }
.faucet-stream { opacity: 0.45; }
.faucet-spigot { transition: fill 0.2s; }

@keyframes faucet-drip {
	0%, 100% { opacity: 0.45; }
	50% { opacity: 0.25; }
}
.faucet-stream { animation: faucet-drip 2.5s ease-in-out infinite; }

/* ── Source Purchase Modal ───────────────────────────── */
.source-modal {
	position: fixed; inset: 0; z-index: 99999;
	display: flex; align-items: center; justify-content: center;
}
.spm-backdrop {
	position: absolute; inset: 0;
	background: rgba(0, 0, 0, 0.7); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.spm-card {
	position: relative; z-index: 1;
	background: var(--rs-bg-surface, #1e293b);
	border: 1px solid var(--rflows-modal-border, #334155);
	border-radius: 16px; padding: 28px;
	width: 440px; max-width: 92vw;
	max-height: 85vh; overflow-y: auto;
	box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.spm-method-grid {
	display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
	margin-bottom: 4px;
}
.spm-method-btn {
	display: flex; flex-direction: column; align-items: center; gap: 4px;
	padding: 12px 8px; border: 2px solid var(--rs-border-strong, #334155);
	border-radius: 10px; background: none; cursor: pointer;
	color: var(--rs-text-secondary, #94a3b8); font-size: 12px; font-weight: 500;
	transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.spm-method-btn:hover {
	border-color: var(--rs-text-muted, #64748b);
	background: var(--rs-bg-surface-raised, #334155);
}
.spm-method-btn--active {
	border-color: #10b981; background: rgba(16, 185, 129, 0.1);
	color: var(--rs-text-primary, #e2e8f0);
}

/* ── Mobile responsive ──────────────────────────────── */
@media (max-width: 768px) {
	.flows-diagram { overflow-x: auto; -webkit-overflow-scrolling: touch; }
	.flows-flows__grid { grid-template-columns: 1fr; }
	.flows-features__grid { grid-template-columns: 1fr; }
	.flows-cards { grid-template-columns: 1fr; }
	.flows-canvas-container { height: 50vh; min-height: 300px; }
	.flows-canvas-container--fullpage { height: 100%; min-height: unset; }
	.flows-canvas-toolbar { width: 130px; top: 6px; left: 6px; padding: 4px; }
	.flows-toolbar-btn { padding: 8px 8px; font-size: 12px; min-height: 40px; }
	.flows-editor-panel { width: 100%; }
	.flows-analytics-panel { width: 100%; }
	.flows-canvas-legend { font-size: 10px; gap: 8px; }
	.flows-landing { padding: 16px 12px 48px; }
	.flows-detail { padding: 12px 12px 48px; }
	.flows-detail--fullpage { padding: 0; }
}

/* ── Guided Tour ────────────────────────────────────── */
.flows-tour-overlay {
	position: absolute; inset: 0; z-index: 10000;
	pointer-events: none;
}
.flows-tour-backdrop {
	position: absolute; inset: 0;
	background: rgba(0, 0, 0, 0.55);
	pointer-events: auto;
	transition: clip-path 0.3s ease;
}
.flows-tour-spotlight {
	position: absolute;
	border: 2px solid var(--rs-primary, #06b6d4);
	border-radius: 8px;
	box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.25);
	pointer-events: none;
	transition: all 0.3s ease;
}
.flows-tour-tooltip {
	position: absolute;
	width: min(320px, calc(100% - 24px));
	background: var(--rs-bg-surface, #1e293b);
	border: 1px solid var(--rs-border, #334155);
	border-radius: 12px;
	padding: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
	color: var(--rs-text-primary, #f1f5f9);
	pointer-events: auto;
	animation: flows-tour-pop 0.25s ease-out;
}
@keyframes flows-tour-pop {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}
.flows-tour-tooltip__step {
	font-size: 0.7rem;
	color: var(--rs-text-muted, #64748b);
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}
.flows-tour-tooltip__title {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 6px;
	background: linear-gradient(135deg, #06b6d4, #7c3aed);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}
.flows-tour-tooltip__msg {
	font-size: 0.85rem;
	color: var(--rs-text-secondary, #94a3b8);
	line-height: 1.5;
	margin-bottom: 12px;
}
.flows-tour-tooltip__nav {
	display: flex;
	align-items: center;
	gap: 8px;
}
.flows-tour-tooltip__btn {
	padding: 6px 14px;
	border-radius: 6px;
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	border: none;
	transition: background 0.15s, transform 0.1s;
}
.flows-tour-tooltip__btn:hover { transform: translateY(-1px); }
.flows-tour-tooltip__btn--next {
	background: linear-gradient(135deg, #06b6d4, #7c3aed);
	color: white;
}
.flows-tour-tooltip__btn--prev {
	background: var(--rs-btn-secondary-bg, #334155);
	color: var(--rs-text-secondary, #94a3b8);
}
.flows-tour-tooltip__btn--skip {
	background: none;
	color: var(--rs-text-muted, #64748b);
	margin-left: auto;
}
.flows-tour-tooltip__btn--skip:hover { color: var(--rs-text-primary, #f1f5f9); }
.flows-tour-tooltip__hint {
	font-size: 0.72rem;
	color: var(--rs-text-muted, #64748b);
	font-style: italic;
}

/* ── Floating Play/Pause FAB ── */
.flows-fab-play {
	position: absolute;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 30;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: 2px solid rgba(6, 182, 212, 0.5);
	background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.2));
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 20px rgba(6, 182, 212, 0.3);
	transition: all 0.2s ease;
}
.flows-fab-play:hover {
	transform: translateX(-50%) scale(1.1);
	box-shadow: 0 6px 28px rgba(6, 182, 212, 0.5);
	border-color: rgba(6, 182, 212, 0.8);
}
.flows-fab-play.playing {
	border-color: rgba(139, 92, 246, 0.6);
	background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(236, 72, 153, 0.15));
	box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
	animation: fabPulse 2s ease-in-out infinite;
}
.flows-fab-play__icon {
	font-size: 22px;
	line-height: 1;
}
@keyframes fabPulse {
	0%, 100% { box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3); }
	50% { box-shadow: 0 4px 28px rgba(139, 92, 246, 0.55); }
}

/* ── Minimizable panels ── */
.flows-analytics-panel .analytics-minimize {
	background: none;
	border: none;
	color: var(--rs-text-secondary);
	font-size: 16px;
	cursor: pointer;
	padding: 2px 6px;
	margin-left: 4px;
}
.flows-analytics-panel .analytics-minimize:hover { color: var(--rs-text-primary); }
.flows-analytics-panel.minimized {
	width: 44px;
	min-width: 44px;
	overflow: hidden;
}
.flows-analytics-panel.minimized .analytics-content,
.flows-analytics-panel.minimized .analytics-tabs,
.flows-analytics-panel.minimized .analytics-title,
.flows-analytics-panel.minimized .analytics-close {
	display: none;
}
.flows-analytics-panel.minimized .analytics-header {
	flex-direction: column;
	padding: 8px 4px;
	border-bottom: none;
}
.flows-analytics-panel.minimized .analytics-minimize {
	writing-mode: vertical-rl;
	text-orientation: mixed;
	padding: 8px 2px;
	font-size: 12px;
}

/* Panel collapse tab — visible when panel is closed */
.flows-panel-tab {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 19;
	width: 24px;
	height: 64px;
	border-radius: 0 8px 8px 0;
	background: var(--rs-bg-surface);
	border: 1px solid var(--rs-border-strong);
	border-left: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--rs-text-secondary);
	font-size: 14px;
	transition: background 0.15s;
}
.flows-panel-tab:hover { background: var(--rs-bg-surface-raised); color: var(--rs-text-primary); }
.flows-panel-tab--left { left: 0; }
.flows-panel-tab--left.panel-open { left: 380px; transition: left 0.25s ease; }
.flows-panel-tab--right { right: 0; border-radius: 8px 0 0 8px; border: 1px solid var(--rs-border-strong); border-right: none; }

/* ── Overflow pipe animations ─────────────────────────── */
@keyframes pipe-flow {
	0% { stroke-dashoffset: 16; }
	100% { stroke-dashoffset: 0; }
}
.funnel-pipe { cursor: pointer; transition: opacity 0.2s, fill 0.2s; }
.funnel-pipe:hover { opacity: 1 !important; filter: brightness(1.2); }
.funnel-pipe--active {
	animation: pipe-pulse 2s ease-in-out infinite;
}
@keyframes pipe-pulse {
	0%, 100% { opacity: 0.85; }
	50% { opacity: 1; filter: brightness(1.3); }
}
.pipe-flow-stripe {
	animation: pipe-flow 0.6s linear infinite;
	pointer-events: none;
}

/* ── Outcome basin hover + cursor ─────────────────────── */
.flow-node[data-node-id] .basin-outline { cursor: pointer; }
.flow-node:hover .basin-outline { filter: drop-shadow(0 0 6px rgba(99,102,241,0.4)); }
.flow-node:hover .node-bg { filter: brightness(1.05); }

/* ── Linked tasks in outcome modal ────────────────────── */
.linked-task-row {
	display: flex; align-items: center; gap: 8px; padding: 8px 10px;
	border: 1px solid var(--rs-border-strong); border-radius: 8px; margin-bottom: 6px;
	transition: background 0.15s;
}
.linked-task-row:hover { background: var(--rs-bg-surface-sunken); }
.linked-task-title {
	font-size: 12px; color: var(--rs-text-primary); flex: 1;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.linked-task-title:hover { color: var(--rflows-status-inprogress); text-decoration: underline; }
.linked-task-unlink {
	background: none; border: none; color: var(--rs-text-muted); font-size: 16px;
	cursor: pointer; padding: 0 4px; line-height: 1; transition: color 0.15s;
}
.linked-task-unlink:hover { color: var(--rflows-status-critical); }

/* ── Task picker overlay ──────────────────────────────── */
.task-picker-overlay {
	margin-top: 12px; border-top: 1px solid var(--rs-border-strong); padding-top: 12px;
}
.task-picker-panel { /* inline in modal */ }
.task-picker-item {
	display: flex; align-items: center; gap: 8px; padding: 8px 10px;
	border-radius: 6px; cursor: pointer; transition: background 0.15s;
}
.task-picker-item:hover { background: var(--rs-bg-surface-raised); }

/* ── rTasks badge on outcome basin ────────────────────── */
.outcome-tasks-badge {
	pointer-events: none;
}
