/* Belästigungs-Tracker – ruhiges, seriöses Erscheinungsbild.
   Farbpalette: „Security blue + protected green“ (ui-ux-pro-max, Insurance/Trust), Systemschriften (keine externen Fonts). */

:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --surface-3: #e2e8f0;
  --text: #0f1b2d;
  --text-muted: #4a5568;
  --border: #d5dde6;
  --border-strong: #a9b6c5;
  --primary: #0369a1;
  --primary-hover: #075985;
  --on-primary: #ffffff;
  --primary-soft: #e0f0fa;
  --primary-soft-text: #075985;
  --ok: #166534;
  --ok-soft: #e6f4ea;
  --warn: #8a5a00;
  --warn-soft: #fdf4dc;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --info-soft: #e7f1f8;
  --focus: #0369a1;
  --heat-rgb: 3 105 161;
  --bar-a: #0369a1;
  --bar-b: #d97706;
  --bubble-in: #ffffff;
  --bubble-out: #dcf0e3;
  --shadow: 0 1px 2px rgb(15 27 45 / 0.06), 0 2px 8px rgb(15 27 45 / 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --dur: 160ms;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2c;
    --surface-2: #1b2638;
    --surface-3: #25334a;
    --text: #e6edf5;
    --text-muted: #a7b4c4;
    --border: #2a3850;
    --border-strong: #42526d;
    --primary: #4cb3ea;
    --primary-hover: #7cc8f0;
    --on-primary: #04121f;
    --primary-soft: #0f2c42;
    --primary-soft-text: #9fd6f5;
    --ok: #4ade80;
    --ok-soft: #10301f;
    --warn: #fbbf24;
    --warn-soft: #33270b;
    --danger: #f87171;
    --danger-soft: #3a1414;
    --info-soft: #11263a;
    --focus: #7cc8f0;
    --heat-rgb: 76 179 234;
    --bar-a: #4cb3ea;
    --bar-b: #f59e0b;
    --bubble-in: #1b2638;
    --bubble-out: #12372a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
p { margin: 0 0 0.5rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--primary); }
img, svg, video { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; vertical-align: middle; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 8px; top: -60px; z-index: 100; padding: 10px 16px; min-height: var(--tap);
  background: var(--primary); color: var(--on-primary); border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.skip-link:focus { top: calc(8px + env(safe-area-inset-top)); }

.muted { color: var(--text-muted); }
.small { font-size: 0.9rem; }
.fine { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.5rem; }
.error-text { color: var(--danger); }
.ok-text { color: var(--ok); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.big-number { font-size: 2.25rem; font-weight: 700; line-height: 1.1; }
.hash { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); word-break: break-all; }
.phone { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.flag { font-size: 1.3em; line-height: 1; }
.flag-lg { font-size: 2.2rem; }
kbd {
  font-family: var(--font); font-size: 0.9em; padding: 1px 7px; border-radius: 6px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: inset 0 -1px 0 var(--border);
}
pre.code {
  font-family: var(--mono); font-size: 0.95rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ---------- Boot / Login ---------- */
.boot {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center; color: var(--text-muted);
}
.auth-screen {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 28px 22px; display: flex; flex-direction: column; gap: 14px;
}
.auth-card > img { align-self: center; }
.auth-card h1 { text-align: center; font-size: 1.5rem; }
.auth-card > p { text-align: center; }
.noscript { padding: 24px; text-align: center; }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; padding-left: calc(16px + env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.5) blur(10px); backdrop-filter: saturate(1.5) blur(10px);
}
@supports not (background: color-mix(in srgb, red, blue)) { .topbar { background: var(--surface); } }
.topbar-title { font-weight: 650; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.live-dot[data-state="open"] { background: var(--ok); }
.live-dot[data-state="connecting"] { background: var(--warn); }

.main {
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 1180px; margin: 0 auto; outline: none;
}
.view { display: flex; flex-direction: column; gap: 16px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-muted);
  border: 0; background: none; cursor: pointer; font: inherit; transition: background-color var(--dur), color var(--dur);
}
.nav-tab { flex-direction: column; justify-content: center; gap: 2px; min-height: 56px; font-size: 0.75rem; font-weight: 600; border-radius: 12px; }
.nav-tab.active { color: var(--primary); }
.nav-tab.active .icon { stroke-width: 2.4; }
.nav-tab:active { background: var(--surface-2); }
.nav-badge {
  position: absolute; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 0.72rem; font-weight: 700;
  line-height: 20px; text-align: center; background: var(--danger); color: #fff;
}
.nav-tab .nav-badge { top: 4px; left: calc(50% + 6px); }
.sidebar { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px;
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 4px 10px 16px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-side { min-height: 48px; padding: 10px 12px; border-radius: 10px; font-weight: 550; color: var(--text); width: 100%; text-align: left; }
  .nav-side:hover { background: var(--surface-2); }
  .nav-side.active { background: var(--primary-soft); color: var(--primary-soft-text); }
  .nav-side .nav-badge { position: static; margin-left: auto; }
  .sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
  .side-user { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); padding: 0 12px 6px; }
  .main { padding: 32px 40px 48px; width: 100%; }
  .view { gap: 20px; }
}

/* ---------- Seitenkopf ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-title { font-size: 1.6rem; font-weight: 700; outline: none; }
.page-sub { color: var(--text-muted); margin: 4px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 599px) {
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1; }
}
.back-link {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); text-decoration: none; font-weight: 600;
  align-self: flex-start; padding-right: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: 1rem;
  text-decoration: none; cursor: pointer; transition: background-color var(--dur), border-color var(--dur), opacity var(--dur);
  text-align: center; line-height: 1.25; touch-action: manipulation;
}
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.btn-block { width: 100%; }
.btn-small { padding: 8px 14px; font-size: 0.95rem; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn:active { opacity: 0.85; }
.btn.is-busy { pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); flex: none;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--danger); }
.text-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* ---------- Karten ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
@media (min-width: 600px) { .card { padding: 20px; } }
.card-title { font-size: 1.15rem; font-weight: 700; }
.card-accent { border-color: var(--primary); border-width: 2px; }
.sub-title { font-size: 1rem; font-weight: 700; margin-top: 8px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Hinweise ---------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--info-soft);
}
.notice-icon { margin-top: 2px; color: var(--primary); }
.notice-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.notice-title { display: block; }
.notice-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.notice-warn .notice-icon { color: var(--warn); }
.notice-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.notice-error .notice-icon { color: var(--danger); }
.notice-success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.notice-success .notice-icon { color: var(--ok); }
.status-area:empty { display: none; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--text-muted); padding: 12px 0; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 28px 12px; color: var(--text-muted); }
.empty .icon { color: var(--primary); opacity: 0.7; }
.empty-title { font-weight: 700; color: var(--text); font-size: 1.1rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.82rem;
  font-weight: 650; white-space: nowrap; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  text-decoration: none;
}
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-link { min-height: var(--tap); padding: 4px 14px; color: var(--primary-soft-text); background: var(--primary-soft); border-color: transparent; }
.st-new { background: var(--primary-soft); color: var(--primary-soft-text); border-color: transparent; }
.st-reviewing { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st-reported { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-blocked { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.st-dismissed { background: var(--surface-2); color: var(--text-muted); }
.risk-low { color: var(--ok); }
.risk-mid { color: var(--warn); }
.risk-high { color: var(--danger); }
.badge.risk-low { background: var(--ok-soft); border-color: transparent; }
.badge.risk-mid { background: var(--warn-soft); border-color: transparent; }
.badge.risk-high { background: var(--danger-soft); border-color: transparent; }

/* ---------- Dashboard ---------- */
.wa-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); text-decoration: none; color: var(--text);
}
.wa-card:hover { border-color: var(--border-strong); }
.wa-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.wa-cta { font-weight: 600; color: var(--primary); }
.wa-bad, .wa-off { border-left: 4px solid var(--border-strong); }
.wa-bad { border-left-color: var(--danger); }
.wa-ok { border-left: 4px solid var(--ok); }
.wa-warn { border-left: 4px solid var(--warn); }
.chev { color: var(--text-muted); }
.status-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--border-strong); }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot-bad { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.dot-off { background: var(--border-strong); box-shadow: 0 0 0 4px var(--surface-2); }

.kpis { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi {
  display: flex; flex-direction: column; height: 100%; padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--shadow); min-height: 96px;
}
a.kpi:hover { border-color: var(--primary); }
.kpi-value { font-size: 1.75rem; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-label { font-weight: 650; }
.kpi-sub { font-size: 0.82rem; color: var(--text-muted); }

.threat { display: flex; align-items: center; gap: 16px; }
.threat-level { font-size: 1.4rem; font-weight: 750; margin: 0; }
.trend { display: flex; align-items: center; gap: 4px; font-weight: 600; margin: 2px 0 6px; }
.score-ring-wrap { position: relative; width: 120px; flex: none; }
.score-ring { width: 120px; height: auto; display: block; }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 10; stroke-linecap: round; }
.ring-fill { fill: none; stroke: currentColor; stroke-width: 10; stroke-linecap: round; }
.score-ring-value { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 1.6rem; font-weight: 750; line-height: 1; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini-list li + li { border-top: 1px solid var(--border); }
.mini-incident { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-height: 56px; text-decoration: none; color: var(--text); }
.mini-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mini-badges { display: none; gap: 6px; }
@media (min-width: 600px) { .mini-badges { display: flex; } }

/* ---------- Diagramme ---------- */
.chart { margin: 0; position: relative; }
.chart-svg { width: 100%; display: block; overflow: visible; }
.chart-bar { fill: var(--bar-a); }
.chart-bar.bar-b { fill: var(--bar-b); }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-max { font-size: 0.8rem; color: var(--text-muted); text-align: right; }
.chart-ticks { position: relative; height: 22px; font-size: 0.78rem; color: var(--text-muted); }
.chart-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; top: 4px; }
.chart-ticks span:first-child { transform: none; left: 0 !important; }
.chart-ticks span:last-child { transform: none; left: auto !important; right: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.88rem; color: var(--text-muted); margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--bar-a); }
.legend-swatch.bar-b { background: var(--bar-b); }

.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap { display: flex; flex-direction: column; gap: 3px; min-width: 330px; }
.hm-row { display: grid; grid-template-columns: 28px repeat(24, minmax(10px, 1fr)); gap: 3px; align-items: center; }
.hm-day, .hm-hour { font-size: 0.75rem; color: var(--text-muted); }
.hm-hour { text-align: left; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.hm-legend { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.hm-scale { width: 100px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, rgb(var(--heat-rgb) / 0.15), rgb(var(--heat-rgb) / 1)); }

.barlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.barlist-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.95rem; }
.barlist-label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.barlist-count { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.barlist-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.barlist-fill { height: 100%; background: var(--primary); border-radius: 4px; }

.confidence { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conf-track { flex: 1; min-width: 120px; max-width: 280px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.conf-fill { height: 100%; border-radius: 4px; }
.conf-hoch { background: var(--ok); }
.conf-mittel { background: var(--warn); }
.conf-gering { background: var(--border-strong); }
.conf-text { font-size: 0.85rem; color: var(--text-muted); }

.stack-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.stack-list > li { padding: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.stack-list > li + li { border-top: 1px solid var(--border); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 4px 14px; border-radius: 999px; font-size: 0.9rem;
  background: var(--primary-soft); color: var(--primary-soft-text); text-decoration: none; font-weight: 600;
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }

/* ---------- Listen ---------- */
.dot-list { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 4px; }
.steps { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 8px; }
.guide { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: g; }
.guide li { display: flex; align-items: flex-start; gap: 12px; counter-increment: g; }
.step-icon {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center;
  justify-content: center; background: var(--primary-soft); color: var(--primary-soft-text);
}
.step-icon::after {
  content: counter(g); position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%;
  font-size: 0.72rem; font-weight: 700; line-height: 20px; text-align: center; background: var(--primary); color: var(--on-primary);
}
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.row-list li + li { border-top: 1px solid var(--border); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.factor-list { list-style: none; margin: 0; padding: 0; }
.factor-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.factor-pts { font-weight: 700; color: var(--warn); white-space: nowrap; }

.menu { list-style: none; margin: 0; padding: 4px 0; gap: 0; }
.menu li + li { border-top: 1px solid var(--border); }
.menu-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 10px 16px; text-decoration: none;
  color: var(--text); background: none; border: 0; cursor: pointer; text-align: left; font: inherit;
}
.menu-icon {
  width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary-soft-text); flex: none;
}
.menu-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Vorfall-Liste ---------- */
.toolbar { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.toolbar .search-box { grid-column: 1 / -1; }
@media (min-width: 760px) { .toolbar { grid-template-columns: 1fr auto auto; } .toolbar .search-box { grid-column: auto; } }
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 48px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-muted);
}
.search-box:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.search-box input { flex: 1; border: 0; background: transparent; min-height: 46px; outline: none; color: var(--text); min-width: 0; }
.list-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.incident-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.incident-card {
  display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: border-color var(--dur);
}
.incident-card:hover { border-color: var(--border-strong); }
.incident-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.inc-check { display: flex; align-items: flex-start; justify-content: center; padding: 14px 4px 14px 12px; min-width: 48px; cursor: pointer; }
.inc-link { flex: 1; min-width: 0; padding: 12px 4px 12px 4px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.incident-card > .chev { align-self: center; margin-right: 10px; }
.inc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inc-top .phone { font-size: 1.1rem; }
.inc-top .badge { margin-left: auto; }
.inc-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.95rem; }
.inc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 0.88rem; color: var(--text-muted); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--primary); margin: 0; cursor: pointer; flex: none; }
.check-inline { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.bulk-bar {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--primary); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}
.bulk-count { flex: 1 0 100%; }
@media (min-width: 600px) { .bulk-count { flex: 0 1 auto; margin-right: auto; } }
@media (min-width: 900px) { .bulk-bar { left: 280px; right: 24px; bottom: 20px; } }
.view.has-bulk { padding-bottom: 120px; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.card { gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .form-row { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-weight: 650; }
.field-inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }
.field-hint { font-size: 0.875rem; color: var(--text-muted); margin: 0; }
.field-error { font-size: 0.9rem; color: var(--danger); margin: 0; font-weight: 600; }
input[type="text"], input[type="tel"], input[type="search"], input[type="password"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 1rem;
}
.search-box input[type="search"] { border: 0; padding: 0; min-height: 46px; }
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
.select-wrap { display: block; min-width: 0; }
.field-inline select { width: auto; flex: 1; min-width: 180px; }
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.8; }
.file-input {
  width: 100%; min-height: 48px; padding: 8px; border: 2px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); cursor: pointer;
}
.file-input::file-selector-button {
  min-height: 40px; padding: 6px 14px; margin-right: 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}

.segmented { display: flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 14px; border: 1px solid var(--border); }
.seg-btn {
  flex: 1; min-height: var(--tap); border: 0; border-radius: 10px; background: transparent; font-weight: 650; cursor: pointer;
  color: var(--text-muted); padding: 6px 10px; line-height: 1.2; transition: background-color var(--dur), color var(--dur);
}
.seg-btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.switch { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; min-height: var(--tap); padding: 4px 0; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none; position: relative; width: 52px; height: 32px; border-radius: 16px; background: var(--surface-3);
  border: 1px solid var(--border-strong); transition: background-color var(--dur); margin-top: 2px;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform var(--dur);
}
.switch-input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch-input:checked + .switch-track::after { transform: translateX(20px); }
.switch-input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-label { font-weight: 650; }

details.disclosure > summary {
  display: flex; align-items: center; gap: 6px; min-height: var(--tap); cursor: pointer; font-weight: 650; color: var(--primary);
  list-style: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "▸"; margin-left: auto; transition: transform var(--dur); color: var(--text-muted); }
details.disclosure[open] > summary::after { transform: rotate(90deg); }
details.disclosure[open] > summary { margin-bottom: 8px; }

.check-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.check-list li + li { border-top: 1px solid var(--border); }
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 56px; cursor: pointer; }
.check-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Vorfall-Detail ---------- */
.detail-head { gap: 12px; }
.detail-title { display: flex; align-items: flex-start; gap: 12px; }
.detail-title > div { flex: 1; min-width: 0; }
.detail-title .page-title { font-size: 1.5rem; overflow-wrap: anywhere; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 1100px) { .detail-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
@media (max-width: 1099px) { .detail-side { order: -1; } }

.chat { list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border-radius: var(--radius-sm); max-height: 70vh; overflow-y: auto; }
.chat-day { align-self: center; font-size: 0.8rem; color: var(--text-muted); }
.chat-day span { background: var(--surface); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; }
.bubble {
  max-width: min(85%, 520px); padding: 8px 12px; border-radius: 14px; background: var(--bubble-in); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere;
}
.bubble.in { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 4px; }
.bubble-text { white-space: pre-wrap; margin: 0; }
.bubble-meta { font-size: 0.75rem; color: var(--text-muted); margin: 0; }
.bubble-meta .hash { font-size: 0.72rem; }
.media-img { border-radius: 10px; max-height: 320px; width: auto; display: block; background: var(--surface-3); }
.media-sticker { width: 140px; height: 140px; object-fit: contain; }
.media-audio { width: 100%; min-width: 220px; height: 44px; }
.media-video { border-radius: 10px; max-height: 360px; width: 100%; background: #000; }
.media-missing { font-style: italic; color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.attach-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.attach { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.attach img { width: 100%; height: 150px; object-fit: cover; display: block; }
.attach-file { height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-decoration: none; font-weight: 600; }
.attach-meta { padding: 8px 10px; font-size: 0.9rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
.tl-title { font-weight: 650; margin: 0; }
.tl-detail { margin: 0; overflow-wrap: anywhere; }
.tpl { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.tpl-body {
  white-space: pre-wrap; font-family: var(--font); font-size: 0.95rem; margin: 0; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); max-height: 320px; overflow-y: auto; overflow-wrap: anywhere;
}

/* ---------- WhatsApp ---------- */
.wa-status-row { display: flex; align-items: flex-start; gap: 14px; }
.wa-status-row .status-dot { margin-top: 6px; }
.wa-status-label { font-size: 1.3rem; font-weight: 750; margin: 0; }
.pair-code {
  font-family: var(--mono); font-size: clamp(2rem, 9vw, 3rem); font-weight: 800; letter-spacing: 0.12em; text-align: center;
  padding: 16px 8px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary-soft-text); margin: 4px 0 8px;
  user-select: all; -webkit-user-select: all;
}
.qr-box { display: flex; justify-content: center; padding: 16px; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); min-height: 200px; align-items: center; }
.qr-box img { width: 264px; height: 264px; image-rendering: pixelated; }
.qr-box .loading { color: #4a5568; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 60; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
@media (min-width: 900px) { .toasts { left: auto; right: 24px; top: 24px; width: 380px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); animation: toast-in 200ms ease-out;
}
.toast-error { background: var(--danger); color: #fff; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action { min-height: var(--tap); padding: 4px 12px; border-radius: 10px; border: 1px solid currentColor; background: transparent; color: inherit; font-weight: 700; cursor: pointer; }
.toast-close { width: var(--tap); height: var(--tap); border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.toast-out { opacity: 0; transition: opacity 180ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Dialog ---------- */
.dialog {
  border: 0; border-radius: 18px; padding: 22px; width: min(92vw, 440px); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
}
.dialog::backdrop { background: rgb(8 14 26 / 0.6); }
.dialog h2 { font-size: 1.2rem; margin-bottom: 8px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-actions .btn { flex: 1 1 140px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .tabbar, .sidebar, .topbar, .toasts, .bulk-bar, .page-actions, .btn, details.disclosure > summary { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
