/* 360 dashboard.
   Palette is the validated reference instance: categorical slots 1-3 for the three
   telemetry lanes, status palette for delivery state. Dark steps are selected for the
   dark surface, not flipped from light. Validator run (all-pairs, both modes): PASS. */

.viz-root {
	color-scheme: light;
	--surface-1: #fcfcfb;
	--plane: #f9f9f7;
	--text-primary: #0b0b0b;
	--text-secondary: #52514e;
	--text-muted: #898781;
	--grid: #e1e0d9;
	--axis: #c3c2b7;
	--border: rgba(11, 11, 11, 0.10);

	/* Lanes — categorical slots 1, 2, 3 */
	--lane-direct: #2a78d6;
	--lane-relayed: #eb6834;
	--lane-backend: #1baf7a;

	/* Status — fixed, never themed */
	--good: #0ca30c;
	--warning: #fab219;
	--serious: #ec835a;
	--critical: #d03b3b;
	--success-text: #006300;
}

@media (prefers-color-scheme: dark) {
	:root:where(:not([data-theme="light"])) .viz-root {
		color-scheme: dark;
		--surface-1: #1a1a19;
		--plane: #0d0d0d;
		--text-primary: #ffffff;
		--text-secondary: #c3c2b7;
		--text-muted: #898781;
		--grid: #2c2c2a;
		--axis: #383835;
		--border: rgba(255, 255, 255, 0.10);
		--lane-direct: #3987e5;
		--lane-relayed: #d95926;
		--lane-backend: #199e70;
		--success-text: #0ca30c;
	}
}
:root[data-theme="dark"] .viz-root {
	color-scheme: dark;
	--surface-1: #1a1a19;
	--plane: #0d0d0d;
	--text-primary: #ffffff;
	--text-secondary: #c3c2b7;
	--text-muted: #898781;
	--grid: #2c2c2a;
	--axis: #383835;
	--border: rgba(255, 255, 255, 0.10);
	--lane-direct: #3987e5;
	--lane-relayed: #d95926;
	--lane-backend: #199e70;
	--success-text: #0ca30c;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--plane);
	color: var(--text-primary);
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 36px 20px 72px; }

header { margin-bottom: 26px; }
h1 { font-size: 23px; margin: 0 0 6px; letter-spacing: -0.01em; }
.lede { color: var(--text-secondary); font-size: 14.5px; margin: 0; max-width: 74ch; }

.panel {
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 22px;
	margin-bottom: 18px;
}
.panel > h2 { font-size: 15px; margin: 0 0 3px; }
.panel > .hint { color: var(--text-secondary); font-size: 13px; margin: 0 0 18px; max-width: 78ch; }

/* ------------------------------------------------------------- stat tiles */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--plane); border-radius: 10px; padding: 14px 16px; }
.tile .n { font-size: 26px; font-weight: 700; line-height: 1.15; }
.tile .l {
	font-size: 11px; color: var(--text-muted); text-transform: uppercase;
	letter-spacing: .06em; font-weight: 650; margin-top: 2px;
}
.tile .sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

/* ---------------------------------------------------------------- legend */

.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-item b { color: var(--text-primary); font-weight: 600; }

/* ----------------------------------------------------------------- chart */

.chart-scroll { overflow-x: auto; }
svg { display: block; }
svg text { font-family: inherit; }
.tick { fill: var(--text-muted); font-size: 11px; }
.step-label { fill: var(--text-secondary); font-size: 12.5px; }
.step-label.server { fill: var(--text-muted); }
.bar-value { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.bar { rx: 4; transition: opacity .12s; }
.bar-hit { fill: transparent; cursor: pointer; }
.bar-group:hover .bar { opacity: .78; }

/* --------------------------------------------------------------- tooltip */

.tooltip {
	position: fixed;
	pointer-events: none;
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-radius: 9px;
	padding: 9px 11px;
	font-size: 12.5px;
	box-shadow: 0 8px 24px rgba(11, 11, 11, .16);
	z-index: 50;
	opacity: 0;
	transition: opacity .1s;
	max-width: 260px;
}
.tooltip.on { opacity: 1; }
.tooltip .tt-title { font-weight: 650; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; gap: 10px; justify-content: space-between; color: var(--text-secondary); }
.tooltip .tt-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tooltip .tt-note { color: var(--text-muted); font-size: 11.5px; margin-top: 5px; line-height: 1.45; }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
	text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
	color: var(--text-muted); font-weight: 650; padding: 8px 10px;
	border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--plane); }
tbody tr.selected { background: var(--plane); }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td code, .mono {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
}

.chip {
	display: inline-flex; align-items: center; gap: 5px;
	font-size: 11.5px; font-weight: 600;
	padding: 2px 8px; border-radius: 20px;
	background: var(--plane); color: var(--text-secondary);
	white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.chip.good .dot { background: var(--good); }
.chip.warning .dot { background: var(--warning); }
.chip.serious .dot { background: var(--serious); }
.chip.critical .dot { background: var(--critical); }

.lane-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.lane-tag .dot { width: 8px; height: 8px; border-radius: 50%; }

/* -------------------------------------------------------------- controls */

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.btn {
	border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
	font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
.btn:hover { background: var(--plane); }
.btn.active { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.spacer { margin-left: auto; }
.status-note { font-size: 12.5px; color: var(--text-muted); }

.finding {
	background: var(--plane);
	border-left: 3px solid var(--lane-backend);
	border-radius: 0 9px 9px 0;
	padding: 13px 16px;
	font-size: 13.5px;
	color: var(--text-secondary);
	margin-top: 18px;
}
.finding b { color: var(--text-primary); }

.empty { color: var(--text-muted); font-size: 13px; padding: 30px 0; text-align: center; }

details.table-view summary {
	cursor: pointer; font-size: 12.5px; color: var(--text-muted);
	padding: 8px 0; user-select: none;
}
details.table-view summary:hover { color: var(--text-secondary); }

@media (max-width: 620px) {
	.wrap { padding: 22px 14px 56px; }
	.panel { padding: 16px; }
}
