:root {
  --bg: #0e1520;
  --bg2: #141d2b;
  --bg3: #1b2738;
  --line: #273548;
  --text: #e3e9f2;
  --muted: #8a9ab0;
  --accent: #ff5a36;
  --ok: #3fb950;
  --warn: #f2b13a;
  --bad: #ef4444;
  --blue: #4c8dff;
  --radius: 8px;
  --s1: #43a047; --s2: #2e7d32; --s3: #f9c623; --s4: #e53935; --s5: #ff8f00; --s6: #6b7280; --s7: #9c27b0; --s8: #5e35b1;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* ---------- Kopfzeile ---------- */
#topbar { height: 50px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--bg2); border-bottom: 1px solid var(--line); position: relative; z-index: 1001; }
.logo { font-weight: 800; letter-spacing: .5px; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.stat { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.stat b { font-family: var(--mono); font-size: 14px; }
.stat small { color: var(--muted); font-size: 11px; }
.spacer { flex: 1; }
#eventBanner { background: linear-gradient(90deg, #7c3aed, #db2777); padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
#swBtn { position: relative; }
#swBtn .badge { position: absolute; top: -6px; right: -6px; }

/* ---------- Layout ---------- */
#main { display: flex; height: calc(100% - 50px); }
#mapWrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #0b111a; }
#panel { width: 440px; max-width: 100%; display: flex; flex-direction: column; background: var(--bg2); border-left: 1px solid var(--line); }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; white-space: nowrap; background: none; border: 0; padding: 11px 4px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; font-size: 13px; position: relative; }
#tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#tabs .badge { margin-left: 4px; }
#panelBody { flex: 1; overflow-y: auto; padding: 12px; }
#panelToggle { display: none; }

#search { position: absolute; top: 10px; left: 54px; z-index: 900; width: min(340px, calc(100% - 70px)); }
#search input { width: 100%; padding: 9px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: rgba(20, 29, 43, .95); }
#searchResults { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 4px; overflow: hidden; }
#searchResults div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
#searchResults div:hover { background: var(--bg3); }
#placeHint { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 900; background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 99px; font-weight: 600; display: none; box-shadow: 0 4px 20px rgba(0, 0, 0, .5); white-space: nowrap; }
#placeHint button { margin-left: 10px; background: rgba(0, 0, 0, .25); border: 0; color: #fff; border-radius: 99px; padding: 2px 10px; cursor: pointer; }
.placing #map { cursor: crosshair !important; }

/* ---------- Elemente ---------- */
.btn { background: var(--bg3); border: 1px solid var(--line); padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3b4f6b; background: #213047; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ok { background: #1f6f3a; border-color: #2c8a4c; }
.btn.danger { background: #7f1d1d; border-color: #991b1b; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
input[type=text], input[type=number], input[type=password], select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--blue); }
.badge { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
h2 { font-size: 16px; margin: 4px 0 10px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 16px 0 8px; }
.card { background: var(--bg3); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.list-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; background: var(--bg3); margin-bottom: 4px; cursor: pointer; border: 1px solid transparent; }
.list-item:hover { border-color: var(--line); }
.grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.subtabs button { background: var(--bg3); border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 12px; color: var(--muted); }
.subtabs button.active { color: #fff; background: #2a3b55; border-color: #3b5277; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--ok); transition: width .9s linear; }

/* FMS-Status */
.fms { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 4px; font-family: var(--mono); font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.fms.s1 { background: var(--s1); } .fms.s2 { background: var(--s2); } .fms.s3 { background: var(--s3); color: #222; } .fms.s4 { background: var(--s4); }
.fms.s5 { background: var(--s5); animation: blink 1s infinite; } .fms.s6 { background: var(--s6); } .fms.s7 { background: var(--s7); } .fms.s8 { background: var(--s8); }

/* Einsatzliste */
.mission { display: flex; gap: 10px; padding: 9px 10px; border-radius: 6px; background: var(--bg3); margin-bottom: 5px; cursor: pointer; border-left: 4px solid var(--bad); }
.mission.started { border-left-color: var(--warn); }
.mission.working { border-left-color: var(--ok); }
.mission.alliance { background: #1f2240; }
.mission .name { font-weight: 600; }
.mission .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.tag.miss { color: #ffb4a6; background: #3a1b17; }
.tag.ok { color: #a7f3c0; background: #143322; }
.tag.purple { color: #d8b4fe; background: #2e1a47; }

/* ---------- Karte ---------- */
.mk-b { width: 26px; height: 26px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: #fff; border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.mk-b.foreign { border-style: dashed; opacity: .85; }
.mk-m { width: 24px; height: 24px; border-radius: 50%; background: var(--bad); border: 2px solid #fff; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; box-shadow: 0 0 0 0 rgba(239, 68, 68, .7); animation: pulse 1.6s infinite; }
.mk-m.started { background: var(--warn); color: #222; animation: none; }
.mk-m.working { background: var(--ok); animation: none; }
.mk-m.alliance { border-color: #c084fc; border-width: 3px; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.mk-v { padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; color: #fff; white-space: nowrap; border: 1px solid rgba(0, 0, 0, .5); box-shadow: 0 1px 3px rgba(0, 0, 0, .6); transform: translate(-50%, -50%); display: inline-block; }
.leaflet-div-icon { background: none; border: none; }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg2); color: var(--text); }
.leaflet-control-zoom a { background: var(--bg2) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(14, 21, 32, .8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tile-pane { filter: brightness(.82) saturate(.85); }

/* ---------- Modal ---------- */
#modal { position: fixed; inset: 0; background: rgba(4, 8, 14, .7); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; }
#modal.open { display: flex; }
#modalBox { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; width: 760px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
#modalHead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#modalHead h2 { margin: 0; flex: 1; }
#modalClose { background: none; border: 0; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
#modalBody { padding: 14px 16px; overflow-y: auto; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.vlist { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.vrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.vrow:hover { background: var(--bg3); }
.vrow.sel { background: #3a2016; }
.vrow input { accent-color: var(--accent); }
.aao-btn { border: 0; color: #fff; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; font-weight: 600; }
.aao-btn:hover { filter: brightness(1.2); }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 16px; left: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 6px; }
.toast { background: var(--bg3); border: 1px solid var(--line); border-left: 4px solid var(--blue); padding: 9px 14px; border-radius: 6px; max-width: 360px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); animation: slidein .2s; }
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateX(-20px); opacity: 0; } }

/* Chat & Funk */
.chat { height: 300px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 13px; }
.chat .msg { margin-bottom: 5px; }
.chat .msg b { color: #9cc3ff; }
.chat .msg.sys { color: var(--muted); font-style: italic; }
.radio-line { font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.radio-line .mono { color: var(--muted); margin-right: 6px; }

/* ---------- Login ---------- */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 20% 20%, rgba(255, 90, 54, .15), transparent 40%), radial-gradient(circle at 80% 70%, rgba(76, 141, 255, .15), transparent 40%), var(--bg); }
.auth-box { width: 380px; max-width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-box h1 { margin: 0 0 4px; font-size: 26px; display: flex; align-items: center; gap: 10px; }
.auth-box p { color: var(--muted); margin: 0 0 20px; }
.auth-box input { width: 100%; margin-bottom: 10px; padding: 10px 12px; }
.auth-box .btn { width: 100%; padding: 10px; }
.auth-box .switch { text-align: center; margin-top: 14px; color: var(--muted); }
.auth-box .err { color: #ff9b8a; min-height: 20px; margin-bottom: 6px; font-size: 13px; }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  #topbar { gap: 10px; padding: 0 10px; }
  .stat.hide-m, #eventBanner { display: none; }
  #main { flex-direction: column; }
  #mapWrap { flex: 1; min-height: 0; }
  #panel { width: 100%; height: 52%; border-left: 0; border-top: 1px solid var(--line); transition: height .2s; }
  #panel.collapsed { height: 44px; }
  #panel.collapsed #panelBody { display: none; }
  #panelToggle { display: block; position: absolute; right: 10px; bottom: 10px; z-index: 900; }
  .cols { grid-template-columns: 1fr; }
  #modal { padding: 0; }
  #modalBox { max-height: 100%; height: 100%; border-radius: 0; }
  #tabs button { font-size: 12px; padding: 11px 2px; }
}
