:root {
	color-scheme: light;
	--surface-0: #f6f6f4;
	--surface-1: #fcfcfb;
	--border: #e3e2de;
	--grid: #ecebe7;
	--text-primary: #0b0b0b;
	--text-secondary: #52514e;
	--text-muted: #77766f;
	--accent: #2a78d6;
	--accent-wash: rgba(42, 120, 214, 0.12);
	--series-1: #2a78d6;
	--series-1-fill: rgba(42, 120, 214, 0.14);
	--good: #006300;
	--radius: 10px;
	font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		color-scheme: dark;
		--surface-0: #121211;
		--surface-1: #1a1a19;
		--border: #2e2e2c;
		--grid: #262624;
		--text-primary: #f0efec;
		--text-secondary: #c3c2b7;
		--text-muted: #94938b;
		--accent: #5598e7;
		--accent-wash: rgba(57, 135, 229, 0.18);
		--series-1: #3987e5;
		--series-1-fill: rgba(57, 135, 229, 0.2);
		--good: #4cc24c;
	}
}

:root[data-theme='dark'] {
	color-scheme: dark;
	--surface-0: #121211;
	--surface-1: #1a1a19;
	--border: #2e2e2c;
	--grid: #262624;
	--text-primary: #f0efec;
	--text-secondary: #c3c2b7;
	--text-muted: #94938b;
	--accent: #5598e7;
	--accent-wash: rgba(57, 135, 229, 0.18);
	--series-1: #3987e5;
	--series-1-fill: rgba(57, 135, 229, 0.2);
	--good: #4cc24c;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--surface-0);
	color: var(--text-primary);
	font-size: 15px;
	line-height: 1.5;
}

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

.shell {
	max-width: 1120px;
	margin: 0 auto;
	padding: 32px 16px 48px;
}

.crumbs {
	font-size: 14px;
	margin-bottom: 12px;
}

.page-head h1 {
	font-size: 28px;
	line-height: 1.2;
	margin: 0 0 6px;
	letter-spacing: -0.01em;
	overflow-wrap: anywhere;
}

.lede {
	margin: 0;
	color: var(--text-secondary);
}

.package-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
}

.links {
	display: flex;
	gap: 16px;
	margin: 0;
	font-size: 14px;
}

.switcher {
	min-width: min(320px, 100%);
}

.switcher .field {
	width: 100%;
}

/* Filters: one row above what they scope. */
.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: flex-end;
	margin: 24px 0 16px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 13px;
	color: var(--text-secondary);
}

.field.grow {
	flex: 1 1 220px;
}

input,
select,
button {
	font: inherit;
	color: inherit;
}

input,
select {
	height: 36px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface-1);
	color: var(--text-primary);
	font-size: 14px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.mobile-only {
	display: none;
}

.segmented {
	display: inline-flex;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface-1);
	padding: 2px;
}

.segmented button {
	border: 0;
	background: none;
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 14px;
	color: var(--text-secondary);
	cursor: pointer;
}

.segmented button:hover {
	background: var(--accent-wash);
}

.segmented button[aria-pressed='true'] {
	background: var(--text-primary);
	color: var(--surface-1);
	font-weight: 600;
}

/* Listing table */
.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface-1);
}

table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

th,
td {
	padding: 10px 14px;
	text-align: left;
	border-bottom: 1px solid var(--grid);
	white-space: nowrap;
}

tbody tr:last-child > * {
	border-bottom: 0;
}

tbody tr:hover {
	background: var(--accent-wash);
}

thead th {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-muted);
	padding-top: 8px;
	padding-bottom: 8px;
}

thead th button {
	all: unset;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

thead th button:focus-visible {
	outline: 2px solid var(--accent);
}

th.num,
td.num {
	text-align: right;
}

th.num button {
	flex-direction: row-reverse;
}

.sort-icon::after {
	content: '↕';
	opacity: 0.35;
	font-size: 11px;
}

th[aria-sort='ascending'] .sort-icon::after {
	content: '↑';
	opacity: 1;
}

th[aria-sort='descending'] .sort-icon::after {
	content: '↓';
	opacity: 1;
}

th[aria-sort='ascending'],
th[aria-sort='descending'] {
	color: var(--text-primary);
}

.period-label {
	text-transform: none;
	font-weight: 500;
	color: var(--text-muted);
}

tbody th {
	font-weight: 600;
}

.spark-col {
	width: 112px;
}

.spark {
	display: block;
	color: var(--series-1);
}

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

.empty {
	padding: 24px;
	color: var(--text-secondary);
	text-align: center;
	margin: 0;
}

.page-foot {
	margin-top: 24px;
	font-size: 13px;
	color: var(--text-muted);
}

/* Package page */
.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 12px;
	margin-top: 24px;
}

.tile,
.card {
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.tile {
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tile-label {
	font-size: 13px;
	color: var(--text-secondary);
}

.tile-value {
	font-size: 26px;
	font-weight: 650;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
}

.tile-note {
	font-size: 13px;
	color: var(--good);
}

.charts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr));
	gap: 16px;
}

.card {
	margin: 0;
	padding: 16px 16px 8px;
	min-width: 0;
}

.card figcaption {
	font-weight: 600;
	margin-bottom: 8px;
}

.chart {
	position: relative;
	height: 240px;
}

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

.chart .axis text {
	fill: var(--text-muted);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

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

.chart .baseline {
	stroke: var(--border);
	stroke-width: 1;
}

.chart .bar {
	fill: var(--series-1);
}

.chart .bar.dim {
	opacity: 0.45;
}

.chart .line {
	fill: none;
	stroke: var(--series-1);
	stroke-width: 2;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.chart .area {
	fill: var(--series-1-fill);
}

.chart .crosshair {
	stroke: var(--text-muted);
	stroke-width: 1;
}

.chart .dot {
	fill: var(--series-1);
	stroke: var(--surface-1);
	stroke-width: 2;
}

.tooltip {
	position: absolute;
	top: 0;
	pointer-events: none;
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 6px 10px;
	font-size: 13px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	white-space: nowrap;
	z-index: 1;
}

.tooltip strong {
	display: block;
	font-size: 15px;
	font-variant-numeric: tabular-nums;
}

.tooltip span {
	color: var(--text-secondary);
}

.data-table {
	margin-top: 16px;
	padding: 12px 16px;
}

.data-table summary {
	cursor: pointer;
	font-weight: 600;
}

.data-table .table-wrap {
	margin-top: 12px;
	max-height: 360px;
	overflow-y: auto;
}

@media (max-width: 720px) {
	.shell {
		padding-top: 20px;
	}

	.page-head h1 {
		font-size: 22px;
	}

	.mobile-only {
		display: flex;
	}

	.spark-col,
	.listing th:nth-child(7),
	.listing td:nth-child(7) {
		display: none;
	}

	th,
	td {
		padding: 8px 10px;
	}

	.chart {
		height: 200px;
	}
}

/* Three charts: daily downloads across the top, the two running totals below. */
.charts > .card:first-child:nth-last-child(3) {
	grid-column: 1 / -1;
}
