/* BIZEN · Tracción. Colores del design system de BIZEN (packages/ui/src/tokens.css): azul de marca #0069ff,
   neutros de marca y letra Geist. Paleta de series validada (CVD, banda de luz, croma, contraste; light y dark):
   azul de marca, naranja de marca, aqua, amarillo de marca. Rampa ordinal = la rampa azul de marca. */
@font-face { font-family: 'Geist'; src: url('fonts/Geist-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('fonts/Geist-Medium.ttf') format('truetype'); font-weight: 500 600; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('fonts/Geist-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
.viz-root {
	color-scheme: light;
	--brand: #0069ff;
	--brand-strong: #0050e5;
	--brand-chip: #0069ff;
	--brand-focus: #000399;
	--brand-tint: #ebf3ff;
	--wordmark: linear-gradient(160deg, #0056e7 0%, #3b82f6 100%);
	--page: #f7f8f9;
	--surface-1: #ffffff;
	--text-primary: #080821;
	--text-secondary: #525c6c;
	--grid: #eceef1;
	--axis: #c5cbd4;
	--border: rgba(8, 8, 33, 0.1);
	--event-band: rgba(8, 8, 33, 0.04);
	--series-1: #0069ff;
	--series-2: #db5b00;
	--series-3: #00b894;
	--series-4: #d9aa00;
	--series-all: #525c6c;
	--ordinal-1: #99c3ff;
	--ordinal-2: #3387ff;
	--ordinal-3: #0050e5;
	--ordinal-4: #000399;
	--ordinal-text-1: #080821;
	--ordinal-text-2: #080821;
	--ordinal-text-3: #ffffff;
	--ordinal-text-4: #ffffff;
	--in-label: #ffffff;
	--delta-good: #006c10;
	--delta-bad: #b42b2c;
	--banner: #fff4d6;
	--banner-ink: #5c4300;
}
@media (prefers-color-scheme: dark) {
	.viz-root {
		color-scheme: dark;
		--brand: #3387ff;
		--brand-strong: #66a5ff;
		/* Blanco sobre #0050e5 pasa 4.5:1 en modo oscuro (el azul claro no). */
		--brand-chip: #0050e5;
		--brand-focus: #99c3ff;
		--brand-tint: rgba(51, 135, 255, 0.14);
		--wordmark: linear-gradient(160deg, #66a5ff 0%, #cce1ff 100%);
		--page: #080821;
		--surface-1: #14172e;
		--text-primary: #f7f8f9;
		--text-secondary: #9ea8b8;
		--grid: #262a45;
		--axis: #364359;
		--border: rgba(255, 255, 255, 0.1);
		--event-band: rgba(255, 255, 255, 0.05);
		--series-1: #3387ff;
		--series-2: #e76624;
		--series-3: #00a888;
		--series-4: #d28e05;
		--series-all: #c5cbd4;
		--ordinal-1: #0050e5;
		--ordinal-2: #3387ff;
		--ordinal-3: #66a5ff;
		--ordinal-4: #cce1ff;
		--ordinal-text-1: #ffffff;
		--ordinal-text-2: #080821;
		--ordinal-text-3: #080821;
		--ordinal-text-4: #080821;
		--delta-good: #53c556;
		--delta-bad: #eb6263;
		--banner: #3a2f0f;
		--banner-ink: #ffe3a1;
	}
}

* { box-sizing: border-box; }
body {
	margin: 0;
	background: var(--page);
	color: var(--text-primary);
	font: 15px/1.45 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.sample-banner {
	background: var(--banner);
	color: var(--banner-ink);
	padding: 10px 24px;
	font-size: 14px;
}
.top, main, footer { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.top { padding-top: 24px; }
.brand-bar { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.brand-icon { width: 40px; height: 40px; border-radius: 10px; display: block; }
.wordmark { font-weight: 500; font-size: 28px; line-height: 1; letter-spacing: -0.03em; text-transform: uppercase;
	background: var(--wordmark); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sep { width: 1px; height: 24px; background: var(--axis); }
.brand-tag { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.sub, .intro, .note, .tile-note, footer { color: var(--text-secondary); font-size: 13px; }
.sub { margin: 6px 0 0; }
.intro { margin: 0 0 14px; }
.block { margin-top: 32px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

/* Fichas */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.headline .tiles { grid-template-columns: 2fr repeat(3, 1fr); }
@media (max-width: 900px) { .headline .tiles { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) {
	.headline .tiles { grid-template-columns: 1fr; }
	.hero .tile-value { font-size: 44px; }
	/* En teléfono la gráfica conserva un ancho legible (texto de 11 px a ~10 px) y se desplaza de lado. */
	.grid > *, .tiles > * { min-width: 0; }
	.chart { overflow-x: auto; }
	.chart svg { min-width: 520px; }
}
.tile, .chart, .light {
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 16px 18px;
	margin: 0;
}
.tile-label { font-size: 13px; color: var(--text-secondary); }
.tile-value { font-size: 30px; font-weight: 600; margin: 4px 0 6px; }
.hero .tile-value { font-size: 56px; line-height: 1.05; }
.deltas { list-style: none; padding: 0; margin: 0 0 6px; font-size: 13px; }
.delta { color: var(--text-secondary); }
.delta.up-good { color: var(--delta-good); }
.delta.down-bad { color: var(--delta-bad); }
.delta-vs { color: var(--text-secondary); }
.spark { width: 120px; height: 32px; display: block; }
.spark path { fill: none; stroke: var(--text-secondary); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }

/* Semáforos (sin color hasta tener umbrales) */
.lights { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.light-name { font-weight: 600; }
.light-value { font-size: 24px; font-weight: 600; margin: 4px 0; }
.light-detail { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.light-status { font-size: 13px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--grid); }

/* Filtro de segmento: una fila arriba de todo lo que filtra. Funciona sin JavaScript. */
.filters {
	border: 0;
	padding: 0;
	margin: 36px 0 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	position: sticky;
	top: 0;
	z-index: 4;
	background: var(--page);
	padding: 10px 0;
}
.filters legend { font-size: 13px; color: var(--text-secondary); padding: 0; margin-bottom: 6px; float: left; width: 100%; }
.filters input { position: absolute; opacity: 0; pointer-events: none; }
.filters label {
	padding: 6px 14px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: var(--surface-1);
	cursor: pointer;
	font-size: 14px;
}
.filters input:checked + label { background: var(--brand-chip); color: #ffffff; border-color: var(--brand-chip); }
.filters input:focus-visible + label { outline: 2px solid var(--brand-focus); outline-offset: 2px; }
.view { display: none; }
body:has(#seg-all:checked) .view[data-segment='all'],
body:has(#seg-b2c:checked) .view[data-segment='b2c'],
body:has(#seg-byo:checked) .view[data-segment='byo'],
body:has(#seg-seats:checked) .view[data-segment='seats'],
body:has(#seg-grant:checked) .view[data-segment='grant'] { display: block; }
@supports not selector(:has(*)) { .view[data-segment='all'] { display: block; } }

/* Gráficas */
.chart { position: relative; }
figcaption { display: flex; flex-direction: column; margin-bottom: 8px; }
.chart-title { font-weight: 600; font-size: 15px; margin: 0; }
.chart-sub { font-size: 13px; color: var(--text-secondary); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart:focus-visible { outline: 2px solid var(--brand-focus); outline-offset: 2px; }
.grid, .axis { stroke-width: 1; shape-rendering: crispEdges; }
line.grid { stroke: var(--grid); }
line.axis { stroke: var(--axis); }
.tick { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.end-dot { stroke: var(--surface-1); stroke-width: 2; }
.end-key { stroke-width: 2; stroke-linecap: round; }
.end-label { fill: var(--text-secondary); font-size: 12px; }
.end-value { fill: var(--text-primary); font-weight: 600; }
.event-band { fill: var(--event-band); }
.event-line { stroke: var(--axis); stroke-width: 1; }
.event-label { fill: var(--text-secondary); font-size: 11px; }
.hit { fill: transparent; cursor: crosshair; }
.crosshair { stroke: var(--text-secondary); stroke-width: 1; pointer-events: none; }
.bar-hit { fill: transparent; }
.bar:hover .bar-mark, .bar:focus .bar-mark, .bar:hover rect:not(.bar-hit), .bar:focus rect:not(.bar-hit) { opacity: 0.8; }
.bar:focus { outline: none; }
.bar:focus-visible .bar-label { text-decoration: underline; }
.bar-label { fill: var(--text-primary); font-size: 13px; }
.bar-value { fill: var(--text-primary); font-size: 13px; font-weight: 600; }
.in-label { font-size: 12px; font-weight: 600; }
.suppressed { color: var(--text-secondary); font-size: 14px; margin: 8px 0; }
.legend { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--text-secondary); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; background: var(--c); }
.c-series-1 { --c: var(--series-1); }
.c-series-2 { --c: var(--series-2); }
.c-series-3 { --c: var(--series-3); }
.c-series-4 { --c: var(--series-4); }
.c-series-all { --c: var(--series-all); }
.c-ordinal-1 { --c: var(--ordinal-1); }
.c-ordinal-2 { --c: var(--ordinal-2); }
.c-ordinal-3 { --c: var(--ordinal-3); }
.c-ordinal-4 { --c: var(--ordinal-4); }
.t-ordinal-text-1 { fill: var(--ordinal-text-1); }
.t-ordinal-text-2 { fill: var(--ordinal-text-2); }
.t-ordinal-text-3 { fill: var(--ordinal-text-3); }
.t-ordinal-text-4 { fill: var(--ordinal-text-4); }
.t-in-label { fill: var(--in-label); }
.line, .end-key { stroke: var(--c); }
.end-dot, .bar-mark, .seg { fill: var(--c); }
.key-line { width: 14px; height: 2px; border-radius: 1px; }
.key-rect { width: 10px; height: 10px; border-radius: 3px; }

/* Tabla (equivalente accesible de cada gráfica) */
.table-view { margin-top: 8px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--text-secondary); }
table { border-collapse: collapse; margin-top: 8px; width: 100%; font-variant-numeric: tabular-nums; }
caption { text-align: left; color: var(--text-secondary); font-size: 12px; padding-bottom: 4px; }
th, td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--grid); font-weight: 400; }
th[scope='row'], th:first-child, td:first-child { text-align: left; }
thead th { color: var(--text-secondary); }
.missing td { text-align: left; }
.table-scroll { max-height: 280px; overflow: auto; }
.suppressed { color: var(--text-secondary); font-size: 14px; margin: 8px 0; }

/* Tooltip */
.tooltip {
	position: fixed;
	z-index: 10;
	pointer-events: none;
	background: var(--surface-1);
	color: var(--text-primary);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 13px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	min-width: 140px;
}
.tooltip[hidden] { display: none; }
.tip-head { color: var(--text-secondary); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-key { width: 12px; height: 2px; border-radius: 1px; }
.tip-value { font-weight: 600; min-width: 48px; }
.tip-name { color: var(--text-secondary); }

footer { padding-top: 32px; padding-bottom: 48px; }

@media print {
	.filters, .sample-banner { position: static; }
	.table-view[open] table { max-height: none; }
}
@media (forced-colors: active) {
	.line, .end-key { stroke: CanvasText; }
}
