:root {
	--bg: #f6f6f3;
	--surface: #ffffff;
	--surface-2: #f0f0ec;
	--text: #16171a;
	--muted: #686c74;
	--border: #e2e2dc;
	--accent: #4f46e5;
	--good: #11733f;
	--good-bg: #e3f3e9;
	--bad: #b42318;
	--bad-bg: #fde9e7;
	--pending: #8a5a00;
	--pending-bg: #fff2cf;
	--neutral: #4f46e5;
	--neutral-bg: #eceafd;
	--in: #0f6e66;
	--in-bg: #ddf1ee;
	--out: #6d35d8;
	--out-bg: #efe6ff;
	--shadow: 0 1px 2px rgb(16 17 20 / 6%), 0 4px 16px rgb(16 17 20 / 4%);
	--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
	--sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0d0e10;
		--surface: #15171a;
		--surface-2: #1c1f23;
		--text: #ececea;
		--muted: #9a9fa8;
		--border: #2a2d33;
		--accent: #8b85ff;
		--good: #5fd394;
		--good-bg: rgb(95 211 148 / 12%);
		--bad: #ff8a80;
		--bad-bg: rgb(255 138 128 / 12%);
		--pending: #f2c14e;
		--pending-bg: rgb(242 193 78 / 12%);
		--neutral: #a5a0ff;
		--neutral-bg: rgb(165 160 255 / 14%);
		--in: #5fd3c4;
		--in-bg: rgb(95 211 196 / 12%);
		--out: #c4a2ff;
		--out-bg: rgb(196 162 255 / 13%);
		--shadow: 0 1px 2px rgb(0 0 0 / 40%);
	}
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 var(--sans);
}

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

code,
.mono {
	font-family: var(--mono);
	font-size: 0.92em;
}

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

.small {
	font-size: 13px;
}

.wrap {
	width: 100%;
	max-width: 1180px;
	margin: 0 auto;
	padding: 0 16px;
}

/* Top bar */

.topbar {
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}

.topbar-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 56px;
	flex-wrap: wrap;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-weight: 650;
	font-size: 17px;
	letter-spacing: -0.01em;
}

.brand:hover {
	text-decoration: none;
}

.logo {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: var(--accent);
	color: #fff;
	font-size: 16px;
}

.top-links {
	display: flex;
	align-items: center;
	gap: 14px;
	font-size: 14px;
}

.chip {
	padding: 3px 10px;
	border: 1px solid var(--border);
	border-radius: 999px;
	color: var(--muted);
	background: var(--surface-2);
	font-size: 13px;
}

/* Intro and stats */

.intro {
	padding: 32px 0 20px;
}

.intro h1 {
	margin: 0 0 6px;
	font-size: 30px;
	letter-spacing: -0.02em;
}

.intro p {
	margin: 0;
	max-width: 680px;
	color: var(--muted);
}

/* System status (written every minute by the anchor's health check) */

.system-status {
	margin: 0 0 12px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	box-shadow: var(--shadow);
}

.status-summary {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 12px 16px;
	border: 0;
	background: none;
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.status-dot {
	flex: none;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--muted);
}

.system-status[data-tone="good"] .status-dot {
	background: var(--good);
	box-shadow: 0 0 0 3px var(--good-bg);
}

.system-status[data-tone="bad"] .status-dot {
	background: var(--bad);
	box-shadow: 0 0 0 3px var(--bad-bg);
}

.system-status[data-tone="pending"] .status-dot {
	background: var(--pending);
	box-shadow: 0 0 0 3px var(--pending-bg);
}

.status-more {
	margin-left: auto;
	color: var(--muted);
	font-size: 13px;
}

.status-checks {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 6px 16px;
	margin: 0;
	padding: 0 16px 14px 36px;
	list-style: none;
	font-size: 13.5px;
}

.status-checks li {
	display: flex;
	gap: 8px;
	min-width: 0;
}

.status-checks .check-ok {
	color: var(--good);
}

.status-checks .check-fail {
	color: var(--bad);
}

.status-checks .check-detail {
	color: var(--muted);
	overflow-wrap: anywhere;
}

.stats {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px;
	margin-bottom: 20px;
}

.stat {
	padding: 16px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	box-shadow: var(--shadow);
	min-width: 0;
}

.stat h2 {
	margin: 0 0 6px;
	color: var(--muted);
	font-size: 13px;
	font-weight: 550;
}

.stat .value {
	margin: 0;
	font-size: 22px;
	font-weight: 650;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.stat .note {
	margin: 4px 0 0;
	color: var(--muted);
	font-size: 12.5px;
	min-height: 1.5em;
}

.stat[data-tone="good"] .value {
	color: var(--good);
}

.stat[data-tone="bad"] .value {
	color: var(--bad);
}

/* Transfers panel */

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

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 12px;
	padding: 14px;
	border-bottom: 1px solid var(--border);
}

.search {
	flex: 1 1 280px;
	min-width: 0;
}

.search input {
	width: 100%;
	height: 38px;
	padding: 0 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
}

.search input:focus {
	outline: 2px solid var(--accent);
	outline-offset: -1px;
}

.search-note {
	margin: 4px 0 0;
	color: var(--bad);
	font-size: 13px;
}

.search-note:empty {
	display: none;
}

.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 3px;
	border-radius: 9px;
	background: var(--surface-2);
}

.filters button,
button.secondary {
	height: 32px;
	padding: 0 12px;
	border: 0;
	border-radius: 7px;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 13.5px;
	cursor: pointer;
}

.filters button[aria-pressed="true"] {
	background: var(--surface);
	color: var(--text);
	box-shadow: var(--shadow);
}

button.secondary {
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
}

button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.meta {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-left: auto;
	min-height: 38px;
	color: var(--muted);
	font-size: 13px;
}

.live {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--good);
	box-shadow: 0 0 0 3px var(--good-bg);
}

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

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

th {
	padding: 10px 14px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 550;
	text-align: left;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
	background: var(--surface-2);
}

td {
	padding: 12px 14px;
	border-top: 1px solid var(--border);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

tbody tr {
	cursor: pointer;
}

tbody tr:hover,
tbody tr:focus-visible {
	background: var(--surface-2);
	outline: none;
}

.dir,
.pill {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 12.5px;
	font-weight: 600;
	white-space: nowrap;
}

.dir-in {
	color: var(--in);
	background: var(--in-bg);
}

.dir-out {
	color: var(--out);
	background: var(--out-bg);
}

.dir-refund,
.pill-neutral {
	color: var(--neutral);
	background: var(--neutral-bg);
}

.pill {
	font-family: var(--mono);
	font-size: 11.5px;
	letter-spacing: 0.02em;
}

.pill-good {
	color: var(--good);
	background: var(--good-bg);
}

.pill-bad {
	color: var(--bad);
	background: var(--bad-bg);
}

.pill-pending {
	color: var(--pending);
	background: var(--pending-bg);
}

.pill-muted {
	color: var(--muted);
	background: var(--surface-2);
}

.empty {
	margin: 0;
	padding: 28px 16px;
	color: var(--muted);
	text-align: center;
}

.more-wrap {
	display: flex;
	justify-content: center;
	padding: 0 0 16px;
}

.more-wrap:has(button[hidden]) {
	display: none;
}

/* About and footer */

.about {
	margin: 28px 0 0;
	color: var(--muted);
	max-width: 760px;
}

.about h2 {
	color: var(--text);
	font-size: 16px;
}

.about li {
	margin-bottom: 6px;
}

.footer {
	padding-top: 24px;
	padding-bottom: 40px;
	color: var(--muted);
	font-size: 13px;
}

/* Detail dialog */

dialog {
	width: min(760px, calc(100vw - 32px));
	max-height: calc(100vh - 48px);
	padding: 0 20px 20px;
	border: 1px solid var(--border);
	border-radius: 14px;
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 20px 60px rgb(0 0 0 / 25%);
}

dialog::backdrop {
	background: rgb(10 11 13 / 45%);
}

.detail-head {
	position: sticky;
	top: 0;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 18px 0 12px;
	background: var(--surface);
}

.detail-head > div:first-child {
	flex: 1;
	min-width: 0;
}

.detail-head h2 {
	margin: 0;
	font-size: 15px;
	overflow-wrap: anywhere;
}

.eyebrow {
	margin: 0 0 2px;
	color: var(--muted);
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.detail-meta {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.close {
	width: 32px;
	height: 32px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface-2);
	color: var(--text);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.legs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin: 12px 0;
}

.leg {
	padding: 14px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface-2);
	min-width: 0;
}

.leg h3,
dialog section > h3 {
	margin: 0 0 10px;
	font-size: 13px;
	color: var(--muted);
	font-weight: 600;
}

.leg dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 6px 12px;
	margin: 0;
	font-size: 14px;
}

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

.leg dd {
	margin: 0;
	min-width: 0;
	overflow-wrap: anywhere;
}

.events {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 13.5px;
}

.events li {
	padding: 8px 0;
	border-top: 1px solid var(--border);
	overflow-wrap: anywhere;
}

.event-kind {
	display: inline-block;
	min-width: 62px;
	font-weight: 600;
	text-transform: capitalize;
}

.signed {
	color: var(--good);
}

.steps {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 13.5px;
}

.step {
	display: grid;
	grid-template-columns: 18px 1fr auto;
	gap: 8px;
	padding: 6px 0;
	border-top: 1px solid var(--border);
}

.step-mark {
	color: var(--good);
}

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

.step-todo .step-mark {
	color: var(--muted);
}

.step-time {
	font-size: 12.5px;
	white-space: nowrap;
}

.related {
	margin: 4px 0 0;
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--neutral-bg);
	font-size: 14px;
}

.linkish {
	padding: 0;
	border: 0;
	background: none;
	color: var(--accent);
	font: inherit;
	cursor: pointer;
}

.linkish:hover {
	text-decoration: underline;
}

.raw {
	margin-top: 14px;
}

.raw summary {
	cursor: pointer;
	color: var(--muted);
	font-size: 13px;
}

.raw pre {
	max-height: 320px;
	overflow: auto;
	padding: 12px;
	border-radius: 8px;
	background: var(--surface-2);
	font: 12.5px/1.45 var(--mono);
}

/* Small screens: rows become cards */

@media (max-width: 900px) {
	.stats {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 720px) {
	.intro h1 {
		font-size: 25px;
	}

	.meta {
		margin-left: 0;
	}

	thead {
		display: none;
	}

	table,
	tbody,
	tr,
	td {
		display: block;
	}

	tbody tr {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 8px 12px;
		padding: 14px;
		border-top: 1px solid var(--border);
	}

	td {
		padding: 0;
		border: 0;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	td::before {
		content: attr(data-label);
		display: block;
		color: var(--muted);
		font-size: 11.5px;
		text-transform: uppercase;
		letter-spacing: 0.04em;
	}

	.legs {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 460px) {
	.stats {
		grid-template-columns: 1fr;
	}

	.top-links .chip {
		display: none;
	}
}
