:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f0f1ed;
  --text: #1b1f1c;
  --muted: #69716b;
  --border: #dfe2dc;
  --accent: #15803d;
  --accent-text: #ffffff;
  --danger: #b91c1c;
  --star: #e8a317;
  --home: #2563eb;
  --shadow: 0 6px 24px rgb(20 30 20 / 0.12);

  --r1: #16a34a;
  --r2: #ca8a04;
  --r3: #ea580c;
  --r4: #b91c1c;
  --rx: #6b7280;

  --radius: 10px;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111412;
    --surface: #1a1e1b;
    --surface-2: #232824;
    --text: #e8ebe7;
    --muted: #98a29a;
    --border: #2f3631;
    --accent: #22c55e;
    --accent-text: #08130b;
    --danger: #f87171;
    --star: #f5b83d;
    --home: #3b82f6;
    --shadow: 0 6px 24px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

body.app {
  display: grid;
  grid-template-columns: 228px 1fr;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }

.hidden { display: none !important; }

/* --- Navigation ------------------------------------------------------------ */

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; text-decoration: none; }
.brand-text { min-width: 0; }
.brand h1 { font-size: 16px; letter-spacing: -0.02em; line-height: 1.2; }
.brand p { color: var(--muted); font-size: 12px; }
.logo { display: grid; grid-template-columns: repeat(3, 6px); gap: 3px; padding: 6px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.logo span { width: 6px; height: 6px; border-radius: 50%; }
.logo .r1 { background: var(--r1); }
.logo .r2 { background: var(--r2); }
.logo .r3 { background: var(--r3); }
.logo .r4 { background: var(--r4); }

.nav svg, .icon-btn svg, .btn svg, .combo-icon, .back svg, .ext svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

.nav-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.nav-cta:hover { filter: brightness(1.06); }
.nav-cta.active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); }
.nav-links a.active { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); }
.nav-links a.active svg { color: var(--accent); }
.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.nav-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-usage {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}
.nav-usage strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* --- Inhalt & Ansichten ---------------------------------------------------------- */

.content { position: relative; min-width: 0; min-height: 0; height: 100vh; display: flex; flex-direction: column; }
.content > .alert { margin: 12px 16px 0; }
.view { flex: 1; min-height: 0; }

.view.page { overflow-y: auto; padding: 24px 32px 48px; }
.view.page > * { max-width: 1240px; margin-left: auto; margin-right: auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; letter-spacing: -0.02em; line-height: 1.2; }
.page-head .hint { margin-top: 4px; max-width: 640px; }
.page-head.compact { margin-bottom: 4px; }
.page-head.compact h2 { font-size: 20px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions select { width: auto; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.section-title { font-size: 15px; margin: 28px 0 10px; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.back:hover { color: var(--text); }
.back svg { width: 15px; height: 15px; }
.view.page > .back { display: flex; width: fit-content; margin-left: max(0px, calc((100% - 1240px) / 2)); }

.biz-hero { display: flex; gap: 14px; align-items: flex-start; }
.biz-hero .biz-dot { margin-top: 9px; }
.ext { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); text-decoration: none; }
.ext:hover { color: var(--text); }
.ext svg { width: 13px; height: 13px; }

/* KPI-Kacheln */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi-tile > span { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi-tile strong { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-tile small { font-size: 12px; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a {
  padding: 10px 14px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a span { font-size: 11px; padding: 1px 6px; margin-left: 4px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar select { width: auto; max-width: 100%; }

/* --- Karten & Formulare ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.card + .card { margin-top: 12px; }
.view.page .card { margin-bottom: 16px; }
.card h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.step {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
}
.card.disabled { opacity: 0.5; pointer-events: none; }
.card.disabled .step { background: var(--muted); }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
label small { font-size: 11px; font-weight: 400; }

input, select, button { font: inherit; }

input, select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}
input:hover, select:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--border)); }
input:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

.unit { position: relative; display: block; }
.unit input { padding-right: 34px; }
.unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm, button.sm { padding: 5px 9px; font-size: 12px; }
.btn.sm svg, button.sm svg { width: 14px; height: 14px; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover, button.primary:hover { background: var(--accent); filter: brightness(1.06); }
#scanBtn { width: 100%; height: 40px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

#scanForm { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

details.more summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  user-select: none;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  margin: 0 2px;
}
details.more[open] summary::before { transform: rotate(45deg); }
details.more summary:hover { color: var(--text); }
details.more[open] > .grid2 { margin-top: 10px; }

.auto-box { border-top: 1px solid var(--border); padding-top: 12px; }
.auto-box[open] { display: flex; flex-direction: column; gap: 10px; }
.auto-box[open] > .grid2 { margin-top: 0; }
.auto-box button { width: 100%; }

.hint { color: var(--muted); font-size: 12px; line-height: 1.45; }
.hint.center { text-align: center; margin-top: -4px; }
.hint strong { color: var(--text); font-weight: 600; }
#estimate strong { color: var(--accent); }
.hint.foot { margin-top: 8px; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: -4px; }
.chip { padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); }
.chip:hover { border-color: var(--accent); }

/* Unternehmen (Karte im Formular) */
.biz-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}
.biz-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--home); box-shadow: 0 0 0 3px color-mix(in srgb, var(--home) 22%, transparent); flex-shrink: 0; }
.biz-text { flex: 1; min-width: 0; }
.biz-text strong, .biz-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-text small { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* Bewertungen & Kategorie */
.place-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.place-meta:empty { display: none; }
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.rating b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.rating.none { font-style: italic; }
.stars { position: relative; display: inline-block; font-size: 13px; line-height: 1; letter-spacing: 1px; color: color-mix(in srgb, var(--muted) 35%, transparent); }
.stars::before { content: "★★★★★"; }
.stars::after { content: "★★★★★"; position: absolute; inset: 0 auto 0 0; width: var(--pct); overflow: hidden; color: var(--star); white-space: nowrap; }
.tag { font-size: 11px; color: var(--muted); padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }

/* Suche */
.combo { position: relative; }
.combo-icon { position: absolute; left: 10px; top: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 16px; height: 16px; }
.combo input { padding-left: 34px; }
.add-combo { width: min(360px, 100%); }

.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.results:empty { display: none; }
.results.suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 4px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.results li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.results li div { min-width: 0; }
.results strong { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li.active, .results li:hover { background: var(--surface-2); }
.results li.empty { color: var(--muted); cursor: default; }
.results mark { background: none; color: inherit; font-weight: 700; }

/* --- Tabellen ------------------------------------------------------------------------ */

.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:first-child td { border-top: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.tbl td small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.tbl tr[data-href], .tbl tr[data-comp] { cursor: pointer; }
.tbl tbody tr[data-href]:hover, .tbl tbody tr[data-comp]:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .actions > * + * { margin-left: 4px; }
.tbl .biz-cell { min-width: 200px; }
.tbl .biz-cell strong, .tbl .biz-cell > span { font-weight: 600; }

/* Kennzahl-Badges: Farbe als Markierung, Text in Textfarbe */
.m {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 52px;
  justify-content: flex-end;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.m::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); margin-right: auto; }
.m.r1 { --c: var(--r1); }
.m.r2 { --c: var(--r2); }
.m.r3 { --c: var(--r3); }
.m.r4 { --c: var(--r4); }
.m.none { --c: var(--rx); background: none; border-color: transparent; color: var(--muted); }
.m.none::before { display: none; }

.delta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--r1); }
.delta.bad { color: var(--danger); }
.kpi-tile .delta, .kpi .delta { display: inline; margin: 0; font-size: 12px; font-weight: 600; }

.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.live { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); color: var(--text); }
.badge.bad { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }
.badge.you { background: var(--home); color: #fff; }

/* Konkurrenztabelle */
.tbl.comp .pos { width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; padding-right: 4px; }
.tbl.comp .presence { font-size: 11px; }
.tbl.comp tr.me td { background: color-mix(in srgb, var(--home) 9%, var(--surface)); }
.tbl.comp tr.focus td { background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.tbl.comp tr.gap td { border-top: 2px dashed var(--border); }
.more-btn { margin-top: 10px; width: 100%; }

/* Mini-Heatmap */
.mini { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 1px; width: 58px; aspect-ratio: 1; }
.mini i { border-radius: 50%; background: var(--rx); min-width: 0; }
.mini.none { background: var(--surface-2); border-radius: 6px; }
.mini .r1 { background: var(--r1); }
.mini .r2 { background: var(--r2); }
.mini .r3 { background: var(--r3); }
.mini .r4 { background: var(--r4); }
.mini .p { background: color-mix(in srgb, var(--rx) 35%, transparent); }
.mini .e { background: var(--text); }
.mini.lg { width: min(260px, 100%); gap: 3px; }
.mini.lg i { display: grid; place-items: center; color: #fff; font: 700 clamp(7px, 1.6vw, 11px)/1 ui-sans-serif, system-ui, sans-serif; font-style: normal; }

.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

/* Auto-Scans */
.sched-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sched-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; }
.sched-list li.off { opacity: 0.6; }
.sched-list .meta { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.sched-list .meta a { font-size: 13px; color: var(--muted); }
.sched-list small { color: var(--muted); font-size: 12px; }
.sched-list .actions { display: flex; gap: 6px; align-items: center; }

/* Leerzustand */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; }
.empty-state h3 { font-size: 16px; }
.empty-state .hint { max-width: 420px; }
.empty-state .btn { margin-top: 8px; }
.empty-grid { display: grid; grid-template-columns: repeat(3, 10px); gap: 5px; margin-bottom: 6px; }
.empty-grid i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.empty-grid i:nth-child(5) { background: var(--home); }

/* Trend-Chart */
.chart-card .seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: none; background: transparent; padding: 4px 12px; font-size: 12px; border-radius: 6px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; max-height: 300px; cursor: pointer; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; transition: r 0.1s; }
.chart .dot.on { r: 6; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; }
.chart-tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}
.chart-tip .delta { display: inline; margin-left: 4px; }
.chart-tip small { color: var(--muted); font-size: 11px; }

/* Vorher / Nachher */
.ba { display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap; }
.ba-fig { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; padding: 10px; border-radius: 10px; }
.ba-fig:hover { background: var(--surface-2); }
.ba-cap { font-size: 12px; color: var(--muted); text-align: center; }
.ba-cap strong { color: var(--text); }
.ba-arrow { color: var(--muted); }
.ba-arrow svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }

/* --- Neuer Scan (Formular + Karte) --------------------------------------------------- */

.view.split { display: grid; grid-template-columns: 400px 1fr; }
.split-side { display: flex; flex-direction: column; gap: 12px; padding: 20px 16px 24px; overflow-y: auto; border-right: 1px solid var(--border); }
.split-side .card + .card { margin-top: 0; }
.split-main { position: relative; min-height: 0; }

/* --- Scan-Report ----------------------------------------------------------------------- */

.view.report { display: grid; grid-template-rows: auto 1fr; }
.report-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 8px 20px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.report-head .back { margin-bottom: 2px; }
.report-head h2 { font-size: 19px; letter-spacing: -0.01em; }
.report-head .progress, .report-head .rh-prev { grid-column: 1 / -1; }
.rh-kpis { display: flex; gap: 4px; }
.kpi { padding: 2px 12px; display: flex; flex-direction: column; align-items: center; min-width: 74px; border-left: 1px solid var(--border); }
.kpi:first-child { border-left: none; }
.kpi > span { font-size: 11px; color: var(--muted); letter-spacing: 0.05em; font-weight: 600; }
.kpi strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi small { line-height: 1; }
.rh-actions { display: flex; gap: 6px; align-items: center; }

.report-body { display: grid; grid-template-columns: 1fr 460px; min-height: 0; }
.report-map { position: relative; min-height: 0; }
.report-panel { overflow-y: auto; padding: 16px; background: var(--surface); border-left: 1px solid var(--border); min-height: 0; }
.panel-head { margin-bottom: 12px; }
.report-panel > .btn + .panel-head { margin-top: 12px; }
.panel-head h3 { font-size: 15px; margin-bottom: 4px; }
.report-panel .tbl-wrap { border-radius: 10px; }
.report-panel .tbl td, .report-panel .tbl th { padding: 8px; }
.report-panel .tbl .biz-cell { min-width: 0; }
.report-panel .m { min-width: 0; padding: 2px 6px; }
.report-panel .m::before { display: none; }
.report-panel .tbl.comp .pos { width: 26px; padding-left: 4px; }
.report-panel .tbl th { padding: 8px 6px; }
.report-panel .tbl td { padding: 8px 6px; }

.rank-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.rank-list li { display: flex; gap: 10px; align-items: baseline; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.rank-list li:hover { background: var(--surface-2); }
.rank-list li.me { background: color-mix(in srgb, var(--home) 12%, transparent); }
.rank-list li.focus { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.rank-list .pos { min-width: 26px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-list strong { font-weight: 600; }
.rank-list small { display: block; color: var(--muted); }

.progress { position: relative; height: 22px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width 0.3s; }
.progress span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 22px; font-variant-numeric: tabular-nums; mix-blend-mode: difference; color: #fff; }

.focus-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  max-width: calc(100% - 24px);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 2;
}

.legend {
  position: absolute;
  left: 12px;
  bottom: 24px;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 2;
}
.legend .pin { width: auto; min-width: 0; height: 24px; padding: 0 8px; border-radius: 999px; font-size: 11px; cursor: default; }

/* --- Karte ------------------------------------------------------------------------------ */

.map-slot { position: relative; height: 100%; min-height: 0; }
.map-wrap { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }

.grid-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 24px 72px;
  overflow: auto;
  background: var(--bg);
}
.fb-grid { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; width: min(100%, calc(var(--n) * 44px), 70vh); }
.fb-grid .pin { width: 100%; height: auto; min-width: 0; aspect-ratio: 1; padding: 0; font-size: clamp(8px, 1.1vw, 12px); }
.fb-grid .pin.preview { width: 100%; height: auto; min-width: 0; justify-self: center; transform: scale(0.45); }
.fb-grid .center { box-shadow: 0 0 0 3px var(--home); }

/* Rang-Pins (Karte + Legende) */
.pin {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 12px/1 ui-sans-serif, system-ui, sans-serif;
  color: #fff;
  border: 2px solid rgb(255 255 255 / 0.9);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pin.r1 { background: var(--r1); }
.pin.r2 { background: var(--r2); }
.pin.r3 { background: var(--r3); }
.pin.r4 { background: var(--r4); }
.pin.rx { background: var(--rx); }
.pin.pending { background: var(--rx); opacity: 0.55; }
.pin.preview { width: 12px; height: 12px; min-width: 12px; background: var(--rx); opacity: 0.7; cursor: default; }
.pin.err { background: #111; }
.pin.selected { outline: 3px solid var(--home); outline-offset: 1px; }

.home {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--home);
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.4);
}

/* --- Dialog & Toast ---------------------------------------------------------------- */

.dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.dialog h3 { font-size: 16px; margin: 0 36px 6px 0; }
.dialog .hint { margin-bottom: 12px; }
.dialog-close { position: absolute; top: 12px; right: 12px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: calc(100vw - 32px);
}

/* --- Login ------------------------------------------------------------------------------ */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 28px; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; letter-spacing: -0.02em; }
.login-card button { width: 100%; height: 40px; }
.login-grid { display: grid; grid-template-columns: repeat(3, 14px); gap: 6px; margin-bottom: 4px; }
.login-grid .pin { width: 14px; height: 14px; min-width: 14px; border-width: 0; box-shadow: none; cursor: default; }

/* --- Schmalere Bildschirme ------------------------------------------------------------- */

@media (max-width: 1180px) {
  .report-head { grid-template-columns: 1fr auto; }
  .rh-kpis { grid-column: 1 / -1; grid-row: 2; }
  .report-body { grid-template-columns: 1fr 380px; }
}

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100%; }
  .nav { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 16px; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .brand { padding: 0; }
  .brand-text p { display: none; }
  .nav-cta { order: 3; height: 34px; margin: 0; padding: 0 12px; }
  .nav-links { order: 4; flex-direction: row; width: 100%; overflow-x: auto; }
  .nav-links a { padding: 7px 10px; white-space: nowrap; }
  .nav-foot { order: 2; margin: 0 0 0 auto; padding: 0; border: none; }
  .content { height: auto; }
  .view.page { padding: 16px 16px 40px; overflow: visible; }
  .view.split { display: flex; flex-direction: column; }
  .split-side { border-right: none; padding: 16px; overflow: visible; }
  .split-main { height: 60vh; flex: none; }
  .view.report { display: flex; flex-direction: column; }
  .report-head { grid-template-columns: 1fr; padding: 12px 16px; }
  .rh-kpis { grid-row: auto; justify-content: space-between; }
  .kpi { min-width: 0; padding: 2px 6px; }
  .report-body { display: flex; flex-direction: column; }
  .report-map { height: 60vh; flex: none; }
  .report-panel { border-left: none; border-top: 1px solid var(--border); padding: 16px; overflow: visible; }
  .focus-banner { left: 12px; right: 12px; transform: none; flex-wrap: wrap; }
  .legend { bottom: 12px; flex-wrap: wrap; right: 12px; }
  .page-head h2 { font-size: 20px; }
  .add-combo { width: 100%; }
}
