*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	--bg: #fff;
	--fg: #111;
	--muted: #555555;
	--online: #1a5e1a;
	--offline: #555555;
	--border: #ddd;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1a1a1a;
		--fg: #e0e0e0;
		--muted: #a8a8a8;
		--online: #65bb69;
		--offline: #a8a8a8;
		--border: #333;
	}

}

body {
	font-family: sans-serif, system-ui;
	background: var(--bg);
	color: var(--fg);
	font-size: 15px;
	line-height: 1.6;
}

a { color: inherit; }

.site-header {
	border-bottom: 1px solid var(--border);
}

.site-header-inner {
	max-width: 960px;
	margin: 0 auto;
	padding: 1.5rem 2rem 0.75rem;
}

header h1 {
	font-size: 1.2rem;
	font-weight: bold;
	margin-top: 0.25rem;
}

nav {
	display: flex;
	gap: 1.25rem;
}

nav a {
	color: var(--muted);
	text-decoration: none;
	font-size: 0.85rem;
}

nav a:hover { color: var(--fg); }

.nav-spacer { flex: 1; }

.export-btn {
	padding: 0.15rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 3px;
	font-size: 0.75rem;
}

.export-btn:hover {
	border-color: var(--muted);
}

main {
	padding: 1rem 2rem 2rem;
	max-width: 960px;
	margin: 0 auto;
}


.col-headers {
	display: grid;
	grid-template-columns: 1fr 160px 100px;
	color: var(--muted);
	font-size: 0.8rem;
	font-weight: bold;
	padding: 0.25rem 0;
	border-bottom: 1px solid var(--border);
	margin-bottom: 0.5rem;
}

.col-headers span:nth-child(2),
.col-headers span:nth-child(3) {
	text-align: right;
}

section { margin-top: 1.5rem; }

section h2 {
	font-size: 0.95rem;
	font-weight: bold;
	margin-bottom: 0.25rem;
	text-transform: capitalize;
}

section h2 .count {
	font-weight: normal;
	color: var(--muted);
}

.peer {
	display: grid;
	grid-template-columns: 1fr 160px 100px;
	padding: 0.15rem 0;
	font-size: 0.9rem;
}

.peer .uri {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-family: 'Courier New', Courier, monospace;
	font-size: 0.85rem;
}

.peer .status,
.peer .uptime {
	text-align: right;
}

.peer.up .status,
.peer.up .uptime {
	color: var(--online);
}

.peer.down .status,
.peer.down .uptime {
	color: var(--offline);
}

.site-footer {
	border-top: 1px solid var(--border);
}

.site-footer-inner {
	max-width: 960px;
	margin: 0 auto;
	padding: 1.5rem 2rem;
	color: var(--muted);
	font-size: 0.8rem;
}

.site-footer a { color: var(--muted); }

/* Info boxes */
.info-box {
	margin: 1.25rem 0 0.5rem;
	padding: 1rem 1.25rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: 0.85rem;
	line-height: 1.7;
}

.info-box h3 {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
	margin-bottom: 0.5rem;
}

.info-box p {
	margin-bottom: 0.5rem;
}

.info-box ul {
	margin: 0.5rem 0 0 1.25rem;
}

.info-box li {
	margin-bottom: 0.2rem;
}

.info-box a {
	color: var(--muted);
	text-decoration: underline;
}

.info-box a:hover {
	color: var(--fg);
}

/* Stats page */
.stats-page {
	max-width: 1200px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.stats-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.5rem;
	align-items: start;
}

.stats-row:has(> :only-child) {
	grid-template-columns: 1fr;
}

.stat-card {
	margin-top: 0;
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 1rem 1.25rem;
	min-width: 0;
}

.stat-card h2 {
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	margin-bottom: 0.75rem;
}

.table-scroll {
	overflow-x: auto;
}

.stat-card table {
	width: 100%;
	border-collapse: collapse;
}

.stat-card td {
	padding: 0.25rem 0.5rem;
	font-size: 0.9rem;
	white-space: nowrap;
}

.stat-card td:not(:first-child) {
	text-align: right;
}

.stat-card .table-head td {
	color: var(--muted);
	font-size: 0.8rem;
	border-bottom: 1px solid var(--border);
	padding-bottom: 0.35rem;
}

.stat-card .country-name {
	text-transform: capitalize;
}

.stat-card .up td,
.stat-card td.up {
	color: var(--online);
}

.stat-card .down td {
	color: var(--offline);
}

.stat-card td.muted {
	color: var(--muted);
}

.chart-card {
	position: relative;
}

.chart-wrap {
	position: relative;
	width: 100%;
}

.chart-wrap-timeline {
	height: 350px;
}

.chart-wrap-country {
	height: 350px;
}

.chart-wrap-countryproto {
	height: 350px;
}

.pie-wrap {
	max-width: 280px;
	margin: 0 auto;
}

/* Section divider */
.section-divider {
	margin-top: 2.5rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--border);
	color: var(--muted);
	font-size: 0.85rem;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

/* Mobile */
@media (max-width: 700px) {
	.site-header-inner { padding: 1rem 1rem 0.5rem; }
	main { padding: 0.75rem 1rem 1.5rem; }
	.site-footer-inner { padding: 1rem; }

	.col-headers { display: none; }

	.peer {
		display: flex;
		flex-direction: column;
		gap: 0;
		padding: 0.4rem 0;
		border-bottom: 1px solid var(--border);
	}

	.peer .uri {
		white-space: normal;
		word-break: break-all;
		font-size: 0.85rem;
	}

	.peer .status,
	.peer .uptime {
		text-align: left;
		font-size: 0.8rem;
	}

	.peer .status::before { content: "status: "; color: var(--muted); }
	.peer .uptime::before { content: "7d uptime: "; color: var(--muted); }

	/* Stats page mobile */
	.stats-page {
		max-width: 100%;
		gap: 0.75rem;
	}

	.stats-row {
		grid-template-columns: 1fr;
		gap: 0.75rem;
	}

	.stat-card {
		padding: 0.75rem 0.75rem;
	}

	.stat-card h2 {
		font-size: 0.8rem;
		margin-bottom: 0.5rem;
	}

	.stat-card table {
		table-layout: fixed;
		width: 100%;
	}

	.stat-card td {
		font-size: 0.8rem;
		padding: 0.2rem 0.25rem;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.stat-card td:first-child {
		width: 40%;
	}

	/* Hide less-important columns on small screens */
	.stat-card .hide-mobile {
		display: none;
	}

	.pie-wrap {
		max-width: 200px;
	}

	.chart-wrap-timeline {
		height: 220px;
	}

	.chart-wrap-country {
		height: 300px;
	}

	.chart-wrap-countryproto {
		height: 300px;
	}

	.info-box { font-size: 0.8rem; }
}

/* Breakpoint for 2-col -> 1-col transition */
@media (min-width: 701px) and (max-width: 900px) {
	.stats-row {
		grid-template-columns: 1fr;
	}
}

/* API page */
.api-page {
	max-width: 860px;
}

.api-section {
	margin-top: 2rem;
}

.api-section h2 {
	font-size: 0.9rem;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	margin-bottom: 0.75rem;
	padding-bottom: 0.35rem;
	border-bottom: 1px solid var(--border);
}

.api-endpoint {
	display: flex;
	align-items: baseline;
	gap: 0.75rem;
	margin-bottom: 0.5rem;
}

.api-method {
	font-size: 0.75rem;
	font-weight: bold;
	color: var(--online);
	font-family: 'Courier New', Courier, monospace;
}

.api-path {
	font-family: 'Courier New', Courier, monospace;
	font-size: 1rem;
}

.api-desc {
	font-size: 0.85rem;
	color: var(--muted);
	margin-bottom: 0.75rem;
	line-height: 1.6;
}

.api-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.85rem;
}

.api-table th {
	text-align: left;
	padding: 0.4rem 0.75rem;
	font-size: 0.8rem;
	color: var(--muted);
	border-bottom: 1px solid var(--border);
}

.api-table td {
	padding: 0.5rem 0.75rem;
	vertical-align: top;
	border-bottom: 1px solid var(--border);
	line-height: 1.5;
}

.api-table td:first-child {
	white-space: nowrap;
}

.api-table td:nth-child(2) {
	white-space: nowrap;
	color: var(--muted);
}

.api-pre {
	background: transparent;
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 1rem 1.25rem;
	font-family: 'Courier New', Courier, monospace;
	font-size: 0.8rem;
	line-height: 1.7;
	overflow-x: auto;
	white-space: pre;
	color: var(--fg);
}

.api-examples {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.api-example {
	display: flex;
	align-items: baseline;
	gap: 1rem;
	font-size: 0.85rem;
}

.example-label {
	color: var(--muted);
	min-width: 260px;
	flex-shrink: 0;
}

.example-url {
	font-family: 'Courier New', Courier, monospace;
	font-size: 0.82rem;
	color: var(--fg);
	text-decoration: none;
	border-bottom: 1px solid var(--border);
}

.example-url:hover {
	border-bottom-color: var(--fg);
}

.api-notes {
	margin-left: 1.25rem;
	font-size: 0.85rem;
	line-height: 1.7;
	color: var(--muted);
}

.api-notes a {
	color: var(--muted);
	text-decoration: underline;
}

.api-notes a:hover {
	color: var(--fg);
}

code {
	font-family: 'Courier New', Courier, monospace;
	font-size: 0.85em;
}

@media (max-width: 700px) {
	.api-example {
		flex-direction: column;
		gap: 0.15rem;
	}

	.example-label {
		min-width: 0;
	}

	.api-table td:nth-child(2) {
		display: none;
	}
}

/* Map page */
main.map-page {
	max-width: 100%;
	padding: 0;
	position: relative;
}

#map {
	width: 100%;
	height: calc(100vh - 80px);
}

#legend {
	position: absolute;
	bottom: 2rem;
	right: 1rem;
	background: rgba(26, 26, 26, 0.95);
	padding: 0.75rem 1rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: 0.8rem;
	z-index: 1000;
	line-height: 1.8;
}

@media (prefers-color-scheme: light) {
	#legend {
		background: rgba(255, 255, 255, 0.92);
	}
}

.legend-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.5rem;
}

#legend strong {
	display: block;
	margin: 0;
}

.toggle-group {
	display: flex;
	gap: 2px;
	background: var(--border);
	padding: 2px;
	border-radius: 2px;
}

.toggle-btn {
	padding: 0.25rem 0.5rem;
	border: none;
	background: var(--bg);
	color: var(--muted);
	font-size: 0.75rem;
	font-weight: 600;
	cursor: pointer;
	border-radius: 2px;
	transition: all 0.15s ease;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.toggle-btn:hover {
	background: #f5f5f5;
	color: var(--fg);
}

@media (prefers-color-scheme: dark) {
	.toggle-btn:hover {
		background: #333;
		color: var(--fg);
	}
}

.toggle-btn.active {
	background: #1a5e1a;
	color: #fff;
}

#legend div {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 1px solid #bbb;
}

.maplibregl-popup-content {
	font-family: inherit;
	font-size: 0.85rem;
	line-height: 1.6;
	padding: 0.5rem 0.75rem;
	color: #111;
}

