:root {
	color-scheme: light dark;
	--bg: #f4f6f8;
	--surface: #ffffff;
	--surface-alt: #eef1f4;
	--border: #dde2e7;
	--text: #1c2126;
	--text-dim: #5b6670;
	--accent: #2563eb;
	--accent-contrast: #ffffff;
	--ok: #1f9d55;
	--warn: #e6a700;
	--warn-strong: #e8740c;
	--fail: #d9342b;
	--row-ok: #eafaf0;
	--row-warn: #fff8e1;
	--row-warn-strong: #fff1e0;
	--row-fail: #fdeceb;
	--shadow: 0 1px 2px rgba(20, 24, 28, 0.06), 0 8px 24px rgba(20, 24, 28, 0.06);
	--radius: 10px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #14171a;
		--surface: #1c2024;
		--surface-alt: #22262b;
		--border: #2d3238;
		--text: #e7eaed;
		--text-dim: #9aa4ad;
		--accent: #5b9bff;
		--accent-contrast: #0b1220;
		--ok: #3ecb77;
		--warn: #e6b400;
		--warn-strong: #ef8a3d;
		--fail: #f06158;
		--row-ok: #10251a;
		--row-warn: #2a2410;
		--row-warn-strong: #2c1e10;
		--row-fail: #2a1414;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
	}
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	padding: 1.5rem 1rem 4rem;
}

#main {
	max-width: 1200px;
	margin: 0 auto;
}

a { color: var(--accent); }

h1 {
	font-size: 1.5rem;
	margin: 0 0 0.1rem;
	letter-spacing: -0.01em;
}

h1 .dot {
	display: inline-block;
	width: 0.5em;
	height: 0.5em;
	border-radius: 50%;
	background: var(--ok);
	margin-right: 0.5em;
	vertical-align: middle;
}

.subtitle {
	color: var(--text-dim);
	font-size: 0.95rem;
	margin: 0 0 1.25rem;
}

header.page-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.25rem;
}

nav.top-nav {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.btn {
	appearance: none;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	padding: 0.45rem 0.9rem;
	border-radius: 999px;
	font-size: 0.85rem;
	cursor: pointer;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--surface-alt); border-color: var(--accent); }

.btn.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-contrast);
}

.btn.primary:hover { filter: brightness(1.08); }

.status-bar {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 0.75rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 1rem 1.25rem;
	margin-bottom: 1.5rem;
}

.status-item .label {
	display: block;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-dim);
	margin-bottom: 0.15rem;
}

.status-item .value {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.status-item .value.error { color: var(--fail); }

.icon-btn {
	appearance: none;
	border: 1px solid var(--border);
	background: var(--surface-alt);
	color: var(--text-dim);
	width: 1.3rem;
	height: 1.3rem;
	flex: 0 0 auto;
	border-radius: 50%;
	font-size: 0.85rem;
	line-height: 1;
	padding: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }

#hinweis_text {
	display: none;
	background: var(--row-warn);
	border: 1px solid var(--warn);
	border-radius: var(--radius);
	padding: 0.75rem 1rem;
	margin-bottom: 1.25rem;
}

.panel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	margin-bottom: 1.5rem;
	overflow: hidden;
}

.panel-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.9rem 1.1rem;
	border-bottom: 1px solid var(--border);
}

.panel-header h2 {
	font-size: 1rem;
	margin: 0;
}

.panel-header .count {
	color: var(--text-dim);
	font-size: 0.85rem;
}

input[type="search"] {
	border: 1px solid var(--border);
	background: var(--surface-alt);
	color: var(--text);
	border-radius: 999px;
	padding: 0.4rem 0.9rem;
	font-size: 0.85rem;
	min-width: 160px;
}

input[type="search"]:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

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

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.88rem;
}

thead th {
	position: sticky;
	top: 0;
	background: var(--surface-alt);
	text-align: left;
	padding: 0.55rem 0.8rem;
	border-bottom: 1px solid var(--border);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--text-dim);
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
}

thead th:hover { color: var(--text); }

thead th .arrow { opacity: 0.4; margin-left: 0.25em; font-size: 0.8em; }
thead th.sorted .arrow { opacity: 1; }

tbody td {
	padding: 0.5rem 0.8rem;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-alt); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

tr.ok td.pct-cell { background: var(--row-ok); }
tr.warn td.pct-cell { background: var(--row-warn); }
tr.warn-strong td.pct-cell { background: var(--row-warn-strong); }
tr.fail td.pct-cell { background: var(--row-fail); }

.pct-pill {
	display: inline-block;
	padding: 0.1rem 0.55rem;
	border-radius: 999px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

tr.ok .pct-pill { background: var(--ok); color: #fff; }
tr.warn .pct-pill { background: var(--warn); color: #3a2c00; }
tr.warn-strong .pct-pill { background: var(--warn-strong); color: #fff; }
tr.fail .pct-pill { background: var(--fail); color: #fff; }

.empty-row td {
	text-align: center;
	color: var(--text-dim);
	padding: 2rem;
}

.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem 1.2rem;
	font-size: 0.82rem;
	color: var(--text-dim);
	padding: 0.9rem 1.1rem;
}

.legend b { color: var(--text); }

footer.page-footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 1rem;
	color: var(--text-dim);
	font-size: 0.85rem;
	margin-top: 2rem;
}

.link-btn {
	font: inherit;
	color: var(--accent);
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

dialog {
	border: none;
	border-radius: var(--radius);
	padding: 0;
	max-width: 640px;
	width: 92vw;
	color: var(--text);
	background: var(--surface);
	box-shadow: var(--shadow);
}

dialog::backdrop {
	background: rgba(10, 12, 14, 0.5);
	backdrop-filter: blur(2px);
}

dialog .dialog-body {
	padding: 1.25rem 1.5rem 1.5rem;
	max-height: 80vh;
	overflow-y: auto;
}

dialog .dialog-body pre {
	white-space: pre-wrap;
	word-break: break-word;
	font-size: 0.85rem;
}

dialog h3 {
	margin-top: 0;
}

dialog .dialog-body h4 { margin: 1.25rem 0 0.35rem; color: var(--text-dim); font-size: 0.85rem; }
dialog .dialog-body h4:first-of-type { margin-top: 0; }
dialog .dialog-body ul { margin: 0 0 0.5rem; padding-left: 1.2rem; }
dialog .dialog-body li { margin-bottom: 0.2rem; }

dialog .dialog-close {
	position: sticky;
	top: 0;
	float: right;
	margin: 0.6rem 0.6rem 0 0;
}

.spinner-row td {
	text-align: center;
	color: var(--text-dim);
	padding: 1.5rem;
}


@media (max-width: 640px) {
	body { padding: 1rem 0.75rem 3rem; }
	.panel-header { flex-direction: column; align-items: stretch; }
	input[type="search"] { width: 100%; }
}

.map-wrap { padding: 1rem; display: flex; justify-content: center; }
.map-box { position: relative; width: 100%; max-width: 480px; }
#map { display: block; width: 100%; height: auto; }
#map.zoomed { cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }
/* --z = Zoomfaktor, --zd = gedaempft: Punkte wachsen nur leicht mit, Staedte bleiben gleich gross (Cluster loesen sich beim Zoomen auf) */
#map polygon { vector-effect: non-scaling-stroke; }
#map circle.dot { r: calc(var(--r) * 1px / var(--zd, 1)); vector-effect: non-scaling-stroke; }
#map circle.dot:hover { stroke: var(--text); stroke-width: 2; }
#map .cityg { transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)) scale(calc(1 / var(--z, 1))); }
.map-ctrl { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; }
.map-ctrl .btn { width: 2.25rem; height: 2.25rem; padding: 0; justify-content: center; }
.map-ctrl .btn svg { display: block; }
.swatch { display: inline-block; width: .8em; height: .8em; border-radius: 50%; margin-right: .3em; }
.chart-controls { display: flex; gap: .75rem; padding: .75rem 1rem; flex-wrap: wrap; align-items: center; }
.chart-controls input { font: inherit; padding: .3rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
#chart { width: 100%; height: auto; display: block; padding: .5rem 1rem 1rem; }
#chart text { fill: var(--text-dim); font-size: 10px; }
#chart .bar { cursor: pointer; }
td a { color: var(--accent); }
[hidden] { display: none !important; }
select#month { font: inherit; padding: .25rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
#hinweise-list { margin: 0; padding: .75rem 1.5rem 1rem 2.25rem; white-space: pre-wrap; }

.legal { padding: 1.5rem 1.75rem 2rem; line-height: 1.65; }
.legal h3 { margin: 0 0 .75rem; font-size: 1.25rem; }
.legal h3:not(:first-child) { margin-top: 2.25rem; padding-top: 1.75rem; border-top: 1px solid var(--border); }
.legal h4 { margin: 1.5rem 0 .4rem; font-size: 1rem; }
.legal p, .legal ul, .legal address { margin: 0 0 1rem; }
.legal address { font-style: normal; }
.legal ul { padding-left: 1.4rem; }
@media (max-width: 600px) { .legal { padding: 1.25rem 1rem 1.5rem; } }

.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert a { color: inherit; font-weight: 600; }
.alert-fail { background: var(--row-fail); border-color: var(--fail); }
.alert-ok { background: var(--row-ok); border-color: var(--ok); }
tr.now-fail td { background: var(--row-fail); }
tr.now-fail td:first-child { box-shadow: inset 4px 0 0 var(--fail); font-weight: 600; color: var(--fail); }
@media (max-width: 600px) { #chart text { font-size: 14px; } }
.status-item .value.running { color: var(--fail); }
#map .city { font-size: 8px; fill: var(--text-dim); opacity: .85; stroke: var(--surface-alt); stroke-width: 2.5px; paint-order: stroke; }
#map .country-label { font-size: 9px; fill: var(--text-dim); opacity: .8; text-anchor: middle; stroke: var(--surface); stroke-width: 3px; paint-order: stroke; }
#map .country-label.de { font-size: 11px; font-weight: 700; fill: var(--accent); opacity: 1; }
