:root {
	color-scheme: light dark;
	--brand-primary: #990066;
	--brand-secondary: #007a00;
	--surface-page: #f3f0f2;
	--surface-shell: rgba(255, 255, 255, 0.88);
	--surface-panel: #fbfafb;
	--surface-subtle: #f3eff2;
	--surface-muted: #ece6eb;
	--surface-input: #ffffff;
	--text-body: #141116;
	--text-heading: #0f0c12;
	--text-supporting: #4d4750;
	--text-soft: #625a61;
	--text-subtle: #7b727a;
	--border-strong: rgba(23, 17, 22, 0.12);
	--border-subtle: rgba(23, 17, 22, 0.08);
	--shadow-shell: 0 28px 80px rgba(24, 16, 22, 0.10);
	--shadow-panel: 0 16px 36px rgba(24, 16, 22, 0.07);
	--shadow-panel-hover: 0 20px 48px rgba(24, 16, 22, 0.10);
	--radius-panel: 0.75rem;
	--radius-field: 0.6rem;
	--radius-button: 0.7rem;
	--radius-status: 0.65rem;
	--radius-table: 0.7rem;
	--radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--brand-primary: #e0559e;
		--brand-secondary: #4ec94e;
		--surface-page: #0f0d11;
		--surface-shell: rgba(22, 20, 26, 0.90);
		--surface-panel: #17151b;
		--surface-subtle: #1c1820;
		--surface-muted: #221d25;
		--surface-input: #121015;
		--text-body: #ebe6ec;
		--text-heading: #f5f2f6;
		--text-supporting: #c5bdc8;
		--text-soft: #a99faa;
		--text-subtle: #8d838f;
		--border-strong: rgba(255, 255, 255, 0.10);
		--border-subtle: rgba(255, 255, 255, 0.07);
		--shadow-shell: 0 32px 88px rgba(0, 0, 0, 0.38);
		--shadow-panel: 0 20px 44px rgba(0, 0, 0, 0.22);
		--shadow-panel-hover: 0 24px 56px rgba(0, 0, 0, 0.34);
	}
}

:root[data-theme="dark"] {
	--brand-primary: #e0559e;
	--brand-secondary: #4ec94e;
	--surface-page: #0f0d11;
	--surface-shell: rgba(22, 20, 26, 0.90);
	--surface-panel: #17151b;
	--surface-subtle: #1c1820;
	--surface-muted: #221d25;
	--surface-input: #121015;
	--text-body: #ebe6ec;
	--text-heading: #f5f2f6;
	--text-supporting: #c5bdc8;
	--text-soft: #a99faa;
	--text-subtle: #8d838f;
	--border-strong: rgba(255, 255, 255, 0.10);
	--border-subtle: rgba(255, 255, 255, 0.07);
	--shadow-shell: 0 32px 88px rgba(0, 0, 0, 0.38);
	--shadow-panel: 0 20px 44px rgba(0, 0, 0, 0.22);
	--shadow-panel-hover: 0 24px 56px rgba(0, 0, 0, 0.34);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "Avenir Next", Avenir, "Segoe UI Variable", "Segoe UI", sans-serif;
	background:
		linear-gradient(180deg, rgba(153, 0, 102, 0.06), transparent 22%),
		linear-gradient(120deg, rgba(0, 122, 0, 0.04), transparent 28%),
		var(--surface-page);
	color: var(--text-body);
}

h1,
h2,
h3,
p {
	margin-top: 0;
}

h1,
h2,
h3 {
	color: var(--text-heading);
	letter-spacing: -0.03em;
}

a {
	color: var(--brand-primary);
}

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

.form-layout {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.panel,
.form-panel {
	background: var(--surface-panel);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-panel);
	box-shadow: var(--shadow-panel);
	padding: 1.5rem;
}

.form-panel {
	padding: 1.35rem;
}

.panel-header {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.panel-header h2,
.panel h3 {
	margin-bottom: 0;
}

.panel-header h2 {
	font-size: clamp(1.4rem, 2vw, 1.75rem);
}

.panel-header p,
.panel p,
.semantic-list,
.field small {
	color: var(--text-supporting);
}

.semantic-list {
	margin: 0;
	padding-left: 1.25rem;
}

.semantic-list li + li {
	margin-top: 0.55rem;
}

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

.field span {
	font-size: 0.88rem;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.field input {
	width: 100%;
	padding: 0.58rem 0.8rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-field);
	background: var(--surface-input);
	color: var(--text-body);
	font: inherit;
	line-height: 1.1;
	transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.field input:focus {
	border-color: var(--brand-primary);
	outline: none;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 14%, transparent);
}

.field select {
	width: 100%;
	padding: 0.58rem 2.2rem 0.58rem 0.8rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-field);
	background: var(--surface-input);
	color: var(--text-body);
	font: inherit;
	line-height: 1.1;
	appearance: none;
	background-image:
		linear-gradient(45deg, transparent 50%, var(--text-subtle) 50%),
		linear-gradient(135deg, var(--text-subtle) 50%, transparent 50%);
	background-position:
		calc(100% - 1rem) calc(50% - 0.1rem),
		calc(100% - 0.72rem) calc(50% - 0.1rem);
	background-size: 0.38rem 0.38rem, 0.38rem 0.38rem;
	background-repeat: no-repeat;
	transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.field select:focus {
	border-color: var(--brand-primary);
	outline: none;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 14%, transparent);
}

.field-error {
	color: #b42318;
	font-size: 0.86rem;
}

@media (prefers-color-scheme: dark) {
	.field-error {
		color: #f87171;
	}
}

.primary-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.95rem;
	padding: 0.8rem 1.1rem;
	border: none;
	border-radius: var(--radius-button);
	background: linear-gradient(180deg, color-mix(in srgb, var(--brand-primary) 84%, white 16%), var(--brand-primary));
	color: #ffffff;
	font: inherit;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.primary-action:hover {
	box-shadow: var(--shadow-panel-hover);
	filter: saturate(1.04);
}

.primary-action:active {
	transform: translateY(1px);
}

.inline-form {
	display: flex;
}

.form-actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 0.75rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border-subtle);
}

.form-actions .inline-form {
	display: flex;
}

.form-actions .primary-action,
.form-actions .secondary-action {
	width: auto;
	min-width: 10.5rem;
}

.status-message {
	padding: 0.7rem 0.85rem;
	border-left: 4px solid #b7791f;
	background: color-mix(in srgb, #b7791f 10%, var(--surface-subtle));
	border-radius: var(--radius-status);
	color: var(--text-supporting);
}

.status-message-success {
	border-left-color: #2f855a;
	background: color-mix(in srgb, #2f855a 10%, var(--surface-subtle));
}

.status-message-error {
	border-left-color: #c53030;
	background: color-mix(in srgb, #c53030 10%, var(--surface-subtle));
}

.auth-card {
	backdrop-filter: blur(18px);
	background: var(--surface-shell);
}

caimito-app-shell,
caimito-auth-shell {
	display: block;
	min-height: 100vh;
}

.app-shell {
	min-height: 100vh;
	padding: 0 1.25rem 2rem;
}

.app-shell__frame {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	width: 100%;
}

.app-shell__nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1.25rem;
	padding: 0.75rem 1.25rem;
	margin: 0 -1.25rem;
	background: var(--surface-shell);
	border-bottom: 1px solid var(--border-subtle);
	box-shadow: 0 12px 32px rgba(24, 16, 22, 0.06);
	backdrop-filter: blur(18px);
}

.app-shell__nav-left {
	display: flex;
	align-items: center;
	gap: 1.75rem;
	min-width: 0;
	flex: 1 1 auto;
}

.app-shell__home-link {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
}

.app-shell__logo {
	width: 6.8rem;
	height: auto;
	display: block;
}

.app-shell__menu {
	display: flex;
	align-items: center;
	gap: 1.5rem;
	min-width: 0;
	flex: 1 1 auto;
}

.app-shell__menu a {
	color: var(--text-supporting);
	font: inherit;
	font-size: 1.08rem;
	font-weight: 600;
	text-decoration: none;
}

.app-shell__menu a[aria-current="page"] {
	color: var(--text-heading);
}

.app-shell__menu a:hover {
	color: var(--brand-primary);
}

.app-shell__user {
	flex: 0 0 auto;
}

.app-shell__content {
	flex: 1 1 auto;
	min-width: 0;
	padding-top: 0.25rem;
}

.auth-shell {
	display: flex;
	justify-content: center;
	padding: 1.5rem 1.25rem 2.25rem;
}

.auth-shell__content {
	width: min(100%, 78rem);
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	align-items: flex-start;
}

.auth-shell__hero {
	display: flex;
	flex: 1 1 18rem;
	flex-direction: column;
	gap: 1rem;
	min-width: 16rem;
	max-width: 25rem;
	padding: 1rem 0;
}

.auth-shell__logo {
	width: min(15rem, 58vw);
	height: auto;
}

.auth-shell__eyebrow {
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--brand-primary);
}

.auth-shell__title {
	margin: 0;
	font-size: clamp(2.2rem, 4.6vw, 4rem);
	line-height: 0.98;
	letter-spacing: -0.05em;
	color: var(--text-heading);
}

.auth-shell__intro {
	margin: 0;
	max-width: 26rem;
	font-size: 1rem;
	line-height: 1.7;
	color: var(--text-supporting);
}

.auth-shell__rule {
	width: 100%;
	max-width: 12rem;
	height: 1px;
	background: linear-gradient(90deg, var(--brand-primary), rgba(127, 127, 127, 0));
}

.auth-shell__meta {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.auth-shell__panel {
	flex: 1 1 34rem;
	min-width: min(34rem, 100%);
}

caimito-user-menu {
	display: block;
	position: relative;
	color: var(--text-body);
}

.user-menu__button {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.35rem 0.7rem;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-button);
	background: var(--surface-subtle);
	color: var(--text-heading);
	font: inherit;
	font-size: 1.02rem;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.user-menu__button:hover,
.user-menu__button[aria-expanded="true"] {
	background: color-mix(in srgb, var(--brand-primary) 10%, var(--surface-subtle));
	border-color: color-mix(in srgb, var(--brand-primary) 22%, var(--border-subtle));
	color: var(--brand-primary);
	box-shadow: 0 8px 20px rgba(24, 16, 22, 0.08);
}

.user-menu__button:focus-visible,
.theme-toggle__button:focus-visible {
	outline: 2px solid var(--brand-primary);
	outline-offset: 2px;
}

.user-menu__caret {
	font-size: 0.78rem;
	line-height: 1;
}

.user-menu__popup {
	position: absolute;
	top: calc(100% + 0.55rem);
	right: 0;
	display: none;
	min-width: 10rem;
	padding: 0.4rem;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-panel);
	background: var(--surface-panel);
	color: var(--text-body);
	box-shadow: var(--shadow-panel);
}

.user-menu__popup[data-open="true"] {
	display: block;
}

.user-menu__popup form {
	margin: 0;
}

.user-menu__role {
	padding: 0.4rem 0.75rem 0.55rem;
	border-bottom: 1px solid var(--border-subtle);
	margin-bottom: 0.25rem;
	font-size: 0.84rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--text-supporting);
}

.user-menu__action {
	display: flex;
	width: 100%;
	align-items: center;
	justify-content: flex-start;
	padding: 0.55rem 0.75rem;
	border: 0;
	border-radius: var(--radius-button);
	background: transparent;
	color: var(--text-body);
	font: inherit;
	font-size: 0.96rem;
	font-weight: 600;
	cursor: pointer;
	text-align: left;
	appearance: none;
}

.user-menu__action:hover {
	background: color-mix(in srgb, var(--brand-primary) 8%, var(--surface-subtle));
	color: var(--text-heading);
}

theme-mode-toggle {
	display: inline-flex;
}

.theme-toggle__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.75rem;
	padding: 0.7rem 1rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-pill);
	background: var(--surface-shell);
	color: var(--text-heading);
	font: inherit;
	font-size: 0.92rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.theme-toggle__button:hover {
	box-shadow: 0 12px 28px rgba(24, 16, 22, 0.12);
}

.styleguide-page {
	width: 100%;
	margin: 0 auto;
	padding: 2.5rem 2rem 4rem;
}

.styleguide-header {
	margin-bottom: 2rem;
}

.styleguide-header__topline {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.25rem;
}

.styleguide-header__brand {
	display: flex;
	align-items: flex-start;
	gap: 1.5rem;
}

.styleguide-header__logo {
	width: 10rem;
	height: auto;
	flex: 0 0 auto;
}

.styleguide-header__text {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	max-width: 32rem;
	padding-top: 0.4rem;
}

.styleguide-header__eyebrow,
.section-eyebrow {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--brand-primary);
}

.styleguide-header h1 {
	margin-bottom: 0;
	font-size: clamp(2.2rem, 4vw, 3.6rem);
	line-height: 0.98;
	letter-spacing: -0.05em;
}

.styleguide-header p {
	font-size: 1rem;
	line-height: 1.65;
	color: var(--text-supporting);
}

.theme-toggle-shell {
	display: flex;
	justify-content: flex-end;
	flex: 0 0 auto;
}

.styleguide-layout {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	align-items: start;
}

.styleguide-column {
	display: flex;
	flex-direction: column;
	flex: 1 1 24rem;
	align-items: stretch;
	gap: 1.5rem;
	min-width: 0;
}

.styleguide-column--primary {
	flex: 1 1 44rem;
}

.styleguide-column--secondary {
	flex: 0 1 32rem;
}

.styleguide-section {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	width: auto;
}

.styleguide-form {
	max-width: 26rem;
}

.styleguide-form-card {
	flex: 0 0 auto;
	align-self: flex-start;
	width: min(100%, 28.5rem);
}

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

.section-header h2 {
	margin: 0.2rem 0 0;
	font-size: clamp(1.25rem, 2vw, 1.65rem);
}

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

.type-stack h1,
.type-stack h2,
.type-stack h3,
.type-stack p {
	margin-bottom: 0;
}

.type-stack h1 {
	font-size: clamp(1.9rem, 3vw, 2.6rem);
	line-height: 1.02;
}

.type-stack h2 {
	font-size: clamp(1.4rem, 2.2vw, 1.9rem);
}

.type-stack h3 {
	font-size: 1.1rem;
}

.text-supporting {
	color: var(--text-supporting);
}

.text-subtle {
	color: var(--text-subtle);
}

.metric-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
}

.metric-card {
	display: flex;
	flex-direction: column;
	flex: 1 1 13rem;
	gap: 0.45rem;
	padding: 1rem;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-table);
	background: var(--surface-subtle);
}

.metric-card__label {
	font-size: 0.84rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--text-subtle);
}

.metric-card__value {
	font-size: 1.9rem;
	line-height: 1;
	letter-spacing: -0.05em;
	color: var(--text-heading);
}

.metric-card__delta {
	font-size: 0.9rem;
	color: var(--text-supporting);
}

.metric-card__delta--positive {
	color: var(--brand-secondary);
}

.metric-card__delta--attention {
	color: var(--brand-primary);
}

.table-shell {
	overflow-x: auto;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-table);
	background: var(--surface-panel);
}

.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

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

.data-table th {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--text-subtle);
	background: var(--surface-subtle);
}

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

.pill {
	display: inline-flex;
	align-items: center;
	padding: 0.35rem 0.65rem;
	border-radius: var(--radius-pill);
	background: var(--surface-subtle);
	color: var(--text-supporting);
	font-size: 0.82rem;
	font-weight: 600;
}

.pill--positive {
	background: color-mix(in srgb, var(--brand-secondary) 14%, var(--surface-subtle));
	color: color-mix(in srgb, var(--brand-secondary) 72%, var(--text-heading));
}

.pill--attention {
	background: color-mix(in srgb, var(--brand-primary) 14%, var(--surface-subtle));
	color: color-mix(in srgb, var(--brand-primary) 72%, var(--text-heading));
}

.button-row {
	display: flex;
	gap: 0.85rem;
	align-items: center;
	flex-wrap: wrap;
	justify-content: flex-end;
	padding-top: 1rem;
	border-top: 1px solid var(--border-subtle);
}

.button-row__primary {
	flex: 0 0 auto;
	min-width: 11rem;
}

.secondary-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.95rem;
	padding: 0.8rem 1.1rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-button);
	background: transparent;
	color: var(--text-heading);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

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

.button-stack--content {
	align-items: flex-start;
}

.button-stack--content .primary-action,
.button-stack--content .secondary-action {
	width: auto;
	min-width: 11rem;
}

.app-dialog {
	width: min(100% - 2rem, 32rem);
	margin: auto;
	padding: 0;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-panel);
	background: var(--surface-panel);
	box-shadow: var(--shadow-shell);
	color: var(--text-body);
}

.app-dialog::backdrop {
	background: rgba(15, 13, 17, 0.48);
	backdrop-filter: blur(6px);
}

.app-dialog__form {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	padding: 1.35rem;
}

.app-dialog__actions {
	margin-top: 0.25rem;
}

.text-link {
	font-weight: 600;
	text-decoration: none;
}

@media (max-width: 72rem) {
	.auth-shell__content {
		flex-direction: column;
	}

	.styleguide-column,
	.styleguide-column--primary,
	.styleguide-column--secondary {
		flex-basis: 100%;
		max-width: none;
	}

	.metric-card {
		flex-basis: 100%;
	}
}

@media (max-width: 40rem) {
	.app-shell {
		padding: 0 1rem 1.5rem;
	}

	.app-shell__nav {
		flex-direction: column;
		align-items: flex-start;
		margin: 0 -1rem;
		padding: 0.72rem 1rem;
	}

	.app-shell__nav-left {
		width: 100%;
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
	}

	.app-shell__menu {
		flex-wrap: wrap;
		gap: 0.85rem 1rem;
	}

	.auth-shell {
		padding: 1.25rem 1rem 2rem;
	}

	.auth-shell__hero {
		padding-top: 0.75rem;
	}

	.auth-shell__panel {
		min-width: 0;
		width: 100%;
	}

	.styleguide-page {
		padding: 1.5rem 1rem 2.5rem;
	}

	.styleguide-header__topline,
	.styleguide-header__brand {
		flex-direction: column;
		gap: 1rem;
	}

	.theme-toggle-shell {
		width: 100%;
		justify-content: flex-start;
	}

	.styleguide-header__logo {
		width: 8.5rem;
	}

	.button-row {
		flex-direction: column;
		align-items: stretch;
	}

	.form-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.form-actions .primary-action,
	.form-actions .secondary-action,
	.form-actions .inline-form {
		width: 100%;
	}

	.form-actions .inline-form .secondary-action {
		width: 100%;
	}
}
