:root {
	--bg: #f4f5f8;
	--surface: #ffffff;
	--surface-2: #f8f9fb;
	--text: #161a23;
	--muted: #646b7a;
	--line: #e3e6ec;
	--accent: #2e56d9;
	--accent-soft: #e8edfc;
	--ok: #127a55;
	--ok-soft: #e2f4ec;
	--warn: #a6510a;
	--warn-soft: #fcefdf;
	--bad: #be2f28;
	--bad-soft: #fcebea;
	--info: #2e56d9;
	--info-soft: #e8edfc;
	--sidebar: #131a2c;
	--sidebar-text: #b9c0cf;
	--radius: 12px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .05);
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f131b;
		--surface: #171c26;
		--surface-2: #1c2230;
		--text: #e8eaf0;
		--muted: #98a0b0;
		--line: #2a3140;
		--accent: #7d9cff;
		--accent-soft: #1f2a4a;
		--ok: #4cc79a;
		--ok-soft: #14322a;
		--warn: #f0a75a;
		--warn-soft: #3a2a17;
		--bad: #f07b74;
		--bad-soft: #3a1c1c;
		--info: #7d9cff;
		--info-soft: #1f2a4a;
		--sidebar: #0b0f17;
		--shadow: none;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0; }
small { font-size: .8em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Grundlayout */
.demo-banner {
	background: #2e56d9;
	color: #fff;
	text-align: center;
	font-size: .85rem;
	padding: .45rem 1rem;
}
.demo-banner a { color: #fff; text-decoration: underline; }
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 34px); }
.sidebar {
	background: var(--sidebar);
	color: var(--sidebar-text);
	padding: 1.25rem .9rem;
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
	position: sticky;
	top: 0;
	height: 100vh;
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 0 .4rem; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--sidebar-text); }
.brand-mark {
	width: 32px; height: 32px; border-radius: 9px;
	display: grid; place-items: center;
	background: linear-gradient(135deg, #6d8cff, #2e56d9);
	color: #fff; font-weight: 800;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
	display: flex; align-items: center; gap: .7rem;
	color: var(--sidebar-text);
	padding: .6rem .7rem;
	border-radius: 8px;
	font-size: .93rem;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.is-active { background: rgba(125, 156, 255, .16); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; gap: .65rem; align-items: center; font-size: .85rem; padding: 0 .4rem; color: #fff; }
.sidebar-foot small { color: var(--sidebar-text); }

.main { padding: 1.75rem clamp(1rem, 3vw, 2.25rem) 3rem; display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.topbar .muted { font-size: .9rem; margin-top: .15rem; }

@media (max-width: 900px) {
	.app { grid-template-columns: 1fr; }
	.sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: .7rem 1rem; gap: 1rem; overflow-x: auto; }
	.brand span:last-child, .sidebar-foot { display: none; }
	.nav { flex-direction: row; gap: 4px; }
	.nav a { white-space: nowrap; padding: .5rem .65rem; }
	.nav a span { display: none; }
	.nav a.is-active span { display: inline; }
}

/* Formularelemente */
select, input[type="text"], input[type="search"], input[type="number"], input[type="date"] {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: .5rem .7rem;
	min-height: 38px;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
	display: inline-flex; align-items: center; gap: .45rem;
	font: inherit; font-weight: 600; font-size: .9rem;
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--text);
	border-radius: 8px;
	padding: .5rem .85rem;
	min-height: 38px;
	cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-sm { min-height: 30px; padding: .25rem .6rem; font-size: .82rem; }
.btn-icon { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: .25rem .5rem; border-radius: 6px; }
.btn-icon:hover { background: var(--surface-2); }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search .icon { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 2.1rem; width: min(260px, 100%); }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.segmented a { padding: .35rem .8rem; border-radius: 6px; color: var(--muted); font-size: .88rem; font-weight: 600; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.is-active { background: var(--accent-soft); color: var(--accent); }

/* Karten und Raster */
.grid { display: grid; gap: 1rem; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.15rem .25rem; }
.card-head a { font-size: .85rem; }
.card-body { padding: 1rem 1.15rem 1.15rem; }
.card-body.flush { padding: .5rem 0 .25rem; }

.kpi { padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: .25rem; }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.trend-up { color: var(--ok); font-weight: 600; }
.trend-down { color: var(--bad); font-weight: 600; }
a.kpi { color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .65rem 1.15rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr[data-href], tr[data-detail], tr[data-toggle] { cursor: pointer; }
tbody tr[data-href]:hover, tbody tr[data-detail]:hover, tbody tr[data-toggle]:hover { background: var(--surface-2); }
tr.is-open { background: var(--surface-2); }
tr.detail-row td { background: var(--surface-2); padding-top: 0; }
tr.detail-row[hidden] { display: none; }
tr.is-highlight td { background: var(--accent-soft); }
tfoot td { font-weight: 700; background: var(--surface-2); }
.cell-person { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.positions { width: 100%; font-size: .85rem; }
.positions td { border: 0; padding: .2rem 0; background: none; }

/* Kennzeichnungen */
.badge {
	display: inline-flex; align-items: center;
	font-size: .76rem; font-weight: 600;
	padding: .15rem .55rem;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--muted);
	white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }

.avatar {
	width: 34px; height: 34px; border-radius: 50%;
	display: inline-grid; place-items: center;
	background: var(--accent-soft); color: var(--accent);
	font-weight: 700; font-size: .8rem; flex: none;
}
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.is-bad span { background: var(--bad); }
.meter.is-warn span { background: var(--warn); }

/* Diagramm */
.chart { display: flex; align-items: stretch; gap: 4px; height: 220px; padding-top: .5rem; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; color: var(--muted); }
.chart-bar:hover { text-decoration: none; }
.chart-val { font-size: .68rem; white-space: nowrap; opacity: 0; transition: opacity .15s; font-variant-numeric: tabular-nums; }
.chart-bar:hover .chart-val, .chart-bar.is-active .chart-val { opacity: 1; color: var(--text); }
.chart-col { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.chart-fill { width: 100%; max-width: 34px; margin: 0 auto; background: var(--accent-soft); border-radius: 5px 5px 2px 2px; min-height: 2px; transition: background .15s; }
.chart-bar:hover .chart-fill { background: color-mix(in srgb, var(--accent) 55%, var(--accent-soft)); }
.chart-bar.is-active .chart-fill { background: var(--accent); }
.chart-label { font-size: .68rem; white-space: nowrap; }
.chart-bar.is-empty .chart-label { opacity: .5; }
@media (max-width: 640px) {
	.chart { gap: 2px; height: 180px; }
	.chart-label { writing-mode: vertical-rl; transform: rotate(180deg); }
}

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .8rem; padding: .65rem 1.15rem; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .time { font-variant-numeric: tabular-nums; color: var(--muted); width: 3.2rem; flex: none; }
.list .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { font-size: .82rem; color: var(--muted); }

.empty { padding: 2rem 1.15rem; text-align: center; color: var(--muted); }

/* Profil */
.profile { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: .25rem; font-size: .9rem; }

/* Katalog */
.catalog-card { padding: 1.1rem 1.15rem; display: flex; flex-direction: column; gap: .5rem; }
.catalog-card .price { font-size: 1.25rem; font-weight: 700; }
.catalog-meta { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }

/* Dialog */
.modal {
	border: 0;
	border-radius: 14px;
	padding: 0;
	width: min(520px, calc(100vw - 2rem));
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal::backdrop { background: rgba(15, 20, 30, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.1rem 1.25rem .5rem; }
.modal-body { padding: .5rem 1.25rem 1.25rem; }
.modal-body dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
.modal-body dt { color: var(--muted); }
.modal-body dd { margin: 0; font-weight: 500; }
.form { display: grid; gap: .85rem; }
.form label { display: grid; gap: .3rem; font-size: .88rem; font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }

.toast {
	position: fixed; left: 50%; bottom: 1.5rem;
	transform: translate(-50%, 1rem);
	background: #161a23; color: #fff;
	padding: .7rem 1.1rem; border-radius: 10px;
	font-size: .9rem;
	opacity: 0; pointer-events: none;
	transition: opacity .2s, transform .2s;
	max-width: calc(100vw - 2rem);
	z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
