/*
 * The admin site's styles: shadcn/ui's look (docs/master-server-plan.md, section 5) in plain CSS. The tokens are
 * shadcn's neutral theme; component classes follow its anatomy (btn, card, badge, table, input, alert, sidebar).
 * Dark mode follows the operating system.
 */

:root {
	--radius: 0.625rem;
	--background: oklch(1 0 0);
	--foreground: oklch(0.145 0 0);
	--card: oklch(1 0 0);
	--card-foreground: oklch(0.145 0 0);
	--primary: oklch(0.205 0 0);
	--primary-foreground: oklch(0.985 0 0);
	--secondary: oklch(0.97 0 0);
	--secondary-foreground: oklch(0.205 0 0);
	--muted: oklch(0.97 0 0);
	--muted-foreground: oklch(0.556 0 0);
	--accent: oklch(0.97 0 0);
	--accent-foreground: oklch(0.205 0 0);
	--destructive: oklch(0.577 0.245 27.325);
	--destructive-foreground: oklch(0.985 0 0);
	--border: oklch(0.922 0 0);
	--input: oklch(0.922 0 0);
	--ring: oklch(0.708 0 0);
	--sidebar: oklch(0.985 0 0);
	--sidebar-foreground: oklch(0.145 0 0);
	--sidebar-accent: oklch(0.97 0 0);
	--sidebar-border: oklch(0.922 0 0);
	--shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--font-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-mono: "Geist Mono", ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
	:root {
		--background: oklch(0.145 0 0);
		--foreground: oklch(0.985 0 0);
		--card: oklch(0.205 0 0);
		--card-foreground: oklch(0.985 0 0);
		--primary: oklch(0.922 0 0);
		--primary-foreground: oklch(0.205 0 0);
		--secondary: oklch(0.269 0 0);
		--secondary-foreground: oklch(0.985 0 0);
		--muted: oklch(0.269 0 0);
		--muted-foreground: oklch(0.708 0 0);
		--accent: oklch(0.269 0 0);
		--accent-foreground: oklch(0.985 0 0);
		--destructive: oklch(0.704 0.191 22.216);
		--border: oklch(1 0 0 / 10%);
		--input: oklch(1 0 0 / 15%);
		--ring: oklch(0.556 0 0);
		--sidebar: oklch(0.205 0 0);
		--sidebar-foreground: oklch(0.985 0 0);
		--sidebar-accent: oklch(0.269 0 0);
		--sidebar-border: oklch(1 0 0 / 10%);
	}
}

/* Base */

*, *::before, *::after {
	box-sizing: border-box;
	border-color: var(--border);
}

html, body {
	margin: 0;
	padding: 0;
	background: var(--background);
	color: var(--foreground);
	font-family: var(--font-sans);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

a {
	color: inherit;
}

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

code {
	background: var(--muted);
	border-radius: calc(var(--radius) - 4px);
	padding: 0.1rem 0.3rem;
}

p {
	margin: 0 0 0.75rem;
}

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

.small {
	font-size: 0.8rem;
}

.nowrap {
	white-space: nowrap;
}

.w-full {
	width: 100%;
}

.stack {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 2px;
}

/* Shell: sidebar + content */

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

.sidebar {
	position: sticky;
	top: 0;
	display: flex;
	flex-direction: column;
	width: 15rem;
	height: 100vh;
	flex-shrink: 0;
	background: var(--sidebar);
	color: var(--sidebar-foreground);
	border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 1rem;
}

.brand-mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: calc(var(--radius) - 2px);
	background: var(--primary);
	color: var(--primary-foreground);
	font-weight: 700;
	font-size: 0.75rem;
	letter-spacing: 0.02em;
}

.brand-text {
	display: flex;
	flex-direction: column;
	line-height: 1.2;
}

.brand-name {
	font-weight: 600;
}

.brand-sub {
	font-size: 0.75rem;
	color: var(--muted-foreground);
}

.sidebar-nav {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	padding: 0 0.5rem;
	flex: 1;
	overflow-y: auto;
}

.sidebar-group-label {
	padding: 0.75rem 0.5rem 0.25rem;
	font-size: 0.75rem;
	font-weight: 500;
	color: var(--muted-foreground);
}

.nav-link {
	display: flex;
	align-items: center;
	height: 2rem;
	padding: 0 0.5rem;
	border-radius: calc(var(--radius) - 2px);
	text-decoration: none;
	color: var(--sidebar-foreground);
}

.nav-link:hover {
	background: var(--sidebar-accent);
}

.nav-link.active {
	background: var(--sidebar-accent);
	font-weight: 500;
}

.sidebar-footer {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 0.75rem;
	border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.sidebar-user-text {
	display: flex;
	flex-direction: column;
	line-height: 1.2;
	min-width: 0;
}

.sidebar-user-name {
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sidebar-user-sub, .sidebar-version {
	font-size: 0.75rem;
	color: var(--muted-foreground);
}

.content {
	flex: 1;
	min-width: 0;
	padding: 1.5rem 2rem 3rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* Plain layout (sign-in, errors) */

.plain {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	padding: 1.5rem;
	background: var(--muted);
}

.plain-column {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	width: 100%;
	max-width: 24rem;
}

.plain-brand {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
}

/* Page header */

.page-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1rem;
}

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

.page-description {
	margin: 0.25rem 0 0;
	color: var(--muted-foreground);
}

.page-actions {
	display: flex;
	gap: 0.5rem;
}

.toolbar {
	display: flex;
	gap: 0.5rem;
	max-width: 32rem;
}

/* Button */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	height: 2.25rem;
	padding: 0 1rem;
	border: 1px solid transparent;
	border-radius: calc(var(--radius) - 2px);
	font: inherit;
	font-weight: 500;
	white-space: nowrap;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn:disabled, .btn[disabled] {
	opacity: 0.5;
	pointer-events: none;
}

.btn-default {
	background: var(--primary);
	color: var(--primary-foreground);
	box-shadow: var(--shadow-xs);
}

.btn-default:hover {
	background: color-mix(in oklch, var(--primary) 90%, transparent);
}

.btn-secondary {
	background: var(--secondary);
	color: var(--secondary-foreground);
	box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
	background: color-mix(in oklch, var(--secondary) 80%, transparent);
}

.btn-outline {
	background: var(--background);
	color: var(--foreground);
	border-color: var(--input);
	box-shadow: var(--shadow-xs);
}

.btn-outline:hover, .btn-ghost:hover {
	background: var(--accent);
	color: var(--accent-foreground);
}

.btn-ghost {
	background: transparent;
	color: inherit;
}

.btn-destructive {
	background: var(--destructive);
	color: var(--destructive-foreground);
	box-shadow: var(--shadow-xs);
}

.btn-destructive:hover {
	background: color-mix(in oklch, var(--destructive) 90%, transparent);
}

.btn-link {
	background: transparent;
	color: var(--primary);
	padding: 0;
	height: auto;
}

.btn-link:hover {
	text-decoration: underline;
}

.btn-sm {
	height: 2rem;
	padding: 0 0.75rem;
	font-size: 0.8125rem;
}

.btn-lg {
	height: 2.5rem;
	padding: 0 1.5rem;
}

.btn-icon {
	width: 2.25rem;
	padding: 0;
}

/* Card */

.card {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	padding: 1.25rem 0;
	background: var(--card);
	color: var(--card-foreground);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-xs);
}

.card-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: 0 1.25rem;
}

.card-title {
	font-weight: 600;
	line-height: 1.2;
}

.card-description {
	margin-top: 0.25rem;
	color: var(--muted-foreground);
	font-size: 0.8125rem;
}

.card-content {
	padding: 0 1.25rem;
}

.card-content-flush {
	padding: 0;
}

.card:has(> .card-content-flush:only-child) {
	padding: 0;
	overflow: hidden;
}

.card-footer {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0 1.25rem;
}

.stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
	gap: 1rem;
}

.stat-value {
	font-size: 1.75rem;
	font-weight: 600;
	letter-spacing: -0.02em;
}

/* Badge */

.badge {
	display: inline-flex;
	align-items: center;
	padding: 0.125rem 0.5rem;
	border: 1px solid transparent;
	border-radius: calc(var(--radius) - 4px);
	font-size: 0.75rem;
	font-weight: 500;
	white-space: nowrap;
}

.badge-default {
	background: var(--primary);
	color: var(--primary-foreground);
}

.badge-secondary {
	background: var(--secondary);
	color: var(--secondary-foreground);
}

.badge-outline {
	border-color: var(--border);
	color: var(--foreground);
}

.badge-destructive {
	background: var(--destructive);
	color: var(--destructive-foreground);
}

/* Table */

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th {
	height: 2.5rem;
	padding: 0 0.75rem;
	text-align: left;
	font-weight: 500;
	color: var(--muted-foreground);
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

.table td {
	padding: 0.6rem 0.75rem;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}

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

.table tbody tr:hover {
	background: color-mix(in oklch, var(--muted) 50%, transparent);
}

.table td.details {
	max-width: 24rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.user-cell {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.user-cell-name {
	font-weight: 500;
}

/* Input */

.input {
	flex: 1;
	height: 2.25rem;
	width: 100%;
	padding: 0 0.75rem;
	background: transparent;
	color: var(--foreground);
	border: 1px solid var(--input);
	border-radius: calc(var(--radius) - 2px);
	font: inherit;
	box-shadow: var(--shadow-xs);
}

.input::placeholder {
	color: var(--muted-foreground);
}

.input:focus-visible {
	outline: none;
	border-color: var(--ring);
	box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

/* Alert */

.alert {
	padding: 0.75rem 1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--card);
}

.alert-title {
	font-weight: 500;
	margin-bottom: 0.15rem;
}

.alert-description {
	color: var(--muted-foreground);
	font-size: 0.8125rem;
}

.alert-destructive {
	color: var(--destructive);
}

.alert-destructive .alert-description {
	color: color-mix(in oklch, var(--destructive) 90%, transparent);
}

/* Avatar */

.avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	flex-shrink: 0;
	border-radius: 9999px;
	overflow: hidden;
	background: var(--muted);
}

.avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.avatar-fallback {
	font-size: 0.8rem;
	font-weight: 500;
	color: var(--muted-foreground);
}

/* Separator with a label */

.separator {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	color: var(--muted-foreground);
	font-size: 0.75rem;
}

.separator::before, .separator::after {
	content: "";
	flex: 1;
	border-top: 1px solid var(--border);
}

/* Empty state */

.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.25rem;
	padding: 3rem 1rem;
	text-align: center;
}

.empty-state-title {
	font-weight: 500;
}

.empty-state-description {
	color: var(--muted-foreground);
}

/* Pagination */

.pagination {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
}

.pagination-status {
	margin-right: 0.5rem;
	color: var(--muted-foreground);
	font-size: 0.8125rem;
}

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

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

	.content {
		padding: 1rem;
	}
}

/* Step 2: user detail, invites, forms */

.two-column {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.75rem;
}

.two-column .toolbar {
	flex: 1;
	min-width: 18rem;
}

.row-link {
	text-decoration: none;
}

.row-link:hover .user-cell-name {
	text-decoration: underline;
}

.badge-row {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0.25rem;
}

.cell-actions {
	text-align: right;
	width: 1%;
	white-space: nowrap;
}

.detail-grid {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
	gap: 1rem;
}

.kv {
	display: grid;
	grid-template-columns: 9rem minmax(0, 1fr);
	align-items: center;
	gap: 0.75rem;
}

.form-grid {
	display: grid;
	grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto;
	gap: 0.75rem;
	align-items: end;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.field-end {
	justify-content: flex-end;
}

.label {
	font-size: 0.8125rem;
	font-weight: 500;
}

.input-inline {
	height: 1.9rem;
	min-width: 16rem;
	font-size: 0.75rem;
	box-shadow: none;
}

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

/* Step 3: desktop sign-in */

.confirm-code {
	padding: 0.75rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--muted);
	font-family: var(--font-mono);
	font-size: 1.5rem;
	font-weight: 600;
	letter-spacing: 0.15em;
	text-align: center;
}

/* Step 5: inline forms */

.inline-form {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.input-compact {
	flex: 0 0 auto;
	width: auto;
	height: 2rem;
}

.checkbox-label {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.8125rem;
}
