/* One stylesheet, served fingerprinted, so the CSP needs no 'unsafe-inline'.
   No web fonts and no external requests: the CSP forbids them and the console
   should render on a locked-down corporate network.

   The look follows shadcn/ui's design language (zinc neutrals, hairline borders,
   0.5rem radii, quiet shadows, pill badges, segmented tabs) written as plain CSS.
   shadcn itself is React + Tailwind and needs a build step, which this binary
   deliberately does not have. */

/* Theme: dark is the default. With no saved choice, a light operating system gets
   the light palette. theme.js sets data-theme on <html> once the customer picks
   one, which wins over the system setting in either direction. The light values
   appear twice because CSS cannot share one block between a media query and an
   attribute selector; keep the two in step. color-scheme makes form controls and
   scrollbars follow the palette.

   Names: --panel is a card, --panel-2 is a muted surface (hover, tab rail, code),
   --primary is the solid button, --tab-on is the selected tab. */
:root {
	color-scheme: dark;
	--bg: #09090b;
	--panel: #0f0f12;
	--panel-2: #18181b;
	--line: #27272a;
	--text: #fafafa;
	--muted: #a1a1aa;
	--accent: #3b82f6;
	--chart-2: #a78bfa;
	--ok: #22c55e;
	--bad: #f87171;
	--warn: #eab308;
	--primary: #fafafa;
	--primary-fg: #18181b;
	--tab-on: #09090b;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
	--shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
	--radius: 12px;
	--radius-sm: 6px;
}

@media (prefers-color-scheme: light) {
	:root:not([data-theme="dark"]) {
		color-scheme: light;
		--bg: #fafafa;
		--panel: #ffffff;
		--panel-2: #f4f4f5;
		--line: #e4e4e7;
		--text: #09090b;
		--muted: #71717a;
		--accent: #2563eb;
		--chart-2: #7c3aed;
		--ok: #16a34a;
		--bad: #dc2626;
		--warn: #ca8a04;
		--primary: #18181b;
		--primary-fg: #fafafa;
		--tab-on: #ffffff;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.06);
		--shadow-lg: 0 10px 30px -12px rgba(0, 0, 0, 0.18);
	}
}

:root[data-theme="light"] {
	color-scheme: light;
	--bg: #fafafa;
	--panel: #ffffff;
	--panel-2: #f4f4f5;
	--line: #e4e4e7;
	--text: #09090b;
	--muted: #71717a;
	--accent: #2563eb;
	--chart-2: #7c3aed;
	--ok: #16a34a;
	--bad: #dc2626;
	--warn: #ca8a04;
	--primary: #18181b;
	--primary-fg: #fafafa;
	--tab-on: #ffffff;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.06);
	--shadow-lg: 0 10px 30px -12px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

/* Author display rules (inline-flex buttons, grid cards) would otherwise beat the
   browser's own [hidden] rule and show things that are meant to stay hidden. */
[hidden] { display: none !important; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration: underline; }

p { margin: 0 0 10px; }

/* Keyboard focus must stay visible: this is an account console, and a customer
   navigating by keyboard should never lose their place. */
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.skip {
	position: absolute;
	left: -9999px;
}
.skip:focus {
	left: 8px;
	top: 8px;
	z-index: 20;
	background: var(--panel);
	padding: 8px 12px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--line);
}

@media (prefers-reduced-motion: no-preference) {
	a, button, .provider, input, textarea, .side li a, .tabs a, tbody tr {
		transition: background-color 0.15s ease, border-color 0.15s ease,
			color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	}
}

/* Shell ------------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.side {
	width: 248px;
	flex: 0 0 248px;
	background: var(--panel);
	border-right: 1px solid var(--line);
	padding: 16px 12px;
	display: flex;
	flex-direction: column;
	position: sticky;
	top: 0;
	height: 100vh;
	align-self: flex-start;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 600;
	font-size: 15px;
	letter-spacing: -0.01em;
	padding: 4px 8px 18px;
}
.mark {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: var(--primary);
	color: var(--primary-fg);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0;
}

.side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side li a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	color: var(--muted);
	text-decoration: none;
	border-radius: var(--radius-sm);
	font-weight: 500;
}
.side li a:hover { color: var(--text); background: var(--panel-2); }
.side li a.on { color: var(--text); background: var(--panel-2); }
.side li a.on .ico { color: var(--accent); }
.dot { color: var(--warn); }

.ico {
	width: 16px;
	height: 16px;
	flex: 0 0 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.side-foot {
	margin-top: auto;
	padding-top: 14px;
	border-top: 1px solid var(--line);
	font-size: 13px;
	display: grid;
	gap: 2px;
}
.side-foot a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: var(--radius-sm);
	color: var(--muted);
	text-decoration: none;
	font-weight: 500;
}
.side-foot a:hover { color: var(--text); background: var(--panel-2); }
/* Icon-only button at the right end of the sidebar header. A sun means "switch
   to light", a moon means "switch to dark"; theme.js sets data-mode. */
.theme-toggle { margin-left: auto; width: 32px; height: 32px; padding: 0; flex: 0 0 32px; }
.theme-toggle .ico { width: 16px; height: 16px; }
.theme-toggle span { display: inline-flex; }
.theme-toggle[data-mode="dark"] .ico-moon,
.theme-toggle[data-mode="light"] .ico-sun,
.theme-toggle:not([data-mode]) .ico-moon { display: none; }

.body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.top {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	height: 56px;
	padding: 0 32px;
	border-bottom: 1px solid var(--line);
	background: color-mix(in srgb, var(--bg) 94%, transparent);
	backdrop-filter: blur(10px);
}
.who {
	color: var(--muted);
	font-size: 13px;
	padding: 4px 12px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--panel);
	/* A long display name is cut with an ellipsis; the tooltip has the email. */
	max-width: 260px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Confirmation modal ------------------------------------------------------- */

dialog.modal {
	width: min(400px, calc(100vw - 32px));
	padding: 24px;
	color: var(--text);
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.45);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
dialog.modal h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
dialog.modal p { margin: 0; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 22px; }
/* Form buttons get a top margin elsewhere; in a row of two it would stagger them. */
dialog.modal .modal-actions button { margin: 0; }

.main { padding: 32px; width: 100%; max-width: 1120px; }
.main h1 { font-size: 28px; line-height: 1.2; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.025em; }

.lede { color: var(--muted); margin: 0 0 24px; max-width: 70ch; }
.main h1 + section, .main h1 + nav { margin-top: 24px; }

/* Cards ------------------------------------------------------------------- */

.card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px 24px;
	margin: 16px 0;
}
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; letter-spacing: -0.01em; }
.card h3 { font-size: 14px; margin: 18px 0 8px; font-weight: 600; }
.card ul { margin: 0; padding-left: 18px; color: var(--muted); }
.card li { margin: 4px 0; }

/* Stat-style cards read as a quiet label over a large figure. */
.stat h2, .budget h2 { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-bottom: 8px; }

.card.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.budget.low { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.budget.spent { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }

.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 > .card, .grid-3 > .card { margin: 0; }
.grid-2, .grid-3 { margin: 16px 0; }

.figure { font-size: 24px; line-height: 1.25; font-weight: 600; margin: 0 0 2px; letter-spacing: -0.025em; }
.stat .figure, .budget .figure { font-size: 30px; }
.exact { color: var(--muted); font-size: 12px; margin: 0 0 12px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 13px; margin: 2px 0; }
.note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.asof { color: var(--muted); font-size: 12px; margin: 24px 0 0; }

.alert {
	margin: 14px 0 0;
	padding: 10px 14px;
	border-radius: 8px;
	background: color-mix(in srgb, var(--warn) 10%, transparent);
	border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
	font-size: 13px;
}
.spent .alert {
	background: color-mix(in srgb, var(--bad) 10%, transparent);
	border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}

.bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 12px 0 10px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.low .bar span { background: var(--warn); }
.spent .bar span { background: var(--bad); }

/* Text and tables --------------------------------------------------------- */

.mono, .code, code {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 12.5px;
}
.mono.big { font-size: 16px; font-weight: 500; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }

.code {
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 14px 16px;
	overflow-x: auto;
	white-space: pre;
	margin: 8px 0;
	line-height: 1.6;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
	text-align: left;
	color: var(--muted);
	font-weight: 500;
	font-size: 12.5px;
	padding: 8px 16px 8px 0;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}
td { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Status words, never colour alone, so the meaning survives a colour-blind
   reader or a monochrome print. Inside a table they become pill badges; the word
   is still the signal and the tint only reinforces it. */
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn-text { color: var(--warn); }
td .ok, td .bad, td .warn-text {
	display: inline-flex;
	align-items: center;
	padding: 1px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.6;
	border: 1px solid currentColor;
	background: color-mix(in srgb, currentColor 10%, transparent);
	border-color: color-mix(in srgb, currentColor 30%, transparent);
}

.pairs { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.pairs dt { color: var(--muted); }
.pairs dd { margin: 0; font-weight: 500; }

/* Controls ---------------------------------------------------------------- */

/* The default button is the solid "primary" one. Anything quieter opts in with a
   class: .secondary / .provider are outlined, .link is a ghost, .danger is a
   destructive outline. */
button, .provider {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	height: 36px;
	padding: 0 16px;
	border-radius: var(--radius-sm);
	border: 1px solid transparent;
	background: var(--primary);
	color: var(--primary-fg);
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
}
button:hover { opacity: 0.88; }

.provider, button.secondary {
	background: var(--panel);
	color: var(--text);
	border-color: var(--line);
	box-shadow: var(--shadow);
}
.provider:hover, button.secondary:hover {
	opacity: 1;
	background: var(--panel-2);
	text-decoration: none;
}

button[disabled] { opacity: 0.5; cursor: default; pointer-events: none; }
button.small, .provider.small { font-size: 13px; height: 32px; padding: 0 12px; }

button.danger {
	background: transparent;
	color: var(--bad);
	border-color: color-mix(in srgb, var(--bad) 40%, var(--line));
	box-shadow: none;
}
button.danger:hover { opacity: 1; background: color-mix(in srgb, var(--bad) 10%, transparent); }

button.link {
	background: transparent;
	color: var(--muted);
	border-color: transparent;
	box-shadow: none;
	height: 32px;
	padding: 0 10px;
	font-size: 13px;
}
button.link:hover { opacity: 1; color: var(--text); background: var(--panel-2); }

label { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
input, textarea {
	font: inherit;
	width: 100%;
	max-width: 440px;
	height: 36px;
	padding: 0 12px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--line);
	background: var(--bg);
	color: var(--text);
	box-shadow: var(--shadow);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus-visible, textarea:focus-visible {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
textarea {
	max-width: none;
	height: auto;
	padding: 10px 12px;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	font-size: 12.5px;
	line-height: 1.6;
	resize: vertical;
}
form button[type="submit"], form > button { margin-top: 14px; }
.row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row > form { width: 100%; }
.row form button[type="submit"] { margin-top: 14px; }
.field-status { font-size: 13px; color: var(--muted); margin-left: 10px; }

/* Account page ------------------------------------------------------------ */

.badge {
	display: inline-flex;
	align-items: center;
	padding: 1px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.6;
	color: var(--muted);
	background: var(--panel-2);
	border: 1px solid var(--line);
	white-space: nowrap;
}
.badge.ok, .badge.bad {
	background: color-mix(in srgb, currentColor 10%, transparent);
	border-color: color-mix(in srgb, currentColor 30%, transparent);
}

.profile-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar {
	display: inline-grid;
	place-items: center;
	flex: 0 0 56px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	font-size: 22px;
	font-weight: 600;
	color: var(--accent);
	background: color-mix(in srgb, var(--accent) 16%, var(--panel-2));
	border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
}
.profile-id { min-width: 0; }
.profile-name { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 0; line-height: 1.3; }
.profile-email { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.profile-meta { display: flex; gap: 36px; margin: 0 0 0 auto; }
.profile-meta dt { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.profile-meta dd { margin: 0; font-weight: 500; }

/* Main column and a narrower side column; one column on small screens. */
.account-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
	gap: 16px;
	align-items: start;
}
.account-grid .card { margin: 0; }
/* min-width:0 and an explicit track keep a column to its grid track; without
   them a long unbreakable child (a nowrap button) widens the whole page. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
/* Buttons may wrap here, so a long label cannot overflow a narrow column. */
.account-grid button {
	white-space: normal;
	height: auto;
	min-height: 36px;
	padding-top: 8px;
	padding-bottom: 8px;
	line-height: 1.3;
	text-align: center;
}
.account-grid button.small { min-height: 32px; padding-top: 6px; padding-bottom: 6px; }

.inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 220px; }
.inline-form button[type="submit"] { margin-top: 0; }
.inline-form .field-status { margin-left: 0; }

.field-label { font-size: 13px; font-weight: 500; margin: 18px 0 6px; }
.field-static { margin: 0; color: var(--muted); overflow-wrap: anywhere; }

.card ul.list { list-style: none; margin: 0; padding: 0; color: inherit; }
.list-row {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0;
	padding: 14px 0;
	border-bottom: 1px solid var(--line);
}
.list-row:first-child { padding-top: 0; }
.list-row:last-child { border-bottom: none; }
.list-main { flex: 1; min-width: 0; }
.list-main .muted { overflow-wrap: anywhere; }
.list-title { font-weight: 500; margin: 0; }
.list-end { flex: 0 0 auto; }
.provider-mark {
	display: inline-grid;
	place-items: center;
	flex: 0 0 36px;
	width: 36px;
	height: 36px;
	border-radius: var(--radius-sm);
	background: var(--panel-2);
	border: 1px solid var(--line);
	font-weight: 600;
	font-size: 14px;
}

/* Automatic top-up --------------------------------------------------------- */

.row-center { align-items: center; }
.row > button[type="submit"] { margin-top: 0; }

/* A real switch on the existing checkbox, so the script and form semantics are
   untouched: it is still an <input type="checkbox"> with a label. */
.switch { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; }
.switch input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	flex: 0 0 40px;
	width: 40px;
	height: 22px;
	max-width: none;
	margin: 0;
	padding: 0;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--panel-2);
	box-shadow: none;
	position: relative;
	cursor: pointer;
}
.switch input[type="checkbox"]::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--muted);
	transition: transform 0.15s ease, background-color 0.15s ease;
}
.switch input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.switch input[type="checkbox"]:checked::after { background: #ffffff; transform: translateX(18px); }
.switch input[type="checkbox"]:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.switch label { display: block; font-size: 14px; font-weight: 500; margin: 0; cursor: pointer; }
.switch label .muted { font-weight: 400; margin-left: 4px; }

.amounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 24px; margin-top: 4px; }

/* Input group: the dollar sign is a prefix cell outside the input, so the value
   the customer types is exactly the value the server parses. */
.money { display: flex; align-items: stretch; max-width: 240px; }
.money .currency {
	display: inline-grid;
	place-items: center;
	padding: 0 12px;
	height: 36px;
	color: var(--muted);
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-right: 0;
	border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.money input { flex: 1; min-width: 0; max-width: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* A field with a problem is marked on the field itself, not only in the status
   line. Colour is never the only signal: the message and aria-invalid carry it. */
input.invalid, input[aria-invalid="true"] {
	border-color: var(--bad);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent);
}
.field-error { color: var(--bad); font-size: 12.5px; margin: 6px 0 0; }

/* "Use default" reads as an inline text link, not a button. */
.account-grid .note button.link {
	display: inline;
	height: auto;
	min-height: 0;
	padding: 0 2px;
	line-height: inherit;
	font-size: inherit;
	color: var(--accent);
	text-decoration: underline;
	text-underline-offset: 3px;
	background: transparent;
}
.account-grid .note button.link:hover { background: transparent; color: var(--text); }

.recharge-facts { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.recharge-facts dd span.muted { display: block; margin-top: 2px; }

/* The sidebar and padding take about 310px, so two columns need a wide window. */
@media (max-width: 1180px) {
	.account-grid { grid-template-columns: minmax(0, 1fr); }
	.profile-meta { margin-left: 0; width: 100%; }
}

/* Segmented tabs: a muted rail with the selected range lifted onto it. */
.tabs {
	display: inline-flex;
	gap: 2px;
	padding: 4px;
	margin: 0 0 8px;
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: 10px;
}
.tabs a {
	padding: 5px 14px;
	border-radius: 7px;
	color: var(--muted);
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { background: var(--tab-on); color: var(--text); box-shadow: var(--shadow); }

.reveal {
	margin-top: 16px;
	padding: 16px;
	border-radius: 10px;
	background: var(--panel-2);
	border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
}
.reveal { margin: 0 0 20px; }
.reveal h3 { margin-top: 0; }
.reveal .mono.big { word-break: break-all; }

/* API keys page ------------------------------------------------------------ */

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.key-line { display: flex; align-items: center; gap: 6px; }
.key-line .mono.big { margin: 0; min-width: 0; }
/* An icon button with its own tooltip. data-tip is the label; the script swaps it
   to "Copied" for a moment so the click is acknowledged where the eye already is. */
.copy-btn {
	position: relative;
	flex: none;
	width: 28px;
	height: 28px;
	padding: 0;
	background: transparent;
	color: var(--muted);
	border-color: transparent;
	box-shadow: none;
}
.copy-btn:hover { opacity: 1; color: var(--text); background: var(--panel-2); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.copy-btn::after {
	content: attr(data-tip);
	/* The key cells are monospace and the tooltip would inherit it. */
	font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	position: absolute;
	bottom: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%);
	padding: 4px 8px;
	border-radius: 6px;
	background: var(--text);
	color: var(--bg);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.3;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.12s ease;
	z-index: 10;
}
.copy-btn:hover::after, .copy-btn:focus-visible::after, .copy-btn.copied::after { opacity: 1; }
.copy-btn .icon-check { display: none; }
.copy-btn.copied { color: var(--ok); }
.copy-btn.copied .icon-copy { display: none; }
.copy-btn.copied .icon-check { display: block; }
.reveal button + .alert, .reveal .alert + button { margin-top: 12px; }

.chart { min-height: 214px; margin-top: 4px; }
.chart.muted { min-height: 0; }
.chart-plot { position: relative; height: 180px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .series-a { fill: var(--accent); }
.chart .series-b { fill: var(--chart-2); }
.chart .series-err { fill: var(--bad); }
.chart .hover-band { fill: var(--text); opacity: 0.07; pointer-events: none; }

/* The legend says what each colour is; the note says what one bar covers. */
.chart-legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 16px;
	margin: 0 0 10px;
	font-size: 12px;
	color: var(--text);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-note { margin-left: auto; color: var(--muted); }

/* Swatches reuse the series classes, which colour SVG with fill, so they set
   the background here instead. */
.swatch {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 3px;
	flex: none;
}
.swatch.series-a { background: var(--accent); }
.swatch.series-b { background: var(--chart-2); }
.swatch.series-err { background: var(--bad); }

.chart-tip {
	position: absolute;
	z-index: 5;
	min-width: 190px;
	padding: 10px 12px;
	background: var(--panel);
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 8px;
	box-shadow: var(--shadow-lg);
	font-size: 12px;
	line-height: 1.5;
	pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.tip-title { font-weight: 600; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.tip-name { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.tip-value { font-variant-numeric: tabular-nums; }
.tip-row.strong .tip-name { color: var(--text); }
.tip-row.strong .tip-value { font-weight: 600; }

/* Login ------------------------------------------------------------------- */

.login-body {
	display: grid;
	place-items: center;
	min-height: 100vh;
	background:
		radial-gradient(60% 45% at 50% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
		var(--bg);
}
.login-shell { width: 100%; max-width: 400px; padding: 24px; }
.login-panel {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 14px;
	box-shadow: var(--shadow-lg);
	padding: 32px;
}
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.login-kicker { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.login-panel h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; margin: 4px 0 20px; }
.login-panel .provider { display: flex; width: 100%; height: 40px; margin-bottom: 10px; }
.login-panel form { margin: 0; }
.login-panel form .provider { margin-top: 0; }
.login-error {
	padding: 10px 14px;
	border-radius: 8px;
	background: color-mix(in srgb, var(--bad) 10%, transparent);
	border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
	font-size: 13px;
	margin: 0 0 16px;
}
.login-error a { color: inherit; font-weight: 600; }
.login-note { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }

/* Username and password form. Inputs fill the panel rather than the 440px cap the
   in-console forms use. */
.login-form label:first-of-type { margin-top: 0; }
.login-form input[type="text"], .login-form input[type="password"] {
	display: block;
	width: 100%;
	max-width: none;
	height: 40px;
}
.login-help { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.login-panel .login-form .login-submit { width: 100%; height: 40px; margin-top: 20px; }
.login-panel .login-form + .provider, .login-panel .login-form + form { margin-top: 12px; }

/* Narrow screens: the nav becomes a strip across the top rather than
   disappearing behind a menu that needs script to open. */
@media (max-width: 860px) {
	.shell { flex-direction: column; }
	.side {
		position: static;
		height: auto;
		width: auto;
		flex: none;
		border-right: none;
		border-bottom: 1px solid var(--line);
		padding: 12px 12px 8px;
	}
	.brand { padding-bottom: 10px; }
	.side ul { display: flex; overflow-x: auto; gap: 4px; }
	.side li a { white-space: nowrap; }
	/* The footer holds only the docs link, which is dropped on narrow screens;
	   the theme toggle lives in the header and stays. */
	.side-foot { display: none; }
	.top { padding: 0 16px; }
	.main { padding: 20px 16px; }
	.pairs { grid-template-columns: 1fr; gap: 2px 16px; }
	.pairs dd { margin-bottom: 8px; }
}
