/* ── Funds module theme ───────────────────────────────── */

/* ── Shared utility classes ──────────────────────────── */
.funds-loading { text-align: center; color: #64748b; padding: 48px 16px; font-size: 14px; }
.funds-error { text-align: center; color: #ef4444; padding: 20px 16px; font-size: 14px; }

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

/* Features grid */
.funds-features { margin-bottom: 48px; }
.funds-features__grid {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px;
}
.funds-features__card {
	background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 20px;
	transition: border-color 0.2s;
}
.funds-features__card:hover { border-color: #475569; }
.funds-features__icon { font-size: 24px; margin-bottom: 8px; }
.funds-features__card h3 { font-size: 14px; font-weight: 600; color: #e2e8f0; margin: 0 0 6px; }
.funds-features__card p { font-size: 12px; color: #94a3b8; line-height: 1.6; margin: 0; }

/* Flow list */
.funds-flows { margin-bottom: 48px; }
.funds-flows__header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.funds-flows__heading { font-size: 18px; font-weight: 600; color: #e2e8f0; margin: 0; }
.funds-flows__user { font-size: 12px; color: #64748b; }
.funds-flows__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.funds-flows__empty {
	text-align: center; color: #64748b; padding: 32px 16px; font-size: 14px;
	background: #1e293b; border: 1px solid #334155; border-radius: 10px;
}
.funds-flows__empty a { color: #6366f1; text-decoration: none; }
.funds-flows__empty a:hover { text-decoration: underline; }

.funds-flow-card {
	display: block; text-decoration: none;
	background: #1e293b; border: 1px solid #334155; border-radius: 10px;
	padding: 16px; cursor: pointer; transition: border-color 0.2s, transform 0.15s;
}
.funds-flow-card:hover { border-color: #6366f1; transform: translateY(-1px); }
.funds-flow-card__name { font-size: 15px; font-weight: 600; color: #e2e8f0; margin-bottom: 4px; }
.funds-flow-card__value { font-size: 20px; font-weight: 700; color: #0ea5e9; margin-bottom: 4px; }
.funds-flow-card__meta { font-size: 12px; color: #64748b; }

/* About / how-it-works section */
.funds-about { margin-bottom: 48px; }
.funds-about__heading { font-size: 18px; font-weight: 600; color: #e2e8f0; margin: 0 0 20px; }

/* Steps layout (replaces the old card grid for "how it works") */
.funds-about__steps { display: flex; flex-direction: column; gap: 16px; }
.funds-about__step {
	display: flex; gap: 16px; align-items: flex-start;
	background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 20px;
}
.funds-about__step-num {
	width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
	background: #4f46e5; color: #fff; font-weight: 700; font-size: 14px;
	display: flex; align-items: center; justify-content: center;
}
.funds-about__step h3 { font-size: 14px; font-weight: 600; color: #e2e8f0; margin: 0 0 4px; }
.funds-about__step p { font-size: 13px; color: #94a3b8; line-height: 1.6; margin: 0; }

/* Legacy about grid (kept for compat) */
.funds-about__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.funds-about__card {
	background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 20px;
}
.funds-about__icon { font-size: 28px; margin-bottom: 8px; }
.funds-about__card h3 { font-size: 15px; font-weight: 600; color: #e2e8f0; margin: 0 0 8px; }
.funds-about__card p { font-size: 13px; color: #94a3b8; line-height: 1.6; margin: 0; }

/* ── Detail view ─────────────────────────────────────── */
.funds-detail { max-width: 1100px; margin: 0 auto; padding: 16px 20px 64px; }

/* ── Tabs ────────────────────────────────────────────── */
.funds-tabs {
	display: flex; gap: 4px; border-bottom: 1px solid #1e293b; margin-bottom: 20px;
}
.funds-tab {
	padding: 8px 18px; border: none; border-bottom: 2px solid transparent;
	background: transparent; color: #64748b; font-size: 13px; font-weight: 500;
	cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
.funds-tab:hover { color: #e2e8f0; }
.funds-tab--active { color: #e2e8f0; border-bottom-color: #6366f1; }

.funds-tab-content { min-height: 300px; }

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

.funds-card {
	background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 16px;
}
.funds-card__header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.funds-card__icon { font-size: 18px; }
.funds-card__label { font-size: 14px; font-weight: 600; color: #e2e8f0; flex: 1; }
.funds-card__type { font-size: 11px; color: #64748b; text-transform: uppercase; }
.funds-card__status { font-size: 11px; font-weight: 600; text-transform: capitalize; }
.funds-card__desc { font-size: 12px; color: #94a3b8; margin-bottom: 10px; line-height: 1.5; }

.funds-card__stat { margin-bottom: 10px; }
.funds-card__stat-value { font-size: 18px; font-weight: 700; color: #e2e8f0; }
.funds-card__stat-label { font-size: 12px; color: #64748b; margin-left: 4px; }
.funds-card__stats { display: flex; justify-content: space-between; margin-bottom: 8px; }

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

.funds-card__thresholds {
	display: flex; gap: 12px; font-size: 11px; color: #64748b; margin-bottom: 8px;
}

/* Allocation lists */
.funds-card__allocs { margin-top: 8px; padding-top: 8px; border-top: 1px solid #334155; }
.funds-card__alloc-title { font-size: 11px; color: #64748b; font-weight: 600; margin-bottom: 4px; text-transform: uppercase; }
.funds-card__alloc { font-size: 12px; color: #94a3b8; display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.funds-card__alloc-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* Status colors */
.funds-status--abundant { color: #fbbf24; }
.funds-status--sufficient { color: #10b981; }
.funds-status--seeking { color: #0ea5e9; }
.funds-status--critical { color: #ef4444; }

/* ── Interactive canvas (Diagram tab) ───────────────── */
.funds-canvas-container {
	position: relative; height: 70vh; min-height: 400px;
	background: #0f172a; border-radius: 12px; border: 1px solid #334155;
	overflow: hidden; user-select: none;
}

.funds-canvas-svg {
	width: 100%; height: 100%; display: block;
	cursor: grab;
}
.funds-canvas-svg.panning { cursor: grabbing; }
.funds-canvas-svg.dragging { cursor: move; }

/* Toolbar — top-right overlay */
.funds-canvas-toolbar {
	position: absolute; top: 10px; right: 10px; z-index: 10;
	display: flex; gap: 4px; flex-wrap: wrap; align-items: center;
}
.funds-canvas-btn {
	padding: 5px 10px; border: 1px solid #475569; border-radius: 6px;
	background: #1e293b; color: #e2e8f0; font-size: 11px; font-weight: 500;
	cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.funds-canvas-btn:hover { background: #334155; border-color: #64748b; }
.funds-canvas-btn--source { border-color: #10b981; color: #6ee7b7; }
.funds-canvas-btn--source:hover { background: #064e3b; }
.funds-canvas-btn--funnel { border-color: #3b82f6; color: #93c5fd; }
.funds-canvas-btn--funnel:hover { background: #1e3a5f; }
.funds-canvas-btn--outcome { border-color: #ec4899; color: #f9a8d4; }
.funds-canvas-btn--outcome:hover { background: #4a1942; }
.funds-canvas-btn--active { background: #4f46e5; border-color: #6366f1; color: #fff; }
.funds-canvas-sep {
	width: 1px; height: 20px; background: #334155; margin: 0 4px;
}

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

/* Editor panel — right side slide-in */
.funds-editor-panel {
	position: absolute; top: 0; right: 0; bottom: 0; width: 320px; z-index: 20;
	background: #1e293b; border-left: 1px solid #334155;
	transform: translateX(100%); transition: transform 0.25s ease;
	overflow-y: auto; padding: 16px;
	display: flex; flex-direction: column; gap: 12px;
}
.funds-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: #e2e8f0; }
.editor-close {
	background: none; border: none; color: #94a3b8; font-size: 18px; cursor: pointer; padding: 2px 6px;
}
.editor-close:hover { color: #e2e8f0; }

.editor-field { display: flex; flex-direction: column; gap: 4px; }
.editor-label { font-size: 11px; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.editor-input {
	padding: 6px 10px; border: 1px solid #334155; border-radius: 6px;
	background: #0f172a; color: #e2e8f0; font-size: 13px;
}
.editor-input:focus { outline: none; border-color: #6366f1; }
.editor-select {
	padding: 6px 10px; border: 1px solid #334155; border-radius: 6px;
	background: #0f172a; color: #e2e8f0; font-size: 13px;
}
.editor-alloc-row {
	display: flex; align-items: center; gap: 6px; font-size: 12px; color: #94a3b8;
}
.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 #334155;
}
.editor-section-title { font-size: 12px; font-weight: 600; color: #64748b; margin-bottom: 6px; }
.editor-btn {
	padding: 6px 14px; border: 1px solid #475569; border-radius: 6px;
	background: #334155; color: #e2e8f0; font-size: 12px; cursor: pointer;
	transition: background 0.15s;
}
.editor-btn:hover { background: #475569; }
.editor-btn--danger { border-color: #ef4444; color: #fca5a5; }
.editor-btn--danger:hover { background: #7f1d1d; }

/* Edge +/- controls */
.edge-controls {
	display: flex; align-items: center; gap: 2px; font-size: 11px;
}
.edge-btn {
	width: 18px; height: 18px; border: 1px solid #475569; border-radius: 4px;
	background: #1e293b; color: #e2e8f0; font-size: 12px; cursor: pointer;
	display: flex; align-items: center; justify-content: center; padding: 0;
}
.edge-btn:hover { background: #334155; }
.edge-pct { color: #e2e8f0; font-weight: 600; min-width: 30px; text-align: center; }

/* Legend — bottom-left */
.funds-canvas-legend {
	position: absolute; bottom: 10px; left: 10px; z-index: 10;
	display: flex; flex-wrap: wrap; gap: 12px;
	font-size: 11px; color: #94a3b8; background: rgba(15,23,42,0.85);
	padding: 6px 10px; border-radius: 8px;
}
.funds-canvas-legend-item { display: flex; align-items: center; gap: 4px; }
.funds-canvas-legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* Zoom controls — bottom-right */
.funds-canvas-zoom {
	position: absolute; bottom: 10px; right: 10px; z-index: 10;
	display: flex; gap: 4px;
}

/* Sufficiency badge — top-left */
.funds-canvas-badge {
	position: absolute; top: 10px; left: 10px; z-index: 10;
	background: rgba(15,23,42,0.85); border-radius: 10px; padding: 8px 14px;
	display: flex; align-items: center; gap: 8px;
}
.funds-canvas-badge__score { font-size: 20px; font-weight: 700; }
.funds-canvas-badge__label { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }

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

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

/* ── Transactions tab ────────────────────────────────── */
.funds-tx-list { display: flex; flex-direction: column; gap: 4px; }
.funds-tx-empty { text-align: center; color: #64748b; padding: 48px 16px; font-size: 14px; }

.funds-tx {
	display: flex; align-items: center; gap: 12px; padding: 12px 16px;
	background: #1e293b; border: 1px solid #334155; border-radius: 8px;
}
.funds-tx__icon { font-size: 16px; flex-shrink: 0; }
.funds-tx__body { flex: 1; min-width: 0; }
.funds-tx__desc { font-size: 13px; color: #e2e8f0; font-weight: 500; }
.funds-tx__meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.funds-tx__amount { font-size: 14px; font-weight: 600; white-space: nowrap; }
.funds-tx__amount--positive { color: #10b981; }
.funds-tx__amount--negative { color: #ef4444; }
.funds-tx__time { font-size: 11px; color: #64748b; white-space: nowrap; }

/* ── Port & wiring ──────────────────────────────────── */
.port-group { pointer-events: all; }
.port-hit { cursor: crosshair; }
.port-dot { transition: r 0.15s, filter 0.15s; }
.port-group:hover .port-dot { r: 7; 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: #94a3b8; stroke-width: 2; stroke-dasharray: 8 4;
	stroke-linecap: round; animation: wire-dash 0.6s linear infinite;
}

.funds-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.7s linear infinite; }
.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; }

/* 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 ──────────────────────────────── */
.funds-modal-backdrop {
	position: fixed; inset: 0; z-index: 50;
	background: rgba(0,0,0,0.6); display: flex;
	align-items: center; justify-content: center;
	animation: modalFadeIn 0.15s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.funds-modal {
	background: #1e293b; border-radius: 16px; padding: 24px;
	width: 440px; max-height: 85vh; overflow-y: auto;
	border: 1px solid #334155; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
	animation: modalSlideIn 0.2s ease-out;
}
@keyframes modalSlideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.funds-modal::-webkit-scrollbar { width: 6px; }
.funds-modal::-webkit-scrollbar-track { background: transparent; }
.funds-modal::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
.funds-modal__header {
	display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.funds-modal__close {
	background: none; border: none; color: #94a3b8; font-size: 24px; cursor: pointer;
	padding: 2px 8px; border-radius: 4px; transition: color 0.15s;
}
.funds-modal__close:hover { color: #e2e8f0; }
.funds-modal__progress-bar {
	height: 8px; background: #334155; border-radius: 4px; overflow: hidden; margin-top: 8px;
}
.funds-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 #334155; border-radius: 10px; 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: #0f172a; transition: background 0.15s;
}
.phase-header:hover { background: #1e293b; }
.phase-content { padding: 8px 14px 14px; border-top: 1px solid #334155; }
.phase-task {
	display: flex; align-items: center; gap: 8px; font-size: 13px; color: #94a3b8; padding: 4px 0;
}
.phase-task input[type="checkbox"] { accent-color: #10b981; cursor: pointer; }
.phase-task--done { color: #64748b; text-decoration: line-through; }
.phase-add-btn {
	display: flex; align-items: center; gap: 4px; font-size: 12px; color: #64748b;
	background: none; border: 1px dashed #334155; border-radius: 6px;
	padding: 4px 10px; cursor: pointer; margin-top: 6px; transition: all 0.15s;
}
.phase-add-btn:hover { color: #94a3b8; border-color: #475569; }

/* 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: 10px; border: 2px solid #334155;
	background: #0f172a; color: #94a3b8; cursor: pointer; transition: all 0.15s;
	font-size: 12px; font-weight: 500;
}
.source-type-btn:hover { border-color: #475569; background: #1e293b; }
.source-type-btn--active { border-color: #10b981; background: #064e3b; color: #6ee7b7; }

/* Node hover tooltip */
.funds-node-tooltip {
	position: absolute; z-index: 30; pointer-events: none;
	background: rgba(15,23,42,0.95); border: 1px solid #475569; border-radius: 8px;
	padding: 8px 12px; font-size: 12px; color: #e2e8f0;
	box-shadow: 0 4px 12px rgba(0,0,0,0.4); white-space: nowrap;
}
.funds-node-tooltip__label { font-weight: 600; margin-bottom: 2px; }
.funds-node-tooltip__stat { color: #94a3b8; 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; }

/* ── Mobile responsive ──────────────────────────────── */
@media (max-width: 768px) {
	.funds-diagram { overflow-x: auto; -webkit-overflow-scrolling: touch; }
	.funds-flows__grid { grid-template-columns: 1fr; }
	.funds-features__grid { grid-template-columns: 1fr; }
	.funds-cards { grid-template-columns: 1fr; }
	.funds-tabs { flex-wrap: wrap; }
	.funds-canvas-container { height: 50vh; min-height: 300px; }
	.funds-canvas-toolbar { flex-wrap: wrap; gap: 3px; top: 6px; right: 6px; }
	.funds-canvas-btn { padding: 4px 7px; font-size: 10px; }
	.funds-editor-panel { width: 100%; }
	.funds-canvas-legend { font-size: 10px; gap: 8px; }
}
