:root {
	--bg: #f4f3f1;
	--surface: #ffffff;
	--surface-sunken: #ece9e4;
	--border: rgba(28, 27, 25, 0.1);
	--text: #1c1b19;
	--text-muted: #6e6a63;
	--text-faint: #9c988f;
	--taupe: #a89b8c;
	--accent: #1c1b19;
	--accent-text: #ffffff;
	--brand-green: #4e9a35;
	--good-bg: #e7f1e4;
	--good-text: #3f6b2f;
	--bad-bg: #fbe9e7;
	--bad-text: #9a3324;
	--warn-bg: #fbf1dc;
	--warn-text: #8a6214;
	--radius-sm: 8px;
	--radius: 12px;
	--shadow-card: 0 1px 2px rgba(28, 27, 25, 0.05);
	--shadow-hover: 0 10px 28px rgba(28, 27, 25, 0.1);
}

:root[data-theme="dark"] {
	--bg: #221f1b;
	--surface: #2a2622;
	--surface-sunken: #332e28;
	--border: rgba(255, 255, 255, 0.09);
	--text: #f4f2ee;
	--text-muted: #b2ac9f;
	--text-faint: #7d786d;
	--taupe: #c3b6a5;
	--accent: #f4f2ee;
	--accent-text: #1c1b19;
	--brand-green: #6fc24f;
	--good-bg: rgba(122, 183, 94, 0.16);
	--good-text: #9bd37e;
	--bad-bg: rgba(224, 122, 102, 0.16);
	--bad-text: #e2a494;
	--warn-bg: rgba(214, 168, 74, 0.16);
	--warn-text: #e3c17e;
	--shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
	--shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #221f1b;
		--surface: #2a2622;
		--surface-sunken: #332e28;
		--border: rgba(255, 255, 255, 0.09);
		--text: #f4f2ee;
		--text-muted: #b2ac9f;
		--text-faint: #7d786d;
		--taupe: #c3b6a5;
		--accent: #f4f2ee;
		--accent-text: #1c1b19;
		--brand-green: #6fc24f;
		--good-bg: rgba(122, 183, 94, 0.16);
		--good-text: #9bd37e;
		--bad-bg: rgba(224, 122, 102, 0.16);
		--bad-text: #e2a494;
		--warn-bg: rgba(214, 168, 74, 0.16);
		--warn-text: #e3c17e;
		--shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
		--shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.4);
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.nums { font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
button { font-family: inherit; }

/* ---------- Header ---------- */
header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 28px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	position: sticky;
	top: 0;
	z-index: 10;
}
.wordmark { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 9px; cursor: pointer; }
.wordmark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-green); flex: none; align-self: center; }
.wordmark .scanner { color: var(--text-faint); font-weight: 400; }
.header-nav { display: flex; align-items: center; gap: 18px; }
.header-nav a { color: var(--text-muted); text-decoration: none; font-size: 13px; cursor: pointer; }
.header-nav a.active { color: var(--text); font-weight: 600; }
.header-meta { color: var(--text-muted); font-size: 12px; }
.theme-toggle { border: none; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 8px 16px; font-size: 12.5px; font-weight: 500; cursor: pointer; }

.shell { max-width: 1440px; margin: 0 auto; padding: 26px 28px 64px; }
.view { display: none; }
.view.active { display: block; }

.eyebrow { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 999px; padding: 5px 13px; font-size: 11.5px; margin-bottom: 14px; }
.eyebrow .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-green); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 22px; border-top: 1px solid var(--border); padding-top: 18px; }
.stat { padding: 0 24px; border-left: 1px solid var(--border); }
.stat:first-child { padding-left: 0; border-left: none; }
.stat .label { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.stat .value { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.stat .value .plus { color: var(--taupe); font-weight: 600; font-size: 18px; }
.stat .value.good { color: var(--good-text); }
.stat .sub { color: var(--text-faint); font-size: 12px; margin-top: 6px; }

/* ---------- Filter bar ---------- */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; position: sticky; top: 65px; z-index: 5; box-shadow: var(--shadow-card); }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface-sunken); color: var(--text-muted); border-radius: 999px; padding: 5px 13px; font-size: 12.5px; cursor: pointer; user-select: none; }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.mehrfamilienhaus { font-weight: 600; }
.chip.mehrfamilienhaus.active { background: var(--brand-green); color: #fff; border-color: var(--brand-green); }
.filterbar .sep { width: 1px; height: 22px; background: var(--border); }
.field { display: flex; align-items: center; gap: 6px; }
.field label { color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select { border: 1px solid var(--border); background: var(--surface-sunken); border-radius: 6px; padding: 5px 8px; font-size: 12.5px; color: var(--text); width: 84px; font-family: inherit; }
.field select { width: auto; }
.filterbar .spacer { flex: 1; }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; padding: 2px; gap: 2px; background: var(--surface-sunken); }
.view-toggle button { border: none; background: transparent; color: var(--text-muted); padding: 6px 14px; font-size: 12.5px; cursor: pointer; border-radius: 999px; }
.view-toggle button.active { background: var(--accent); color: var(--accent-text); }
.map-toggle { border: 1px solid var(--border); background: var(--surface-sunken); color: var(--text); border-radius: 999px; padding: 7px 15px; font-size: 12.5px; cursor: pointer; }
.map-toggle.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.main-split { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.main-split.map-hidden { grid-template-columns: 1fr; }
.main-split.map-hidden .map-panel { display: none; }

.badge { display: inline-flex; align-items: center; gap: 3px; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.neu { background: var(--good-bg); color: var(--good-text); }
.badge.up { background: var(--bad-bg); color: var(--bad-text); }
.badge.down { background: var(--good-bg); color: var(--good-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.mfh { background: var(--taupe); color: #fff; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); transition: box-shadow 180ms ease, transform 180ms ease; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card-media { position: relative; aspect-ratio: 16 / 10; background: var(--surface-sunken); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media .no-img { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.card-media .no-img svg { width: 34px; height: 34px; opacity: 0.5; }
.card-media .card-badges { position: absolute; top: 10px; left: 10px; }
.card-media .card-makler { position: absolute; top: 10px; right: 10px; background: rgba(28, 27, 25, 0.55); color: #fff; backdrop-filter: blur(4px); padding: 3px 9px; border-radius: 999px; font-size: 11px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.card-badges .badge { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.card-makler { color: var(--text-faint); font-size: 11.5px; }
.card-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.card-meta { color: var(--text-muted); font-size: 12.5px; }
.card-bottom { display: flex; align-items: baseline; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.card-price { font-size: 18px; font-weight: 700; }
.preis-anfrage { font-size: 14px; font-weight: 500; font-style: italic; color: var(--text-faint); }
.card-price .delta { font-size: 11.5px; font-weight: 600; margin-left: 6px; }
.card-price .delta.up { color: var(--bad-text); }
.card-price .delta.down { color: var(--good-text); }
.card-metrics { color: var(--text-faint); font-size: 12px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; padding: 11px 14px; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-sunken); }
tbody tr { cursor: pointer; }
td.title-cell { max-width: 300px; }
td.title-cell .t { font-weight: 600; display: block; }
td.title-cell .m { color: var(--text-faint); font-size: 11.5px; }
td.thumb-cell { width: 52px; padding-right: 0; }
.thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; display: block; background: var(--surface-sunken); }
.thumb-empty { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.thumb-empty svg { width: 18px; height: 18px; opacity: 0.5; }
td.price-cell { font-weight: 700; white-space: nowrap; }
td.price-cell .delta { font-size: 11px; font-weight: 600; margin-left: 5px; }
td.price-cell .delta.up { color: var(--bad-text); }
td.price-cell .delta.down { color: var(--good-text); }
td.num { white-space: nowrap; }

.map-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: sticky; top: 130px; }
.map-panel .map-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.map-panel .map-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
#leafletMap { height: 340px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-sunken); }
.map-caption { color: var(--text-faint); font-size: 11px; margin-top: 8px; line-height: 1.5; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }

/* ---------- Makler-Verwaltung ---------- */
.makler-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.makler-list { display: flex; flex-direction: column; gap: 10px; }
.makler-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.makler-row .mname { font-weight: 600; font-size: 14px; }
.makler-row .murl { color: var(--text-faint); font-size: 12px; word-break: break-all; }
.makler-row .mmeta { color: var(--text-muted); font-size: 12px; display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.makler-row .mactions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn { border: 1px solid var(--border); background: var(--surface-sunken); color: var(--text-muted); border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad-text); border-color: var(--bad-text); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: var(--brand-green); }
.status-dot.fehler { background: var(--bad-text); }
.status-dot.aus { background: var(--text-faint); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 14px; }
.panel .field-full { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.panel .field-full label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.panel .field-full input { border: 1px solid var(--border); background: var(--surface-sunken); border-radius: 8px; padding: 9px 11px; font-size: 13px; color: var(--text); font-family: inherit; }
.btn-primary { width: 100%; border: none; background: var(--accent); color: var(--accent-text); border-radius: var(--radius-sm); padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.form-msg { font-size: 12px; margin-top: 10px; }
.form-msg.err { color: var(--bad-text); }
.form-msg.ok { color: var(--good-text); }

.toggle { position: relative; width: 34px; height: 20px; flex: none; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 999px; pointer-events: none; transition: background 150ms; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-faint); transition: transform 150ms, background 150ms; pointer-events: none; }
.toggle input:checked ~ .track { background: var(--brand-green); border-color: var(--brand-green); }
.toggle input:checked ~ .knob { transform: translateX(14px); background: #fff; }

footer.hint { margin-top: 28px; color: var(--text-faint); font-size: 11.5px; text-align: center; }

@media (max-width: 900px) {
	.main-split, .makler-grid { grid-template-columns: 1fr; }
	.cards { grid-template-columns: 1fr; }
	.stats { grid-template-columns: repeat(2, 1fr); row-gap: 18px; }
	.stat:nth-child(3) { border-left: none; padding-left: 0; }
}

/* ---------- Mobil: kompakter Header/Stats/Filter, damit die Objekte
   nicht hinter viel Chrome verschwinden. Filterbar bleibt sticky, aber
   als eine einzige horizontal scrollbare Zeile statt 5 umgebrochener. */
@media (max-width: 640px) {
	header { padding: 10px 14px; }
	.wordmark { font-size: 16px; gap: 6px; }
	.wordmark .dot { width: 7px; height: 7px; }
	.header-nav { gap: 10px; }
	.header-nav a { font-size: 12px; }
	.header-meta { display: none; }
	.theme-toggle { padding: 6px 11px; font-size: 11px; }

	.shell { padding: 14px 14px 40px; }

	.eyebrow { display: none; }

	.stats { gap: 0; margin-bottom: 14px; padding-top: 12px; row-gap: 12px; }
	.stat { padding: 0 12px; }
	.stat .label { font-size: 9.5px; margin-bottom: 4px; }
	.stat .value { font-size: 20px; }
	.stat .value .plus { font-size: 13px; }
	.stat .sub { display: none; }

	.filterbar {
		top: 48px;
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		padding: 10px 12px;
		gap: 8px;
		margin-bottom: 12px;
	}
	.filterbar::-webkit-scrollbar { display: none; }
	.chip-group { flex-wrap: nowrap; flex: none; }
	.chip { white-space: nowrap; flex: none; padding: 5px 11px; font-size: 12px; }
	.filterbar .sep { flex: none; }
	.field { flex: none; }
	.field input, .field select { width: 64px; }
	.filterbar .spacer { display: none; }
	.view-toggle, .map-toggle { flex: none; }

	.card-title { font-size: 13.5px; }
	.card-body { padding: 12px 14px 14px; }
}
