/* Theme — see docs/ui-guidelines.md for the canonical token reference */
:root {
	/* Surfaces (neutral zinc family — no blue tint) */
	--bg: #fafafa;
	--bg-surface: #f4f4f5;
	--bg-elevated: #ffffff;
	--bg-hover: #ededee;
	--border: #e4e4e7;
	--border-strong: #d4d4d8;
	--text: #18181b;
	--text-secondary: #52525b;
	--text-muted: #71717a;

	/* Shadows */
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
	--shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
	--shadow-modal: 0 10px 30px rgba(0, 0, 0, 0.18);

	/* Status palette */
	--green: #16a34a;
	--green-bg: #f0fdf4;
	--green-border: #bbf7d0;
	--red: #dc2626;
	--red-bg: #fef2f2;
	--red-border: #fecaca;
	--yellow: #d97706;
	--yellow-bg: #fffbeb;
	--yellow-border: #fde68a;
	--grey: #71717a;
	--grey-bg: #f4f4f5;
	--grey-border: #d4d4d8;
	--blue: #2563eb;
	--blue-bg: #eff6ff;
	--blue-border: #bfdbfe;

	/* Accent (brand green; cross-surface usage per ui-foundation allowlist) */
	--accent: #16a34a;
	--accent-strong: #15803d;
	--accent-bg: rgba(22, 163, 74, 0.1);

	/* Technical-emphasis text (sky blue; used for event-kind names etc.) */
	--text-accent: #0369a1;

	/* Foreground-on-accent / on-coloured-bar */
	--on-accent: #ffffff;

	/* Overlays */
	--overlay-strong: rgba(0, 0, 0, 0.45);
	--overlay-weak: rgba(0, 0, 0, 0.08);

	/* Primary button uses --accent so it reads as the brand action.
	   Hover steps to --accent-strong (slightly deeper green). */
	--btn-bg: var(--accent);
	--btn-bg-hover: var(--accent-strong);
	--btn-fg: var(--on-accent);

	/* Type scale */
	--fs-micro: 10px;
	--fs-xs: 11px;
	--fs-sm: 12px;
	--fs-base: 13px;
	--fs-md: 14px;
	--fs-lg: 16px;

	/* Spacing scale */
	--sp-1: 4px;
	--sp-2: 8px;
	--sp-3: 12px;
	--sp-4: 16px;
	--sp-5: 24px;
	--sp-6: 32px;
	--sp-7: 48px;

	/* Radii */
	--radius-sm: 4px;
	--radius: 8px;
	--radius-pill: 999px;

	/* Focus ring (two-layer: inner surface + outer accent) */
	--focus-ring: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--accent);

	/* Kind colours (cross-surface per ui-foundation: prefix → colour).
	   `--kind-rest` is the colour for the `system` prefix (event log, flamegraph).
	   See dashboard-list-view "Bar visual treatment by kind and status". */
	--kind-trigger: #2563eb;
	--kind-action: #9333ea;
	--kind-rest: #d97706;

	/* Fonts + layout */
	--font:
		-apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
	--font-mono:
		"JetBrains Mono", "SF Mono", "Cascadia Code", "Fira Code", monospace;
	--sidebar-width: 240px;
	--topbar-height: 40px;
	--tabs-height: 44px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #131316;
		--bg-surface: #18181b;
		--bg-elevated: #1d1d20;
		--bg-hover: #232327;
		--border: #2a2a2e;
		--border-strong: #3f3f46;
		--text: #e8e8ea;
		--text-secondary: #a1a1aa;
		--text-muted: #71717a;

		--shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
		--shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
		--shadow-modal: 0 10px 30px rgba(0, 0, 0, 0.5);

		--green: #22c55e;
		--green-bg: rgba(34, 197, 94, 0.14);
		--green-border: #166534;
		--red: #f87171;
		--red-bg: rgba(248, 113, 113, 0.14);
		--red-border: #7f1d1d;
		--yellow: #fbbf24;
		--yellow-bg: rgba(251, 191, 36, 0.14);
		--yellow-border: #92400e;
		--grey: #a1a1aa;
		--grey-bg: rgba(161, 161, 170, 0.14);
		--grey-border: #52525b;
		--blue: #60a5fa;
		--blue-bg: rgba(96, 165, 250, 0.14);
		--blue-border: #1d4ed8;

		--accent: #22c55e;
		--accent-strong: #16a34a;
		--accent-bg: rgba(34, 197, 94, 0.14);

		--text-accent: #7dd3fc;

		--overlay-weak: rgba(255, 255, 255, 0.06);

		/* Kind colours: brighter family for dark surfaces */
		--kind-trigger: #60a5fa;
		--kind-action: #c084fc;
		--kind-rest: #fbbf24;
	}
}

/* Reset */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: var(--font);
	background: var(--bg);
	color: var(--text);
	line-height: 1.5;
	min-height: 100vh;
}

[x-cloak] {
	/* biome-ignore lint/complexity/noImportantStyles: Alpine.js x-cloak requires !important to prevent flash of unstyled content */
	display: none !important;
}

/* Global focus ring — keyboard-only; mouse clicks stay ringless. `:where()`
   keeps specificity at 0 so component-level overrides still win. */
:where(
		a,
		button,
		select,
		input,
		textarea,
		summary,
		[role="button"]
	):focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
	border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) {
	outline: none;
}

::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: var(--radius-sm);
}

/* Shared inline-SVG icon sizing */
.icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	fill: currentColor;
}

/* Top bar */
.topbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: var(--topbar-height);
	background: var(--bg-elevated);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 var(--sp-4);
	z-index: 200;
}

/* Wordmark — sole branding element on every UI surface (universal topbar
   per ui-foundation). No icon; text in --accent with a slight negative
   letter-spacing for a tighter, dev-tool-leaning feel. */
.topbar-brand {
	font-size: var(--fs-md);
	font-weight: 600;
	color: var(--accent);
	letter-spacing: -0.01em;
	white-space: nowrap;
}

/* Row-leading prefix/kind icons (dashboard list, event log). Sized 14×14
   to align with mono text baselines; colour comes from currentColor on
   the surrounding row-icon--<prefix> / trigger-kind-icon--<kind> class. */
.row-icon,
.trigger-kind-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 14px;
	height: 14px;
}
.row-icon .icon,
.trigger-kind-icon .icon {
	width: 14px;
	height: 14px;
}
.row-icon--trigger {
	color: var(--kind-trigger);
}
.row-icon--action {
	color: var(--kind-action);
}
.row-icon--system {
	color: var(--kind-rest);
}
/* Three semantic categories, three colour tokens:
     internal (self-scheduled)            → --kind-rest    (amber)
     external (caller-driven: http, imap) → --kind-trigger (blue)
     manual   (human-initiated)           → --kind-action  (purple) */
.trigger-kind-icon--cron {
	color: var(--kind-rest);
}
.trigger-kind-icon--http {
	color: var(--kind-trigger);
}
.trigger-kind-icon--imap {
	color: var(--kind-trigger);
}
.trigger-kind-icon--manual {
	color: var(--kind-action);
}
/* `upload` is not a trigger kind on the wire — it's the leading icon on
   synthetic system.upload invocation rows. Painted in the accent token so
   upload rows read as a distinct event class from regular triggers. */
.trigger-kind-icon--upload {
	color: var(--accent);
}

.topbar-right {
	display: flex;
	align-items: center;
	gap: var(--sp-4);
}

.topbar-owner {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	font-size: var(--fs-sm);
	color: var(--text-muted);
	margin: 0;
}

.topbar-owner-label {
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-weight: 600;
}

.topbar-owner select {
	background: var(--bg-surface);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: var(--sp-1) var(--sp-2);
	font-size: var(--fs-base);
	font-weight: 500;
	cursor: pointer;
	transition: border-color 0.15s ease;
}

.topbar-owner select:hover,
.topbar-owner select:focus {
	border-color: var(--accent);
	outline: none;
}

.topbar-owner-go {
	background: var(--bg-surface);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: var(--sp-1) var(--sp-2);
	font-size: var(--fs-sm);
	cursor: pointer;
}

.topbar-owner-empty {
	font-size: var(--fs-base);
	color: var(--text-muted);
	font-style: italic;
}

.topbar-user {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
}

.topbar-user-text {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	line-height: 1.2;
}

.topbar-username {
	font-size: var(--fs-base);
	font-weight: 500;
	color: var(--accent);
}

.topbar-email {
	font-size: var(--fs-xs);
	color: var(--text-muted);
	min-height: 1em;
}

.topbar-signout-form {
	display: inline-flex;
}

.topbar-signout {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	color: var(--accent);
	border: 1px solid transparent;
	padding: var(--sp-1);
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition:
		background 0.15s ease,
		color 0.15s ease,
		border-color 0.15s ease;
}

.topbar-signout:hover,
.topbar-signout:focus-visible {
	background: var(--accent-bg);
	color: var(--accent);
	border-color: var(--accent);
}

/* Sidebar */
.sidebar {
	width: var(--sidebar-width);
	background: var(--bg-elevated);
	border-right: 1px solid var(--border);
	padding: var(--sp-2) 0;
	flex-shrink: 0;
	position: fixed;
	top: var(--topbar-height);
	left: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
}

/* In-page surface tabs (Dashboard | Trigger). Layout's `tabs?` slot is
   wrapped in `.page-tabs-slot`; the shared <Tabs/> component emits a
   `.page-tabs-bar` flex row carrying the left-aligned scope breadcrumb and
   right-aligned `<nav class="page-tabs">`. The slot is fixed under the
   global topbar (out of the page scroll area entirely) so both bars stay
   visible at all times. `.main-content` reserves space for it via
   `--tabs-height` margin-top. */
.page-tabs-slot {
	position: fixed;
	top: var(--topbar-height);
	left: var(--sidebar-width);
	right: 0;
	height: var(--tabs-height);
	background: var(--bg-elevated);
	border-bottom: 1px solid var(--border);
	z-index: 5;
}

.page-tabs-bar {
	display: flex;
	align-items: stretch;
	justify-content: space-between;
	gap: var(--sp-4);
	padding: 0 var(--sp-5);
	height: 100%;
}

.page-tabs-breadcrumb {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	font-size: var(--fs-sm);
	color: var(--text-secondary);
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.page-tabs-breadcrumb-link {
	color: var(--text-secondary);
	text-decoration: none;
}

.page-tabs-breadcrumb-link:hover,
.page-tabs-breadcrumb-link:focus-visible {
	color: var(--accent);
	text-decoration: underline;
}

.page-tabs-breadcrumb-current {
	color: var(--text);
	font-weight: 500;
}

.page-tabs-breadcrumb-sep {
	color: var(--text-secondary);
	opacity: 0.6;
}

.page-tabs {
	display: flex;
	gap: var(--sp-1);
}

.page-tabs-link {
	display: inline-flex;
	align-items: center;
	padding: var(--sp-3) var(--sp-3);
	color: var(--text-secondary);
	text-decoration: none;
	font-size: var(--fs-sm);
	font-weight: 500;
	border-bottom: 2px solid transparent;
	transition:
		color 0.15s ease,
		border-color 0.15s ease;
}

.page-tabs-link:hover {
	color: var(--text);
}

.page-tabs-link.active {
	color: var(--accent);
	border-bottom-color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
	.page-tabs-link {
		transition: none;
	}
}

/* Layout */
.main-content {
	margin-left: var(--sidebar-width);
	margin-top: var(--topbar-height);
	flex: 1;
	min-width: 0;
}

/* When a tab strip is present (authenticated surfaces), the fixed tabbar
   sits beneath the topbar; main-content reserves the combined offset. */
.page-tabs-slot ~ .main-content {
	margin-top: calc(var(--topbar-height) + var(--tabs-height));
}

/* Filters */
.filters {
	padding: var(--sp-3) var(--sp-5);
	display: flex;
	gap: var(--sp-2);
	border-bottom: 1px solid var(--border);
	background: var(--bg-surface);
}

.filter-btn {
	padding: var(--sp-1) var(--sp-3);
	border-radius: var(--radius-pill);
	border: 1px solid var(--border);
	background: var(--bg-elevated);
	color: var(--text-secondary);
	font-size: var(--fs-base);
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s ease;
	font-family: var(--font);
	display: flex;
	align-items: center;
}

.filter-btn:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.filter-btn.active {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--on-accent);
}

.filter-select {
	padding: var(--sp-1) var(--sp-3);
	border-radius: var(--radius-pill);
	border: 1px solid var(--border);
	background: var(--bg-elevated);
	color: var(--text-secondary);
	font-size: var(--fs-base);
	font-family: var(--font);
	cursor: pointer;
	appearance: none;
	padding-right: 28px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6f8a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
}

.filter-dropdown {
	position: relative;
}

.filter-dropdown-menu {
	position: absolute;
	top: 100%;
	left: 0;
	margin-top: var(--sp-1);
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-lg);
	padding: var(--sp-2);
	min-width: 200px;
	max-height: 300px;
	overflow-y: auto;
	z-index: 50;
}

/* Content list */
.list {
	max-width: 960px;
	margin: 0 auto;
	padding: var(--sp-4) var(--sp-5);
}

/* Invocation table. Single bordered container with hairline rows — no
   per-invocation card chrome. Status sits in a 3 px coloured strip on the
   row's left edge; identity (repo › workflow › trigger) collapses into one
   ellipsising column; meta cell carries dispatch glyph or status label;
   duration + age live in fixed tabular columns at the right. */
.entry-table {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}

.entry-thead,
.entry,
.entry-summary {
	display: grid;
	grid-template-columns:
		16px /* chevron */
		20px /* kind icon */
		minmax(0, 1fr) /* identity */
		auto /* meta cell (dispatch glyph / status label) */
		5em /* duration */
		7.5em; /* age */
	align-items: center;
	gap: var(--sp-3);
	padding: 0 var(--sp-3) 0 calc(var(--sp-3) + 3px);
}

.entry-thead {
	background: var(--bg-surface);
	border-bottom: 1px solid var(--border);
	min-height: 28px;
	font-size: var(--fs-xs);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--text-muted);
}
.entry-thead-cell--right {
	text-align: right;
}

.entry {
	min-height: 36px;
	border-bottom: 1px solid var(--border);
	transition: background-color 0.08s ease;
	position: relative;
	overflow: hidden;
}
.entry:last-child {
	border-bottom: 0;
}
.entry:hover {
	background: var(--bg-hover);
}

/* Status strip — 3 px coloured bar flush to the row's left edge. */
.entry::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: var(--grey);
}
.entry.s-succeeded::before {
	background: var(--green);
}
.entry.s-failed::before {
	background: var(--red);
}
.entry.s-pending::before {
	background: var(--yellow);
}
.entry.s-upload::before {
	background: var(--blue);
}

.entry-expand-chevron {
	color: var(--text-muted);
	transition: transform 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 16px;
	height: 16px;
}
.entry-expand-chevron--placeholder {
	visibility: hidden;
}
.entry-expandable[open] > summary .entry-expand-chevron {
	transform: rotate(90deg);
}
.entry-expandable > summary:hover {
	background: color-mix(in srgb, var(--text) 3%, transparent);
}

.chevron {
	color: var(--text-muted);
	transition: transform 0.2s ease;
	font-size: var(--fs-lg);
}

.entry.expanded .chevron {
	transform: rotate(90deg);
}

/* State dots */
.state-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex-shrink: 0;
}

.state-dot.pending {
	background: var(--yellow);
	box-shadow: 0 0 0 3px var(--yellow-border);
	animation: pulse 2s ease-in-out infinite;
}

.state-dot.succeeded {
	background: var(--green);
	box-shadow: 0 0 0 3px var(--green-border);
}

.state-dot.failed {
	background: var(--red);
	box-shadow: 0 0 0 3px var(--red-border);
}

@keyframes pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.5;
	}
}

/* Badges */
.badge {
	padding: 2px var(--sp-2);
	border-radius: var(--radius-pill);
	font-size: var(--fs-xs);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.badge.pending {
	background: var(--yellow-bg);
	color: var(--yellow);
	border: 1px solid var(--yellow-border);
}
.badge.succeeded {
	background: var(--green-bg);
	color: var(--green);
	border: 1px solid var(--green-border);
}
.badge.failed {
	background: var(--red-bg);
	color: var(--red);
	border: 1px solid var(--red-border);
}

/* Meta cell — dispatch glyph or status label, depending on row kind.
 * - manual dispatch: person silhouette icon (same as manual trigger kind),
 *   tinted blue to distinguish provenance from a manual trigger. Tooltip
 *   carries the user identity.
 * - upload dispatch: empty in the meta column (kind icon already conveys it).
 * - synthetic exception/rejection: short status label.
 * Cell is grid column 5; collapses to nothing when empty. */
.entry-meta-cell {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: var(--fs-sm);
	color: var(--text-muted);
	white-space: nowrap;
}
.entry-dispatch--manual {
	color: var(--blue);
}
.entry-setup-failed,
.entry-rejected {
	color: var(--red);
	font-weight: 600;
}
.entry-meta-label {
	font-size: var(--fs-sm);
}

/* Tooltip */
.tooltip {
	position: fixed;
	z-index: 1000;
	pointer-events: auto;
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-lg);
	padding: var(--sp-3) var(--sp-4);
	font-size: var(--fs-sm);
	width: 40vw;
	max-width: 480px;
}

.tooltip-title {
	font-weight: 600;
	font-family: var(--font-mono);
	font-size: var(--fs-base);
	margin-bottom: var(--sp-2);
	display: flex;
	align-items: center;
	gap: 6px;
}

.tooltip-title .dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
}

.tooltip-payload {
	position: relative;
	margin-top: var(--sp-2);
	padding: var(--sp-2);
	padding-right: var(--sp-6);
	background: var(--bg-surface);
	border-radius: var(--radius-sm);
	font-family: var(--font-mono);
	font-size: var(--fs-xs);
	color: var(--text-secondary);
	white-space: pre;
	max-height: 40vh;
	overflow-y: auto;
}

/* Buttons */
.copy-btn {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 24px;
	height: 24px;
	padding: 0;
	border: none;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition:
		color 0.15s ease,
		background 0.15s ease;
}

.copy-btn:hover {
	background: var(--bg-elevated);
	color: var(--text);
}

.submit-btn {
	padding: var(--sp-2) var(--sp-5);
	background: var(--accent);
	color: var(--on-accent);
	border: none;
	border-radius: var(--radius-sm);
	font-size: var(--fs-base);
	font-weight: 600;
	font-family: var(--font);
	cursor: pointer;
	transition: opacity 0.15s ease;
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
}

.submit-btn:hover {
	opacity: 0.9;
}

.submit-btn[disabled] {
	cursor: progress;
	opacity: 0.75;
}

/* Loading spinner on .submit-btn--loading */
.submit-btn--loading::before {
	content: "";
	display: inline-block;
	width: 1em;
	height: 1em;
	border: 2px solid color-mix(in srgb, var(--on-accent) 35%, transparent);
	border-top-color: var(--on-accent);
	border-radius: 50%;
	animation: submit-spinner 0.8s linear infinite;
	vertical-align: -0.18em;
}

@keyframes submit-spinner {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.submit-btn--loading::before {
		animation: none;
		border-top-color: color-mix(in srgb, var(--on-accent) 60%, transparent);
	}
}

/* Trigger result dialog */
.trigger-result-dialog[open] {
	background: var(--bg-elevated);
	color: var(--text);
	border: 1px solid var(--border);
	border-left: 4px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-lg);
	padding: var(--sp-4);
	max-width: 720px;
	width: 90vw;
	/* Fixed 80vh (was max-height) so the inner blocks have a stable
	   parent to flex-grow into. With max-height alone the dialog shrunk
	   to its zero-intrinsic-content size when blocks use `flex: 1 1 0`,
	   collapsing them to 0 px. */
	height: 80vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	gap: var(--sp-3);
	position: fixed;
	inset: 0;
	margin: auto;
}

.trigger-result-dialog::backdrop {
	background: var(--overlay-strong);
}

.trigger-result-dialog--success {
	border-left-color: var(--green);
}
.trigger-result-dialog--warn {
	border-left-color: var(--yellow);
}
.trigger-result-dialog--error {
	border-left-color: var(--red);
}

.trigger-result-status {
	display: flex;
	align-items: baseline;
	gap: var(--sp-2);
	padding: var(--sp-2) var(--sp-3);
	border-radius: var(--radius-sm);
	font-size: var(--fs-base);
	font-weight: 600;
}
.trigger-result-dialog--success .trigger-result-status {
	background: var(--green-bg);
	color: var(--green);
	border: 1px solid var(--green-border);
}
.trigger-result-dialog--warn .trigger-result-status {
	background: var(--yellow-bg);
	color: var(--yellow);
	border: 1px solid var(--yellow-border);
}
.trigger-result-dialog--error .trigger-result-status {
	background: var(--red-bg);
	color: var(--red);
	border: 1px solid var(--red-border);
}
.trigger-result-status-detail {
	font-weight: 500;
	color: var(--text-secondary);
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
}

.trigger-result-code {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
}

.trigger-result-body {
	margin: 0;
	padding: var(--sp-3);
	padding-right: var(--sp-6);
	background: var(--bg-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
	line-height: 1.5;
	color: var(--text);
	overflow: auto;
	white-space: pre-wrap;
	word-break: break-word;
	flex: 1 1 auto;
	min-height: 0;
}

.trigger-result-copy {
	position: absolute;
	top: 6px;
	right: 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	background: var(--bg-elevated);
	color: var(--text-secondary);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition:
		border-color 0.15s ease,
		color 0.15s ease;
}

.trigger-result-copy:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.trigger-result-copy--copied {
	color: var(--green);
	border-color: var(--green-border);
}

/* Visually-hidden live region for screen-reader copy confirmations */
.sr-live {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.trigger-result-close {
	align-self: flex-end;
	padding: var(--sp-2) var(--sp-4);
	background: var(--accent);
	color: var(--on-accent);
	border: none;
	border-radius: var(--radius-sm);
	font-size: var(--fs-sm);
	font-weight: 600;
	font-family: var(--font);
	cursor: pointer;
	transition: opacity 0.15s ease;
	flex: 0 0 auto;
}

.trigger-result-close:hover {
	opacity: 0.9;
}

/* Empty state */
.empty-state {
	text-align: center;
	padding: var(--sp-7) var(--sp-5);
	color: var(--text-muted);
	font-size: var(--fs-md);
}

/* Dashboard page — header stats */
.stats {
	display: flex;
	gap: var(--sp-4);
	font-size: var(--fs-base);
	color: var(--text-secondary);
}

.stat {
	display: flex;
	align-items: center;
	gap: 6px;
}

.stat-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
}

.stat-dot[data-color="yellow"] {
	background: var(--yellow);
}
.stat-dot[data-color="red"] {
	background: var(--red);
}
.stat-dot[data-color="green"] {
	background: var(--green);
}

/* Dashboard page — event-type multiselect dropdown */
.event-type-list {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.event-type-option {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	padding: var(--sp-1) var(--sp-2);
	border-radius: var(--radius-sm);
	font-size: var(--fs-sm);
	font-family: var(--font-mono);
	color: var(--text-secondary);
	cursor: pointer;
}

.event-type-option:hover {
	background: var(--bg-surface);
}

.event-type-option input[type="checkbox"] {
	accent-color: var(--accent);
}

.filter-btn-caret {
	margin-left: var(--sp-1);
	font-size: var(--fs-micro);
}

/* Dashboard page — entries */
.entry-type {
	font-weight: 600;
	font-size: var(--fs-md);
	font-family: var(--font-mono);
	flex: 1;
}

.entry-identity {
	display: inline-flex;
	align-items: baseline;
	gap: var(--sp-2);
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.entry-scope {
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
	color: var(--text-muted);
}

.entry-workflow {
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
	color: var(--text-muted);
}

.entry-identity-sep {
	color: var(--border-strong);
}

.entry-trigger {
	font-family: var(--font-mono);
	font-size: var(--fs-base);
	color: var(--text-secondary);
}

.entry-duration,
.entry-age {
	font-family: var(--font-mono);
	font-variant-numeric: tabular-nums;
	color: var(--text-muted);
	font-size: var(--fs-sm);
	text-align: right;
}

.entry-sep {
	color: var(--text-muted);
}

/* Skeleton placeholder */
.entry.skeleton {
	height: 68px;
	position: relative;
	overflow: hidden;
	background: var(--bg-elevated);
}

.entry.skeleton::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		90deg,
		transparent 0%,
		color-mix(in srgb, var(--text) 6%, transparent) 50%,
		transparent 100%
	);
	animation: entry-skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes entry-skeleton-shimmer {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(100%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.entry.skeleton::after {
		animation: none;
		background: color-mix(in srgb, var(--text) 4%, transparent);
	}
}

.timeline-container {
	border-top: 1px solid var(--border);
	background: var(--bg-surface);
	padding: var(--sp-5);
	display: none;
	max-height: 50vh;
	overflow: auto;
}

.entry.expanded .timeline-container {
	display: block;
}

/* Dashboard page — tooltip internals */
.tooltip-title .badge {
	margin-left: auto;
}

/* Dashboard page — timeline SVG */
.timeline-svg {
	overflow: visible;
}

.node {
	cursor: pointer;
}
.node .node-circle {
	transition: r 0.15s ease;
}
.node:hover .node-circle {
	r: 10;
}
.node .node-label {
	font-family: var(--font-mono);
	font-size: var(--fs-xs);
	fill: var(--text);
}
.node .node-action {
	font-family: var(--font-mono);
	font-size: var(--fs-micro);
	fill: var(--text-secondary);
	font-weight: 600;
}
.edge-line {
	stroke: var(--border);
	stroke-width: 2;
	fill: none;
}

/* -------------------------------------------------------------------------
 * Flamegraph
 * ----------------------------------------------------------------------- */

.flame-fragment {
	padding: var(--sp-2) var(--sp-3) var(--sp-3);
	color: var(--text);
}

.event-detail-fragment {
	/* Left padding clears the row's 3px status strip and gives the tree's
	   depth-0 disclosure chevron breathing room. */
	padding: var(--sp-2) var(--sp-3) var(--sp-3) var(--sp-4);
	color: var(--text);
}
.event-detail-tree {
	max-height: 40vh;
	overflow-y: auto;
	/* Indent every JSON-tree row a bit so nested levels are easier to
	   distinguish from the row's left edge. */
	padding-left: var(--sp-2);
}

.flame-header {
	display: flex;
	flex-direction: column;
	gap: var(--sp-1);
	padding: var(--sp-1) 0 var(--sp-2);
}
.flame-header-identity {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
}
.flame-header-identity-workflow {
	font-weight: 600;
	color: var(--text);
	font-size: var(--fs-sm);
}
.flame-header-identity-sep {
	color: var(--text-muted);
}
.flame-header-identity-trigger {
	font-family: var(--font-mono);
	color: var(--text-secondary);
	font-size: var(--fs-sm);
}
.flame-header-identity .badge {
	margin-left: auto;
}
.flame-header-metrics {
	display: flex;
	align-items: baseline;
	gap: var(--sp-3);
	font-size: var(--fs-xs);
	color: var(--text-muted);
	font-family: var(--font-mono);
}
.flame-header-triggered-by {
	margin-left: auto;
	color: var(--text-secondary);
}
.flame-header-triggered-by strong {
	color: var(--text);
	font-weight: 600;
}
.flame-header-duration {
	font-size: var(--fs-md);
	color: var(--text);
	font-weight: 600;
}

.flame-summary {
	font-size: var(--fs-xs);
	color: var(--text-secondary);
	padding: 2px 0;
	font-family: var(--font-mono);
}

.flame-legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--sp-3);
	padding: var(--sp-1) 0;
	font-size: var(--fs-xs);
	color: var(--text-muted);
}
.flame-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.flame-legend-swatch {
	width: 12px;
	height: 12px;
	border-radius: var(--radius-sm);
	display: inline-block;
}
.flame-legend-swatch--trigger {
	background: var(--kind-trigger);
}
.flame-legend-swatch--action {
	background: var(--kind-action);
}
.flame-legend-swatch--rest {
	background: var(--kind-rest);
}
.flame-legend-swatch--orphan {
	background: repeating-linear-gradient(
		45deg,
		var(--kind-rest) 0 4px,
		color-mix(in srgb, var(--kind-rest) 40%, transparent) 4px 8px
	);
}
.flame-legend-icon {
	color: var(--text-secondary);
	flex: none;
}
.flame-legend-item--danger .flame-legend-icon {
	color: var(--red);
}

.flame-ruler {
	display: block;
	width: 100%;
	overflow: visible;
	margin-bottom: 2px;
}

.flame-ruler-tick {
	stroke: var(--border);
}

.flame-ruler-label {
	font-family: var(--font-mono);
	font-size: var(--fs-micro);
	fill: var(--text-muted);
}

.flame-container {
	max-height: 40vh;
	overflow-x: auto;
	overflow-y: auto;
	border-top: 1px solid var(--border);
	border-bottom: 1px solid var(--border);
	/* Hint to browsers that ctrl+wheel will be intercepted; without this
	   Firefox/Chromium may scroll the page on zoom intent. */
	overscroll-behavior-x: contain;
}
.flame-canvas {
	width: 100%;
	display: block;
	/* Inline `style="width:<zoom>%"` is set by static/flamegraph.js on
	   ctrl+wheel; the ruler + graph share this canvas so they zoom and
	   scroll together. */
}

.flame-graph {
	display: block;
	width: 100%;
	overflow: visible;
}

.flame-bar {
	cursor: pointer;
}

.kind-trigger {
	fill: var(--kind-trigger);
}
.kind-action {
	fill: var(--kind-action);
}
.kind-rest {
	fill: var(--kind-rest);
}

.bar-error {
	stroke: var(--red);
	stroke-width: 2;
}

.orphan {
	fill: url(#flame-hatched);
}

/* Bar text. Each label is positioned in the OUTER SVG's user space using
 * percentage `x` (anchored to the bar's left or right edge); the small
 * fixed-pixel insets are applied via the SVG `transform="translate(N 0)"`
 * attribute on the element (set in flamegraph.tsx). All labels carry
 * `clip-path="url(#bc-N)"` referencing the bar's clipPath, which is the
 * one rendering primitive that every browser engine honours uniformly. */
.bar-label {
	font-family: var(--font-mono);
	font-size: var(--fs-xs);
	fill: var(--on-accent);
	dominant-baseline: middle;
}
.bar-label-dim {
	font-family: var(--font-mono);
	font-size: var(--fs-micro);
	fill: color-mix(in srgb, var(--on-accent) 78%, transparent);
	dominant-baseline: middle;
}
.bar-error-icon {
	font-size: var(--fs-xs);
	fill: var(--red);
	font-weight: 700;
	dominant-baseline: middle;
}

.bar-orphan-glyph {
	font-family: var(--font-mono);
	font-size: var(--fs-xs);
	fill: var(--on-accent);
	font-weight: 700;
	dominant-baseline: middle;
	text-anchor: end;
	pointer-events: none;
}

/* Leaf markers — wrapper <g> per marker carrying the click target +
   tooltip; visible glyph rendered via inner <use href="#fi-<name>">.
   All icons render white so the glyph reads uniformly against any
   bar/marker fill; severity is conveyed by glyph shape (triangle-alert
   / circle-x), not colour. */
.flame-marker {
	color: #fff;
	cursor: pointer;
}
/* Transparent hit rect under the icon so clicks anywhere in the marker's
   bbox register, not just on the icon's stroked pixels. fill="transparent"
   (vs none) is required so the rect is hit-testable. */
.flame-marker-hit {
	fill: transparent;
}

/* Cluster count badge — appears next to a representative marker icon when
   2+ leaf events fall within icon-width of each other. The full per-event
   list is in the marker's <title> tooltip (multi-line). */
.flame-marker-badge {
	font-family: var(--font-mono);
	font-size: var(--fs-micro);
	font-weight: 700;
	fill: #fff;
	dominant-baseline: middle;
	pointer-events: none;
}
.flame-marker--auto {
	opacity: 0.55;
}

/* Per-bar icon at the bar's left edge — white over the bar's coloured
   fill. Positioned at x="0" inside the per-bar nested SVG; CSS only sets
   colour. */
.flame-bar-icon {
	color: #fff;
}

.timer-connector {
	stroke: var(--kind-rest);
	stroke-width: 1.3;
	stroke-dasharray: 3 3;
	fill: none;
	opacity: 0.7;
	pointer-events: none;
}

.flame-track-divider {
	stroke: var(--border);
	stroke-dasharray: 4 3;
	pointer-events: none;
}
.flame-track-label {
	font-family: var(--font-mono);
	font-size: var(--fs-micro);
	font-weight: 600;
	fill: var(--text-muted);
	pointer-events: none;
}

.flame-empty {
	padding: var(--sp-3);
	font-size: var(--fs-base);
	color: var(--text-muted);
	text-align: center;
	font-style: italic;
}

.tid-hit {
	filter: drop-shadow(
			0 0 2px color-mix(in srgb, var(--kind-action) 85%, transparent)
		)
		drop-shadow(0 0 4px color-mix(in srgb, var(--kind-action) 55%, transparent));
}
.tid-hit.timer-connector {
	opacity: 1;
	stroke-width: 2;
}
.tid-dim {
	opacity: 0.22;
}

/* Expandable invocation row (<details>) styling. The grid layout for the
   row's summary already comes from the shared `.entry-summary` rule above
   (matched against `.entry-thead, .entry, .entry-summary`). */
.entry-expandable {
	cursor: default;
	/* The grid lives on `<summary>`, not on `<details>`. Disable the inherited
	   grid so the details element is just a stack of summary + flame-slot. */
	display: block;
	padding: 0;
}
.entry-expandable > summary {
	list-style: none;
	cursor: pointer;
	min-height: 36px;
}
.entry-expandable > summary::-webkit-details-marker {
	display: none;
}

/* Dialog result blocks (request + response, each with its own copy button) */
.trigger-result-blocks {
	display: flex;
	flex-direction: column;
	gap: var(--sp-3);
	flex: 1 1 auto;
	min-height: 0;
}
.trigger-result-block {
	display: flex;
	flex-direction: column;
	gap: var(--sp-1);
	min-height: 0;
	/* Each block claims an equal share of the dialog's vertical space so a
	   small Request and a large Response render at the same height (the
	   large one's body scrolls inside its half). With a single block the
	   `flex: 1` still applies so it fills the dialog. */
	flex: 1 1 0;
	overflow: hidden;
}
.trigger-result-label {
	font-size: var(--fs-xs);
	color: var(--text-secondary);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin: 0;
}

/* Auth pages — standalone layout (no topbar / sidebar) for callers
   without an active session. Vertically-centered card on a neutral
   background. */
.auth-page {
	margin: 0;
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	padding: var(--sp-5);
}

/* Auth card. Narrower than before since the brand wordmark moved up to
   the universal topbar; lighter shadow (was --shadow-modal) so the card
   sits in the page rather than feeling like a modal overlay. */
.auth-card {
	width: 100%;
	max-width: 380px;
	padding: var(--sp-6) var(--sp-5) var(--sp-5);
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	gap: var(--sp-5);
	box-shadow: var(--shadow);
}

/* .auth-card__brand* removed: branding now lives in the universal topbar
   above the auth card per ui-foundation. */

.auth-card__title {
	font-size: var(--fs-lg);
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--text);
	text-align: center;
	margin: 0;
}

.auth-card__brand {
	color: var(--accent);
}

.auth-card__banner {
	padding: var(--sp-3) var(--sp-4);
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--bg);
	line-height: 1.5;
	font-size: var(--fs-md);
}

.auth-card__banner[role="alert"] {
	border-left: 3px solid var(--red);
}

.auth-card__banner[role="status"] {
	border-left: 3px solid var(--accent);
}

.auth-card__banner strong {
	display: block;
	font-weight: 600;
	margin-bottom: var(--sp-1);
}

.auth-card__banner code {
	background: var(--overlay-weak);
	padding: 1px 6px;
	border-radius: var(--radius-sm);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: var(--fs-sm);
}

.auth-card__actions {
	display: flex;
	flex-direction: column;
	gap: var(--sp-3);
}

.auth-card__local {
	margin: 0;
}

/* Shared auth button. Both providers render an .auth-btn — same height,
   same radius, same horizontal padding — so the two rows line up as
   peers. The visual difference between GitHub (filled, dark) and local
   (outlined) reads as choice, not hierarchy. */
.auth-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--sp-2);
	width: 100%;
	min-height: 44px;
	padding: 0 var(--sp-4);
	border-radius: var(--radius);
	border: 1px solid transparent;
	background: var(--bg-surface);
	color: var(--text);
	font-family: var(--font);
	font-size: var(--fs-md);
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	transition:
		background 0.15s ease,
		border-color 0.15s ease,
		transform 0.15s ease,
		box-shadow 0.15s ease;
}

.auth-btn:hover {
	transform: translateY(-1px);
	box-shadow: var(--shadow);
}

.auth-btn:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.auth-btn__icon {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
}

.auth-btn__chevron {
	margin-left: auto;
	transition: transform 0.2s ease;
	color: var(--text-muted);
}

/* GitHub button — filled with the brand-green accent so the primary auth
   action keeps the visual weight it had before the rework. The Lucide
   GitHub mark sits on the green field; hover deepens to --accent-strong
   matching .btn--primary. */
.auth-btn--github {
	background: var(--btn-bg);
	color: var(--btn-fg);
	border-color: var(--btn-bg);
}

.auth-btn--github:hover {
	background: var(--btn-bg-hover);
	border-color: var(--btn-bg-hover);
}

/* Local dropdown button — same filled green accent as the GitHub button
   so the two providers read as peers. The chevron picks up --btn-fg
   so it stays visible on the green field. */
.auth-btn--local {
	background: var(--btn-bg);
	color: var(--btn-fg);
	border-color: var(--btn-bg);
}

.auth-btn--local:hover {
	background: var(--btn-bg-hover);
	border-color: var(--btn-bg-hover);
}

.auth-btn--local .auth-btn__chevron {
	color: var(--btn-fg);
	opacity: 0.85;
}

/* <details>-driven dropdown. CSP-strict (no JS): the open/close toggle is
   the native <summary> click. Marker dot on the summary is suppressed so
   the chevron is the sole affordance. */
.auth-local {
	position: relative;
}

.auth-local__summary {
	list-style: none;
}

.auth-local__summary::-webkit-details-marker {
	display: none;
}

.auth-local[open] > .auth-local__summary .auth-btn__chevron {
	transform: rotate(180deg);
}

.auth-local__list {
	position: absolute;
	top: calc(100% + var(--sp-2));
	left: 0;
	right: 0;
	z-index: 10;
	list-style: none;
	margin: 0;
	padding: var(--sp-1);
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-lg);
	display: flex;
	flex-direction: column;
	gap: 2px;
	animation: auth-local-reveal 180ms ease;
	transform-origin: top center;
}

@keyframes auth-local-reveal {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.auth-local__list {
		animation: none;
	}
	.auth-btn:hover {
		transform: none;
	}
	.auth-btn__chevron {
		transition: none;
	}
}

.auth-local__item {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	width: 100%;
	padding: var(--sp-2) var(--sp-3);
	border: 0;
	background: transparent;
	color: var(--text);
	font: inherit;
	text-align: left;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: background 0.12s ease;
}

.auth-local__item:hover {
	background: var(--bg-hover);
}

.auth-local__item:focus-visible {
	outline: none;
	background: var(--bg-hover);
	box-shadow: var(--focus-ring);
}

.auth-local__avatar {
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: var(--fs-sm);
	font-weight: 600;
	color: var(--accent-strong);
	background: var(--accent-bg);
	letter-spacing: 0;
}

.auth-local__name {
	font-size: var(--fs-md);
	font-weight: 500;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--sp-2);
	padding: var(--sp-2) var(--sp-4);
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--bg-surface);
	color: var(--text);
	font-size: var(--fs-md);
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	transition: all 0.15s ease;
}

.btn:hover {
	border-color: var(--text-secondary);
	background: var(--border);
}

.btn--primary {
	background: var(--btn-bg);
	border-color: var(--btn-bg);
	color: var(--btn-fg);
}

.btn--primary:hover {
	background: var(--btn-bg-hover);
	border-color: var(--btn-bg-hover);
}

.btn--secondary {
	opacity: 0.85;
}

/* Error pages (404.html, error.html). Scoped via body class so the flex
   layout never leaks into other pages that import this stylesheet. */
body.error-page {
	display: flex;
	flex-direction: column;
}

.error-content {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: var(--topbar-height);
}

/* Centered error card. Adopts the same .btn--primary visual recipe as
   the rest of the app for the "Go to dashboard"/"Go home" link, so error
   pages feel like part of the same product rather than a separate
   minimal layout. */
.error-card {
	text-align: center;
	padding: var(--sp-7) var(--sp-5);
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	max-width: 420px;
	margin: 0 var(--sp-4);
}

.error-title {
	font-size: var(--fs-lg);
	font-weight: 600;
	color: var(--text);
	margin-bottom: var(--sp-2);
}

.error-message {
	color: var(--text-secondary);
	font-size: var(--fs-md);
	margin-bottom: var(--sp-5);
	line-height: 1.5;
}

.error-link {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	padding: var(--sp-2) var(--sp-4);
	border-radius: var(--radius);
	border: 1px solid var(--btn-bg);
	background: var(--btn-bg);
	color: var(--btn-fg);
	font-size: var(--fs-md);
	font-weight: 500;
	text-decoration: none;
	transition: background-color 0.08s ease;
}

.error-link:hover {
	background: var(--btn-bg-hover);
	border-color: var(--btn-bg-hover);
}

/* ----- Dashboard / trigger collapsible tree --------------------------- */

.dashboard-tree {
	display: flex;
	flex-direction: column;
	gap: var(--sp-2);
}

.tree-owners,
.tree-repos {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: var(--sp-2);
}

.tree-owners > .tree-owner {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	transition: box-shadow 0.15s ease;
}

.tree-owners > .tree-owner:hover {
	box-shadow: var(--shadow);
}

.tree-owner > details > summary,
.tree-repo > details > summary {
	list-style: none;
	cursor: pointer;
}

.tree-owner > details > summary::-webkit-details-marker,
.tree-repo > details > summary::-webkit-details-marker {
	display: none;
}

.tree-row {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	padding: var(--sp-3) var(--sp-4);
}

.tree-row--flat {
	color: inherit;
	text-decoration: none;
}

.tree-owner > details > summary:hover,
.tree-repo > details > summary:hover,
a.tree-row:hover {
	background: color-mix(in srgb, var(--text) 3%, transparent);
}

.tree-chevron {
	color: var(--text-muted);
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	transition: transform 0.2s ease;
}

details[open] > summary .tree-chevron {
	transform: rotate(90deg);
}

.tree-label {
	font-weight: 600;
	color: var(--text);
	font-size: var(--fs-md);
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

a.tree-label {
	text-decoration: none;
	color: var(--text);
}

a.tree-row:hover .tree-label,
.tree-row a.tree-label:hover {
	color: var(--accent);
}

.tree-count {
	color: var(--text-secondary);
	font-size: var(--fs-sm);
	font-variant-numeric: tabular-nums;
	padding: 2px 8px;
	border-radius: var(--radius-pill);
	background: color-mix(in srgb, var(--text) 6%, transparent);
	flex-shrink: 0;
}

.tree-note {
	color: var(--text-muted);
	font-size: var(--fs-sm);
	font-style: italic;
	flex-shrink: 0;
}

.tree-owner-body,
.tree-invocations {
	padding: 0 var(--sp-4) var(--sp-3);
}

.tree-owner > details > .tree-owner-body {
	border-top: 1px solid var(--border);
	padding-top: var(--sp-3);
	background: color-mix(in srgb, var(--text) 2%, transparent);
}

.tree-repos {
	padding-left: var(--sp-4);
}

.tree-repo {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

.tree-repo + .tree-repo {
	margin-top: var(--sp-2);
}

.tree-repo > details > .tree-invocations {
	border-top: 1px solid var(--border);
	padding-top: var(--sp-3);
}

.tree-owner--empty,
.tree-repo--empty {
	opacity: 0.8;
}

.tree-empty {
	padding: var(--sp-4);
	color: var(--text-muted);
	font-size: var(--fs-sm);
	font-style: italic;
}

/* ----- Sidebar tree (single unified owner→repo→workflow→trigger) ------- */

.sidebar-tree-wrap {
	padding: var(--sp-3) var(--sp-2);
	overflow-y: auto;
	flex: 1 1 auto;
	min-height: 0;
}

.sidebar-tree {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sidebar-tree-empty {
	padding: var(--sp-2) var(--sp-3);
	color: var(--text-muted);
	font-size: var(--fs-xs);
	font-style: italic;
}

.sidebar-owner-link,
.sidebar-repo-link,
.sidebar-workflow-link {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	padding: var(--sp-1) var(--sp-2);
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	font-size: var(--fs-sm);
	font-weight: 600;
	text-decoration: none;
}

.sidebar-workflow-link {
	font-weight: 500;
	font-size: var(--fs-xs);
}

.sidebar-owner-link:hover,
.sidebar-repo-link:hover,
.sidebar-workflow-link:hover {
	background: color-mix(in srgb, var(--text) 5%, transparent);
	color: var(--text);
}

.sidebar-owner-link.active,
.sidebar-repo-link.active,
.sidebar-workflow-link.active {
	background: color-mix(in srgb, var(--accent) 14%, transparent);
	color: var(--accent);
}

.sidebar-owner--empty {
	padding: var(--sp-1) var(--sp-2);
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	color: var(--text-muted);
	font-size: var(--fs-sm);
}

.sidebar-owner--empty .sidebar-owner-link {
	flex: 1 1 auto;
	padding: 0;
	background: none;
}

.sidebar-owner-label {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sidebar-note {
	color: var(--text-muted);
	font-size: var(--fs-xs);
	font-style: italic;
}

.sidebar-repos,
.sidebar-workflows {
	list-style: none;
	margin: 0;
	padding: 0 0 0 var(--sp-4);
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sidebar-workflow-label {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sidebar-repo {
	display: block;
	padding: var(--sp-1) var(--sp-2);
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	text-decoration: none;
	font-size: var(--fs-sm);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sidebar-repo:hover {
	background: color-mix(in srgb, var(--text) 5%, transparent);
	color: var(--text);
}

.sidebar-repo.active {
	background: color-mix(in srgb, var(--accent) 14%, transparent);
	color: var(--accent);
	font-weight: 600;
}

.sidebar-repo-label {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 500;
}

.sidebar-triggers {
	list-style: none;
	margin: 0;
	padding: 0 0 0 var(--sp-4);
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.sidebar-trigger {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 2px var(--sp-2);
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	text-decoration: none;
	font-size: var(--fs-xs);
	overflow: hidden;
	white-space: nowrap;
}

.sidebar-trigger:hover {
	background: color-mix(in srgb, var(--text) 5%, transparent);
	color: var(--text);
}

.sidebar-trigger.active {
	background: color-mix(in srgb, var(--accent) 14%, transparent);
	color: var(--accent);
}

.sidebar-trigger-name {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: 1 1 auto;
	min-width: 0;
}

.sidebar-trigger .trigger-kind-icon {
	font-size: var(--fs-xs);
	line-height: 1;
	flex-shrink: 0;
}

.sidebar-repo--empty {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-2);
}

/* Trigger cards inside the tree — skeleton while HTMX is in flight */
.trigger-skeleton {
	height: 40px;
	margin-bottom: var(--sp-2);
	background: linear-gradient(
		90deg,
		color-mix(in srgb, var(--text) 4%, transparent),
		color-mix(in srgb, var(--text) 8%, transparent),
		color-mix(in srgb, var(--text) 4%, transparent)
	);
	background-size: 200% 100%;
	border-radius: var(--radius-sm);
	animation: entry-skeleton-shimmer 1.4s ease-in-out infinite;
}

.tree-trigger-cards {
	padding: var(--sp-3) var(--sp-4);
	border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Queue cards (/queue surface). Mirrors trigger card density. The card body
   lazy-loads server-rendered HTML fragments via the wfeQueueCard Alpine
   component (defined in /static/json-tree.js).
   --------------------------------------------------------------------------- */

.queue-content {
	padding: var(--sp-3) var(--sp-4);
}

.queue-details {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	margin-bottom: var(--sp-2);
	overflow: hidden;
	transition: background-color 0.08s ease;
}

.queue-details:not(.queue-details-empty):hover {
	background: var(--bg-hover);
}

.queue-details[open] {
	background: var(--bg-elevated);
}

.queue-details-empty {
	opacity: 0.7;
}

.queue-summary-empty {
	cursor: default;
	user-select: text;
}

.queue-summary {
	padding: var(--sp-2) var(--sp-3);
	cursor: pointer;
	user-select: none;
	list-style: none;
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	min-height: 32px;
}

.queue-summary::-webkit-details-marker {
	display: none;
}

.queue-summary-chevron {
	color: var(--text-muted);
	transition: transform 0.2s ease;
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
}

.queue-details[open] > .queue-summary .queue-summary-chevron {
	transform: rotate(90deg);
}

.queue-name {
	font-weight: 600;
	font-size: var(--fs-md);
	font-family: var(--font-mono);
}

.queue-meta {
	margin-left: auto;
	display: inline-flex;
	gap: var(--sp-1);
	color: var(--text-muted);
	font-size: var(--fs-sm);
	font-variant-numeric: tabular-nums;
}

.queue-count {
	font-weight: 600;
	color: var(--text-secondary);
}

.queue-body {
	padding: var(--sp-3);
	border-top: 1px solid var(--border);
}

.queue-items[data-loading="true"]::after {
	content: "Loading…";
	color: var(--text-muted);
	font-size: var(--fs-sm);
}

.queue-empty {
	color: var(--text-muted);
	font-style: italic;
	padding: var(--sp-2) 0;
}

.queue-item {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: var(--sp-2) var(--sp-3);
	margin-bottom: var(--sp-2);
}

.queue-item:last-child {
	margin-bottom: 0;
}

.queue-load-more {
	margin-top: var(--sp-2);
	padding: var(--sp-2) var(--sp-3);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text);
	cursor: pointer;
	font-size: var(--fs-sm);
}

.queue-load-more:hover {
	background: var(--bg-hover);
}

.queue-load-more[disabled] {
	opacity: 0.6;
	cursor: progress;
}

.queue-load-error {
	color: var(--text-secondary);
	background: color-mix(in srgb, currentColor 10%, transparent);
	border-radius: var(--radius-sm);
	padding: var(--sp-1) var(--sp-2);
	margin-top: var(--sp-2);
	font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------------------
   Shared interactive JSON tree (wfeJsonTree). Used inline by queue items and
   embedded inside the trigger result dialog.
   --------------------------------------------------------------------------- */

.json-tree {
	font-family: var(--font-mono);
	font-size: var(--fs-sm);
	line-height: 1.5;
	color: var(--text);
}

.json-tree-container {
	display: block;
}

.json-tree-row {
	/* Block-with-inline-children so the key + primitive + trailing comma flow
	on a single visible line. `display: flex` is wrong here because each flex
	item is treated as a block by `innerText`, which breaks "key": "value"
	apart in copy/paste and in DOM-level text assertions. */
	display: block;
	white-space: nowrap;
}

.json-tree-body {
	/* Indent comes entirely from per-depth padding-left on each row, so the
	body wrapper is purely a structural collapse target with no extra
	horizontal offset. */
	padding-left: 0;
	margin-left: 0;
}

/* Per-depth indent — exactly two characters per level in the monospace tree
font. Hardcoded up to 15 levels because (a) `attr(... number)` is not
universally supported and (b) `style="--depth:N"` violates CSP-clean
rendering. Anyone hitting depth > 15 has a bigger problem than indent. */
.json-tree-row[data-depth="0"] {
	padding-left: 0;
}
.json-tree-row[data-depth="1"] {
	padding-left: 2ch;
}
.json-tree-row[data-depth="2"] {
	padding-left: 4ch;
}
.json-tree-row[data-depth="3"] {
	padding-left: 6ch;
}
.json-tree-row[data-depth="4"] {
	padding-left: 8ch;
}
.json-tree-row[data-depth="5"] {
	padding-left: 10ch;
}
.json-tree-row[data-depth="6"] {
	padding-left: 12ch;
}
.json-tree-row[data-depth="7"] {
	padding-left: 14ch;
}
.json-tree-row[data-depth="8"] {
	padding-left: 16ch;
}
.json-tree-row[data-depth="9"] {
	padding-left: 18ch;
}
.json-tree-row[data-depth="10"] {
	padding-left: 20ch;
}
.json-tree-row[data-depth="11"] {
	padding-left: 22ch;
}
.json-tree-row[data-depth="12"] {
	padding-left: 24ch;
}
.json-tree-row[data-depth="13"] {
	padding-left: 26ch;
}
.json-tree-row[data-depth="14"] {
	padding-left: 28ch;
}
.json-tree-row[data-depth="15"] {
	padding-left: 30ch;
}

.json-tree-collapsed-hint {
	color: var(--text-muted);
	font-style: italic;
	margin: 0 0.4em;
}

.json-tree-close-block {
	display: block;
}

.json-tree-container[data-collapsed="true"] > .json-tree-body {
	display: none;
}

.json-tree-container[data-collapsed="true"] > .json-tree-close-block {
	display: none;
}

.json-tree-container[data-collapsed="false"]
	> .json-tree-row
	> .json-tree-collapsed-hint {
	display: none;
}

.json-tree-container[data-collapsed="false"]
	> .json-tree-row
	> .json-tree-close-inline {
	display: none;
}

.json-tree-disclosure {
	background: transparent;
	border: 0;
	padding: 0 0.3em 0 0;
	cursor: pointer;
	color: var(--text-muted);
	font-family: inherit;
	font-size: inherit;
	line-height: 1;
	transition: color 0.08s ease;
}

.json-tree-disclosure:hover {
	color: var(--text);
}

.json-tree-disclosure:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
	border-radius: var(--radius-sm);
}

.json-tree-key {
	color: var(--text-secondary);
}

.json-tree-punct {
	color: var(--text-muted);
}

.json-tree-string {
	color: color-mix(in srgb, currentColor 70%, var(--success, #5a9a5a));
}

.json-tree-number {
	color: color-mix(in srgb, currentColor 70%, var(--info, #4a7fb5));
}

.json-tree-boolean {
	color: color-mix(in srgb, currentColor 70%, var(--warning, #b58a4a));
}

.json-tree-null,
.json-tree-undefined {
	color: var(--text-muted);
	font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
	.queue-summary-chevron {
		transition: none;
	}
	.json-tree-disclosure {
		transition: none;
	}
}
