/* comfoo.js additions on top of the admin console styles (report.css tokens + app.css layout). */

.topbar {
	justify-content: space-between;
	gap: 16px;
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.topbar-actions form {
	margin: 0;
}

.lead {
	margin: 0 0 20px;
	max-width: 760px;
}

/* Stat tiles */
.stats {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
}

.stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 16px 20px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.stat-value {
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
}

.stat-label {
	font-size: 12px;
	color: var(--muted);
}

.stat-bad .stat-value {
	color: var(--red);
}

/* Per-node sync dots in the routes table */
.node-dots {
	display: inline-flex;
	gap: 3px;
	margin-left: 6px;
	vertical-align: middle;
}

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

.dot-ok { background: var(--green); }
.dot-bad { background: var(--red); }
.dot-unknown { background: var(--border-strong); }

.empty-state {
	padding: 48px 24px;
	text-align: center;
}

.empty-state h2 {
	font-size: 16px;
	margin-bottom: 6px;
}

.empty-state p {
	margin: 0 0 16px;
}

/* Forms */
.card-form {
	max-width: 760px;
}

.input small {
	font-size: 12px;
}

.input code,
.muted code,
.block-list code {
	font-size: 12px;
	background: var(--bg);
}

.suffix-input {
	display: flex;
	align-items: stretch;
}

.suffix-input input {
	flex: 1 1 auto;
	min-width: 0;
	border-top-right-radius: 0;
	border-bottom-right-radius: 0;
}

.suffix-input .suffix {
	display: inline-flex;
	align-items: center;
	padding: 0 12px;
	border: 1px solid var(--border-strong);
	border-left: 0;
	border-radius: 0 6px 6px 0;
	background: var(--bg);
	color: var(--muted);
	font-weight: 600;
}

input[readonly] {
	background: var(--bg);
	color: var(--muted);
}

.has-error input {
	border-color: var(--red);
}

.dc-preview {
	padding: 12px 14px;
	border-radius: 6px;
	background: var(--bg);
	border: 1px solid var(--border);
}

.dc-preview.dc-denver {
	background: var(--blue-soft);
	border-color: #b9d6fb;
}

.dc-preview.dc-dallas {
	background: var(--purple-soft);
	border-color: #d9c6f7;
}

.dc-preview.dc-invalid {
	background: var(--amber-soft);
	border-color: #f5d9a8;
	color: var(--amber);
}

.blocks summary {
	cursor: pointer;
	color: var(--muted);
	font-weight: 600;
	font-size: 13px;
}

.block-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 8px 0 0;
}

.inline-form {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.inline-form input {
	height: 30px;
	width: 140px;
	font-size: 13px;
}

/* Detail pages */
.detail-grid {
	align-items: start;
}

.facts {
	display: grid;
	grid-template-columns: 140px 1fr;
	gap: 10px 16px;
	margin: 0 0 8px;
}

.facts dt {
	color: var(--muted);
	font-size: 13px;
}

.facts dd {
	margin: 0;
}

.facts + .form-actions {
	margin-top: 16px;
}

.form-actions form {
	margin: 0;
}

.node-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.table-compact td {
	padding: 10px 0;
}

.table-compact td + td {
	padding-left: 12px;
}

.log {
	margin: 0;
	padding: 12px 14px;
	max-height: 360px;
	overflow: auto;
	background: var(--navy);
	color: #dfe4ee;
	border-radius: 6px;
	font: 12px/1.5 var(--mono);
	white-space: pre-wrap;
	word-break: break-word;
}

.log-bad {
	background: #2a1015;
	color: #ffd5d9;
}

.detail summary {
	cursor: pointer;
	font-size: 12px;
	color: var(--muted);
}

.detail .log {
	margin-top: 6px;
	max-width: 520px;
}

@media (max-width: 900px) {
	.stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.topbar {
		height: auto;
		min-height: 64px;
		flex-wrap: wrap;
		padding-block: 12px;
	}

	.facts {
		grid-template-columns: 1fr;
		gap: 2px;
	}

	.facts dd {
		margin-bottom: 8px;
	}
}

/* Dashboard. Series colours are validated for colour-vision deficiency (dataviz palette slots 1-2). */
:root {
	--series-denver: #2a78d6;
	--series-dallas: #eb6834;
	--grid: #eceef3;
}

.small-note {
	margin: 10px 0 0;
	font-size: 13px;
}

.stat-link {
	color: inherit;
	text-decoration: none !important;
	transition: border-color 0.15s;
}

.stat-link:hover {
	border-color: var(--blue);
}

.stat-value .swatch {
	margin-right: 8px;
	vertical-align: middle;
}

.swatch {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 3px;
	flex-shrink: 0;
}

.swatch-denver { background: var(--series-denver); }
.swatch-dallas { background: var(--series-dallas); }

.dash-grid {
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
	align-items: start;
}

.chart-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
	flex-wrap: wrap;
}

.legend {
	display: flex;
	gap: 14px;
	font-size: 13px;
	color: var(--muted);
}

.legend > span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.chart {
	overflow-x: auto;
}

.chart svg {
	display: block;
	width: 100%;
	height: auto;
}

.grid-line {
	stroke: var(--grid);
	stroke-width: 1;
}

.axis-text {
	fill: var(--muted);
	font: 11px var(--font);
}

.seg-denver { fill: var(--series-denver); }
.seg-dallas { fill: var(--series-dallas); }

.col .hit {
	fill: transparent;
}

.col:hover .hit {
	fill: rgba(18, 28, 45, 0.04);
}

.chart-tip {
	position: fixed;
	z-index: 2;
	padding: 6px 10px;
	background: var(--navy);
	color: #fff;
	border-radius: 6px;
	font-size: 12px;
	white-space: nowrap;
	pointer-events: none;
	transform: translate(-50%, calc(-100% - 8px));
	box-shadow: 0 4px 12px rgba(18, 28, 45, 0.2);
}

.split-bar {
	display: block;
	width: 100%;
	height: 12px;
	border-radius: 4px;
}

.split-empty {
	background: var(--bg);
}

.split-legend {
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.split-legend li,
.node-list li {
	display: flex;
	align-items: center;
	gap: 8px;
}

.split-legend .strong {
	margin-left: auto;
}

.split-legend .muted {
	width: 40px;
	text-align: right;
}

.sub-head {
	margin: 22px 0 10px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
	font-size: 13px;
	font-weight: 700;
}

.node-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.node-list .muted {
	margin-left: auto;
}

.text-strong {
	color: var(--text);
}

.card-pad {
	padding: 20px 24px 0;
	margin-bottom: 12px;
}

p.card-pad {
	padding-bottom: 16px;
	margin: 0;
}

.dash-bottom {
	align-items: start;
}

@media (max-width: 900px) {
	/* minmax(0, …) lets columns shrink below their content so the chart scrolls inside its card. */
	.dash-grid,
	.dash-bottom {
		grid-template-columns: minmax(0, 1fr);
	}

	/* Keep axis text legible: below ~560px the chart scrolls sideways instead of shrinking. */
	.chart svg {
		min-width: 560px;
	}
}

/* Connectivity check results inside a form error */
.probe-list {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-weight: 400;
	color: var(--text);
}

.probe-mark {
	display: inline-block;
	width: 16px;
	font-weight: 700;
}

/* Collapsible sidebar (design guide section 4) */
.sidebar { overflow: hidden; transition: width 0.2s ease, padding 0.2s ease; }   /* .sidebar is already position: sticky */

.brand-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; }
.brand-row .brand { flex: 1; min-width: 0; }
.brand-collapse {
	display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
	width: 28px; height: 28px; margin-top: 6px; padding: 0;
	border: 0; border-radius: 6px; background: none; color: #8891aa; cursor: pointer;
}
.brand-collapse svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-collapse:hover, .brand-collapse:focus-visible { background: var(--navy-2); color: #fff; outline: none; }
.nav-collapsed .brand-collapse { display: none; }
@media (max-width: 900px) { .brand-collapse { display: none; } }
.brand-text, .nav-label, .user-name { white-space: nowrap; }

.sidebar-toggle {
	position: absolute; top: 50%; right: 0; z-index: 2;
	width: 14px; height: 72px; padding: 0;
	border: 0; background: none; cursor: pointer; transform: translateY(-50%);
}
.sidebar-toggle::before {
	content: ""; position: absolute; top: 0; bottom: 0; right: 4px;
	width: 4px; border-radius: 2px; background: #6b7a96;
	transition: background 0.15s, width 0.15s;
}
.sidebar-toggle:hover::before,
.sidebar-toggle:focus-visible::before { width: 5px; background: #fff; }
.sidebar-toggle:focus-visible { outline: none; }

.btn-link { display: inline-flex; align-items: center; gap: 8px; }
.btn-link svg { display: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 901px) {
	.nav-collapsed .sidebar { width: 64px; padding: 16px 8px; }
	.nav-collapsed .brand { justify-content: center; padding: 4px 0 20px; }
	.nav-collapsed .brand-text,
	.nav-collapsed .nav-label,
	.nav-collapsed .user-name { display: none; }
	.nav-collapsed .nav-section {            /* section titles become thin dividers */
		height: 0; margin: 12px 8px; padding: 0; overflow: hidden; border-top: 1px solid var(--navy-2);
	}
	.nav-collapsed .nav a { justify-content: center; padding: 0; }
	.nav-collapsed .sidebar-footer { flex-direction: column; gap: 6px; padding: 12px 0 0; }
	.nav-collapsed .user-chip { padding: 4px; }
	.nav-collapsed .btn-link { padding: 8px; }
	.nav-collapsed .btn-link svg { display: block; }
}
@media (max-width: 900px) { .sidebar-toggle { display: none; } }
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

.nav-tip {                                 /* hover label beside a folded item */
	position: fixed; z-index: 50; padding: 5px 10px; border-radius: 6px;
	background: var(--navy); color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap;
	box-shadow: 0 4px 12px rgba(18, 28, 45, 0.25); transform: translateY(-50%); pointer-events: none;
}
.nav-tip[hidden] { display: none; }

/* fwd-engine additions: loading placeholders, modals, small helpers. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 32px 16px;
	color: var(--muted);
}

.spinner {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	border: 2px solid var(--border-strong);
	border-top-color: var(--blue);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

.btn-secondary.btn-loading::before,
.btn-ghost.btn-loading::before,
.btn-danger.btn-loading::before {
	border-color: rgba(18, 28, 45, 0.18);
	border-top-color: currentColor;
}

.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(18, 28, 45, 0.55);
}

.modal-backdrop[hidden] {
	display: none;
}

.modal {
	width: 100%;
	max-width: 540px;
	max-height: calc(100vh - 32px);
	overflow: auto;
	padding: 24px;
	background: var(--surface);
	border-radius: 12px;
	box-shadow: 0 12px 32px rgba(18, 28, 45, 0.28);
}

.modal h2 {
	font-size: 16px;
	font-weight: 700;
	margin-bottom: 14px;
}

.modal p {
	margin: 0 0 12px;
}

.modal .alert {
	margin-bottom: 0;
}

.modal .log {
	margin-top: 10px;
}

.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 20px;
}

.modal-progress {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 4px 0;
}

.steps {
	margin: 8px 0 0;
	padding-left: 20px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.table code,
.facts code,
.node-list code {
	font-size: 13px;
	background: var(--bg);
	word-break: break-all;
}

.table .sub {
	display: block;
	font-size: 12px;
	color: var(--muted);
}

.cell-error {
	max-width: 360px;
	font-size: 12px;
	color: var(--red);
}

.facts dd .muted {
	margin-left: 6px;
	font-size: 13px;
}

.form-actions .btn-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.content > .alert:first-child {
	margin-top: 0;
}

.alert .probe-list {
	margin-top: 8px;
}

.status-error {
	margin-top: 16px;
}

/* Third series colour for the certificate split (palette slot 3). */
.swatch-s1 { background: var(--series-denver); }
.swatch-s2 { background: var(--series-dallas); }
.swatch-s3 { background: #1baf7a; }
.seg-s1 { fill: var(--series-denver); }
.seg-s2 { fill: var(--series-dallas); }
.seg-s3 { fill: #1baf7a; }
.split-bg { fill: var(--bg); }
