:root {
	color-scheme: light dark;

	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-2: #f0f2f5;
	--border: #dfe3e8;
	--text: #14181f;
	--muted: #5c6673;
	--accent: #f0810f;
	--accent-text: #ffffff;
	--ok: #17803d;
	--warn: #b45309;
	--err: #c02626;
	--radius: 10px;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #14171c;
		--surface: #1c2027;
		--surface-2: #232830;
		--border: #333a45;
		--text: #e8ebef;
		--muted: #98a2b0;
		--accent: #f0810f;
		--ok: #4ade80;
		--warn: #fbbf24;
		--err: #f87171;
	}
}

* {
	box-sizing: border-box;
}

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

.hidden {
	display: none !important;
}

/* ---------- layout ---------- */

header.topbar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 14px 24px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 10;
	flex-wrap: wrap;
}

.brand {
	font-weight: 650;
	letter-spacing: -0.01em;
	display: flex;
	align-items: center;
	gap: 9px;
}

.brand .dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--accent);
}

nav.tabs {
	display: flex;
	gap: 4px;
	margin-left: auto;
	flex-wrap: wrap;
}

nav.tabs button {
	background: transparent;
	border: 1px solid transparent;
	color: var(--muted);
	padding: 6px 12px;
	border-radius: var(--radius);
	cursor: pointer;
	font: inherit;
}

nav.tabs button:hover {
	background: var(--surface-2);
	color: var(--text);
}

nav.tabs button[aria-selected="true"] {
	background: var(--surface-2);
	border-color: var(--border);
	color: var(--text);
	font-weight: 600;
}

main {
	max-width: 1120px;
	margin: 0 auto;
	padding: 24px;
}

section.panel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px;
	margin-bottom: 20px;
}

section.panel h2 {
	margin: 0 0 4px;
	font-size: 16px;
}

section.panel p.hint {
	margin: 0 0 16px;
	color: var(--muted);
	font-size: 13px;
}

/* ---------- controls ---------- */

.row {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: flex-end;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	flex: 1 1 180px;
	min-width: 0;
}

.field label {
	font-size: 12px;
	color: var(--muted);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

input,
select,
textarea {
	font: inherit;
	padding: 8px 10px;
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 8px;
	min-width: 0;
	width: 100%;
}

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

button {
	font: inherit;
	padding: 8px 14px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--surface-2);
	color: var(--text);
	cursor: pointer;
	white-space: nowrap;
}

button:hover:not(:disabled) {
	border-color: var(--accent);
}

button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
	font-weight: 600;
}

button.danger {
	color: var(--err);
}

button.link {
	background: none;
	border: none;
	color: var(--accent);
	padding: 2px 6px;
	text-decoration: underline;
}

/* ---------- table ---------- */

.table-wrap {
	overflow-x: auto;
	margin-top: 14px;
}

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

th,
td {
	text-align: left;
	padding: 9px 10px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

th {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--muted);
}

td.key {
	font-family: var(--mono);
	font-size: 13px;
	max-width: 320px;
	overflow: hidden;
	text-overflow: ellipsis;
}

td.actions {
	text-align: right;
}

tbody tr:hover {
	background: var(--surface-2);
}

.tag {
	display: inline-block;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	font-size: 11px;
	color: var(--muted);
	margin-right: 4px;
}

.tag.private {
	color: var(--warn);
	border-color: var(--warn);
}

/* ---------- stats ---------- */

.cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
	margin-bottom: 18px;
}

.card {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px;
}

.card .label {
	font-size: 12px;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.card .value {
	font-size: 26px;
	font-weight: 650;
	letter-spacing: -0.02em;
	margin-top: 4px;
}

.chart {
	display: flex;
	align-items: flex-end;
	gap: 3px;
	height: 140px;
	padding: 10px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow-x: auto;
}

.chart .bar {
	flex: 1 1 8px;
	min-width: 6px;
	background: var(--border);
	border-radius: 3px 3px 0 0;
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}

.chart .bar .hit {
	background: var(--accent);
	border-radius: 3px 3px 0 0;
	width: 100%;
}

/* ---------- dropzone ---------- */

.dropzone {
	border: 2px dashed var(--border);
	border-radius: var(--radius);
	padding: 32px;
	text-align: center;
	color: var(--muted);
	background: var(--surface-2);
	cursor: pointer;
	margin-top: 14px;
}

.dropzone.dragging {
	border-color: var(--accent);
	color: var(--text);
}

.queue {
	margin-top: 14px;
	font-size: 13px;
}

.queue div {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 6px 0;
	border-bottom: 1px solid var(--border);
	font-family: var(--mono);
}

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

.login {
	max-width: 340px;
	margin: 12vh auto;
}

/* ---------- toast ---------- */

#toasts {
	position: fixed;
	right: 16px;
	bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 50;
	max-width: min(420px, calc(100vw - 32px));
}

.toast {
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: 8px;
	padding: 10px 14px;
	font-size: 14px;
	box-shadow: 0 6px 20px rgb(0 0 0 / 0.16);
	overflow-wrap: anywhere;
}

.toast.ok {
	border-left-color: var(--ok);
}

.toast.err {
	border-left-color: var(--err);
}

.empty {
	color: var(--muted);
	padding: 24px;
	text-align: center;
	font-size: 14px;
}

code.inline {
	font-family: var(--mono);
	font-size: 12.5px;
	background: var(--surface-2);
	padding: 2px 6px;
	border-radius: 5px;
	overflow-wrap: anywhere;
}
