:root{
  --blau:#1e3a8a;--blau2:#1e40af;--rot:#b91c1c;--bg:#f4f4f5;--card:#fff;--text:#18181b;--muted:#6b7280;--line:#e4e4e7;--ok:#16a34a;
  --s-reko_offen:#dc2626;--s-reko:#f97316;--s-beurteilen:#9333ea;--s-arbeit_offen:#ca8a04;--s-arbeit:#2563eb;--s-erledigt:#16a34a;
  --top:calc(54px + env(safe-area-inset-top));--side:400px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;font:16px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;color:var(--text);background:var(--bg)}
button,input,select,textarea{font:inherit}
.hidden{display:none!important}
h1,h2,h3{margin:0}
a{color:var(--blau2)}
.muted{color:var(--muted);font-size:14px}

/* Anmeldung */
.login{min-height:100%;display:flex;align-items:center;justify-content:center;padding:16px;background:linear-gradient(160deg,#1e3a8a,#0f172a)}
.login .box{width:100%;max-width:400px;background:#fff;border-radius:16px;padding:22px;box-shadow:0 10px 40px rgba(0,0,0,.4)}
.brand small{color:var(--muted)}
.brand h1{font-size:26px;margin-bottom:6px}
.breit{width:100%;margin:12px 0 4px}

/* Kopfzeile */
.top{position:fixed;inset:0 0 auto 0;z-index:1000;height:var(--top);padding:env(safe-area-inset-top) 8px 0;
  display:flex;align-items:center;gap:8px;background:var(--blau);color:#fff;box-shadow:0 1px 4px rgba(0,0,0,.3)}
.top .ttl{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.2}
.top .ttl b,.top .ttl small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top .ttl small{opacity:.85;font-size:13px}
.ib{width:40px;height:40px;flex:none;border:0;border-radius:10px;background:rgba(255,255,255,.15);color:#fff;font-size:20px;cursor:pointer}
.sync{flex:none;min-width:40px;height:40px;padding:0 8px;border:0;border-radius:10px;background:rgba(255,255,255,.15);color:#fff;font-size:14px;cursor:pointer;white-space:nowrap}
.sync.off{background:#facc15;color:#111}
.sync.wait{background:#fff;color:var(--blau)}

/* Karte und Seitenleiste (breit nebeneinander, schmal als Schublade) */
.main{position:fixed;inset:var(--top) 0 0 0;display:flex}
.mapwrap{position:relative;flex:1;min-width:0}
#map{position:absolute;inset:0}
.side{width:var(--side);flex:none;background:var(--bg);border-left:1px solid var(--line);display:flex;flex-direction:column;min-height:0}
.side .tabs{display:flex;gap:4px;padding:8px 8px 0;background:#fff;border-bottom:1px solid var(--line);flex-wrap:wrap}
.side .tabs button{flex:1;min-width:0;border:0;background:none;padding:8px 6px;border-bottom:3px solid transparent;cursor:pointer;font-size:14px;white-space:nowrap}
.side .tabs button.on{border-color:var(--blau);font-weight:700}
.side .tabs .n{display:inline-block;min-width:20px;padding:0 5px;margin-left:3px;border-radius:10px;background:#e4e4e7;font-size:12px;font-weight:700}
.side .tabs .n.rot{background:var(--s-reko_offen);color:#fff}
.side .sb{flex:1;overflow:auto;padding:10px;overscroll-behavior:contain}
.fab.listen{display:none}
.side .tabs .zu{display:none;flex:none;width:36px;font-size:16px}
@media (max-width:820px){
  .side{position:fixed;left:0;right:0;bottom:0;top:auto;width:auto;height:62vh;height:62dvh;z-index:1050;border:0;border-radius:16px 16px 0 0;
    box-shadow:0 -4px 20px rgba(0,0,0,.25);transform:translateY(105%);transition:transform .2s}
  body.listen .side{transform:none}
  .fab.listen{display:block}
  .side .tabs .zu{display:block}
  .side .tabs{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
  .side .tabs button{flex:none;padding:8px 8px}
  .side .tabs .zu{margin-left:auto;position:sticky;right:0;background:#fff}
}

/* Suche über der Karte (zwischen Zoom links und Kartenwahl rechts) */
.suche{position:absolute;top:10px;left:58px;right:58px;max-width:420px;margin:0 auto;z-index:950}
.suche input{width:100%;box-sizing:border-box;height:40px;padding:0 14px;border:1px solid var(--line);border-radius:20px;background:#fff;
  box-shadow:0 2px 8px rgba(0,0,0,.25);font-size:16px}
.suche ul{list-style:none;margin:4px 0 0;padding:4px 0;background:#fff;border-radius:12px;box-shadow:0 4px 14px rgba(0,0,0,.25);max-height:50vh;overflow:auto}
.suche li{padding:8px 14px;cursor:pointer;display:flex;flex-direction:column}
.suche li small{color:#71717a}
.suche li:hover,.suche li.on{background:#eff6ff}
.suche li.leer{cursor:default;color:#71717a}
.pin{width:26px;height:26px;margin:0 auto;border-radius:50% 50% 50% 0;background:#2563eb;border:3px solid #fff;transform:rotate(-45deg);box-shadow:0 2px 6px rgba(0,0,0,.4)}
.btn.klein{margin-top:8px;padding:6px 10px;font-size:14px}

.fabs{position:absolute;right:12px;bottom:calc(30px + env(safe-area-inset-bottom));z-index:900;display:flex;flex-direction:column;gap:10px}
.fab{width:52px;height:52px;border:0;border-radius:50%;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,.35);font-size:22px;cursor:pointer}
.fab.neu{background:var(--rot);color:#fff;font-size:28px}
.fab.on{background:#2563eb;color:#fff}
.legend{position:absolute;left:8px;bottom:calc(8px + env(safe-area-inset-bottom));z-index:800;display:flex;flex-wrap:wrap;gap:4px 10px;max-width:calc(100% - 90px);
  padding:5px 8px;border-radius:8px;background:rgba(255,255,255,.9);font-size:12px}
.legend i{display:inline-block;width:11px;height:11px;border-radius:50%;margin-right:4px;vertical-align:-1px}
.s-reko_offen{background:var(--s-reko_offen)}.s-reko{background:var(--s-reko)}.s-beurteilen{background:var(--s-beurteilen)}
.s-arbeit_offen{background:var(--s-arbeit_offen)}.s-arbeit{background:var(--s-arbeit)}.s-erledigt{background:var(--s-erledigt)}

/* Kreuz zum Platzieren */
.cross{position:absolute;left:50%;top:50%;z-index:950;width:44px;height:44px;margin:-22px 0 0 -22px;pointer-events:none}
.cross:before,.cross:after{content:"";position:absolute;background:var(--rot)}
.cross:before{left:21px;top:0;width:2px;height:44px}.cross:after{top:21px;left:0;height:2px;width:44px}
.pickbar{position:absolute;left:12px;right:80px;bottom:calc(30px + env(safe-area-inset-bottom));z-index:1000;background:#fff;border-radius:12px;padding:10px;
  box-shadow:0 2px 10px rgba(0,0,0,.3);font-size:14px}
.pickbar .btns{margin-top:8px}

/* Ereignis-Marker */
.em{width:34px;height:34px;border-radius:50%;border:3px solid #fff;box-shadow:0 1px 5px rgba(0,0,0,.5);color:#fff;font:700 14px/28px Arial,sans-serif;text-align:center;position:relative}
.em.erledigt{opacity:.55}
.em .p{position:absolute;right:-8px;top:-8px;width:18px;height:18px;border-radius:50%;background:#111;color:#fff;font:700 11px/18px Arial,sans-serif;border:2px solid #fff}
.em.sel{outline:3px solid #111;outline-offset:2px}
/* Trupp-Marker: Bild mit Name */
.tm{display:flex;flex-direction:column;align-items:center;pointer-events:auto}
.tm img,.tm .ini{width:40px;height:40px;border-radius:50%;border:3px solid #fff;box-shadow:0 1px 6px rgba(0,0,0,.5);background:#fff;object-fit:cover}
.tm .ini{display:flex;align-items:center;justify-content:center;background:var(--blau);color:#fff;font-weight:700}
.tm span{margin-top:2px;padding:0 6px;border-radius:8px;background:rgba(17,24,39,.85);color:#fff;font-size:12px;white-space:nowrap}
.tm.reko img,.tm.reko .ini{border-color:var(--s-reko)}
.tm.arbeit img,.tm.arbeit .ini{border-color:var(--s-arbeit)}

/* Listen */
.li{display:flex;gap:10px;align-items:flex-start;padding:10px;margin-bottom:8px;background:#fff;border-radius:10px;box-shadow:0 1px 2px rgba(0,0,0,.08);cursor:pointer;border-left:5px solid #ccc}
.li:hover{background:#f8fafc}
.li .nr{flex:none;width:30px;height:30px;border-radius:50%;color:#fff;font:700 13px/30px Arial,sans-serif;text-align:center}
.li .tx2{flex:1;min-width:0}
.li .tx2 b{display:block;overflow:hidden;text-overflow:ellipsis}
.li .tx2 small{display:block;color:var(--muted);font-size:13px}
.li .act{flex:none;display:flex;flex-direction:column;gap:4px;align-items:flex-end}
.leer{color:var(--muted);text-align:center;padding:20px 8px}
h3.gr{font-size:13px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin:14px 2px 6px}
h3.gr:first-child{margin-top:2px}
.pill{display:inline-block;padding:1px 8px;border-radius:10px;font-size:12px;font-weight:600;background:#e4e4e7;color:#111;white-space:nowrap}
.pill.st{color:#fff}
.pill.p1{background:#b91c1c;color:#fff}.pill.p2{background:#ea580c;color:#fff}.pill.p3{background:#65a30d;color:#fff}
.pill.warn{background:#fef3c7;color:#92400e}
.pill.bad{background:#fee2e2;color:#991b1b}
.trupp{display:flex;gap:10px;align-items:center}
.trupp img,.trupp .ini{width:44px;height:44px;border-radius:50%;object-fit:cover;flex:none;background:#e4e4e7}
.trupp .ini{display:flex;align-items:center;justify-content:center;background:var(--blau);color:#fff;font-weight:700}

/* Ereignis-Blatt */
.sheet{position:fixed;z-index:1100;background:var(--card);overflow:auto;overscroll-behavior:contain;padding:14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow:0 -4px 24px rgba(0,0,0,.3);left:0;right:0;bottom:0;max-height:78vh;max-height:78dvh;border-radius:16px 16px 0 0}
@media (min-width:821px){.sheet{left:auto;right:var(--side);top:var(--top);bottom:0;width:440px;max-height:none;border-radius:0}}
.sheet .hd{display:flex;align-items:flex-start;gap:10px;margin-bottom:6px}
.sheet .hd h2{font-size:20px}
.sheet .sub{color:var(--muted);font-size:14px;margin-top:2px}
.x{width:36px;height:36px;border:0;border-radius:50%;background:#e4e4e7;font-size:16px;cursor:pointer;flex:none}
.info{margin:8px 0;font-size:15px}
.info div{margin:3px 0}
.info .k{color:var(--muted);font-size:13px;display:inline-block;min-width:88px}
.box2{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin:10px 0}
.box2 h3{font-size:15px;margin-bottom:6px}
.prios{display:flex;gap:6px}
.prios .btn{flex:1;padding:10px 4px}
.prios .btn.on{outline:3px solid #111}
.btn.p1{background:#b91c1c}.btn.p2{background:#ea580c}.btn.p3{background:#65a30d}

/* Journal */
.jr{position:relative;padding:8px 0 8px 18px;border-left:2px solid var(--line);margin-left:6px}
.jr:before{content:"";position:absolute;left:-7px;top:13px;width:12px;height:12px;border-radius:50%;background:#a1a1aa}
.jr.reko_bericht:before,.jr.reko_abgeschlossen:before{background:var(--s-reko)}
.jr.arbeit_bericht:before{background:var(--s-arbeit)}
.jr.erledigt:before{background:var(--s-erledigt)}
.jr.prio:before{background:var(--s-beurteilen)}
.jr.erfasst:before{background:var(--s-reko_offen)}
.jr .kopf{font-size:13px;color:var(--muted)}
.jr .kopf b{color:var(--text)}
.jr .t{white-space:pre-wrap;margin-top:2px}
.jtab{width:100%;border-collapse:collapse;background:#fff;font-size:14px}
.jtab th,.jtab td{border-bottom:1px solid var(--line);padding:6px 8px;text-align:left;vertical-align:top}
.jtab td.t{white-space:pre-wrap}
.jtab th{background:#f4f4f5;position:sticky;top:0}

/* Fotos */
.photos{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;align-items:center}
.photos .ph{position:relative;width:72px;height:72px;border-radius:8px;overflow:hidden;background:#e4e4e7;cursor:pointer;flex:none}
.photos .ph img{width:100%;height:100%;object-fit:cover;display:block}
.photos .ph button{position:absolute;top:2px;right:2px;width:24px;height:24px;border:0;border-radius:50%;background:rgba(0,0,0,.6);color:#fff;font-size:13px;cursor:pointer}
.photoview{display:block;max-width:100%;max-height:75vh;margin:0 auto;border-radius:8px}

/* Formulare */
.lb{display:block;font-size:13px;color:var(--muted);margin:12px 0 4px}
.tx{width:100%;padding:10px;border:1px solid #d4d4d8;border-radius:8px;background:#fff;color:var(--text)}
textarea.tx{resize:vertical}
.row{display:flex;gap:8px;align-items:center}
.row .tx{flex:1}
.chk{display:flex;gap:8px;align-items:center;margin:10px 0;cursor:pointer}
.chk input{width:20px;height:20px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:12px 16px;border:0;border-radius:10px;background:var(--blau);color:#fff;font-weight:600;cursor:pointer;text-decoration:none}
.btn.sec{background:#e4e4e7;color:var(--text)}
.btn.rot{background:var(--rot)}
.btn.gruen{background:var(--ok)}
.btn.small{padding:6px 10px;font-size:14px;font-weight:500}
.btn:disabled{opacity:.5;cursor:default}
.btns{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.btns .btn{flex:1}
.msg{margin-top:10px;font-size:14px;color:var(--rot)}
.msg.err{padding:10px;border-radius:8px;background:#fee2e2;color:#991b1b}
.msg.ok{color:var(--ok)}
.hint{padding:10px 12px;border-radius:10px;background:#eff6ff;color:#1e3a8a;font-size:14px;margin:8px 0}
.hint.warn{background:#fef3c7;color:#92400e}

/* Panel */
.panel{position:fixed;inset:0;z-index:1200;background:var(--bg);overflow:auto;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}
.panel .ph{position:sticky;top:0;z-index:2;display:flex;align-items:center;gap:8px;padding:10px 12px;background:var(--blau);color:#fff}
.panel .ph h2{flex:1;font-size:18px}
.panel .pb{padding:12px;max-width:900px;margin:0 auto}
.card{background:var(--card);border-radius:12px;padding:14px;margin-bottom:12px;box-shadow:0 1px 2px rgba(0,0,0,.06)}
.card h3{font-size:16px;margin-bottom:8px}
.menu{display:flex;flex-direction:column;gap:8px}
.menu button{display:flex;align-items:center;gap:12px;width:100%;padding:14px;border:0;border-radius:12px;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.06);cursor:pointer;text-align:left;font-size:16px}
.menu button span{font-size:22px;width:28px;text-align:center}
.menu button small{display:block;color:var(--muted);font-size:13px}
.leute{display:flex;flex-direction:column;gap:2px;max-height:45vh;overflow:auto;border:1px solid var(--line);border-radius:8px;padding:4px 8px;background:#fff}
.leute label{display:flex;gap:8px;align-items:center;padding:6px 0;border-bottom:1px solid #f4f4f5}
.leute label.weg{color:var(--muted)}
.leute input{width:18px;height:18px}
.bilder{display:flex;flex-wrap:wrap;gap:8px}
.bilder button{width:64px;height:64px;padding:0;border:3px solid transparent;border-radius:50%;background:none;cursor:pointer;overflow:hidden}
.bilder button img{width:100%;height:100%;object-fit:cover;border-radius:50%}
.bilder button.on{border-color:var(--blau)}
.bilder button:disabled{opacity:.3;cursor:default}
.mat{display:flex;flex-direction:column;gap:2px;max-height:40vh;overflow:auto;border:1px solid var(--line);border-radius:8px;padding:4px 8px;background:#fff}
.mat label{display:flex;gap:8px;align-items:center;padding:5px 0;border-bottom:1px solid #f4f4f5}
.mat img{width:44px;height:22px;object-fit:contain}
.mat .z{margin-left:auto}

/* Dialog */
.dlg{position:fixed;inset:0;z-index:2500;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;padding:16px}
.dlg .box{width:100%;max-width:440px;max-height:90vh;overflow:auto;background:var(--card);border-radius:14px;box-shadow:0 8px 30px rgba(0,0,0,.35)}
.dlg .dh{background:var(--blau);color:#fff;padding:12px 16px;font-weight:700;font-size:17px}
.dlg .db{padding:14px 16px 4px;line-height:1.45}
.dlg .db p{margin:0 0 10px}
.dlg .btns{padding:0 16px 16px;margin-top:8px}
.toast{position:fixed;left:50%;bottom:calc(24px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:3000;max-width:90vw;padding:10px 16px;border-radius:10px;
  background:#111827;color:#fff;font-size:14px;box-shadow:0 4px 14px rgba(0,0,0,.4)}
.toast.err{background:#991b1b}

/* Druck: nur das Journal */
@media print{
  .top,.main,.sheet,.panel .ph,.noprint{display:none!important}
  .panel{position:static;overflow:visible;background:#fff}
  .panel .pb{max-width:none;padding:0}
  .jtab th{position:static}
}
/* Hilfe */
.inhalt{display:flex;flex-wrap:wrap;gap:4px 14px;background:var(--card);border-radius:12px;padding:10px 14px;margin-bottom:12px;box-shadow:0 1px 2px rgba(0,0,0,.08);font-size:15px}
.inhalt b{width:100%}
.hilfe{line-height:1.45}
.hilfe h2{font-size:18px;margin:24px 0 8px}
.hilfe h3{font-size:15px;margin:16px 0 6px}
.hilfe li{margin:3px 0}
.hilfe .tabelle{overflow-x:auto;background:var(--card);border-radius:10px;margin:8px 0}
.hilfe table{border-collapse:collapse;width:100%;font-size:14px}
.hilfe th,.hilfe td{padding:6px 9px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}
.hilfe th{background:#fafafa}
.hilfe code{background:#f4f4f5;padding:1px 5px;border-radius:5px;font-size:13px}
