/* Phone first: one column, 16 px side gutters, big tap targets. Light and dark follow the phone's setting. */
:root {
	--bg: #f4f5f7;
	--surface: #ffffff;
	--text: #1a1d23;
	--muted: #5f6672;
	--line: #dde0e6;
	--accent: #2f6fed;
	--good: #1a8f4e;
	--warn: #b7791f;
	--bad: #c53030;
	--warn-bg: #fff4e0;
	--bad-bg: #fdebeb;
	--good-bg: #e6f6ec;
	--radius: 12px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1115;
		--surface: #181b21;
		--text: #e8eaee;
		--muted: #9aa1ad;
		--line: #2a2f38;
		--accent: #6b9bff;
		--good: #4cc883;
		--warn: #e0a84a;
		--bad: #ff7b7b;
		--warn-bg: #2b2415;
		--bad-bg: #2e1a1a;
		--good-bg: #15271d;
	}
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
	width: 100%;
	max-width: 360px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 20px;
	display: grid;
	gap: 14px;
}
.login-card h1 { font-size: 22px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input[type="email"], input[type="password"], select {
	font: inherit;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 12px;
	min-height: 44px;
	width: 100%;
}
button {
	font: inherit;
	min-height: 44px;
	border-radius: 8px;
	border: 0;
	background: var(--accent);
	color: #fff;
	padding: 0 16px;
	cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
.link-button { background: none; color: var(--accent); padding: 0 8px; }
.form-error { color: var(--bad); font-size: 14px; min-height: 1.4em; }

/* Header and tabs */
.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px 0; max-width: 760px; margin: 0 auto; }
.bar-title { font-size: 18px; margin-bottom: 8px; }
.bar-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bar-controls select { width: auto; flex: 1 1 140px; min-width: 120px; }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--muted); }
.switch input { width: 20px; height: 20px; }
.tabs { display: flex; gap: 4px; margin-top: 8px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 12px 14px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 16px; max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }
.status { max-width: 760px; margin: 0 auto; padding: 4px 16px 24px; color: var(--muted); font-size: 13px; }
.status.bad { color: var(--bad); }

/* Cards */
.glance { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 14px;
	display: grid;
	gap: 4px;
	align-content: start;
}
a.card { min-height: 96px; }
a.card:active { border-color: var(--accent); }
.card-label { font-size: 13px; color: var(--muted); }
.card-value { font-size: 32px; font-weight: 700; line-height: 1.1; }
.card-note { font-size: 12px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 32px 8px; }

/* Servers */
.server-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.server-name { font-weight: 700; flex: 1 1 auto; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.pill.up { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; margin-top: 8px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-weight: 600; }
.server.down { opacity: 0.6; }
.server.outdated { border-color: var(--warn); background: var(--warn-bg); }

/* Errors */
details.error { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.error summary { list-style: none; cursor: pointer; padding: 12px 14px; display: grid; gap: 4px; min-height: 44px; }
details.error summary::-webkit-details-marker { display: none; }
.error-line { display: flex; gap: 10px; align-items: baseline; }
.error-count { font-weight: 700; color: var(--bad); flex: none; }
.error-message { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
details.error[open] .error-message { white-space: normal; overflow-wrap: anywhere; }
.error-meta { font-size: 12px; color: var(--muted); }
.error-body { padding: 0 14px 14px; display: grid; gap: 8px; font-size: 13px; }
.error-body pre { margin: 0; padding: 10px; background: var(--bg); border-radius: 8px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (min-width: 640px) {
	.glance { grid-template-columns: repeat(3, 1fr); }
	.bar { padding-top: 20px; }
}
