/* ════════════════════════════════════════════════════════════════════
   Bowtie Visualizer — global stylesheet.
   Moved out of home-view.php because the visualizer can be opened from
   any page (menu-bar search), not only from the home page.
   ════════════════════════════════════════════════════════════════════ */

	/* ════════════════════════════════════════════════════════════════════
	   Bowtie Visualizer — algorithmic absolute-position layout
	   ════════════════════════════════════════════════════════════════════
	   Layout strategy: JavaScript computes (x,y,w,h) for every node in a
	   single coordinate space and writes them straight to each node's
	   inline style.  Edges read the same coordinates.  No flexbox/grid is
	   used for the diagram graph itself, so there is no possibility of
	   SVG and HTML disagreeing on where things are.                       */

	/* In-page host: the visualizer fills the area between the fixed top menu and the
	   fixed footer. --bv-fill is the combined spacer height (top + bottom) emitted by
	   the view per device class. dvh handles mobile browser chrome; the vh line is the
	   fallback for engines without dvh. */
	.bowtie-page {
		height: calc(100vh - var(--bv-fill, 99px));
		height: calc(100dvh - var(--bv-fill, 99px));
		margin: 0;
		/* Width the details panel occupies when open. The diagram area shrinks by
		   this same amount so the panel sits beside the diagram rather than over
		   it (see .bowtie-page.panel-open below). Kept in sync with the panel's
		   own width (33%, floored at 380px) so the two edges meet exactly. */
		--bv-panel-w: max(33%, 380px);
	}
	.bowtie-page > .bowtie-visualizer {
		height: 100%;
	}
	/* Panel open: narrow only the diagram area (.bowtie-stage), so the control
	   menu (.bowtie-toolbar) keeps the full page width. Excluded in full-screen,
	   where the visualizer fills the screen and the re-parented panel overlays
	   the diagram instead. */
	.bowtie-page.panel-open > .bowtie-visualizer:not(:fullscreen) > .bowtie-stage {
		width: calc(100% - var(--bv-panel-w));
	}
	/* Full-screen mode fills the screen; the toolbar stays inside so controls remain visible. */
	.bowtie-visualizer:-webkit-full-screen {
		width: 100vw;
		height: 100vh;
		background: var(--bv-surface, #ffffff);
	}
	.bowtie-visualizer:fullscreen {
		width: 100vw;
		height: 100vh;
		background: var(--bv-surface, #ffffff);
	}

	.bowtie-visualizer {
		--bv-bg: #f7fbff;
		--bv-surface: #ffffff;
		--bv-border: #d8e2ee;
		--bv-ink: #162941;
		--bv-muted: #5d7490;
		--bv-shadow: 0 6px 18px rgba(16, 42, 72, 0.10);

		--bv-hazard: #ff9800;
		--bv-topevent: #ffc107;
		--bv-cause: #2196f3;
		--bv-outcome: #f44336;
		--bv-df: #ffeb3b;

		--bv-edge-cause: #1976d2;
		--bv-edge-outcome: #d32f2f;
		--bv-edge-df: #c79100;

		font-family: inherit;
		color: var(--bv-ink);
		background: var(--bv-bg);
		display: flex;
		flex-direction: column;
		height: 100%;
		min-height: 0;
	}

	/* The toolbar doubles as the modal header bar — it carries the bowtie code
	   and name (left), the detail-level and zoom controls (right) and the close
	   button, so the diagram gets the full remaining height. */
	.bowtie-toolbar {
		display: flex;
		align-items: center;
		gap: 12px;
		padding: 10px 14px;
		/* Lighter slate-gray than the very dark (#1e293b) top header so the two bars
		   read as distinct; still dark enough to keep the white toolbar text legible. */
		background: linear-gradient(180deg, #6b7787 0%, #5c6676 100%);
		color: #fff;
		border-bottom: 1px solid rgba(255, 255, 255, 0.18);
		flex-wrap: wrap;
		flex: 0 0 auto;
	}

	/* Zoom-percentage readout between the −/+ buttons. */
	.bowtie-zoom-level {
		color: #fff;
		font-size: 12px;
		min-width: 40px;
		text-align: center;
		flex: 0 0 auto;
	}

	/* HAZID code badge — coloured per code via an inline background, white text. */
	.bowtie-toolbar .bowtie-code {
		background: var(--bv-hazard);
		color: #fff;
		padding: 2px 8px;
		border-radius: 6px;
		font-size: 12px;
		font-weight: 700;
		letter-spacing: 0.2px;
		flex: 0 0 auto;
	}

	/* Bow-tie selector — the heading code+name is now a dropdown to switch bow ties. */
	.bowtie-selector {
		position: relative;
		display: inline-flex;
		min-width: 0;
	}

	.bowtie-selector-btn {
		appearance: none;
		border: none;
		background: transparent;
		color: #fff;
		cursor: pointer;
		display: inline-flex;
		align-items: center;
		gap: 8px;
		padding: 4px 8px 4px 4px;
		border-radius: 6px;
		font: inherit;
		max-width: 460px;
		min-width: 0;
	}

	.bowtie-selector-btn:hover {
		background: rgba(255, 255, 255, 0.10);
	}

	.bowtie-selector-name {
		font-size: 14px;
		font-weight: 600;
		color: #fff;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		min-width: 0;
	}

	.bowtie-selector-caret {
		font-size: 15px;
		opacity: 0.9;
		flex: 0 0 auto;
	}

	.bowtie-selector-panel {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		z-index: 30;
		min-width: 360px;
		max-width: 80vw;
		width: max-content;     /* grow to fit the longest hazard name */
		max-height: 60vh;
		overflow-y: auto;
		background: #fff;
		border: 1px solid var(--bv-border);
		border-radius: 8px;
		box-shadow: 0 8px 24px rgba(16, 42, 72, 0.18);
		padding: 6px;
	}

	.bowtie-selector-panel[hidden] {
		display: none;
	}

	.bowtie-selector-group {
		font-size: 10px;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: 0.05em;
		color: var(--bv-muted);
		padding: 8px 8px 3px;
	}

	.bowtie-selector-row {
		appearance: none;
		border: none;
		background: transparent;
		width: 100%;
		text-align: left;
		cursor: pointer;
		display: flex;
		align-items: center;
		gap: 8px;
		padding: 6px 8px;
		border-radius: 6px;
	}

	.bowtie-selector-row:hover {
		background: #f1f6fb;
	}

	.bowtie-selector-row.is-current {
		background: #eaf1f9;
	}

	.bowtie-selector-row-name {
		font-size: 13px;
		color: var(--bv-ink);
		white-space: nowrap;     /* full name, no truncation — the panel widens to fit */
	}

	.bowtie-toolbar .bowtie-spacer {
		flex: 1;
	}

	/* Compact-view checkbox on the dark header. "Compact" text sits to the left
	   of the box; both are centred on the same line. */
	.bowtie-compact-toggle {
		display: inline-flex;
		align-items: center;
		gap: 6px;
		height: 32px;
		padding: 0 8px;
		font-size: 12px;
		font-weight: 600;
		line-height: 1;
		color: #fff;
		cursor: pointer;
		white-space: nowrap;
	}

	.bowtie-compact-toggle span {
		display: inline-flex;
		align-items: center;
		line-height: 1;
	}

	.bowtie-compact-toggle input {
		cursor: pointer;
		margin: 0;
		vertical-align: middle;
		flex: 0 0 auto;
	}

	.bowtie-level-group {
		display: inline-flex;
		gap: 4px;
		background: #eef3f8;
		padding: 3px;
		border-radius: 8px;
		border: 1px solid var(--bv-border);
	}

	.bowtie-level-group .bowtie-level-btn {
		appearance: none;
		border: none;
		background: transparent;
		color: var(--bv-muted);
		padding: 5px 12px;
		border-radius: 6px;
		font-size: 12px;
		font-weight: 600;
		cursor: pointer;
		transition: background 120ms ease, color 120ms ease;
	}

	.bowtie-level-group .bowtie-level-btn:hover {
		color: var(--bv-ink);
	}

	.bowtie-level-group .bowtie-level-btn.active {
		background: var(--bv-ink);
		color: #fff;
		box-shadow: 0 2px 6px rgba(22, 41, 65, 0.18);
	}

	/* Control-info dropdown — a pill button in the header that opens a small
	   panel of checkboxes for switching control-card fields on and off. */
	.bowtie-fieldmenu {
		position: relative;
		display: inline-flex;
	}

	.bowtie-fieldmenu-btn {
		appearance: none;
		box-sizing: border-box;
		border: 1px solid var(--bv-border);
		background: #eef3f8;
		color: var(--bv-ink);
		height: 32px;
		padding: 0 12px;
		border-radius: 8px;
		font-size: 12px;
		font-weight: 600;
		cursor: pointer;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 6px;
		white-space: nowrap;
	}

	.bowtie-fieldmenu-btn:hover {
		background: #e2ebf5;
	}

	.bowtie-fieldmenu-caret {
		font-size: 9px;
		opacity: 0.7;
	}

	.bowtie-fieldmenu-panel {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		/* Sit above the slide-in right-hand panel (z-index: 60) so the
		   control-information and control-filter dropdowns are never hidden
		   behind it. */
		z-index: 70;
		min-width: 190px;
		background: #fff;
		border: 1px solid var(--bv-border);
		border-radius: 8px;
		box-shadow: 0 8px 24px rgba(16, 42, 72, 0.18);
		padding: 8px;
		display: flex;
		flex-direction: column;
		gap: 2px;
	}

	.bowtie-fieldmenu-panel[hidden] {
		display: none;
	}

	.bowtie-fieldmenu-panel label {
		display: flex;
		align-items: center;
		gap: 8px;
		font-size: 12px;
		font-weight: 500;
		color: var(--bv-ink);
		padding: 4px 6px;
		border-radius: 5px;
		cursor: pointer;
		white-space: nowrap;
	}

	.bowtie-fieldmenu-panel label:hover {
		background: #f1f6fb;
	}

	.bowtie-fieldmenu-panel input {
		cursor: pointer;
		margin: 0;
	}

	/* Hierarchical filter dropdown — four collapsible category groups, each
	   holding a checkbox per distinct value. */
	.bowtie-filtermenu-panel {
		max-height: 60vh;
		overflow-y: auto;
	}

	.bowtie-filter-group {
		display: flex;
		flex-direction: column;
	}

	.bowtie-filter-group-head {
		appearance: none;
		border: none;
		background: transparent;
		color: var(--bv-ink);
		font-size: 12px;
		font-weight: 700;
		cursor: pointer;
		display: flex;
		align-items: center;
		gap: 6px;
		padding: 5px 6px;
		border-radius: 5px;
		text-align: left;
		width: 100%;
	}

	.bowtie-filter-group-head:hover {
		background: #f1f6fb;
	}

	.bowtie-filter-group-caret {
		font-size: 9px;
		opacity: 0.7;
		display: inline-block;
		transition: transform 120ms ease;
	}

	.bowtie-filter-group-head[aria-expanded="true"] .bowtie-filter-group-caret {
		transform: rotate(90deg);
	}

	.bowtie-filter-group-body {
		display: flex;
		flex-direction: column;
		gap: 2px;
		padding: 2px 0 6px 18px;
	}

	.bowtie-filter-group-body[hidden] {
		display: none;
	}

	.bowtie-filter-empty {
		font-size: 11px;
		color: var(--bv-muted);
		padding: 2px 6px;
	}

	/* Check all / Uncheck all buttons at the very top of the Control Filter. */
	.bowtie-filter-actions {
		display: flex;
		gap: 6px;
		margin-bottom: 6px;
	}

	.bowtie-filter-action {
		appearance: none;
		flex: 1;
		border: 1px solid var(--bv-border);
		background: #f1f6fb;
		color: var(--bv-ink);
		font-size: 11px;
		font-weight: 600;
		padding: 5px 8px;
		border-radius: 6px;
		cursor: pointer;
	}

	.bowtie-filter-action:hover {
		background: #e2ebf5;
	}

	/* Mode toggles at the top of the Control Filter panel (hide filtered controls,
	   hide empty causes/outcomes/DFs), separated from the category filters below. */
	.bowtie-filter-modes {
		display: flex;
		flex-direction: column;
		gap: 2px;
		border-bottom: 1px solid var(--bv-border);
		margin-bottom: 4px;
		padding-bottom: 6px;
	}

	.bowtie-filter-modes label {
		font-weight: 600;
		white-space: normal;
		align-items: flex-start;
	}

	/* Filtered-out controls in dim mode: greyed and faded. (In hide mode the
	   controls are removed from the layout entirely, so the diagram repositions
	   around them — no CSS needed.) */
	.bn-filtered-dim {
		opacity: 0.3;
		filter: grayscale(1);
	}

	.bowtie-zoom-group {
		display: inline-flex;
		gap: 4px;
		align-items: center;
		color: rgba(255, 255, 255, 0.85);
		font-size: 12px;
	}

	.bowtie-zoom-group .bowtie-zoom-btn {
		appearance: none;
		border: 1px solid var(--bv-border);
		background: #fff;
		color: var(--bv-ink);
		width: 32px;
		height: 32px;
		border-radius: 50%;
		font-size: 15px;
		cursor: pointer;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	.bowtie-zoom-group .bowtie-zoom-btn:hover {
		background: #f1f6fb;
	}

	/* Scrollable stage and the canvas it scrolls. The canvas is the
	   coordinate space the layout engine targets — its width and height are
	   set by JS to the diagram's natural bounding box, so scrolling and
	   zooming are simple browser behaviours. */
	.bowtie-stage {
		flex: 1 1 auto;
		min-height: 0;
		/* Animate the shrink/grow in step with the panel's 0.3s slide. */
		transition: width 0.3s ease;
		/* Scrollbars are intentionally hidden — the diagram is navigated by
		   grab-to-pan and zoom (both drive scrollLeft/scrollTop in JS, which
		   still works with overflow:hidden). No visible scrollbars. */
		overflow: hidden;
		position: relative;
		cursor: grab;
		background: #ffffff;
		/* Take full control of touch gestures (one-finger pan, two-finger pinch
		   are handled in JS); stop the browser from scrolling/zooming the page. */
		touch-action: none;
	}

	.bowtie-stage.is-panning,
	.bowtie-stage.is-panning * {
		cursor: grabbing !important;
		/* Prevent text selection while dragging to pan */
		user-select: none;
	}

	.bowtie-canvas {
		position: relative;
		transform-origin: top left;
		transition: transform 160ms ease;
		/* Width and height are set by the JS renderer once the layout is computed. */
	}

	.bowtie-edges {
		position: absolute;
		top: 0;
		left: 0;
		pointer-events: none;
		z-index: 1;
		overflow: visible;
	}

	.bowtie-nodes {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 2;
	}

	/* ─── Nodes (each is an absolutely-positioned div) ─────────────────── */

	.bn {
		position: absolute;
		box-sizing: border-box;
		/* Shared label font size for every diagram node — matches the control
		   information rows (.bn-ctl-field / .bn-stripe). */
		font-size: 9.5px;
		line-height: 1.25;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 600;
		color: var(--bv-ink);
		border-radius: 10px;
		padding: 6px 8px;
		box-shadow: var(--bv-shadow);
	}

	/* Expand/collapse toggle, pinned half-over the TE-facing edge of an
	   element (right edge for cause-side, left edge for outcome-side). */
	.bn-toggle {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		width: 18px;
		height: 18px;
		padding: 0;
		border: 1px solid var(--bv-border);
		background: #fff;
		color: var(--bv-ink);
		border-radius: 50%;
		font-size: 14px;
		font-weight: 700;
		line-height: 1;
		cursor: pointer;
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 0 1px 3px rgba(16, 42, 72, 0.25);
		z-index: 3;
	}

	.bn-toggle:hover {
		background: #eef3f8;
		border-color: var(--bv-muted);
	}

	.bn-side-cause .bn-toggle { right: -9px; }
	.bn-side-outcome .bn-toggle { left: -9px; }

	/* Barrier defeating-factor toggle sits at the bottom centre of the card
	   (where the DF connector leaves the barrier). Overrides the edge rules. */
	.bn-toggle.bn-toggle-df {
		top: auto;
		bottom: -9px;
		left: 50%;
		right: auto;
		transform: translateX(-50%);
	}

	/* The two bulk icons on the Top Event sit on its left (causes) and right
	   (outcomes) edges. Slightly larger than the per-element toggles. */
	.bn-toggle-te {
		width: 22px;
		height: 22px;
		font-size: 16px;
	}
	.bn-toggle-te-left  { left: -11px; right: auto; }
	.bn-toggle-te-right { right: -11px; left: auto; }

	.bn-hazard {
		background: var(--bv-hazard);
		color: #fff;
		font-weight: 700;
		border: 2px solid var(--bv-hazard);
		flex-direction: column;
		gap: 2px;
	}

	.bn-hazard .bn-hazard-code {
		font-size: 9.5px;
		font-weight: 700;
		letter-spacing: 1px;
		opacity: 0.75;
		text-transform: uppercase;
	}

	.bn-hazard .bn-hazard-name {
		font-size: 9.5px;
	}

	.bn-topEvent {
		background: #fff;
		color: #1a1a1a;
		font-weight: 700;
		border-radius: 50%;
		/* Extra inset so the label sits clear of the curved circle edge,
		   rather than running right up to it (base .bn padding is too small
		   for a round shape). */
		padding: 24px;
		/* Orange stroke matching the hazard fill colour. */
		border: 4px solid var(--bv-hazard);
		/* Same subtle shadow as the hazard shape (the base node shadow). */
		box-shadow: var(--bv-shadow);
		font-size: 9.5px;
	}

	.bn-cause {
		background: var(--bv-cause);
		color: #fff;
		font-weight: 600;
		border: 2px solid var(--bv-cause);
		font-size: 9.5px;
		/* Inset the label well clear of the box edge (overrides the smaller
		   base .bn padding). */
		padding: 16px 18px;
	}

	.bn-outcome {
		background: var(--bv-outcome);
		color: #fff;
		font-weight: 600;
		border: 2px solid var(--bv-outcome);
		font-size: 9.5px;
		padding: 16px 18px;
	}

	/* Risk-assessment squares for the outcome — rendered OUTSIDE the box, just to
	   its right and vertically centred. Inherent risks form the first (top) row,
	   residual risks the second. */
	.bn-outcome-risks {
		position: absolute;
		left: 100%;
		top: 50%;
		transform: translateY(-50%);
		margin-left: 10px;
		display: flex;
		flex-direction: column;
		gap: 6px;
		align-items: flex-start;
	}

	.bn-risk-row {
		display: flex;
		gap: 6px;
	}

	.bn-risk-box {
		box-sizing: border-box;
		width: 18px;
		height: 18px;
		border-radius: 3px;
		box-shadow: 0 1px 2px rgba(16, 42, 72, 0.12);
		font-size: 8px;
		font-weight: 700;
		line-height: 1;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		overflow: hidden;
		flex: 0 0 auto;
	}

	.bn-barrier, .bn-dfc {
		/* Off-white so the control cards stand out against the white diagram
		   background (DF controls override this with their own cream tint). */
		background: #faf9f6;
		border: 1px solid var(--bv-border);
		flex-direction: column;
		align-items: stretch;
		justify-content: flex-start;
		text-align: left;
		font-weight: 500;
		font-size: 9.5px;
		padding: 6px 8px;
		/* One shared gap between every block (name → fields → stripes) so the
		   info rows are evenly spaced; matches the intra-block gaps below. */
		gap: 3px;
		box-shadow: 0 2px 5px rgba(16, 42, 72, 0.06);
	}

	.bn-side-cause.bn-barrier { border-left: 3px solid var(--bv-edge-cause); }
	.bn-side-outcome.bn-barrier { border-right: 3px solid var(--bv-edge-outcome); }
	.bn-dfc { background: #fffdf3; border-color: #e6dca7; opacity: 0.95; }
	/* DF controls carry a TE-facing side border in the DF-line yellow, mirroring
	   the cause/outcome barriers: left edge on the cause side, right edge on the
	   outcome side. */
	.bn-side-cause.bn-dfc { border-left: 3px solid var(--bv-edge-df); }
	.bn-side-outcome.bn-dfc { border-right: 3px solid var(--bv-edge-df); }

	/* Control name: fills the space above the stripes and centres the text
	   both vertically and horizontally. The inner .bn-ctl-name-text carries
	   the multi-line clamp so the wrapper can stay a flex centring box. */
	.bn-ctl-name {
		/* Fill the space above the field/stripe block and centre the name
		   vertically (and horizontally) within it. The block below is a fixed
		   height pinned to the bottom, so this area stays a constant size on
		   every control card regardless of detail level. */
		flex: 1 1 auto;
		min-height: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
		overflow: hidden;
	}

	.bn-ctl-name-text {
		font-weight: 600;
		color: var(--bv-ink);
		display: -webkit-box;
		-webkit-box-orient: vertical;
		/* Allow up to 3 lines before truncating so more of the name is shown;
		   tightened to 2 for the smaller DF-control cards (see override below).
		   The name area itself is a constant height (.bn-ctl-name). */
		-webkit-line-clamp: 3;
		line-clamp: 3;
		overflow: hidden;
		font-size: 9.5px;
		line-height: 1.25;
		width: 100%;
	}

	.bn-dfc .bn-ctl-name-text {
		-webkit-line-clamp: 2;
		line-clamp: 2;
	}

	/* Owning position + safety criticality boxes. White fill, light-grey
	   border, sitting at the bottom of the control card directly above the
	   effectiveness stripe. margin-top:auto pushes this block (and the stripes
	   that follow) to the bottom, leaving the constant name area at the top. */
	.bn-ctl-fields {
		display: flex;
		flex-direction: column;
		gap: 3px;
		margin-top: auto;
	}

	/* Every info row (.bn-ctl-field and .bn-stripe) shares one fixed height and
	   line-height so all rows on a control card are identical in size. border-box
	   keeps the outer height at exactly ROW_H whether or not the row has a border. */
	.bn-ctl-field {
		box-sizing: border-box;
		background: #ffffff;
		border: 1px solid #d0d7e2;
		border-radius: 3px;
		font-size: 9.5px;
		font-weight: 600;
		color: var(--bv-ink);
		padding: 0 5px;
		text-align: center;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		height: 18px;
		line-height: 16px;
	}

	/* The two stripes (effectiveness, type) at the bottom of every barrier
	   and DF-control card.  Auto-pushed to the bottom of the card so the
	   coloured bars always sit flush along the bottom edge. */
	.bn-ctl-stripes {
		display: flex;
		flex-direction: column;
		gap: 3px;
	}

	/* Verification status block — pinned at the TOP of the control card and set
	   apart from the bowtie-XML control information below it with a light divider. */
	.bn-ctl-verif {
		margin-bottom: 5px;
		padding-bottom: 5px;
		border-bottom: 1px solid #d8dee8;
	}

	.bn-stripe {
		box-sizing: border-box;
		font-size: 9.5px;
		font-weight: 600;
		color: #fff;
		padding: 0 5px;
		border-radius: 3px;
		text-align: center;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		height: 18px;
		line-height: 16px;
	}

	.bn-df {
		background: var(--bv-df);
		color: #2b2b2b;
		font-weight: 700;
		font-size: 9.5px;
		border: 1px solid rgba(0, 0, 0, 0.05);
		padding: 16px 18px;
		/* Slightly transparent so the DF endpoints read as secondary. */
		opacity: 0.95;
	}

	.bn-df span {
		display: -webkit-box;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	/* ─── Edges (one SVG layer, one <path> per edge) ───────────────────── */

	.bowtie-edges .edge-main {
		fill: none;
		stroke-width: 2.5;
		stroke-linecap: round;
		stroke-linejoin: round;
		opacity: 0.95;
	}
	.bowtie-edges .edge-cause   { stroke: var(--bv-edge-cause); }
	.bowtie-edges .edge-outcome { stroke: var(--bv-edge-outcome); }

	.bowtie-edges .edge-df,
	.bowtie-edges .edge-df-final {
		fill: none;
		stroke: var(--bv-edge-df);
		stroke-width: 1.6;
		stroke-linecap: round;
		stroke-linejoin: round;
	}
	.bowtie-edges .edge-df-final {
		stroke-dasharray: 5 4;
	}

	/* Orange connector between the hazard and the top event, matching the
	   hazard fill colour. */
	.bowtie-edges .edge-hazard-link {
		fill: none;
		stroke: var(--bv-hazard);
		stroke-width: 4;
		stroke-linecap: round;
	}

	/* ── Slide-in details panel ────────────────────────────────────────────── */
	/* Anchored inside .bowtie-page (which the visualizer JS pins with fixed
	   positioning); hidden off-screen right, slides over the diagram. The `top`
	   here is a pre-JS default — fitPageToViewport() overrides it inline with the
	   measured .bowtie-toolbar (diagram nav) height so the panel sits below the
	   diagram navigation rather than overlapping it. */
	.bowtie-page { position: relative; }
	.bowtie-panel {
		position: absolute;
		top: 0; right: 0; bottom: 0;
		width: 33%;
		min-width: 380px;
		background: #ffffff;
		border-left: 1px solid #d8e2ee;
		box-shadow: -6px 0 18px rgba(16, 42, 72, 0.12);
		transform: translateX(102%);
		transition: transform 0.3s ease;
		z-index: 60;
		display: flex;
		flex-direction: column;
	}
	.bowtie-panel.is-open { transform: translateX(0); }
	.bowtie-panel-head {
		flex: 0 0 auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 8px 12px;
		background: #607d8b;
		color: #ffffff;
	}
	.bowtie-panel-title { font-weight: bold; }
	.bowtie-panel-close {
		background: none;
		border: none;
		color: #ffffff;
		font-size: 22px;
		line-height: 1;
		cursor: pointer;
	}
	.bowtie-panel-content { flex: 1 1 auto; overflow-y: auto; }
	/* The export toolbar is rendered inside the (scrolling) panel content, but is
	   pinned onto the "Details" heading band: absolutely positioned against
	   #bowtiePanel, sitting to the right of the title and clearing the × close
	   button. It only exists in search mode, so it disappears with the results. */
	.bowtie-panel-toolbar {
		position: absolute;
		top: 0;
		right: 40px;
		height: 38px;
		display: flex;
		align-items: center;
		padding: 0;
		margin: 0;
		z-index: 2;
	}
	.bowtie-panel-toolbar button { padding: 3px 10px; font-size: 12px; line-height: 1.4; }
	.bowtie-panel-empty { padding: 16px; }

	/* Search-result list */
	.bowtie-result-hazard {
		display: flex;
		align-items: center;
		gap: 8px;
		padding: 8px 12px;
		background: #ff9800;
		color: #ffffff;
		font-weight: bold;
		cursor: pointer;
	}
	.bowtie-result-item {
		display: flex;
		align-items: center;
		gap: 8px;
		padding: 6px 12px 6px 24px;
		border-bottom: 1px solid #eef2f7;
		cursor: pointer;
	}
	.bowtie-result-item:hover { background: #f0f6ff; }
	.bowtie-result-name { flex: 1 1 auto; }
	.bowtie-result-parent { color: #5d7490; font-size: 12px; white-space: nowrap; }

	@media (max-width: 768px) {
		.bowtie-panel { width: 100%; min-width: 0; }
		/* On phones the panel covers the full width (overlay), so the diagram
		   is not shrunk — reset the reserved width to zero. */
		.bowtie-page { --bv-panel-w: 0px; }
	}

/* Search-result highlight — pulsing outline on the matched control card. */
.bn-highlight {
	outline: 3px solid #ff9800;
	box-shadow: 0 0 0 6px rgba(255, 152, 0, 0.35);
	animation: bvHighlightPulse 1.2s ease-in-out 3;
}
@keyframes bvHighlightPulse {
	50% { box-shadow: 0 0 0 14px rgba(255, 152, 0, 0.10); }
}

/* Panel-source selection — green outline on the double-clicked element whose
   details are shown in the right-hand panel. */
.bn-selected {
	outline: 3px solid #2e7d32;
	box-shadow: 0 0 0 6px rgba(46, 125, 50, 0.35);
	animation: bvSelectedPulse 1.2s ease-in-out 3;
}
@keyframes bvSelectedPulse {
	50% { box-shadow: 0 0 0 14px rgba(46, 125, 50, 0.10); }
}
