/* app.css: design tokens (panel-ui 2), the base styles, and the page frame (top bar, sidebar, content).
   Colours and sizes are custom properties on :root. The default is the dark theme (the brand).
   Light is used when data-theme is "light", or when it is "system" and the system prefers light.
   Layout uses logical properties (inline start and end), so Persian mirrors without extra rules.
   Components live in css/kit.css. Nothing here loads anything from the network. */

:root {
	color-scheme: dark;
	--bg-app: #0e0820;
	--bg-chrome: #130d2a;
	--surface-1: #1c1236;
	--surface-2: #251a45;
	--surface-3: #2e2254;
	--line: #33285a;
	--line-input: #7a68b5;
	--text-1: #f3eeff;
	--text-2: #c2b8e0;
	--text-3: #9a90bd;
	--accent-1: #b38cff;
	--accent-2: #ff5cc8;
	--accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
	--on-accent: #14082b;
	--focus: #ffb8eb;
	--ok: #5fd9a4;
	--warn: #ffc861;
	--danger: #ff7a8f;
	--on-danger: #14082b;
	--danger-fill: #ff7a8f;
	--info: #8fd3ff;
	--scrim: rgba(7, 4, 16, 0.72);
	--shadow-1: none;
	--shadow-2: 0 12px 32px rgba(0, 0, 0, 0.45);
	--shadow-3: 0 24px 64px rgba(0, 0, 0, 0.6);
	--dur-fast: 120ms;
	--dur-base: 180ms;
	--dur-slow: 280ms;
	--ease-out: cubic-bezier(0.2, 0, 0, 1);
	--control-h: 32px;
	--radius-s: 8px;
	--radius-m: 12px;
	--radius-l: 16px;
}

:root[data-theme="light"] {
	color-scheme: light;
	--bg-app: #f7f4fc;
	--bg-chrome: #ffffff;
	--surface-1: #ffffff;
	--surface-2: #f1ebfa;
	--surface-3: #e7ddf7;
	--line: #e5ddf2;
	--line-input: #7a7098;
	--text-1: #1a1230;
	--text-2: #4a3f66;
	--text-3: #6e6491;
	--accent-1: #6e3fe0;
	--accent-2: #c5188a;
	--on-accent: #ffffff;
	--focus: #7a3df0;
	--ok: #0e7a4f;
	--warn: #8a5300;
	--danger: #b3203a;
	--on-danger: #ffffff;
	--danger-fill: #b3203a;
	--info: #1a5fb0;
	--scrim: rgba(26, 18, 48, 0.35);
	--shadow-1: 0 1px 2px rgba(26, 18, 48, 0.06);
	--shadow-2: 0 8px 24px rgba(26, 18, 48, 0.12);
	--shadow-3: 0 24px 48px rgba(26, 18, 48, 0.18);
}

@media (prefers-color-scheme: light) {
	:root[data-theme="system"] {
		color-scheme: light;
		--bg-app: #f7f4fc;
		--bg-chrome: #ffffff;
		--surface-1: #ffffff;
		--surface-2: #f1ebfa;
		--surface-3: #e7ddf7;
		--line: #e5ddf2;
		--line-input: #7a7098;
		--text-1: #1a1230;
		--text-2: #4a3f66;
		--text-3: #6e6491;
		--accent-1: #6e3fe0;
		--accent-2: #c5188a;
		--on-accent: #ffffff;
		--focus: #7a3df0;
		--ok: #0e7a4f;
		--warn: #8a5300;
		--danger: #b3203a;
		--on-danger: #ffffff;
		--danger-fill: #b3203a;
		--info: #1a5fb0;
		--scrim: rgba(26, 18, 48, 0.35);
		--shadow-1: 0 1px 2px rgba(26, 18, 48, 0.06);
		--shadow-2: 0 8px 24px rgba(26, 18, 48, 0.12);
		--shadow-3: 0 24px 48px rgba(26, 18, 48, 0.18);
	}
}

/* Reduced motion: the durations drop to 0 when the system (system) or the profile (on) asks for it. */
@media (prefers-reduced-motion: reduce) {
	:root[data-motion="system"] {
		--dur-fast: 0ms;
		--dur-base: 0ms;
		--dur-slow: 0ms;
	}
}

:root[data-motion="on"] {
	--dur-fast: 0ms;
	--dur-base: 0ms;
	--dur-slow: 0ms;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg-app);
	color: var(--text-1);
	font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

:lang(fa) {
	font-family: Vazirmatn, "Noto Sans Arabic", Tahoma, "Segoe UI", sans-serif;
	line-height: 1.8;
}

:lang(fa) h1,
:lang(fa) h2,
:lang(fa) h3 {
	line-height: 1.5;
}

h1,
h2,
h3 {
	margin: 0;
	font-weight: 600;
}

h1 {
	font-size: 24px;
	line-height: 32px;
}

h2 {
	font-size: 18px;
	line-height: 26px;
}

h3 {
	font-size: 15px;
	line-height: 22px;
}

p {
	margin: 0;
}

code,
kbd,
pre,
.mono {
	font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
	font-size: 13px;
	direction: ltr;
}

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

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

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	border: 0;
	white-space: nowrap;
}

.skip-link {
	position: absolute;
	inset-inline-start: 8px;
	inset-block-start: -100px;
	z-index: 90;
	padding: 8px 12px;
	border-radius: var(--radius-s);
	background: var(--surface-1);
	color: var(--text-1);
	text-decoration: none;
}

.skip-link:focus {
	inset-block-start: 8px;
}

.app {
	min-height: 100vh;
}

.app-frame {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* Top bar */
.topbar {
	position: sticky;
	inset-block-start: 0;
	z-index: 30;
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 56px;
	padding: 8px 16px;
	background: var(--bg-chrome);
	border-block-end: 1px solid var(--line);
}

.topbar::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-end: -1px;
	height: 1px;
	background: var(--accent-grad);
}

.spacer {
	flex: 1;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--text-1);
	font-weight: 600;
	text-decoration: none;
}

.brand-mark {
	width: 20px;
	height: 20px;
	border-radius: 6px;
	background: var(--accent-grad);
}

.session-chip {
	white-space: nowrap;
	min-height: 32px;
	padding: 0 10px;
	border: 1px solid var(--line-input);
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text-2);
	font: inherit;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
}

.session-chip.is-warn {
	color: var(--warn);
}

.session-chip.is-danger {
	color: var(--danger);
}

.role-badge {
	padding: 2px 8px;
	border-radius: 4px;
	background: var(--surface-2);
	color: var(--text-2);
	font-size: 12px;
}

/* Page frame: sidebar and content */
.layout {
	display: flex;
	flex: 1;
	min-height: 0;
}

.sidenav {
	position: sticky;
	inset-block-start: 56px;
	align-self: flex-start;
	width: 232px;
	min-height: calc(100vh - 56px);
	padding: 16px 12px;
	background: var(--bg-chrome);
	border-inline-end: 1px solid var(--line);
	overflow-y: auto;
}

.nav-group + .nav-group {
	margin-block-start: 16px;
}

.nav-heading {
	padding: 0 8px 4px;
	color: var(--text-3);
	font-size: 12px;
	font-weight: 500;
}

.nav-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nav-link {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 32px;
	padding: 4px 8px;
	border-radius: var(--radius-s);
	color: var(--text-2);
	text-decoration: none;
}

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

.nav-link.is-active {
	background: var(--surface-3);
	color: var(--accent-1);
	font-weight: 500;
}

.content {
	flex: 1;
	min-width: 0;
	padding: 20px;
	outline: none;
}

.banners {
	display: grid;
	gap: 8px;
}

.page-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-block: 8px 24px;
}

.page-title {
	min-width: 0;
}

.page-title:focus {
	outline: none;
}

.page-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.page-body {
	display: grid;
	gap: 24px;
	min-width: 0;
}

.drawer-scrim {
	position: fixed;
	inset: 0;
	z-index: 20;
	background: var(--scrim);
}

/* Phone: the sidebar is a drawer opened by the menu button. */
@media (max-width: 899px) {
	.menu-btn {
		display: inline-flex;
	}

	.sidenav {
		position: fixed;
		inset-block: 0;
		inset-inline-start: 0;
		z-index: 25;
		top: 0;
		width: min(280px, 84vw);
		min-height: 100vh;
		translate: -100% 0;
		transition: translate var(--dur-slow) var(--ease-out);
	}

	:root[dir="rtl"] .sidenav,
	[dir="rtl"] .sidenav {
		translate: 100% 0;
	}

	.drawer-open .sidenav {
		translate: 0 0;
	}

	.content {
		padding: 16px;
	}
}

@media (min-width: 900px) {
	.menu-btn {
		display: none;
	}

	.drawer-scrim {
		display: none !important;
	}
}

@media (max-width: 599px) {
	/* On phones the brand name is visually hidden (the link keeps its name for screen readers). */
	.brand-name {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}

	/* On phones the search button keeps its name for screen readers and shows only the icon. */
	.search-btn span {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}

	.page-head {
		margin-block-end: 16px;
	}

	.page-title {
		font-size: 20px;
	}
}

/* Pages that are not signed in (sign-in and setup) have no sidebar, and no account controls. */
.no-session .sidenav,
.no-session .session-only,
.no-session .menu-btn,
.no-session .search-btn {
	display: none !important;
}

.no-session .layout {
	display: block;
}

.no-session .content {
	max-width: 480px;
	margin-inline: auto;
	padding-block-start: 32px;
}

.login-prefs {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 12px;
	margin-block-end: 16px;
}

.login-card {
	display: grid;
	gap: 16px;
	padding: 24px;
	border: 1px solid var(--line);
	border-radius: var(--radius-l);
	background: var(--surface-1);
	box-shadow: var(--shadow-1);
}

.section-title {
	margin-block-end: 8px;
}

/* Dashboard and health */
.kpi-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
}

.kpi {
	display: grid;
	gap: 4px;
	padding: 16px;
	border: 1px solid var(--line);
	border-radius: var(--radius-m);
	background: var(--surface-1);
}

.kpi-value {
	font-size: 32px;
	line-height: 40px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.kpi-label {
	color: var(--text-3);
	font-size: 12px;
}

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

.card {
	display: grid;
	gap: 12px;
	min-width: 0;
	padding: 16px;
	border: 1px solid var(--line);
	border-radius: var(--radius-m);
	background: var(--surface-1);
	box-shadow: var(--shadow-1);
}

@media (min-width: 900px) {
	.card {
		padding: 20px;
	}
}

.card-title {
	font-size: 15px;
	font-weight: 600;
}

.kv {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 6px 16px;
	margin: 0;
}

.kv dt {
	color: var(--text-3);
}

.kv dd {
	margin: 0;
}

.check-list {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.check-list li {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.chip-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.dashboard,
.health,
.stack {
	display: grid;
	gap: 16px;
}

.stack {
	gap: 12px;
}

.form-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px;
}

.form-error {
	color: var(--danger);
	min-height: 0;
}

.form-error:empty {
	display: none;
}

.field-hint {
	color: var(--text-3);
	font-size: 12px;
	line-height: 18px;
}

.field-hint:empty {
	display: none;
}

.stack > .field-hint,
.card > .field-hint {
	margin: 0;
}
