:root {
	--bg: #0f0f0f;
	--bg-elevated: #141414;
	--surface: #1a1a1a;
	--border: rgba(255, 255, 255, 0.08);
	--border-strong: rgba(255, 255, 255, 0.12);
	--text: #f4f4f5;
	--muted: #a1a1aa;
	--accent: #6366f1;
	--accent-hover: #818cf8;
	--success: #22c55e;
	--warning: #eab308;
	--danger: #ef4444;
	--radius: 12px;
	--radius-sm: 8px;
	--shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
	--shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.55);
	--font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-font-smoothing: antialiased;
}

body {
	margin: 0;
	min-height: 100vh;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text);
	font-size: 14px;
	line-height: 1.5;
}

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

a:hover {
	color: var(--accent-hover);
}

.hidden {
	display: none !important;
}

/* Toast */
.toast-root {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 200;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}

.toast {
	padding: 12px 16px;
	border-radius: var(--radius-sm);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	box-shadow: var(--shadow);
	font-size: 13px;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.25s ease, transform 0.25s ease;
	max-width: 320px;
}

.toast-show {
	opacity: 1;
	transform: translateY(0);
}

.toast-success {
	border-color: rgba(34, 197, 94, 0.35);
}

.toast-error {
	border-color: rgba(239, 68, 68, 0.45);
}

/* Login */
.login-wrap {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: radial-gradient(
			ellipse 80% 50% at 50% -20%,
			rgba(99, 102, 241, 0.15),
			transparent 50%
		),
		var(--bg);
}

.glass {
	background: rgba(26, 26, 26, 0.85);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	border: 1px solid var(--border);
}

.login-card {
	width: 100%;
	max-width: 400px;
	border-radius: var(--radius);
	padding: 32px;
	box-shadow: var(--shadow);
}

.login-brand {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	margin-bottom: 24px;
}

.login-logo {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: var(--radius-sm);
	background: linear-gradient(135deg, var(--accent), #8b5cf6);
	color: #fff;
	font-weight: 700;
	font-size: 18px;
	flex-shrink: 0;
}

.login-card h1 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

.login-card .sub {
	margin: 4px 0 0;
	color: var(--muted);
	font-size: 13px;
}

.field {
	margin-bottom: 16px;
}

.field label,
.field-label {
	display: block;
	margin-bottom: 6px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.field input,
.input {
	width: 100%;
	padding: 10px 14px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border-strong);
	background: rgba(0, 0, 0, 0.35);
	color: var(--text);
	font-size: 14px;
	font-family: inherit;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.input:focus {
	outline: none;
	border-color: rgba(99, 102, 241, 0.6);
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-search {
	max-width: 280px;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 18px;
	border-radius: var(--radius-sm);
	border: none;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	font-family: inherit;
	transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.btn-block {
	width: 100%;
}

.btn-primary {
	background: linear-gradient(135deg, #6366f1, #7c3aed);
	color: #fff;
	box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-danger {
	background: linear-gradient(135deg, #dc2626, #b91c1c);
	color: #fff;
}

.btn-danger:hover:not(:disabled) {
	transform: translateY(-1px);
}

.btn-ghost {
	background: transparent;
	color: var(--muted);
	border: 1px solid var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
	color: var(--text);
	border-color: rgba(255, 255, 255, 0.2);
	background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
	padding: 6px 10px;
	font-size: 12px;
	border-radius: 6px;
}

.btn-accent {
	background: rgba(99, 102, 241, 0.2);
	color: #a5b4fc;
	border: 1px solid rgba(99, 102, 241, 0.35);
}

.btn-accent:hover:not(:disabled) {
	background: rgba(99, 102, 241, 0.3);
	color: #fff;
}

.btn-danger-outline {
	background: rgba(239, 68, 68, 0.1);
	color: #fca5a5;
	border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-danger-outline:hover:not(:disabled) {
	background: rgba(239, 68, 68, 0.2);
	color: #fff;
}

.btn-success {
	background: rgba(34, 197, 94, 0.15);
	color: #86efac;
	border: 1px solid rgba(34, 197, 94, 0.35);
}

.btn-success:hover:not(:disabled) {
	background: rgba(34, 197, 94, 0.25);
	color: #fff;
}

.msg-error {
	margin-top: 14px;
	padding: 12px 14px;
	border-radius: var(--radius-sm);
	background: rgba(239, 68, 68, 0.1);
	border: 1px solid rgba(239, 68, 68, 0.25);
	color: #fca5a5;
	font-size: 13px;
}

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

.sidebar {
	width: 248px;
	flex-shrink: 0;
	background: var(--bg-elevated);
	border-right: 1px solid var(--border);
}

.sidebar-inner {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	padding: 20px 0;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 20px 20px;
	font-weight: 600;
	font-size: 16px;
	letter-spacing: -0.02em;
	border-bottom: 1px solid var(--border);
	margin-bottom: 8px;
}

.brand-mark {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	background: linear-gradient(135deg, var(--accent), #8b5cf6);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
}

.nav {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 12px;
	flex: 1;
}

.nav-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	border-radius: var(--radius-sm);
	color: var(--muted);
	font-size: 14px;
	font-weight: 500;
	transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
	color: var(--text);
	background: rgba(255, 255, 255, 0.05);
	text-decoration: none;
}

.nav-item.active {
	color: #fff;
	background: rgba(99, 102, 241, 0.15);
	box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.sidebar-foot {
	padding: 16px 20px 0;
	margin-top: auto;
	border-top: 1px solid var(--border);
}

.main {
	flex: 1;
	padding: 28px 32px 40px;
	overflow-x: auto;
	background: linear-gradient(180deg, var(--bg) 0%, #0c0c0c 100%);
}

.page {
	animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.page-header {
	margin-bottom: 24px;
}

.page-header-row {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
}

.page-title {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 600;
	letter-spacing: -0.03em;
}

.page-desc {
	margin: 6px 0 0;
	color: var(--muted);
	font-size: 14px;
}

.toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
}

/* Stats */
.stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px;
}

.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px 22px;
	box-shadow: var(--shadow);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-hover);
	border-color: var(--border-strong);
}

.stat-card-accent {
	background: linear-gradient(
		145deg,
		rgba(99, 102, 241, 0.12) 0%,
		var(--surface) 60%
	);
	border-color: rgba(99, 102, 241, 0.25);
}

.stat-label {
	margin: 0;
	font-size: 12px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted);
}

.stat-value {
	margin: 8px 0 0;
	font-size: 1.75rem;
	font-weight: 700;
	letter-spacing: -0.03em;
}

/* Cards & tables */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

/* Round 16 — generic "title block + actions on the right" header used by
 * GPU pool cards, ticket headers, etc. Wraps cleanly on narrow widths
 * (actions drop below the title block) so we don't get clipped buttons. */
.row-split {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.row-split__main {
	flex: 1 1 auto;
	min-width: 0; /* lets long URLs wrap instead of pushing siblings off-screen */
}

.row-split__actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
	flex-wrap: wrap;
}

/* Round 16 — Add-GPU form. Inline-styled before; now uses CSS so the
 * Label input doesn't get clipped off the card edge on narrow viewports. */
.add-gpu-form {
	display: grid;
	grid-template-columns: minmax(220px, 2fr) minmax(140px, 1fr) auto;
	gap: 12px 16px;
	align-items: flex-end;
}

.add-gpu-form > .field {
	min-width: 0;
}

.add-gpu-form .field-label {
	display: block;
	margin-bottom: 4px;
	font-size: 13px;
	color: var(--muted);
}

.add-gpu-form .input {
	width: 100%;
	box-sizing: border-box;
}

.add-gpu-form .btn {
	white-space: nowrap;
}

@media (max-width: 720px) {
	.add-gpu-form {
		grid-template-columns: 1fr;
	}
	.add-gpu-form .btn {
		justify-self: start;
	}
}

/* Round 16 — Per-GPU card body header (title + buttons). Adds a clean
 * border between the header strip and the sessions table below. */
.gpu-card-head {
	padding-bottom: 12px;
	margin-bottom: 12px;
	border-bottom: 1px solid var(--border);
}

.gpu-card-title {
	margin: 0;
	font-size: 0.95rem;
	font-weight: 600;
	word-break: break-all; /* long URLs shouldn't blow up the layout */
}

.gpu-card-meta {
	margin: 4px 0 0;
	color: var(--muted);
	font-size: 13px;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
}

.gpu-card-meta .meta-dot {
	color: var(--border-strong, var(--border));
}

/* Empty state inside a GPU card. Less padding than table-empty, left-aligned
 * with a subtle border so it reads as "this section is empty" not "the page
 * has nothing." */
.gpu-card-empty {
	padding: 14px 0 4px;
	color: var(--muted);
	font-size: 13px;
	text-align: left;
}

/* Round 16 — Ticket thread chat-bubble styling.
 * User messages appear left-aligned with a subtle surface color; admin
 * replies appear right-aligned with the primary accent. Includes a small
 * "User" / "Admin" label above each message. */
.ticket-thread {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px 0 8px;
}

.ticket-msg {
	display: flex;
	flex-direction: column;
	max-width: 78%;
}

.ticket-msg--user {
	align-self: flex-start;
}

.ticket-msg--admin {
	align-self: flex-end;
}

.ticket-msg__author {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted);
	margin: 0 4px 4px;
	display: flex;
	gap: 8px;
}

.ticket-msg--admin .ticket-msg__author {
	justify-content: flex-end;
}

.ticket-msg__author-name {
	font-weight: 600;
	color: var(--text);
}

.ticket-msg__bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.ticket-msg--user .ticket-msg__bubble {
	background: var(--surface-2, color-mix(in srgb, var(--surface) 70%, var(--border)));
	border: 1px solid var(--border);
	border-bottom-left-radius: 4px;
}

.ticket-msg--admin .ticket-msg__bubble {
	background: color-mix(in srgb, var(--primary, #6366f1) 18%, var(--surface));
	border: 1px solid color-mix(in srgb, var(--primary, #6366f1) 35%, var(--border));
	color: var(--text);
	border-bottom-right-radius: 4px;
}

/* Ticket thread header — title on left, status + Close on right. */
.ticket-thread-head {
	padding-bottom: 14px;
	margin-bottom: 4px;
	border-bottom: 1px solid var(--border);
}

.ticket-thread-head .gpu-card-title {
	font-size: 1.15rem;
}

/* Round 16 — Reply form. Sits below the thread with its own block of
 * vertical breathing room and a clear "Send reply" button on the right. */
.ticket-reply-form {
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px solid var(--border);
}

.ticket-reply-form__label {
	display: block;
	font-size: 13px;
	font-weight: 500;
	color: var(--muted);
	margin-bottom: 6px;
}

.ticket-reply-form__textarea {
	width: 100%;
	box-sizing: border-box;
	min-height: 96px;
	padding: 10px 12px;
	background: var(--surface-0, var(--surface));
	border: 1px solid var(--border);
	border-radius: 10px;
	color: var(--text);
	font: inherit;
	resize: vertical;
}

.ticket-reply-form__textarea:focus {
	outline: none;
	border-color: var(--primary, #6366f1);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #6366f1) 20%, transparent);
}

.ticket-reply-form__actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 10px;
}

.table-card {
	overflow: hidden;
}

.table-scroll {
	overflow: auto;
	max-width: 100%;
}

.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.data-table th,
.data-table td {
	text-align: left;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
}

.data-table th {
	color: var(--muted);
	font-weight: 600;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	background: rgba(0, 0, 0, 0.25);
	white-space: nowrap;
}

.data-table tbody tr {
	transition: background 0.12s ease;
}

.data-table tbody tr:hover td {
	background: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr:last-child td {
	border-bottom: none;
}

.td-email {
	font-weight: 500;
	max-width: 220px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.td-muted {
	color: var(--muted);
	font-size: 12px;
}

.td-mono {
	font-family: ui-monospace, monospace;
	font-size: 12px;
}

.td-actions {
	white-space: nowrap;
}

.td-actions .btn {
	margin-right: 6px;
	margin-bottom: 4px;
}

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

.empty-inline {
	text-align: center;
	color: var(--muted);
	padding: 24px !important;
}

.loading {
	color: var(--muted);
	padding: 24px !important;
	text-align: center;
}

/* Badges */
.badge {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.badge-success {
	background: rgba(34, 197, 94, 0.15);
	color: #86efac;
	border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-pending {
	background: rgba(234, 179, 8, 0.12);
	color: #fde047;
	border: 1px solid rgba(234, 179, 8, 0.35);
}

.badge-failed {
	background: rgba(239, 68, 68, 0.12);
	color: #fca5a5;
	border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-neutral {
	background: rgba(161, 161, 170, 0.12);
	color: #d4d4d8;
	border: 1px solid rgba(161, 161, 170, 0.25);
}

/* ── Node status badges ─────────────────────────────────────── */
.node-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.badge-green  { background:rgba(52,211,153,0.12); color:#34d399; border:1px solid rgba(52,211,153,0.3); }
.badge-yellow { background:rgba(234,179,8,0.12);  color:#fbbf24; border:1px solid rgba(234,179,8,0.3); }
.badge-orange { background:rgba(251,146,60,0.12); color:#fb923c; border:1px solid rgba(251,146,60,0.3); }
.badge-red    { background:rgba(239,68,68,0.12);  color:#f87171; border:1px solid rgba(239,68,68,0.3); }
.badge-gray   { background:rgba(161,161,170,0.12);color:#a1a1aa; border:1px solid rgba(161,161,170,0.25); }

.node-credits-low  { color: #f87171; }
.node-credits-warn { color: #fbbf24; }
.node-endpoint { font-size: 0.78rem; color: #818cf8; text-decoration: none; }
.node-endpoint:hover { text-decoration: underline; }
.td-center { text-align: center; }

.alert-banner { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.875rem; }
.alert-banner-warn {
	background: rgba(234,179,8,0.1);
	border: 1px solid rgba(234,179,8,0.3);
	color: #fbbf24;
}

/* Dedicated credits modal — above shell, toasts, and other overlays */
.admin-credit-modal-root {
	position: fixed;
	inset: 0;
	z-index: 10050;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.admin-credit-modal-root.hidden {
	display: none !important;
}

/* Modal */
.modal-root {
	position: fixed;
	inset: 0;
	z-index: 150;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.modal-root.hidden {
	display: none;
}

.modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
	backdrop-filter: blur(4px);
}

.modal-dialog {
	position: relative;
	width: 100%;
	max-width: 400px;
	border-radius: var(--radius);
	padding: 24px;
	box-shadow: var(--shadow-hover);
	animation: modalIn 0.2s ease;
}

@keyframes modalIn {
	from {
		opacity: 0;
		transform: scale(0.96);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.modal-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}

.modal-title {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 600;
}

.modal-close {
	background: none;
	border: none;
	color: var(--muted);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	border-radius: 4px;
}

.modal-close:hover {
	color: var(--text);
	background: rgba(255, 255, 255, 0.06);
}

.modal-desc {
	margin: 0 0 16px;
	font-size: 13px;
	color: var(--muted);
	line-height: 1.5;
}

.modal-body {
	margin-bottom: 20px;
}

.modal-body .input.hidden {
	display: none;
}

.modal-body .field-label.hidden {
	display: none;
}

.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

@media (max-width: 900px) {
	.shell {
		flex-direction: column;
	}

	.sidebar {
		width: 100%;
		border-right: none;
		border-bottom: 1px solid var(--border);
	}

	.sidebar-inner {
		min-height: auto;
	}

	.nav {
		flex-direction: row;
		flex-wrap: wrap;
		padding: 8px 12px 12px;
	}

	.sidebar-foot {
		border-top: none;
		padding-top: 0;
		width: 100%;
	}

	.main {
		padding: 20px 16px 32px;
	}

	.input-search {
		max-width: 100%;
		width: 100%;
	}

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

/* Dashboard charts */
.stat-grid-6 {
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.stat-value-sm {
	font-size: 1.35rem;
}

.chart-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 20px;
	margin-top: 24px;
}

.chart-card {
	padding: 20px 22px 16px;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.chart-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-hover);
	border-color: var(--border-strong);
}

.chart-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: -0.02em;
}

.chart-sub {
	margin: 4px 0 16px;
	font-size: 12px;
	color: var(--muted);
}

.chart-canvas-wrap {
	position: relative;
	height: 240px;
}

/* User detail */
.modal-dialog-wide {
	max-width: 520px;
}

.modal-hint {
	margin: 10px 0 0;
	font-size: 12px;
	color: var(--muted);
	line-height: 1.45;
}

.modal-field-mode {
	margin-bottom: 12px;
}

.modal-body-flush {
	margin-bottom: 0;
	padding-top: 4px;
}

.detail-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 16px 24px;
	margin: 0;
}

.detail-grid dt {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted);
	margin: 0 0 4px;
}

.detail-grid dd {
	margin: 0;
	font-size: 14px;
	color: var(--text);
	word-break: break-word;
}

/* Integrations */
.integration-intro {
	margin: 0 0 20px;
	font-size: 13px;
	color: var(--muted);
	line-height: 1.55;
	max-width: 640px;
}

.integration-form {
	max-width: 640px;
}

.integration-field {
	padding: 18px 20px;
	margin-bottom: 14px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.integration-field:hover {
	border-color: var(--border-strong);
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.integration-label {
	display: block;
	font-size: 14px;
	font-weight: 600;
	margin-bottom: 6px;
}

.integration-hint {
	margin: 0 0 12px;
	font-size: 12px;
	color: var(--muted);
}

.integration-actions {
	margin-top: 8px;
}

.integration-loading,
.integration-error {
	color: var(--muted);
	font-size: 14px;
}

.integration-subtitle {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 600;
}

.inline-code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	font-size: 12px;
	background: rgba(255, 255, 255, 0.06);
	padding: 2px 6px;
	border-radius: 4px;
}

.np-stack {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-bottom: 20px;
}

.np-card {
	padding: 18px 20px;
}

.np-card-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.np-card-title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
}

.np-secret-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-bottom: 14px;
}

@media (max-width: 720px) {
	.np-secret-grid {
		grid-template-columns: 1fr;
	}
}

.np-secret-grid dt {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted);
	margin: 0 0 4px;
}

.np-secret-grid dd {
	margin: 0 0 8px;
	font-size: 13px;
}

.np-secret-actions {
	margin-top: 4px;
}

.np-card-actions {
	margin-top: 8px;
}

.np-edit-panel {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px solid var(--border);
}

.np-edit-panel .input {
	margin-bottom: 10px;
}

.np-seed {
	margin-top: 16px;
	padding: 16px 18px;
}

.np-seed .input {
	margin-bottom: 10px;
}

.pool-add {
	margin-top: 16px;
}

.pool-add-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

.pool-add-row .input {
	flex: 1;
	min-width: 140px;
}

.pool-credits-inp {
	max-width: 160px;
}

.np-revealed {
	color: #a7f3d0;
	word-break: break-all;
}

.np-revealed-code {
	display: block;
	max-width: min(100%, 480px);
	overflow: auto;
	font-size: 11px;
	word-break: break-all;
}

.integration-legacy-foot {
	margin-top: 8px;
}

/* Operator dashboard — live + glow */
.page-header-dashboard {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
}

.live-indicator {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #a5b4fc;
	background: rgba(99, 102, 241, 0.12);
	border: 1px solid rgba(99, 102, 241, 0.35);
	box-shadow: 0 0 24px rgba(99, 102, 241, 0.15);
}

.live-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 10px #22c55e;
	animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
	0%,
	100% {
		opacity: 1;
		transform: scale(1);
	}
	50% {
		opacity: 0.65;
		transform: scale(0.92);
	}
}

.live-indicator.live-tick {
	animation: liveFlash 0.45s ease;
}

@keyframes liveFlash {
	0% {
		box-shadow: 0 0 24px rgba(99, 102, 241, 0.15);
	}
	50% {
		box-shadow: 0 0 32px rgba(52, 211, 153, 0.35);
		border-color: rgba(52, 211, 153, 0.45);
	}
	100% {
		box-shadow: 0 0 24px rgba(99, 102, 241, 0.15);
	}
}

.stat-row-live {
	margin-bottom: 8px;
}

.stat-grid-3 {
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.stat-card-glow {
	border-color: rgba(99, 102, 241, 0.22);
	box-shadow:
		0 4px 24px rgba(0, 0, 0, 0.45),
		0 0 0 1px rgba(99, 102, 241, 0.08),
		inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stat-card-glow:hover {
	border-color: rgba(129, 140, 248, 0.45);
	box-shadow:
		0 8px 36px rgba(0, 0, 0, 0.55),
		0 0 40px rgba(99, 102, 241, 0.12);
}

.stat-card-mint {
	border-color: rgba(52, 211, 153, 0.2);
}

.stat-card-rose {
	border-color: rgba(251, 113, 133, 0.22);
}

.card-glow {
	border-color: rgba(99, 102, 241, 0.18);
	box-shadow:
		0 4px 28px rgba(0, 0, 0, 0.4),
		0 0 0 1px rgba(139, 92, 246, 0.06);
}

.chart-card-funnel {
	min-height: 280px;
}

.chart-canvas-funnel {
	height: 220px;
}

.badge-stream-on {
	background: rgba(52, 211, 153, 0.12);
	color: #6ee7b7;
	border: 1px solid rgba(52, 211, 153, 0.35);
}

.badge-stream-off {
	background: rgba(113, 113, 122, 0.15);
	color: #d4d4d8;
	border: 1px solid rgba(113, 113, 122, 0.3);
}

.td-actions-wrap {
	max-width: 420px;
	white-space: normal;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

.btn-icon {
	min-width: 2.25rem;
	padding-left: 10px;
	padding-right: 10px;
}

.integration-field-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.integration-updated {
	margin: 6px 0 0;
	font-size: 11px;
	color: var(--muted);
}

.integration-quick {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.dashboard-header-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.alert-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	color: #fca5a5;
	background: rgba(239, 68, 68, 0.12);
	border: 1px solid rgba(239, 68, 68, 0.35);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.alert-pill-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #ef4444;
	box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.nav-badge {
	min-width: 1.25rem;
	height: 1.25rem;
	padding: 0 6px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.25rem;
	text-align: center;
	background: rgba(239, 68, 68, 0.9);
	color: #fff;
}

.stat-hint {
	margin: 6px 0 0;
	font-size: 11px;
	color: var(--muted);
	line-height: 1.35;
}

.stat-card-metric .stat-value {
	font-size: 1.5rem;
}

.dashboard-panels {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
	gap: 20px;
	margin-top: 24px;
}

.dashboard-panel {
	padding: 20px 22px 18px;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dashboard-panel:hover {
	transform: translateY(-1px);
	box-shadow: var(--shadow-hover);
	border-color: var(--border-strong);
}

.dashboard-panel-head {
	margin-bottom: 12px;
}

.table-scroll-tight {
	max-height: 280px;
}

.data-table-compact th,
.data-table-compact td {
	padding: 10px 12px;
	font-size: 12px;
}

.td-muted {
	color: var(--muted);
	font-size: 12px;
}

.alert-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 320px;
	overflow: auto;
}

.alert-list-item {
	padding: 12px 14px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: rgba(0, 0, 0, 0.2);
	transition: border-color 0.15s ease, background 0.15s ease;
}

.alert-list-item:hover {
	border-color: var(--border-strong);
}

.alert-list-item-resolved {
	opacity: 0.65;
}

.alert-list-meta {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	margin-bottom: 6px;
}

.alert-list-msg {
	margin: 0;
	font-size: 13px;
	line-height: 1.45;
	color: var(--text);
}

.alert-list-item .btn-sm {
	margin-top: 10px;
}

.detail-sub {
	display: block;
	margin-top: 4px;
	font-size: 12px;
	color: var(--muted);
	line-height: 1.35;
}

.td-credit-hint {
	font-size: 11px;
	color: var(--muted);
	margin-top: 4px;
	line-height: 1.3;
}

.td-credits {
	vertical-align: top;
}

.integration-section {
	padding: 20px 22px;
	margin-bottom: 20px;
}

.integration-section-title {
	margin: 0 0 12px;
	font-size: 1.05rem;
	font-weight: 600;
}

.billing-inline-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 8px;
}

.billing-cps-input {
	max-width: 160px;
}

.cred-history-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
	max-height: 360px;
	overflow: auto;
}

.cred-history-item {
	padding: 12px 14px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: rgba(0, 0, 0, 0.2);
}

.cred-history-meta {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	font-size: 12px;
	color: var(--muted);
}

.cred-history-name {
	font-weight: 600;
	color: var(--text);
}

.cred-history-mask {
	margin: 8px 0 0;
	font-family: ui-monospace, monospace;
	font-size: 12px;
}

.cred-history-actions {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}

.email-broadcast-card {
	padding: 22px 24px;
	max-width: 640px;
}

.email-textarea {
	min-height: 160px;
	resize: vertical;
	font-family: inherit;
}

.email-result {
	margin-top: 16px;
	padding: 12px;
	border-radius: var(--radius-sm);
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid var(--border);
	font-size: 12px;
	overflow: auto;
	max-height: 280px;
	white-space: pre-wrap;
}

.field-row {
	margin-top: 4px;
}

.checkbox-label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 14px;
}

.user-identities-block {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
}

.user-identities-title {
	margin: 0 0 12px;
	font-size: 0.95rem;
	font-weight: 600;
}

.user-identities-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 12px;
}

.identity-card {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 8px;
	background: rgba(0, 0, 0, 0.2);
}

.identity-thumb-wrap {
	display: block;
	width: 100%;
	border: none;
	padding: 0;
	cursor: zoom-in;
	border-radius: 6px;
	overflow: hidden;
	aspect-ratio: 1;
	background: rgba(255, 255, 255, 0.04);
	font: inherit;
	color: inherit;
	text-align: left;
}

.identity-thumb-wrap:focus-visible {
	outline: 2px solid rgba(99, 102, 241, 0.7);
	outline-offset: 2px;
}

.identity-card-links {
	margin: 0 0 4px;
	font-size: 11px;
}

.identity-open-tab {
	color: var(--accent, #818cf8);
	text-decoration: none;
}

.identity-open-tab:hover {
	text-decoration: underline;
}

.identity-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.identity-label {
	margin: 8px 0 6px;
	font-size: 11px;
	color: var(--muted);
	word-break: break-word;
}

.pricing-form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 16px;
	align-items: end;
}

.pricing-form-actions {
	display: flex;
	align-items: flex-end;
}

.pricing-table-card {
	margin-top: 20px;
}

.pricing-edit-minutes {
	margin: 0 0 12px;
}

.logs-page-hint {
	margin: 0 0 12px;
}

.th-log-expand {
	width: 44px;
}

.td-log-expand {
	width: 44px;
	vertical-align: middle;
}

.log-expand-btn {
	min-width: 32px;
	padding: 4px 8px;
	font-size: 12px;
}

.td-log-action {
	max-width: 220px;
	word-break: break-word;
}

.td-log-target {
	max-width: 280px;
	word-break: break-word;
}

.td-log-meta-cell {
	padding: 0 12px 12px 48px !important;
	background: rgba(0, 0, 0, 0.18);
	border-bottom: 1px solid var(--border);
}

.log-meta-pre {
	margin: 0;
	padding: 12px;
	font-size: 11px;
	line-height: 1.45;
	color: var(--muted);
	white-space: pre-wrap;
	word-break: break-word;
	max-height: 240px;
	overflow: auto;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: rgba(0, 0, 0, 0.25);
}

.identity-lightbox {
	z-index: 12000;
}

.identity-lightbox-inner {
	position: relative;
	z-index: 1;
	max-width: min(96vw, 1100px);
	max-height: min(92vh, 900px);
	margin: auto;
	padding: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.identity-lightbox-img {
	max-width: 100%;
	max-height: min(88vh, 860px);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 8px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}

.identity-lightbox-close {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.identity-lightbox-close:hover {
	background: rgba(0, 0, 0, 0.75);
}

.integration-secrets-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	margin-bottom: 8px;
}

.integration-secrets-head .integration-section-title {
	margin: 0;
}

.cred-history-modal-body {
	max-height: min(70vh, 560px);
	overflow: auto;
	padding-right: 4px;
}

.broadcast-card {
	padding: 20px 24px;
}

.broadcast-form .field {
	margin-bottom: 16px;
}

.updates-form .field {
	margin-bottom: 14px;
}

.tutorial-admin-form {
	margin-top: 12px;
}

.tutorial-form-row {
	margin-bottom: 14px;
}

.tutorial-form-row .input {
	width: 100%;
	max-width: 520px;
}

.tutorials-admin-list {
	margin-top: 20px;
}

.tutorial-url-cell {
	max-width: 280px;
	overflow-wrap: anywhere;
	word-break: break-word;
}

/* ===========================================================================
 * Round 18 — Mobile-responsive overrides.
 *
 * The existing @media (max-width: 900px) handles tablets; this block is for
 * phone-sized viewports (~ iPhone 12 mini and up). Goals:
 *   - Sidebar nav scrolls horizontally so all menu items reach on one line.
 *   - Stat cards stack two-up (still visible at a glance) instead of cramming.
 *   - Page header + toolbar stack vertically so search inputs get full width.
 *   - Action buttons wrap to multiple lines per row in tables.
 *   - Modals fill the viewport.
 *   - Comfortable touch targets (≥40px tap area on important controls).
 * =========================================================================== */
@media (max-width: 640px) {
	/* Sidebar — horizontal scroll, sticky to the top, smaller. */
	.shell {
		flex-direction: column;
	}
	.sidebar {
		position: sticky;
		top: 0;
		z-index: 50;
		border-bottom: 1px solid var(--border);
		background: var(--bg-elevated);
	}
	.sidebar-inner {
		min-height: auto;
		padding: 8px 0;
	}
	.brand {
		padding: 4px 14px 8px;
		font-size: 15px;
		border-bottom: none;
		margin-bottom: 0;
	}
	.nav {
		flex-direction: row;
		flex-wrap: nowrap;
		overflow-x: auto;
		gap: 4px;
		padding: 6px 10px 8px;
		-webkit-overflow-scrolling: touch;
		/* Hide scrollbar visually but keep functionality. */
		scrollbar-width: thin;
	}
	.nav::-webkit-scrollbar {
		height: 4px;
	}
	.nav-item {
		flex: 0 0 auto;
		padding: 8px 12px;
		font-size: 13px;
		white-space: nowrap;
	}
	.sidebar-foot {
		display: none;
	}

	/* Main content — tighter padding, less title chrome. */
	.main {
		padding: 14px 12px 28px;
	}
	.page-title {
		font-size: 1.2rem;
	}
	.page-desc {
		font-size: 13px;
	}
	.page-header,
	.page-header-row {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}
	.toolbar {
		flex-direction: column;
		align-items: stretch;
		width: 100%;
	}
	.toolbar .input-search,
	.toolbar select.input-search {
		width: 100%;
		max-width: 100%;
	}

	/* Stat grid — single column on the narrowest phones for max readability. */
	.stat-grid,
	.stat-grid-3,
	.stat-grid-6 {
		grid-template-columns: 1fr 1fr;
		gap: 10px;
	}
	.stat-card {
		padding: 14px 16px;
	}
	.stat-value {
		font-size: 1.4rem;
	}
	.stat-value-sm {
		font-size: 1.1rem;
	}

	/* Tables stay horizontally scrollable (already are via .table-scroll).
	 * Bump font + cell padding for readability. */
	.data-table {
		font-size: 12.5px;
	}
	.data-table th,
	.data-table td {
		padding: 10px 12px;
		white-space: nowrap;
	}
	.td-actions-wrap {
		display: flex;
		flex-wrap: wrap;
		gap: 4px;
	}
	.td-actions .btn-sm,
	.td-actions-wrap .btn-sm {
		padding: 6px 10px;
		font-size: 12px;
		min-height: 32px;
	}

	/* Modals — almost full-viewport so admin can actually read inside. */
	.modal-dialog,
	.modal-dialog-wide {
		max-width: calc(100vw - 24px);
		max-height: calc(100vh - 48px);
		overflow-y: auto;
	}
	.detail-grid {
		grid-template-columns: 1fr;
	}

	/* Inputs / buttons — bigger tap target. iOS HIG recommends ≥44px. */
	.input-search,
	.input,
	.btn,
	select {
		min-height: 40px;
		font-size: 15px; /* prevents iOS zoom on focus */
	}
	.btn-sm {
		min-height: 32px;
		font-size: 12.5px;
	}

	/* Login card — works on phones too. */
	.login-card {
		padding: 24px 18px;
	}

	/* Push pill should sit clear of iOS home-indicator + URL bar safe areas. */
	#admin-push-pill {
		bottom: max(18px, env(safe-area-inset-bottom)) !important;
		right: 14px !important;
		font-size: 12.5px;
	}

	/* Chart cards single-column, shorter height. */
	.chart-grid {
		grid-template-columns: 1fr;
	}
	.chart-canvas-wrap {
		height: 200px;
	}

	/* Ticket bubble width on phones — let bubbles use most of the row. */
	.ticket-msg {
		max-width: 92%;
	}

	/* GPU pool card — tighter padding. */
	.gpu-card-head {
		padding-bottom: 8px;
		margin-bottom: 8px;
	}
}

/* Very narrow phones (iPhone SE / older Androids). */
@media (max-width: 380px) {
	.stat-grid,
	.stat-grid-3,
	.stat-grid-6 {
		grid-template-columns: 1fr;
	}
	.nav-item {
		font-size: 12px;
		padding: 7px 10px;
	}
}
