/* platform admin. No inline styles: the CSP allows only this file. */

/* Inter (SIL OFL 1.1, see inter-LICENSE.txt), variable weight, Latin. */
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("inter.woff2") format("woff2");
}

:root {
	--bg: #ffffff;
	--fg: #1b1f24;
	--muted: #5f6b76;
	--line: #d8dee4;
	--line-soft: #eaeef2;
	--card: #f6f8fa;
	--stripe: #fafbfc;
	--hover: #eef3f9;
	--accent: #0b5cad;
	--accent-hover: #094c8f;
	--accent-soft: #e7f0fa;
	--on-accent: #ffffff;
	--focus: #4a90e2;
	--ok: #1a7f37;
	--ok-soft: #e6f4ea;
	--bad: #c62828;
	--bad-soft: #fdecea;
	--warn: #8a6100;
	--warn-soft: #fff8e1;
	--warn-line: #e0b000;
	--neutral-soft: #eef1f4;
	--radius: 6px;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1216;
		--fg: #e6e9ed;
		--muted: #98a2ad;
		--line: #2d343c;
		--line-soft: #20262d;
		--card: #161a20;
		--stripe: #13171c;
		--hover: #1b2430;
		--accent: #6cb0ff;
		--accent-hover: #8fc3ff;
		--accent-soft: #15273b;
		--on-accent: #0b1520;
		--focus: #6cb0ff;
		--ok: #4cc26a;
		--ok-soft: #12261a;
		--bad: #ff7b72;
		--bad-soft: #2d1515;
		--warn: #e3b341;
		--warn-soft: #2b2410;
		--warn-line: #a88400;
		--neutral-soft: #222830;
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-feature-settings: "cv11";
	-webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
a.strong { font-weight: 600; }
code, pre { font: 12.5px/1.45 var(--mono); }
h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 1.6rem 0 0.5rem; }
h2.section { padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.3rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
h3 .muted { font-weight: 400; }
p { margin: 0.5rem 0; }

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
	border-radius: 3px;
}

/* Top bar. All items have the same height and are centred, so that the
   logo, the name, the label and the menu are on one line. */

.top {
	--bar-item: 32px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 1.5rem;
	padding: 0.5rem 16px;
	border-bottom: 1px solid var(--line);
	background: var(--card);
}
.brand-group { display: flex; align-items: center; gap: 0.6rem; height: var(--bar-item); }
.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	height: 100%;
	font-weight: 650;
	line-height: 1;
	color: var(--fg);
	text-decoration: none;
}
.brand:hover { color: var(--fg); }
.brand img { display: block; flex: none; }
.top nav {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	flex: 1;
	/* The text of the first link lines up with the logo when the bar wraps. */
	margin-left: -0.6rem;
}
.top nav a {
	display: inline-flex;
	align-items: center;
	height: var(--bar-item);
	padding: 0 0.6rem;
	border-radius: var(--radius);
	line-height: 1;
	color: var(--muted);
	text-decoration: none;
}
.top nav a:hover { color: var(--fg); background: var(--hover); }
.top nav a.active { color: var(--fg); font-weight: 600; background: var(--accent-soft); }
.logout {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	height: var(--bar-item);
	margin: 0;
	font-size: 0.9em;
	line-height: 1;
}
.logout button { align-self: center; }

.env {
	display: inline-flex;
	align-items: center;
	height: 20px;
	padding: 0 0.5rem;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #fff;
}
.env-prod { background: #c62828; }
.env-other { background: #b7791f; }

/* Narrow screens: name and "Log out" on the first row, the menu below. */
@media (max-width: 640px) {
	.logout { margin-left: auto; }
	.logout .muted { display: none; }
	.top nav { order: 3; flex-basis: 100%; }
}

/* Page */

main { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }
main.narrow { max-width: 380px; padding-top: 4rem; }

.page-head { margin: 0.25rem 0 1rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.15rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--line); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.login { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.5rem; }
.login-brand { font-size: 1.1rem; }

/* Alerts and badges */

.alert {
	margin: 0.4rem 0;
	padding: 0.5rem 0.75rem;
	border: 1px solid;
	border-left-width: 4px;
	border-radius: var(--radius);
}
.alert-error { color: var(--bad); background: var(--bad-soft); border-color: var(--bad); }
.alert-ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }
.alert-warn { color: var(--fg); background: var(--warn-soft); border-color: var(--warn-line); }

.badge {
	display: inline-block;
	padding: 0 0.5rem;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	line-height: 1.6;
	white-space: nowrap;
}
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-bad { color: var(--bad); background: var(--bad-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-info { color: var(--accent); background: var(--accent-soft); }
.badge-neutral { color: var(--muted); background: var(--neutral-soft); }

/* Tables. The wrapper scrolls on narrow screens only, so that the sticky
   header works on wide screens. */

.table-wrap { margin: 0.25rem 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td {
	text-align: left;
	padding: 0.3rem 0.6rem;
	border-bottom: 1px solid var(--line-soft);
	vertical-align: middle;
}
th {
	position: sticky;
	top: 0;
	z-index: 1;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
	white-space: nowrap;
}
td { font-variant-numeric: tabular-nums; }
tbody tr:nth-child(even) td { background: var(--stripe); }
tbody tr:hover td { background: var(--hover); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions .btn-group + .btn-group { margin-left: 0.75rem; }
.btn-group { display: inline-flex; gap: 0.3rem; }

@media (max-width: 720px) {
	.table-wrap { overflow-x: auto; }
	th { position: static; }
	td.actions { white-space: normal; }
}

/* Facts and cards */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.2rem; margin: 0 0 0.5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.secret { background: var(--warn-soft); padding: 0.1rem 0.3rem; border-radius: 3px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.75rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.85rem 1rem; }
.card > p.muted:first-of-type { margin-top: 0; font-size: 0.9em; }
.card form, .stack { display: flex; flex-direction: column; gap: 0.6rem; }
.stack { max-width: 560px; }

/* Forms */

label { display: flex; flex-direction: column; gap: 0.2rem; font-weight: 500; }
label .muted, .hint { font-weight: 400; font-size: 0.85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 0.3rem; margin: 0; }
legend { font-weight: 500; padding: 0 0.3rem; }

input[type=text], input[type=password], input[type=number], input[type=search], textarea {
	width: 100%;
	padding: 0.35rem 0.5rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}
input:focus, textarea:focus {
	outline: none;
	border-color: var(--focus);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
input:user-invalid, textarea:user-invalid { border-color: var(--bad); }
input:user-invalid:focus, textarea:user-invalid:focus { box-shadow: 0 0 0 3px var(--bad-soft); }
input[type=checkbox] { accent-color: var(--accent); }
textarea { font: 12.5px/1.45 var(--mono); resize: vertical; }
.search { margin-bottom: 0.5rem; max-width: 320px; }

/* Buttons */

button, .button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	align-self: flex-start;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--accent);
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--on-accent);
	font: inherit;
	font-weight: 600;
	line-height: 1.4;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.button.block { align-self: stretch; }

button.secondary, .button.secondary {
	background: var(--bg);
	border-color: var(--line);
	color: var(--fg);
}
button.secondary:hover, .button.secondary:hover { background: var(--hover); border-color: var(--accent); color: var(--fg); }

button.danger, .button.danger {
	background: transparent;
	border-color: var(--bad);
	color: var(--bad);
}
button.danger:hover, .button.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }

button.small, .button.small { padding: 0.1rem 0.5rem; font-size: 0.85rem; font-weight: 500; }

button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 400; }
button.link:hover { background: none; color: var(--accent-hover); text-decoration: underline; }

button:disabled { opacity: 0.6; cursor: default; }
.htmx-request button[type=submit], button.htmx-request { opacity: 0.6; cursor: progress; }

.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* Commands and logs */

pre.commands, pre.log {
	margin: 0.4rem 0;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 0.6rem 0.7rem;
	overflow-x: auto;
	white-space: pre;
}
pre.log { max-height: 320px; overflow-y: auto; }
.job { margin: 0.75rem 0; }
.pager { justify-content: flex-start; margin-top: 0.5rem; gap: 0.5rem; }
ul.plain { margin: 0 0 0.5rem; padding-left: 1.1rem; }
