:root,
html[data-theme="light"],
html[data-theme="system"] {
	color-scheme: light;
	--bg: #f6f7f4;
	--bg-soft: #edf2ef;
	--surface: #ffffff;
	--surface-raised: #fbfcfb;
	--text: #1e2421;
	--muted: #647069;
	--line: #d9e1dc;
	--primary: #0f766e;
	--primary-strong: #0a5f59;
	--primary-soft: #dff3ef;
	--accent: #b76e1f;
	--danger: #b42318;
	--danger-soft: #fde7e3;
	--success: #1f7a4d;
	--success-soft: #e1f4e9;
	--shadow: 0 18px 45px rgba(31, 41, 37, 0.12);
}

@media (prefers-color-scheme: dark) {
	html[data-theme="system"] {
		color-scheme: dark;
		--bg: #101412;
		--bg-soft: #171d1a;
		--surface: #1e2420;
		--surface-raised: #252c28;
		--text: #eef4ef;
		--muted: #aab7af;
		--line: #354039;
		--primary: #46d0bb;
		--primary-strong: #7ee6d5;
		--primary-soft: #173f3a;
		--accent: #f0b35b;
		--danger: #ff8a7a;
		--danger-soft: #4b211d;
		--success: #83d9a8;
		--success-soft: #1d3b2b;
		--shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
	}
}

html[data-theme="dark"] {
	color-scheme: dark;
	--bg: #101412;
	--bg-soft: #171d1a;
	--surface: #1e2420;
	--surface-raised: #252c28;
	--text: #eef4ef;
	--muted: #aab7af;
	--line: #354039;
	--primary: #46d0bb;
	--primary-strong: #7ee6d5;
	--primary-soft: #173f3a;
	--accent: #f0b35b;
	--danger: #ff8a7a;
	--danger-soft: #4b211d;
	--success: #83d9a8;
	--success-soft: #1d3b2b;
	--shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--text);
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	line-height: 1.45;
}

a {
	color: inherit;
	text-decoration: none;
}

button,
input,
select,
textarea {
	font: inherit;
}

input,
select,
textarea {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	padding: 10px 12px;
	outline: none;
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
	resize: vertical;
}

label span {
	display: block;
	margin-bottom: 6px;
	color: var(--muted);
	font-size: 0.88rem;
	font-weight: 700;
}

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

th,
td {
	border-bottom: 1px solid var(--line);
	padding: 12px;
	text-align: left;
	vertical-align: top;
}

th {
	color: var(--muted);
	font-size: 0.78rem;
	text-transform: uppercase;
}

code {
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--bg-soft);
	padding: 2px 6px;
	font-size: 0.86rem;
}

.login-page {
	display: grid;
	place-items: center;
	padding: 24px;
}

.login-shell {
	width: min(100%, 420px);
}

.login-card,
.form-panel,
.table-panel,
.calendar-panel,
.upcoming-panel {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	box-shadow: var(--shadow);
}

.login-card {
	display: grid;
	gap: 18px;
	padding: 28px;
}

.login-card h1,
.section-head h1,
.calendar-toolbar h1 {
	margin: 0;
	font-size: 1.55rem;
	line-height: 1.2;
}

.login-head,
.topbar,
.topbar-actions,
.section-head,
.calendar-toolbar,
.form-actions,
.table-actions {
	display: flex;
	align-items: center;
	gap: 12px;
}

.login-head,
.section-head,
.calendar-toolbar {
	justify-content: space-between;
}

.brand-mark {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: 8px;
	background: var(--primary);
	color: #ffffff;
	font-weight: 800;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 5;
	justify-content: space-between;
	border-bottom: 1px solid var(--line);
	background: color-mix(in srgb, var(--surface) 92%, transparent);
	backdrop-filter: blur(14px);
	padding: 12px clamp(16px, 3vw, 34px);
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	font-weight: 800;
	white-space: nowrap;
}

.nav {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--bg-soft);
}

.nav a {
	border-radius: 6px;
	color: var(--muted);
	font-weight: 700;
	padding: 8px 12px;
}

.nav a.is-active,
.nav a:hover {
	background: var(--surface);
	color: var(--text);
}

.topbar-actions {
	justify-content: flex-end;
}

.user-pill {
	display: grid;
	gap: 0;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 6px 10px;
	min-width: 126px;
	background: var(--surface-raised);
}

.user-pill span {
	font-weight: 800;
	white-space: nowrap;
}

.user-pill small {
	color: var(--muted);
	font-size: 0.76rem;
}

.page {
	width: min(100% - 32px, 1480px);
	margin: 24px auto 40px;
}

.button,
.icon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface-raised);
	color: var(--text);
	cursor: pointer;
	font-weight: 800;
	min-height: 38px;
	padding: 9px 14px;
	white-space: nowrap;
}

.button:hover,
.icon-button:hover {
	border-color: var(--primary);
}

.button-primary {
	border-color: var(--primary);
	background: var(--primary);
	color: #ffffff;
}

.button-ghost {
	background: transparent;
}

.button-danger {
	border-color: var(--danger);
	background: var(--danger-soft);
	color: var(--danger);
}

.button-small {
	min-height: 32px;
	padding: 6px 10px;
	font-size: 0.86rem;
}

.button-wide {
	width: 100%;
}

.icon-button {
	width: 38px;
	height: 38px;
	padding: 0;
}

.alert {
	border: 1px solid var(--line);
	border-radius: 8px;
	margin-bottom: 16px;
	padding: 12px 14px;
	font-weight: 700;
}

.login-card .alert {
	margin-bottom: 0;
}

.alert-error {
	border-color: var(--danger);
	background: var(--danger-soft);
	color: var(--danger);
}

.alert-success {
	border-color: var(--success);
	background: var(--success-soft);
	color: var(--success);
}

.calendar-layout {
	display: grid;
	grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
	gap: 18px;
	align-items: start;
}

.upcoming-panel,
.calendar-panel,
.form-panel,
.table-panel {
	padding: 18px;
}

.upcoming-panel {
	position: sticky;
	top: 88px;
}

.eyebrow {
	margin: 0 0 4px;
	color: var(--accent);
	font-size: 0.76rem;
	font-weight: 900;
	text-transform: uppercase;
}

.section-head h2 {
	margin: 0;
	font-size: 1.2rem;
}

.upcoming-list {
	display: grid;
	gap: 10px;
	margin-top: 16px;
}

.upcoming-item {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface-raised);
	padding: 12px;
}

.upcoming-item strong,
.upcoming-item span,
.upcoming-item small {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.upcoming-item span,
.upcoming-item small {
	color: var(--muted);
}

.inline-link {
	grid-column: 2;
	color: var(--primary-strong);
	font-weight: 800;
	font-size: 0.86rem;
}

.empty-state {
	border: 1px dashed var(--line);
	border-radius: 8px;
	color: var(--muted);
	padding: 18px;
	text-align: center;
}

.calendar-viewbar {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 14px;
}

.segmented {
	display: inline-flex;
	gap: 4px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--bg-soft);
	padding: 4px;
}

.segmented a {
	border-radius: 6px;
	color: var(--muted);
	font-weight: 800;
	padding: 7px 12px;
}

.segmented a.is-active,
.segmented a:hover {
	background: var(--surface);
	color: var(--text);
}

.calendar-toolbar {
	margin-bottom: 16px;
}

.tenant-switch {
	display: flex;
	align-items: end;
	gap: 10px;
	max-width: 320px;
	margin: -4px 0 16px auto;
}

.calendar-grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 8px;
}

.year-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
}

.mini-month {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface-raised);
	padding: 12px;
}

.mini-month-title {
	display: block;
	font-weight: 900;
	margin-bottom: 10px;
}

.mini-calendar-grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 4px;
}

.mini-weekday {
	color: var(--muted);
	font-size: 0.68rem;
	font-weight: 900;
	text-align: center;
	text-transform: uppercase;
}

.mini-day {
	position: relative;
	display: grid;
	place-items: center;
	aspect-ratio: 1;
	border-radius: 6px;
	color: var(--muted);
	font-size: 0.76rem;
	font-weight: 800;
}

.mini-day.has-vacation {
	background: var(--primary-soft);
	color: var(--text);
}

.mini-day.is-today {
	outline: 2px solid var(--primary);
}

.weekday {
	color: var(--muted);
	font-size: 0.78rem;
	font-weight: 900;
	padding: 0 6px;
	text-transform: uppercase;
}

.calendar-day {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	min-height: 126px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface-raised);
	padding: 8px;
	overflow: hidden;
}

.calendar-day.is-muted {
	opacity: 0.54;
}

.calendar-day.is-today {
	border-color: var(--primary);
	box-shadow: inset 0 0 0 2px var(--primary-soft);
}

.day-number {
	color: var(--muted);
	font-weight: 900;
}

.day-vacations {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
	overflow: hidden;
	padding-top: 8px;
}

.vac-chip {
	display: block;
	border-radius: 6px;
	color: #0e1714;
	font-size: 0.78rem;
	font-weight: 800;
	overflow: hidden;
	padding: 5px 7px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.color-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	margin-top: 5px;
}

.color-0 { background: #8bd3c7; }
.color-1 { background: #f3c969; }
.color-2 { background: #a4cafe; }
.color-3 { background: #f7a6b5; }
.color-4 { background: #b9e28c; }
.color-5 { background: #d8b4fe; }
.color-6 { background: #ffbf8a; }
.color-7 { background: #9fd3a7; }

.narrow-panel {
	width: min(100%, 760px);
	margin: 0 auto;
}

.stacked-form {
	display: grid;
	gap: 16px;
	margin-top: 18px;
}

.compact-form {
	gap: 12px;
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
}

.check-row {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 42px;
	margin-top: 24px;
}

.check-row input {
	width: auto;
}

.check-row span {
	margin: 0;
}

.table-check {
	margin-top: 0;
	min-height: 0;
}

.danger-zone {
	border-top: 1px solid var(--line);
	margin-top: 20px;
	padding-top: 16px;
}

.admin-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
	gap: 18px;
	margin-bottom: 18px;
}

.table-panel {
	margin-top: 18px;
}

.table-panel.no-margin {
	margin-top: 0;
}

.table-wrap {
	overflow-x: auto;
}

.table-wrap table {
	min-width: 720px;
}

.table-actions {
	justify-content: flex-end;
}

.table-actions form {
	margin: 0;
}

@media (max-width: 1080px) {
	.topbar {
		align-items: flex-start;
		flex-wrap: wrap;
	}

	.nav {
		order: 3;
		width: 100%;
		overflow-x: auto;
	}

	.calendar-layout,
	.admin-grid {
		grid-template-columns: 1fr;
	}

	.upcoming-panel {
		position: static;
	}

	.year-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 720px) {
	.page {
		width: min(100% - 20px, 1480px);
		margin-top: 14px;
	}

	.topbar-actions,
	.form-actions,
	.calendar-toolbar,
	.calendar-viewbar,
	.tenant-switch {
		flex-wrap: wrap;
	}

	.calendar-viewbar,
	.tenant-switch {
		justify-content: stretch;
		max-width: none;
		margin: 0 0 14px;
	}

	.segmented,
	.tenant-switch,
	.tenant-switch label,
	.tenant-switch .button {
		width: 100%;
	}

	.segmented a {
		flex: 1;
		text-align: center;
	}

	.user-pill {
		min-width: 0;
	}

	.calendar-grid {
		grid-template-columns: 1fr;
		gap: 8px;
	}

	.weekday,
	.calendar-day.is-muted {
		display: none;
	}

	.calendar-day {
		grid-template-columns: 54px minmax(0, 1fr);
		grid-template-rows: auto;
		min-height: 54px;
		padding: 8px;
	}

	.day-number {
		align-self: start;
		border-right: 1px solid var(--line);
		height: 100%;
		padding-right: 10px;
	}

	.day-vacations {
		padding: 0 0 0 10px;
	}

	.vac-chip {
		font-size: 0.7rem;
		padding: 4px 5px;
	}

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

	.table-wrap {
		margin: 0 -10px;
		padding: 0 10px;
	}

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