:root {
	--bg: #0e1116;
	--panel: #161b22;
	--panel-2: #1c232c;
	--line: #2a323d;
	--text: #e6edf3;
	--muted: #8b98a9;
	--accent: #3fb950;
	--accent-dim: #1f6f33;
	--warn: #d29922;
	--danger: #f85149;
	--sidebar-w: 320px;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	overflow: hidden;
}

#map { position: absolute; inset: 0; }

/* ---------- sidebar ---------- */

#sidebar {
	position: absolute;
	top: 0; left: 0; bottom: 0;
	width: var(--sidebar-w);
	display: flex;
	flex-direction: column;
	background: color-mix(in srgb, var(--panel) 92%, transparent);
	backdrop-filter: blur(12px);
	border-right: 1px solid var(--line);
	z-index: 2;
}

.bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--line);
}

.bar-foot {
	border-bottom: 0;
	border-top: 1px solid var(--line);
	margin-top: auto;
}

.bar h1 { font-size: 15px; margin: 0; letter-spacing: .02em; }

.pill {
	font-size: 11px;
	padding: 3px 8px;
	border-radius: 999px;
	border: 1px solid var(--line);
	color: var(--muted);
	white-space: nowrap;
}
.pill-live { color: var(--accent); border-color: var(--accent-dim); }
.pill-idle { color: var(--muted); }
.pill-down { color: var(--danger); border-color: #5a2321; }

.devices { overflow-y: auto; flex: 1; }

.device {
	display: grid;
	grid-template-columns: 10px 1fr auto;
	gap: 10px;
	align-items: center;
	width: 100%;
	padding: 11px 14px;
	background: none;
	border: 0;
	border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}
.device:hover { background: var(--panel-2); }
.device[aria-selected="true"] { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--accent); }
.dot.offline { background: var(--danger); }
.dot.unknown { background: var(--warn); }

.device .name { font-weight: 600; }
.device .meta { color: var(--muted); font-size: 12px; }
.device .speed { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; text-align: right; }

button.ghost {
	background: none;
	border: 1px solid var(--line);
	color: var(--muted);
	border-radius: 6px;
	padding: 5px 10px;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: var(--muted); }

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

/* ---------- history bar ---------- */

.history {
	position: absolute;
	top: 12px;
	left: calc(var(--sidebar-w) + 12px);
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	background: color-mix(in srgb, var(--panel) 92%, transparent);
	backdrop-filter: blur(12px);
	border: 1px solid var(--line);
	border-radius: 8px;
	font-size: 12px;
}
.history select {
	background: var(--panel-2);
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 5px;
	padding: 3px 6px;
	font: inherit;
}
.history label { display: flex; align-items: center; gap: 6px; color: var(--muted); }

/* ---------- markers ---------- */

.marker {
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--accent);
	border: 2px solid #0b0e12;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .6);
	cursor: pointer;
	transition: transform .15s;
}
.marker.stale { background: var(--muted); }
.marker.selected { transform: scale(1.25); z-index: 1; }
/* Rotated to the device's course; hidden when we have no heading to show. */
.marker .arrow {
	width: 0; height: 0;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-bottom: 9px solid #0b0e12;
	transform: translateY(-1px);
}
.marker .arrow[hidden] { display: none; }

.mapboxgl-popup-content {
	background: var(--panel);
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 8px;
	font: 12px/1.5 inherit;
	padding: 10px 12px;
}
.mapboxgl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }
.mapboxgl-popup-content b { display: block; margin-bottom: 4px; font-size: 13px; }
.mapboxgl-popup-close-button { color: var(--muted); }

/* ---------- login ---------- */

.overlay {
	position: absolute;
	inset: 0;
	z-index: 10;
	display: grid;
	place-items: center;
	background: rgba(5, 7, 10, .82);
	backdrop-filter: blur(4px);
}
.overlay[hidden] { display: none; }

.card {
	width: min(360px, calc(100vw - 32px));
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 24px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 12px;
}
.card h2 { margin: 0; font-size: 18px; }
.card p { margin: 0; font-size: 12px; }
.card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.card input {
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 9px 10px;
	color: var(--text);
	font: inherit;
}
.card input:focus { outline: 2px solid var(--accent-dim); outline-offset: -1px; }
.card button[type="submit"] {
	margin-top: 4px;
	padding: 10px;
	background: var(--accent);
	color: #06210d;
	border: 0;
	border-radius: 6px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.error { color: var(--danger) !important; }
.error[hidden] { display: none; }

/* ---------- narrow screens: sidebar becomes a bottom sheet ---------- */

@media (max-width: 700px) {
	:root { --sidebar-w: 100vw; }
	#sidebar {
		top: auto;
		height: 44vh;
		border-right: 0;
		border-top: 1px solid var(--line);
	}
	.history { left: 12px; right: 12px; }
}
