/* Home-Assistant-Look, hell/dunkel. Umschaltbar per URL: ?theme=dark | light (Standard: Systemeinstellung) */
:root {
  --bg: #fafafa; --panel: rgba(255,255,255,.88); --panel2: #eceff1; --line: rgba(0,0,0,.12);
  --text: #212121; --muted: #727272; --primary: #03a9f4;
  --blocked: #ff9800; --ips: #f44336; --crowdsec: #ab47bc; --web: #03a9f4; --ok: #4caf50; --bad: #db4437;
  --shadow: 0 2px 8px rgba(0,0,0,.18); --r: 12px; --mapbg: #e8ecef;
}
:root[data-theme="dark"] {
  --bg: #111111; --panel: rgba(28,28,28,.86); --panel2: #2a2a2a; --line: rgba(225,225,225,.14);
  --text: #e1e1e1; --muted: #9b9b9b; --ok: #66bb6a; --bad: #ef5350; --shadow: 0 2px 10px rgba(0,0,0,.5); --mapbg: #1a1c1f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.45 Roboto, "Noto Sans", "Segoe UI", system-ui, sans-serif; }
.hidden { display: none !important; }
#map { position: absolute; inset: 0; background: var(--mapbg); font: inherit; }
.leaflet-control-attribution { background: var(--panel) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); backdrop-filter: blur(8px); }

.hud { position: absolute; z-index: 800; }
.hud, .hud * { -webkit-user-select: none; user-select: none; }
.panel, .top .title, .kpi, .seg, .side, .traffic, .legend { background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: var(--shadow); border-radius: var(--r); }

.top { left: 12px; right: 12px; top: 12px; display: flex; gap: 10px; align-items: stretch; pointer-events: none; flex-wrap: wrap; }
.top > * { pointer-events: auto; }
.title { display: flex; align-items: center; gap: 10px; padding: 0 16px; min-height: 44px; font-size: 15px; }
.title b { font-weight: 500; }
.live { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.live.on { background: var(--ok); animation: beat 2s infinite; }
.live.off { background: var(--blocked); }
@keyframes beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 10px; background: var(--blocked); color: #fff; }

.kpis { display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.kpi { display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 8px; min-height: 44px; pointer-events: auto; }
.kpi::before { content: ""; flex: none; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle, var(--c) 0 5px, color-mix(in srgb, var(--c) 22%, transparent) 6px); }
.kpi .n { font-size: 18px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11px; color: var(--muted); line-height: 1.1; }
.kpi.bump .n { animation: bump .5s ease-out; }
@keyframes bump { 30% { transform: scale(1.25); color: var(--c); } }

.seg { margin-left: auto; display: inline-flex; padding: 4px; gap: 2px; align-self: flex-start; border-radius: 22px; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 18px; font: inherit; font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }

.side { right: 12px; top: 68px; bottom: 56px; width: min(320px, 34vw); padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); animation: slide .35s ease-out; }
.feed li:last-child { border: 0; }
@keyframes slide { from { opacity: 0; transform: translateY(-6px); } }
.feed .k { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--c); }
.feed .ip { font-size: 11.5px; color: var(--muted); }
.feed .t { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 4px 0; }
.bar-row { display: grid; grid-template-columns: 1fr 70px 38px; gap: 8px; align-items: center; margin: 5px 0; }
.bar-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .b { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; }
.bar-row .b > span { display: block; height: 100%; background: var(--ips); }
.bar-row .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 6px 0; padding: 3px 10px; border-radius: 14px; background: var(--panel2); font-size: 11.5px; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--st); }

.bottom { left: 12px; right: 12px; bottom: 12px; display: flex; gap: 10px; align-items: flex-end; pointer-events: none; flex-wrap: wrap; }
.bottom > * { pointer-events: auto; }
.traffic { padding: 10px 14px; width: 380px; max-width: 100%; }
.thead { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11.5px; }
.thead b { color: var(--text); font-weight: 500; font-size: 13px; }
.trow { display: flex; gap: 14px; align-items: center; margin-top: 4px; }
.tbig { display: grid; border-left: 3px solid var(--c); padding-left: 8px; min-width: 96px; }
.tbig .tl { font-size: 11px; color: var(--muted); }
.tbig .tn { font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tbig small { font-size: 11px; color: var(--muted); font-weight: 400; }
.tchart { flex: 1; height: 44px; color: var(--text); min-width: 80px; }
.tchart svg { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 14px; font-size: 12px; margin-left: auto; margin-right: 52px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c); }

.leaflet-interactive.pulse { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { stroke-opacity: .9; stroke-width: 2; } 100% { stroke-opacity: 0; stroke-width: 16; } }

@media (max-width: 900px) {
  .side { display: none; }
  .legend { margin-left: 0; margin-right: 52px; }
  .seg { margin-left: 0; }
}
@media (max-width: 560px) { .kpi .l { display: none; } .kpi { padding-right: 10px; } .traffic { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .live.on, .feed li, .leaflet-interactive.pulse, .kpi.bump .n { animation: none; } }

/* ───────── Dramatische Effekte ───────── */
:root { --alert: 0; }
.fxcanvas { position: absolute; left: 0; top: 0; z-index: 450; pointer-events: none; }
.leaflet-marker-pane { z-index: 600; }
#map.shake { animation: shake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 10%, 90% { transform: translate(-1px, 0); } 20%, 80% { transform: translate(3px, 1px); } 30%, 50%, 70% { transform: translate(-5px, -1px); } 40%, 60% { transform: translate(5px, 1px); } }
.alertfx { position: fixed; inset: 0; z-index: 700; pointer-events: none; box-shadow: inset 0 0 calc(40px + 150px * var(--alert)) rgba(244, 67, 54, calc(var(--alert) * .75)); }
:root[data-theme="dark"] body::after { content: ""; position: fixed; inset: 0; z-index: 650; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.5) 100%); }
:root[data-theme="dark"] .kpi::before { box-shadow: 0 0 14px var(--c); }
:root[data-theme="dark"] .kpi .n { text-shadow: 0 0 12px color-mix(in srgb, var(--c) 70%, transparent); }
:root[data-theme="dark"] .title, :root[data-theme="dark"] .kpi, :root[data-theme="dark"] .side, :root[data-theme="dark"] .traffic, :root[data-theme="dark"] .legend { border: 1px solid rgba(255,255,255,.07); }

.level { margin-left: 4px; padding: 3px 11px; border-radius: 12px; font-size: 11.5px; font-weight: 500; letter-spacing: .03em; text-transform: uppercase; background: color-mix(in srgb, var(--st, var(--ok)) 22%, transparent); color: var(--st, var(--ok)); border: 1px solid color-mix(in srgb, var(--st, var(--ok)) 55%, transparent); }
.level.crit { animation: crit 1.1s ease-in-out infinite; }
@keyframes crit { 50% { box-shadow: 0 0 14px var(--st); } }

.flag { width: 20px; height: 15px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.25); vertical-align: -2px; margin-right: 7px; }
.flag.noflag, .bigflag.noflag, .pinflag.noflag { visibility: hidden; }
.feed li { grid-template-columns: 8px 22px 1fr auto; }
.feed li.sev2 .k, .feed li.sev3 .k { box-shadow: 0 0 8px var(--c); }
.feed li.sev3 { background: linear-gradient(90deg, rgba(244,67,54,.16), transparent 70%); }
.tip { display: flex; gap: 8px; align-items: center; }

.threat { left: 50%; top: 70px; transform: translate(-50%, -14px); display: flex; align-items: center; gap: 14px; padding: 10px 20px 10px 14px; min-width: 300px; max-width: min(560px, 60vw); background: var(--panel); backdrop-filter: blur(10px); border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--c, #f44336) 70%, transparent); box-shadow: 0 0 26px color-mix(in srgb, var(--c, #f44336) 55%, transparent), var(--shadow); opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s; }
.threat.show { opacity: 1; transform: translate(-50%, 0); }
.threat.sev3.show { animation: warn .8s ease-in-out infinite; }
@keyframes warn { 50% { box-shadow: 0 0 44px var(--c), var(--shadow); } }
.bigflag { width: 60px; height: 45px; border-radius: 4px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.3), 0 0 18px color-mix(in srgb, var(--c) 60%, transparent); flex: none; }
.threat .tag { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--c); }
.threat .tag b { font-weight: 700; }
.threat .ttl { font-size: 15px; font-weight: 500; line-height: 1.25; }
.threat .sub { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }

.flagpin { width: 0; height: 0; }
.flagpin img, .flagpin span { position: absolute; transform: translate(-50%, -150%); white-space: nowrap; }
.flagpin img { width: 26px; height: 19px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 2px 10px rgba(0,0,0,.5); animation: drop .5s cubic-bezier(.2,1.4,.4,1); }
.flagpin span { transform: translate(-50%, 160%); font: 11px/1 ui-monospace, Menlo, Consolas, monospace; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,.65); color: #ffd7d2; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -300%) scale(.4); } }
@media (max-width: 900px) { .threat { top: 124px; max-width: 92vw; } }
@media (prefers-reduced-motion: reduce) { #map.shake, .level.crit, .threat.sev3.show, .flagpin img { animation: none; } }
