/* Palette roles are defined once here and referenced by name everywhere else,
   so the light/dark swap happens in a single place. */
:root {
	color-scheme: light;
	--plane: #f9f9f7;
	--surface: #fcfcfb;
	--text-primary: #0b0b0b;
	--text-secondary: #52514e;
	--text-muted: #898781;
	--grid: #e1e0d9;
	--baseline: #c3c2b7;
	--border: rgba(11, 11, 11, 0.1);
	--series-1: #2a78d6;
	--series-2: #eb6834;
	--good: #0ca30c;
	--good-text: #006300;
	--critical: #d03b3b;
	--accent-wash: rgba(42, 120, 214, 0.08);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--plane: #0d0d0d;
		--surface: #1a1a19;
		--text-primary: #ffffff;
		--text-secondary: #c3c2b7;
		--text-muted: #898781;
		--grid: #2c2c2a;
		--baseline: #383835;
		--border: rgba(255, 255, 255, 0.1);
		--series-1: #3987e5;
		--series-2: #d95926;
		--good: #0ca30c;
		--good-text: #0ca30c;
		--critical: #d03b3b;
		--accent-wash: rgba(57, 135, 229, 0.14);
	}
}

* { box-sizing: border-box; }

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

a { color: var(--series-1); }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px 56px; }

/* ── Header ─────────────────────────────────────────────────────────── */
header.top {
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	margin-bottom: 24px;
}
.top-inner {
	max-width: 1160px;
	margin: 0 auto;
	padding: 14px 20px;
	display: flex;
	align-items: center;
	gap: 20px;
	flex-wrap: wrap;
}
.brand { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand span { color: var(--text-muted); font-weight: 400; }
nav.tabs { display: flex; gap: 4px; margin-left: auto; }
nav.tabs a {
	padding: 6px 12px;
	border-radius: 7px;
	text-decoration: none;
	color: var(--text-secondary);
	font-weight: 500;
}
nav.tabs a:hover { background: var(--accent-wash); }
nav.tabs a.active { background: var(--accent-wash); color: var(--series-1); }
.logout { color: var(--text-muted); text-decoration: none; font-size: 13px; }
.logout:hover { color: var(--critical); }

h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 2px; }
.subtitle { color: var(--text-muted); margin: 0 0 22px; font-size: 13px; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 14px; }

/* ── Cards & tiles ──────────────────────────────────────────────────── */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 18px;
	margin-bottom: 18px;
}
.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
	gap: 12px;
	margin-bottom: 18px;
}
.tile {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 16px 18px;
}
.tile .label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.055em;
	color: var(--text-muted);
	font-weight: 600;
}
.tile .value { font-size: 27px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; }
.tile .note { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.tile .note.good { color: var(--good-text); }
.tile .note.bad { color: var(--critical); }

/* ── Charts ─────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .value { fill: var(--text-secondary); font-size: 10px; font-weight: 600; }
.chart .bar { fill: var(--series-1); }
.chart .bar-hit { fill: transparent; }
.chart .bar-group:hover .bar { fill: var(--text-primary); }
.chart .bar-group:hover .bar-hit { fill: var(--accent-wash); }
.chart-empty {
	color: var(--text-muted);
	text-align: center;
	padding: 40px 0;
	margin: 0;
	font-size: 13px;
}

/* Provider breakdown bars */
.meter { display: grid; gap: 12px; }
.meter-row { display: grid; grid-template-columns: 92px 1fr 108px; align-items: center; gap: 12px; }
.meter-name { font-weight: 550; text-transform: capitalize; }
.meter-track { background: var(--grid); border-radius: 4px; height: 8px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.meter-row:nth-child(2) .meter-fill { background: var(--series-2); }
.meter-stat { text-align: right; color: var(--text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ── Filters ────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.055em;
	color: var(--text-muted);
	font-weight: 600;
}
select, input[type="text"], input[type="password"] {
	background: var(--surface);
	color: var(--text-primary);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 7px 10px;
	font: inherit;
	min-width: 150px;
}
select:focus, input:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.btn {
	background: var(--series-1);
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 8px 15px;
	font: inherit;
	font-weight: 550;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost {
	background: transparent;
	color: var(--text-secondary);
	border: 1px solid var(--border);
}
.btn.ghost:hover { background: var(--accent-wash); color: var(--series-1); }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }

/* ── Table ──────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
	text-align: left;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.055em;
	color: var(--text-muted);
	font-weight: 600;
	padding: 0 12px 9px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: var(--accent-wash); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-secondary); }
td.msg { max-width: 420px; color: var(--text-secondary); }
.empty { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* Status uses an icon + word, never colour alone. */
.pill { display: inline-flex; align-items: center; gap: 5px; font-weight: 550; white-space: nowrap; }
.pill.sent { color: var(--good-text); }
.pill.failed { color: var(--critical); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.err { color: var(--critical); font-size: 12px; display: block; margin-top: 3px; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.pager .count { color: var(--text-muted); font-size: 13px; margin-right: auto; }
.pager .btn.ghost[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* ── Login ──────────────────────────────────────────────────────────── */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 30px;
	width: 100%;
	max-width: 348px;
}
.login-card h1 { margin-bottom: 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card input, .login-card .btn { width: 100%; }
.alert {
	background: color-mix(in srgb, var(--critical) 12%, transparent);
	color: var(--critical);
	border-radius: 8px;
	padding: 9px 12px;
	font-size: 13px;
	margin-bottom: 16px;
}
.banner {
	background: color-mix(in srgb, var(--critical) 12%, transparent);
	color: var(--critical);
	border-radius: 10px;
	padding: 11px 14px;
	font-size: 13px;
	margin-bottom: 18px;
}

td.src { color: var(--text-secondary); max-width: 220px; word-break: break-all; }
