/* Kontrolable Monitor Hub — no framework, no build step. */

:root {
	--bg: #f6f7f9;
	--surface: #fff;
	--border: #d8dbe0;
	--text: #1d2327;
	--muted: #646970;
	--ok: #0a7c2f;
	--warn: #b26b00;
	--bad: #b32d2e;
	--stale: #7a1a1b;
	--accent: #2271b1;
	--radius: 8px;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* --- Top bar ------------------------------------------------------------ */
.topbar {
	background: #1d2327;
	color: #f0f0f1;
}
.topbar__inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 20px;
	display: flex;
	align-items: center;
	gap: 28px;
	min-height: 52px;
}
.brand {
	font-weight: 600;
	font-size: 15px;
	color: #fff;
	text-decoration: none;
}
.brand span { font-weight: 400; opacity: .7; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav__link {
	padding: 6px 12px;
	border-radius: 6px;
	color: #c3c4c7;
	text-decoration: none;
}
.nav__link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav__link.is-active { background: var(--accent); color: #fff; }
.topbar__user { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #a7aaad; }
.topbar__user a { color: #c3c4c7; }
.topbar__user form { margin: 0; }

/* --- Layout ------------------------------------------------------------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 18px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.site-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.site-header h1 { margin: 0; }
.btn {
	display: inline-block;
	padding: 6px 14px;
	border: 1px solid var(--accent);
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	font-weight: 500;
	font-size: 14px;
	text-decoration: none;
	white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }

/*
 * --- Pie charts (Analytics) --------------------------------------------
 *
 * Server-rendered inline SVG (see lib/Chart.php) — no JS chart library is
 * possible under this app's CSP (script-src 'none'), and slice fill colors
 * are SVG presentation attributes rather than the "style" attribute, which
 * style-src 'self' (no 'unsafe-inline') would otherwise block.
 */
.pie-chart { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.pie-svg { width: 160px; height: 160px; flex-shrink: 0; }
.pie-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 180px; }
.pie-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-swatch { flex-shrink: 0; border-radius: 2px; }
.legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-value { margin-left: auto; white-space: nowrap; font-size: 12px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 30px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.breadcrumb { margin: 0 0 12px; font-size: 13px; }
.subtle { color: var(--muted); margin: -8px 0 20px; }
.muted { color: var(--muted); font-weight: 400; }
.empty { color: var(--muted); font-style: italic; }
.link-muted { color: var(--muted); font-size: 13px; }

/* --- Cards -------------------------------------------------------------- */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 16px;
	margin-bottom: 16px;
}
.card--highlight { border-color: var(--accent); border-width: 2px; }

/* --- Tiles -------------------------------------------------------------- */
.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 12px;
	margin-bottom: 20px;
}
.tile {
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 4px solid var(--border);
	border-radius: var(--radius);
	padding: 14px 16px;
	display: block;
	text-decoration: none;
	color: inherit;
}
.tile__value { display: block; font-size: 26px; font-weight: 600; line-height: 1.1; }
.tile__label { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile--ok { border-left-color: var(--ok); }
.tile--warn { border-left-color: var(--warn); }
.tile--bad { border-left-color: var(--bad); }
.tile--neutral { border-left-color: var(--accent); }

/* --- Tables ------------------------------------------------------------- */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid th, .grid td {
	text-align: left;
	padding: 9px 10px;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}
.grid thead th {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--muted);
	font-weight: 600;
}
.grid tbody tr:last-child td { border-bottom: none; }
.card .grid { border: 1px solid var(--border); border-radius: 6px; }
summary { cursor: pointer; color: var(--accent); font-weight: 500; }
details[open] summary { margin-bottom: 10px; }
.row--critical td { background: #fdf3f3; }
.site-link { font-weight: 600; text-decoration: none; }
.site-url { display: block; font-size: 12px; color: var(--muted); }
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { text-align: left; padding: 5px 0; vertical-align: top; font-weight: 400; }
.kv th { width: 45%; color: var(--muted); }
.reasons { margin: 0; padding-left: 18px; }
.reasons li { margin-bottom: 4px; }

/* --- Badges + pills ----------------------------------------------------- */
.badge {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 11px;
	font-size: 12px;
	font-weight: 600;
	color: #fff;
	white-space: nowrap;
}
.badge--ok { background: var(--ok); }
.badge--warning { background: var(--warn); }
.badge--critical { background: var(--bad); }
.badge--stale { background: var(--stale); }
.badge--unknown { background: #8c8f94; }

.counts { white-space: nowrap; }
.pill {
	display: inline-block;
	min-width: 34px;
	text-align: center;
	padding: 2px 6px;
	margin-right: 3px;
	border-radius: 4px;
	background: #f0f0f1;
	color: var(--muted);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}
.pill--warn { background: #fcf3e3; color: var(--warn); font-weight: 600; }
.pill--bad { background: #fbeaea; color: var(--bad); font-weight: 600; }
.chip {
	display: inline-block;
	padding: 1px 7px;
	border: 1px solid var(--border);
	border-radius: 10px;
	font-size: 11px;
	color: var(--muted);
	margin-left: 4px;
}

/* --- Forms -------------------------------------------------------------- */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
input[type=text], input[type=url], input[type=search], input[type=password], select {
	padding: 6px 9px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: #fff;
	font: inherit;
	min-width: 180px;
}
button {
	padding: 6px 14px;
	border: 1px solid var(--accent);
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}
button:hover { filter: brightness(1.08); }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.actions { white-space: nowrap; }
.inline { display: inline; }
.btn-link {
	background: none;
	border: none;
	color: var(--accent);
	padding: 2px 6px;
	font-size: 13px;
	cursor: pointer;
	text-decoration: underline;
}
.btn-link--danger { color: var(--bad); }

/* --- Active toggle switch ------------------------------------------------ */
.toggle-switch {
	position: relative;
	width: 38px;
	height: 21px;
	padding: 0;
	border: none;
	border-radius: 11px;
	background: #8c8f94;
	cursor: pointer;
}
.toggle-switch.is-on { background: var(--ok); }
.toggle-switch__knob {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 17px;
	height: 17px;
	border-radius: 50%;
	background: #fff;
	transition: left .1s;
}
.toggle-switch.is-on .toggle-switch__knob { left: 19px; }

/*
 * --- CSS-only modal --------------------------------------------------------
 *
 * No JS is possible under this app's CSP (script-src 'none'), so "open" is a
 * same-page anchor link (#edit-site-5) and "close" is a link back to the
 * plain page URL — :target is what shows/hides the overlay, entirely in CSS.
 */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 100; }
.modal-overlay:target { display: block; }
.modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.5);
	display: block;
}
.modal-box {
	position: relative;
	z-index: 1;
	max-width: 480px;
	margin: 12vh auto 0;
	background: var(--surface);
	padding: 20px;
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.modal-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.modal-actions { display: flex; gap: 12px; align-items: center; }

code { font-family: Menlo, Consolas, monospace; font-size: 12px; }
.selectable {
	display: inline-block;
	user-select: all;
	background: #f0f0f1;
	padding: 4px 8px;
	border-radius: 4px;
	word-break: break-all;
}

/* --- Flash -------------------------------------------------------------- */
.flash {
	padding: 10px 14px;
	border-radius: 6px;
	margin-bottom: 16px;
	border-left: 4px solid;
	background: var(--surface);
}
.flash--success { border-left-color: var(--ok); }
.flash--warning { border-left-color: var(--warn); }
.flash--error { border-left-color: var(--bad); }

/* --- Login -------------------------------------------------------------- */
.login {
	max-width: 340px;
	margin: 8vh auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 28px;
}
.login h1 { font-size: 18px; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.login input { min-width: 0; }

@media (max-width: 782px) {
	.topbar__inner { flex-wrap: wrap; padding: 8px 14px; }
	.grid { font-size: 13px; }
}

/* Wake failure indicators. */
.wake-fail { color: var(--bad); }
.card--warn { border-left: 4px solid var(--warn); }

/* --- Download-release button (far right of the menu) --------------------- */
.nav__download {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 5px 12px;
	border: 1px solid rgba(255,255,255,.25);
	border-radius: 6px;
	background: transparent;
	color: #f0f0f1;
	font-size: 13px;
	text-decoration: none;
	white-space: nowrap;
}
.nav__download:hover {
	background: rgba(255,255,255,.1);
	border-color: rgba(255,255,255,.45);
	color: #fff;
}
.nav__download-ver {
	padding: 1px 6px;
	border-radius: 9px;
	background: rgba(255,255,255,.16);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}
.nav__download--empty { opacity: .55; }
.nav__download--empty .nav__download-ver { background: rgba(255,255,255,.08); }

input[type=file] {
	padding: 5px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: #fff;
	font: inherit;
	font-size: 13px;
}
