@media (max-width: 1200px) {
	:root { --space-page: 24px; --sidebar-width: 264px; }
	.topbar { padding: 0 var(--space-page); }
	.page-content { padding-top: 20px; padding-bottom: 32px; }
	.kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.kpi { padding: 16px; }
	.kpi:nth-child(odd) { border-left: 0; }
	.kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
	.page-heading h1 { font-size: 34px; }
	.today-label, .topbar-divider { display: none; }
	.notification-popover { right: 16px; width: min(360px, calc(100vw - 32px)); }
}

@media (max-width: 960px) {
	.sidebar {
		width: min(var(--sidebar-width), 88vw);
		transform: translateX(-105%);
		transition: transform .24s ease;
		box-shadow: 12px 0 40px #12201840;
	}
	.sidebar.is-open { transform: translateX(0); }
	.mobile-scrim.is-visible { position: fixed; inset: 0; z-index: 19; display: block; background: #18231d80; }
	.main-area { margin-left: 0; }
	.menu-toggle { display: grid; margin-right: 8px; }
	.topbar { justify-content: flex-start; padding: 0 16px; }
	.breadcrumbs > span, .breadcrumbs > svg { display: none; }
	.global-search { max-width: 280px; flex-basis: 140px; }
	.chat-layout { grid-template-columns: 1fr; min-height: 0; }
	.chat-panel { min-height: min(520px, 70dvh); }
	.dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
	.topbar { min-height: 56px; padding: 0 12px; }
	.global-search { width: 44px; max-width: 44px; flex: 0 0 44px; padding: 0 10px; border-color: transparent; background: transparent; }
	.global-search:focus-within { position: absolute; left: 64px; right: 16px; z-index: 2; width: auto; max-width: none; flex: 1 1 auto; border-color: #d5dbd3; background: white; }
	.global-search input { width: 0; padding: 0; }
	.global-search:focus-within input { width: 100%; }
	.global-search kbd { display: none; }
	.page-content { padding: 18px 14px 28px; }
	.page-heading { align-items: stretch; flex-direction: column; gap: 14px; }
	.page-heading h1 { font-size: 28px; }
	.heading-actions, .heading-actions .button, .search-hero .button, .form-actions .button { width: 100%; }
	.kpi-grid { grid-template-columns: 1fr; }
	.kpi + .kpi, .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); border-left: 0; }
	.panel-heading { align-items: flex-start; flex-wrap: wrap; padding: 14px; }
	.list-toolbar, .search-hero, .form-actions, .version-row { align-items: stretch; flex-direction: column; }
	.list-search, .list-toolbar .filter-select { width: 100%; }
	.chat-message { max-width: 94%; }
	.modal { width: min(520px, calc(100% - 16px)); padding: 20px; }
	.activity-chart { padding-right: 12px; padding-left: 12px; }
	.auth-card { padding: 22px; }
	.auth-card h1 { font-size: 32px; }
}

@media (max-height: 820px) {
	.sidebar { padding: 14px 12px 10px; }
	.workspace-switcher { margin: 12px 2px 10px; }
	.secure-note { display: none; }
	.nav-link { min-height: 38px; }
	.nav-label-spaced { margin-top: 10px; }
}

@media (max-height: 680px) {
	.brand-name { font-size: 16px; }
	.workspace-switcher { margin: 8px 2px; padding: 8px; }
	.nav-link { min-height: 34px; gap: 10px; }
	.nav-link span:nth-child(2) { font-size: 14px; }
	.profile-button { padding: 6px; }
	.logout-link { min-height: 36px; }
}

.logout-link {
	margin-top: 2px;
	color: #f3f6f1;
	flex: 0 0 auto;
}

.logout-link:hover { background: #ffffff14; }

.auth-gate {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	place-items: center;
	padding: 24px;
	overflow: auto;
	background: #f4f5ef;
}

.auth-gate[hidden] { display: none; }
.auth-card { display: grid; gap: 14px; width: min(460px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 18px 50px #23332914; }
.auth-card h1 { margin: 0; color: #202a23; font-family: var(--display); font-size: 36px; font-weight: 400; }
.auth-card p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.5; }
.auth-card label { display: grid; gap: 6px; color: #314036; font-size: 14px; font-weight: 600; }
.auth-card input { min-height: 48px; padding: 10px 12px; border: 1px solid #d5dbd3; border-radius: 8px; color: #243028; font-size: 16px; font-weight: 400; }
.auth-error { color: #a45b4e; font-size: 15px; }
.auth-card .button { margin-top: 4px; width: 100%; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
