/* dark theme · vanilla css · no third-party */

:root {
	--bg: #0e0e10;
	--panel: #17171b;
	--panel-2: #1d1d22;
	--row-alt: #131318;
	--border: #2a2a31;
	--text: #e7e7ea;
	--mute: #8a8a93;
	--accent: #5dd;
	--accent-strong: #62e8d3;
	--good: #6dd56d;
	--good-bg: rgba(109, 213, 109, 0.07);
	--warn: #d8b34a;
	--bad: #e07070;
	--shadow: 0 4px 16px rgba(0,0,0,0.4);
	--font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
	--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: 13px;
	line-height: 1.4;
}

body {
	height: 100vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

button, input, select {
	font: inherit;
	color: inherit;
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 4px 8px;
}
button:hover, input:focus, select:focus {
	border-color: var(--accent);
	outline: none;
}
button { cursor: pointer; }

.hidden { display: none !important; }

/* topbar */
.topbar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 16px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	z-index: 30;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.logo { color: var(--accent); font-size: 18px; }
.title { font-weight: 600; letter-spacing: 0.02em; }
.meta { color: var(--mute); font-family: var(--font-mono); font-size: 11px; }
.meta.warn { color: var(--warn); }
.meta.bad { color: var(--bad); }

.actions { display: flex; align-items: center; gap: 16px; }
.ratio-label {
	display: flex;
	align-items: center;
	gap: 4px;
	color: var(--mute);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}
.ratio-label input {
	width: 44px;
	font-family: var(--font-mono);
	text-align: center;
	font-size: 12px;
}
.ratio-label span { color: var(--mute); font-family: var(--font-mono); font-size: 12px; }

/* filter bar
 *
 * Multi-column layout: each .filter-group is atomic (break-inside:avoid)
 * and the browser flows them into columns top-to-bottom, then left-to-
 * right. Small groups (variant, tier, openness, ...) stack inside the
 * same column to fill the vertical space left by tall ones (provider,
 * family, license). column-width gives the minimum column width; the
 * browser fits as many as the bar width allows.
 */
.filters {
	flex: 0 0 auto;
	column-width: 260px;
	column-gap: 18px;
	padding: 10px 16px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	z-index: 20;
	max-height: 50vh;
	overflow-y: auto;
}
.filter-group {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
	break-inside: avoid;
	page-break-inside: avoid;          /* legacy webkit */
	-webkit-column-break-inside: avoid;
	margin-bottom: 14px;
}
.filter-group.button-row { flex-direction: row; gap: 6px; align-items: flex-end; }
.filter-group.toggle { justify-content: flex-end; }
.filter-group label {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--mute);
}
.numeric-range { display: flex; align-items: center; gap: 4px; }
.numeric-range input { width: 70px; font-family: var(--font-mono); }
.numeric-range span { color: var(--mute); }
.checkable { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checkable input { margin: 0; accent-color: var(--accent); }

.pillbox {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	/* width is bounded by the surrounding column in .filters */
}
.pill {
	font-family: var(--font-mono);
	font-size: 11px;
	padding: 2px 8px;
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 999px;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}
.pill:hover { border-color: var(--accent); }
.pill.active {
	background: var(--accent);
	color: #04201e;
	border-color: var(--accent);
	font-weight: 600;
}
.pill .count { color: var(--mute); margin-left: 4px; }
.pill.active .count { color: #04201e88; }

/* table */
.table-wrap {
	flex: 1 1 auto;
	min-height: 0;
	padding: 0 16px;
	overflow: auto;
	position: relative;
}
table {
	width: 100%;
	border-collapse: collapse;
	font-family: var(--font-mono);
	font-size: 12px;
}
thead th {
	position: sticky;
	top: 0;
	background: var(--panel);
	color: var(--mute);
	text-align: left;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-size: 10px;
	padding: 8px 10px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
	z-index: 10;
	user-select: none;
}
thead th::after {
	content: "";
	position: absolute;
	left: 0; right: 0; bottom: -1px;
	height: 1px;
	background: var(--border);
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--accent); }
thead th .sort-ind { color: var(--accent); margin-left: 4px; }
thead th .sort-ord { color: var(--mute); font-size: 9px; }
thead th.numeric, td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

tbody tr {
	border-bottom: 1px solid var(--row-alt);
	transition: background 0.06s;
}
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: #20202a; }
tbody tr.cheapest {
	background: var(--good-bg);
	box-shadow: inset 3px 0 0 var(--good);
}
tbody tr.cheapest:hover { background: #1a2a1a; }
tbody td {
	padding: 6px 10px;
	white-space: nowrap;
	max-width: 320px;
	overflow: hidden;
	text-overflow: ellipsis;
}
tbody td.notes { color: var(--mute); max-width: 240px; }
tbody td a { color: var(--accent); text-decoration: none; }
tbody td a:hover { text-decoration: underline; }
.dim { color: var(--mute); }
.tag {
	display: inline-block;
	font-size: 10px;
	padding: 1px 6px;
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 3px;
	color: var(--mute);
}
.empty {
	padding: 60px 20px;
	text-align: center;
	color: var(--mute);
	font-style: italic;
}

/* statusbar */
.statusbar {
	flex: 0 0 auto;
	padding: 6px 16px;
	background: var(--panel);
	border-top: 1px solid var(--border);
	color: var(--mute);
	font-family: var(--font-mono);
	font-size: 11px;
	display: flex;
	justify-content: space-between;
}
.statusbar b { color: var(--text); font-weight: 600; }

/* collapsible filter group */
.filter-group.collapsible {
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 4px 8px;
	max-width: 420px;
	align-self: stretch;
}
.filter-group.collapsible .filter-head {
	display: flex;
	align-items: center;
	gap: 8px;
}
.filter-group.collapsible .filter-toggle {
	background: transparent;
	border: none;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--mute);
	cursor: pointer;
	flex: 0 0 auto;
}
.filter-group.collapsible .filter-toggle:hover { color: var(--text); }
.filter-group.collapsible .filter-toggle .caret {
	color: var(--accent);
	font-size: 10px;
	transition: transform 0.12s;
	display: inline-block;
}
.filter-group.collapsible[data-collapsed="false"] .filter-toggle .caret {
	transform: rotate(90deg);
}
.filter-group.collapsible .selected-count {
	color: var(--accent);
	font-weight: 600;
}
.filter-group.collapsible .pill-search {
	flex: 1 1 auto;
	min-width: 120px;
	font-family: var(--font-mono);
	font-size: 11px;
	padding: 3px 6px;
}
.filter-group.collapsible .pillbox {
	margin-top: 6px;
	max-height: 240px;
	overflow-y: auto;
	max-width: 100%;
}
.filter-group.collapsible[data-collapsed="true"] .pillbox {
	display: none;
}
.pill.search-hidden { display: none; }
.pill.zero {
	opacity: 0.35;
}
.pill.zero:hover { opacity: 0.6; }
