/* variables */
:root {
	color-scheme: dark;

	--bg: #1f1f1f;
	--surface: #282828;
	--surface-2: #323232;
	--surface-3: #3c3c3c;
	--border: #444444;
	--text: #e6e6e6;
	--text-muted: #aaaaaa;
	--accent: #ffffff;
	--accent-hover: #ffffff;
	--accent-soft: rgba(255, 255, 255, 0.1);
	--on-accent: #1f1f1f;

	--error: #ff6b6b;
	--error-soft: rgba(255, 107, 107, 0.14);
	--warning: #f5c04e;
	--warning-soft: rgba(245, 192, 78, 0.14);
	--success: #4ad991;
	--success-soft: rgba(74, 217, 145, 0.14);

	--radius: 8px;
	--radius-sm: 5px;
	--shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
	--topbar-height: 60px;
	--content-width: 1100px;
	--font: "Segoe UI", Verdana, system-ui, sans-serif;
	--font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
	color-scheme: light;

	--bg: #eeeeee;
	--surface: #f8f8f8;
	--surface-2: #e4e4e4;
	--surface-3: #d9d9d9;
	--border: #c8c8c8;
	--text: #333333;
	--text-muted: #6b6b6b;
	--accent: #111111;
	--accent-hover: #000000;
	--accent-soft: rgba(0, 0, 0, 0.07);
	--on-accent: #ffffff;

	--error: #d63a3a;
	--error-soft: rgba(214, 58, 58, 0.1);
	--warning: #b07a00;
	--warning-soft: rgba(176, 122, 0, 0.1);
	--success: #18925a;
	--success-soft: rgba(24, 146, 90, 0.1);

	--shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* general */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
}

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

body {
	min-height: 100vh;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

a {
	color: var(--accent);
	text-decoration: none;
}

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

h1 {
	font-size: 1.75rem;
	font-weight: 650;
	letter-spacing: -0.02em;
	line-height: 1.2;
}

h2 {
	font-size: 1.1rem;
	font-weight: 600;
}

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

.hidden,
[hidden] {
	display: none !important;
}

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

/* top bar */
.topbar {
	position: sticky;
	top: 0;
	z-index: 50;
	background: color-mix(in srgb, var(--bg) 82%, transparent);
	backdrop-filter: blur(14px);
	-webkit-backdrop-filter: blur(14px);
	border-bottom: 1px solid var(--border);
}

.topbar-inner {
	display: flex;
	align-items: center;
	gap: 24px;
	height: var(--topbar-height);
	padding: 0 24px;
}

.brand {
	color: var(--text);
	font-size: 1.15rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	flex-shrink: 0;
}

.brand span {
	color: var(--accent);
}

.brand:hover {
	color: var(--text);
}

.nav {
	display: flex;
	gap: 4px;
	flex: 1;
	min-width: 0;
	overflow-x: auto;
	scrollbar-width: none;
}

.nav::-webkit-scrollbar {
	display: none;
}

.nav a {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 7px 12px;
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	font-weight: 500;
	white-space: nowrap;
}

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

.nav a[aria-current="page"] {
	color: var(--text);
	background: var(--surface-3);
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

/* account dropdown */
.dropdown {
	position: relative;
}

.dropdown summary {
	list-style: none;
	cursor: pointer;
}

.dropdown summary::-webkit-details-marker {
	display: none;
}

.account {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 10px 4px 4px;
	border-radius: 999px;
	color: var(--text-muted);
}

.account:hover,
.dropdown[open] .account {
	background: var(--surface-2);
	color: var(--text);
}

.account .fa-chevron-down {
	font-size: 0.7rem;
}

.avatar {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 700;
	font-size: 0.85rem;
}

.dropdown-menu {
	position: absolute;
	right: 0;
	top: calc(100% + 8px);
	min-width: 190px;
	padding: 6px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.dropdown-menu a,
.dropdown-menu button {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
	background: var(--surface-2);
	color: var(--text);
}

.dropdown-menu i {
	width: 16px;
	color: var(--text-muted);
	text-align: center;
}

/* page */
.page {
	max-width: var(--content-width);
	margin: 0 auto;
	padding: 40px 16px 64px;
}

.layout-wide .page {
	max-width: none;
	padding: 24px 24px 48px;
}

.page-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 28px;
}

.page-header p {
	margin-top: 6px;
	color: var(--text-muted);
}

/* cards */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 24px;
}

.card + .card {
	margin-top: 16px;
}

.card h2 {
	margin-bottom: 16px;
}

/* tiles on the start page */
.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 14px;
}

.tile {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 22px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
	transition: border-color 0.15s, transform 0.15s;
}

.tile:hover {
	color: var(--text);
	border-color: var(--accent);
	transform: translateY(-2px);
}

.tile-icon {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	background: var(--accent-soft);
	color: var(--accent);
	font-size: 1.2rem;
}

.tile strong {
	font-size: 1.05rem;
}

.tile span {
	color: var(--text-muted);
	font-size: 0.9rem;
}

/* buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-weight: 550;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
	background: var(--surface-3);
	color: var(--text);
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--on-accent);
}

.btn-primary:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: var(--on-accent);
}

.btn-danger {
	color: var(--error);
}

.btn-danger:hover {
	background: var(--error-soft);
	color: var(--error);
}

.btn-small {
	height: 34px;
	padding: 0 12px;
	font-size: 0.9rem;
}

.btn-block {
	width: 100%;
}

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	color: var(--text-muted);
	font-size: 1rem;
	cursor: pointer;
}

.icon-btn:hover {
	background: var(--surface-2);
	color: var(--text);
}

.icon-btn.active {
	color: var(--accent);
}

/* forms */
.form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.field label {
	color: var(--text-muted);
	font-size: 0.85rem;
	font-weight: 550;
}

.field small {
	color: var(--text-muted);
	font-size: 0.8rem;
}

.input,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
	width: 100%;
	height: 42px;
	padding: 0 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--text);
	font: inherit;
	transition: border-color 0.15s, box-shadow 0.15s;
}

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

select {
	appearance: none;
	padding-right: 36px;
	background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
	background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
	background-size: 5px 5px;
	background-repeat: no-repeat;
}

.check {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
}

.check input {
	width: 18px;
	height: 18px;
	accent-color: var(--accent);
}

.divider {
	display: flex;
	align-items: center;
	gap: 12px;
	color: var(--text-muted);
	font-size: 0.85rem;
}

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

/* small centered pages like login */
.auth {
	max-width: 400px;
	margin: 6vh auto 0;
}

.auth h1 {
	margin-bottom: 20px;
}

.auth > h1 + p {
	margin: -12px 0 24px;
	color: var(--text-muted);
}

/* without top bar the content sits in the middle of the window */
.no-topbar:not(.layout-wide) .page {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 100vh;
	min-height: 100dvh;
	padding-top: 32px;
	padding-bottom: 32px;
}

.no-topbar .auth {
	width: 100%;
	margin: 0 auto;
}

.auth-footer {
	margin-top: 20px;
	text-align: center;
	color: var(--text-muted);
	font-size: 0.9rem;
}

.narrow {
	max-width: 560px;
}

/* toasts */
.toasts {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 100;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-width: min(380px, calc(100vw - 32px));
}

.toast {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 12px 12px 14px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 3px solid var(--accent);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	animation: toast-in 0.2s ease-out;
	transition: opacity 0.25s, transform 0.25s;
}

.toast > i {
	margin-top: 3px;
	color: var(--accent);
}

.toast span {
	flex: 1;
}

.toast.error {
	border-left-color: var(--error);
}

.toast.error > i {
	color: var(--error);
}

.toast.warning {
	border-left-color: var(--warning);
}

.toast.warning > i {
	color: var(--warning);
}

.toast.success {
	border-left-color: var(--success);
}

.toast.success > i {
	color: var(--success);
}

.toast.leaving {
	opacity: 0;
	transform: translateY(8px);
}

.toast-close {
	padding: 2px 4px;
	border: 0;
	background: none;
	color: var(--text-muted);
	cursor: pointer;
}

@keyframes toast-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
}

/* badges */
.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--surface-3);
	color: var(--text-muted);
	font-size: 0.75rem;
	font-weight: 600;
}

.badge.accent {
	background: var(--accent-soft);
	color: var(--accent);
}

/* progress bar */
.progress {
	height: 4px;
	border-radius: 999px;
	background: var(--surface-3);
	overflow: hidden;
}

.progress > div {
	width: 0;
	height: 100%;
	background: var(--accent);
	transition: width 0.2s;
}

/* error page */
.site-error .page {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: calc(100vh - var(--topbar-height));
	min-height: calc(100dvh - var(--topbar-height));
}

.error-page {
	width: 100%;
	max-width: 480px;
	margin: 0 auto;
	text-align: center;
}

.error-code {
	font-size: 5rem;
	font-weight: 800;
	letter-spacing: -0.05em;
	line-height: 1;
	color: var(--accent);
}

.error-page h1 {
	margin: 12px 0 8px;
}

.error-page p {
	margin-bottom: 24px;
	color: var(--text-muted);
}

/* small screens */
@media (max-width: 720px) {
	.topbar-inner {
		gap: 12px;
		padding: 0 16px;
	}

	.nav a span {
		display: none;
	}

	.nav a {
		padding: 8px 10px;
	}

	.account-name {
		display: none;
	}

	.page {
		padding-top: 24px;
	}

	.layout-wide .page {
		padding: 0 0 32px;
	}

	.card {
		padding: 18px;
	}
}

/* dialogs */
.dialog {
	width: min(440px, calc(100vw - 32px));
	margin: auto;
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	box-shadow: var(--shadow);
}

.dialog::backdrop {
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(3px);
}

.dialog h2 {
	font-size: 1.15rem;
}

.dialog-buttons {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 4px;
}

.btn-danger-solid {
	background: var(--error);
	border-color: var(--error);
	color: #fff;
}

.btn-danger-solid:hover {
	background: var(--error);
	color: #fff;
	filter: brightness(1.1);
}
