/* Baustellen-Cockpit
   Layout: feste Seitennavigation links, Arbeitsfläche rechts; auf dem Handy Navigation als Leiste oben.
   Farbwelt: Beton-Grau als Grund, Bauplan-Blau als Akzent, Signalgelb nur für Hervorhebungen. */
:root {
  --bg: #e9ecea;
  --panel: #ffffff;
  --panel2: #f4f6f5;
  --ink: #18212b;
  --muted: #5a6573;
  --line: #d3d9d6;
  --accent: #1d5fa8;
  --accent-ink: #ffffff;
  --accent-soft: #e1eaf6;
  --signal: #f2b300;
  --ok: #2c7a4b;   --ok-soft: #dff0e5;
  --warn: #a86200; --warn-soft: #fbedd5;
  --bad: #b3362c;  --bad-soft: #f8e1de;
  --earth: #b9ab95;
  --roof: #3b4653;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 4px 14px rgba(20, 30, 40, .06);
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c; --panel: #19212a; --panel2: #1f2832; --ink: #e5e9ed; --muted: #95a1ae; --line: #2c3743;
    --accent: #6aa5ea; --accent-ink: #0d1620; --accent-soft: #1b2d43; --signal: #f2c230;
    --ok: #63c08a; --ok-soft: #173326; --warn: #e8a64a; --warn-soft: #3a2a12; --bad: #ee7b70; --bad-soft: #3d1d1a;
    --earth: #4a4235; --roof: #7d8a98; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: .01em; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
.mono, .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .86em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Grundgerüst */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100%; }
#nav { background: var(--ink); color: #dfe5ea; display: flex; flex-direction: column; overflow-y: auto; padding: 18px 12px; gap: 2px; }
@media (prefers-color-scheme: dark) { #nav { background: #0b0f13; } }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand b { font-family: var(--f-display); font-size: 1.3rem; letter-spacing: .02em; line-height: 1; display: block; color: #fff; }
.brand span { font-size: .75rem; color: #9aa6b2; }
.nav-sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7c8894; padding: 14px 10px 4px; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; color: inherit; text-align: left;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: .93rem; }
.nav-btn svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-btn:hover { background: rgba(255,255,255,.07); }
.nav-btn.on { background: var(--accent); color: #fff; }
.nav-btn.on svg { opacity: 1; }
.nav-btn .badge { margin-left: auto; }
.nav-foot { margin-top: auto; padding: 14px 10px 0; font-size: .8rem; color: #9aa6b2; display: grid; gap: 6px; }
.nav-foot button { background: none; border: 1px solid rgba(255,255,255,.18); color: #dfe5ea; border-radius: 6px; padding: 5px 8px; cursor: pointer; }
.badge { background: var(--signal); color: #1b1b1b; border-radius: 99px; font-size: .72rem; font-weight: 600; padding: 0 7px; line-height: 18px; min-width: 18px; text-align: center; }

.right { display: flex; flex-direction: column; min-width: 0; height: 100%; }
#top { display: flex; align-items: center; gap: 14px; padding: 10px 28px; border-bottom: 1px solid var(--line); background: var(--panel); }
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--panel2); border-radius: 6px; padding: 8px 12px; }
.qres { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); z-index: 30; max-height: 60vh; overflow: auto; padding: 6px; }
.qres button { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px; border-radius: 6px; cursor: pointer; }
.qres button:hover, .qres button:focus { background: var(--accent-soft); }
.qres .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); width: 82px; flex: none; padding-top: 2px; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.conn.off { background: var(--bad); }
.online { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.online .lbl { font-size: .8rem; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.av { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 600; color: #fff; flex: none; border: 2px solid var(--panel); }

#main { flex: 1; overflow: auto; padding: 24px 28px 48px; }
.page { max-width: 1320px; margin: 0 auto; display: grid; gap: 20px; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.eyebrow { font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 4px; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Bausteine */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.pri:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 9px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.ib { border: 0; background: none; cursor: pointer; width: 30px; height: 30px; border-radius: 6px; font-size: 1.2rem; line-height: 1; color: var(--muted); }
.ib:hover { background: var(--panel2); color: var(--ink); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

.kpi { display: grid; gap: 2px; }
.kpi .v { font-family: var(--f-display); font-size: 2.1rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi .s { font-size: .8rem; }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 1px 9px; font-size: .78rem; font-weight: 500; white-space: nowrap; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.demo { border-style: dashed; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 4px 12px; cursor: pointer; font-size: .86rem; }
.fbtn.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.filters select, .filters input { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 5px 8px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel2); }
.tbl .r { text-align: right; }
.tbl tfoot td { font-weight: 600; border-bottom: 0; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty h3 { color: var(--ink); }
.list { display: grid; gap: 2px; }
.li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 6px; min-width: 0; }
.li.click { cursor: pointer; }
.li.click:hover { background: var(--panel2); }
.li .grow { flex: 1; min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Formulare */
#modal { position: fixed; inset: 0; background: rgba(10, 16, 22, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.mbox { background: var(--panel); border-radius: 10px; width: min(640px, 100%); max-height: calc(100% - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.mbox form { display: flex; flex-direction: column; min-height: 0; }
.mhead { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
.mbody { padding: 8px 20px 16px; overflow: auto; }
.mfoot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); align-items: center; }
.sp { flex: 1; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.fld { display: grid; gap: 4px; min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld label, .lab { font-size: .8rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], input[type=search], input[type=month], select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.chk { display: flex; gap: 8px; align-items: center; }
fieldset.multi { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.multi legend { padding: 0; margin-bottom: 6px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; max-height: 260px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.mgrid .chk { align-items: flex-start; }
.mgrid .chk input { margin-top: 3px; }
details summary { cursor: pointer; color: var(--accent); }
.fotos { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.foto { position: relative; width: 74px; height: 74px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--panel2); display: grid; place-items: center; font-size: .7rem; text-align: center; }
.foto img { width: 100%; height: 100%; object-fit: cover; }
.foto button { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 4px; width: 20px; height: 20px; cursor: pointer; line-height: 1; }
.upl { border: 1px dashed var(--line); border-radius: 6px; width: 74px; height: 74px; display: grid; place-items: center; cursor: pointer; color: var(--muted); font-size: .75rem; text-align: center; }
.upl input { display: none; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
#toast div { background: var(--ink); color: var(--panel); padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw; }

/* ---------- Anmeldung */
#auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 28px 28px, linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px, var(--bg); }
.auth-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(420px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow); }
.auth-box h1 { font-size: 2.2rem; }
.err { color: var(--bad); font-size: .9rem; }

/* ---------- Übersicht */
.hello h1 { font-size: 2.4rem; }
.site { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.site:last-child { border-bottom: 0; }
.site:hover { background: var(--panel2); }
.ministack { display: flex; flex-direction: column-reverse; gap: 2px; width: 34px; }
.ministack i { height: 7px; border-radius: 1px; background: var(--panel2); border: 1px solid var(--line); position: relative; overflow: hidden; }
.ministack i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 1%); background: var(--ok); }
.ministack i.ug { opacity: .6; }

/* ---------- Projekte */
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 10px; cursor: pointer; grid-template-columns: minmax(0, 1fr) auto; align-content: start; }
.pcard:hover { border-color: var(--accent); }
.pcard h3 { font-size: 1.25rem; }
.pcard .meta { color: var(--muted); font-size: .85rem; }
.pcard .full { grid-column: 1 / -1; }
.phead { display: grid; gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpis .card { padding: 12px 14px; }

/* ---------- Gebäude */
.bwrap { display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
.bstage { background: linear-gradient(var(--accent-soft), var(--panel) 70%); border: 1px solid var(--line); border-radius: var(--r); padding: 24px 22px 18px; display: grid; gap: 14px; }
.bldg { width: 100%; max-width: 330px; margin: 0 auto; display: flex; flex-direction: column; }
.roof { height: 54px; background: var(--roof); clip-path: polygon(50% 0, 100% 100%, 0 100%); margin: 0 -14px; }
.floor { position: relative; border: 2px solid var(--roof); border-top-width: 0; background: var(--panel); min-height: 68px; padding: 8px 12px; cursor: pointer; display: grid; gap: 5px; text-align: left; width: 100%; color: inherit; font: inherit; overflow: hidden; }
.floor:first-of-type, .roof + .floor { border-top-width: 2px; }
.floor .fill { position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 1%); background: var(--ok-soft); transition: width .4s; }
.floor > *:not(.fill) { position: relative; }
.floor .fn { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.floor .fn b { font-family: var(--f-display); font-size: 1.2rem; }
.floor.sel { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.floor:hover:not(.sel) { background: var(--panel2); }
.floor.ug { background: var(--panel2); }
.wins { display: flex; flex-wrap: wrap; gap: 4px; }
.win { width: 14px; height: 18px; border: 1.5px solid var(--roof); border-radius: 2px; background: var(--panel); }
.win.arbeit { background: var(--signal); border-color: var(--warn); }
.win.erledigt { background: var(--ok); border-color: var(--ok); }
.win.mangel { background: var(--bad); border-color: var(--bad); }
.ground { height: 10px; background: var(--ink); margin: 0 -16px; border-radius: 2px; }
.soil { background: repeating-linear-gradient(135deg, var(--earth) 0 6px, transparent 6px 12px); padding: 0 16px 12px; margin: 0 -16px; border-radius: 0 0 6px 6px; display: flex; flex-direction: column; }
.soil .floor { border-top-width: 0; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); justify-content: center; }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.legend .win { width: 10px; height: 13px; }
.btabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.trow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow .tt { font-weight: 500; }
.trow.done .tt { text-decoration: line-through; color: var(--muted); }
.trow .tmain { cursor: pointer; min-width: 0; }
.st { border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: .78rem; cursor: pointer; min-width: 84px; background: var(--panel2); }
.st.arbeit { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st.erledigt { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.addrow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 8px; margin-top: 12px; }

/* ---------- Kanban */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 14px; overflow-x: auto; align-items: start; }
.kcol { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; min-height: 200px; align-content: start; }
.kcol.over { outline: 2px dashed var(--accent); }
.kcol h3 { display: flex; justify-content: space-between; padding: 2px 4px 4px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--pc, var(--line)); border-radius: 6px; padding: 9px 11px; cursor: grab; display: grid; gap: 4px; }
.kcard.mangel { box-shadow: inset 0 0 0 1px var(--bad); }
.kcard .meta { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Einsatzplan */
.plan { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 860px; }
.plan th, .plan td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; vertical-align: top; }
.plan th { background: var(--panel2); font-size: .8rem; text-align: left; position: sticky; top: 0; }
.plan th.today { background: var(--accent-soft); color: var(--accent); }
.plan td.cell { cursor: pointer; min-width: 120px; height: 64px; }
.plan td.cell:hover { background: var(--panel2); }
.plan td.today { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.plan .who { white-space: nowrap; font-weight: 500; }
.ein { display: block; border-left: 4px solid var(--pc); background: var(--panel2); border-radius: 4px; padding: 3px 6px; font-size: .78rem; margin-bottom: 4px; cursor: pointer; text-align: left; width: 100%; border-top: 0; border-right: 0; border-bottom: 0; }

/* ---------- Kalender (Einsatzplan) */
.caltools { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.caltools input[type=date] { width: auto; }
.calwrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.calside { position: sticky; top: 0; display: grid; gap: 8px; padding: 14px; }
.calside-h { display: flex; justify-content: space-between; align-items: baseline; }
.calmas { display: grid; gap: 2px; max-height: 52vh; overflow-y: auto; margin: 0 -6px; }
.calma { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 6px; cursor: pointer; }
.calma:hover { background: var(--panel2); }
.calma.off { opacity: .5; }
.calma .dot { width: 12px; height: 12px; }
.calmain { min-width: 0; }
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
.cal-row { display: grid; grid-template-columns: var(--tpl); min-width: var(--minw); }
.cev.multi { cursor: default; }
.cev { user-select: none; -webkit-user-select: none; }
.cev-rs { position: absolute; left: 0; right: 0; height: 9px; cursor: ns-resize; z-index: 3; touch-action: none; }
.cev-rs.top { top: -3px; }
.cev-rs.bot { bottom: -3px; }
.cev-rs::after { content: ""; position: absolute; left: 50%; width: 22px; margin-left: -11px; height: 3px; border-radius: 2px; background: var(--c); opacity: 0; transition: opacity .15s; }
.cev-rs.top::after { top: 4px; }
.cev-rs.bot::after { bottom: 4px; }
.cev:hover .cev-rs::after, .cev.resizing .cev-rs::after { opacity: .9; }
.cev.resizing { box-shadow: 0 0 0 2px var(--c), 0 4px 14px rgba(0,0,0,.2); z-index: 4; }
.calma[draggable=true] { cursor: grab; }
.calma[draggable=true]:active { cursor: grabbing; }
.cev-ppl { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.cev-p { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border-radius: 99px; padding: 0 7px 0 5px; font-size: .72rem; line-height: 18px; cursor: pointer; white-space: nowrap; }
.cev-p::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--d); flex: none; }
.cev-p:hover { outline: 1px solid var(--d); }
.cev-p[draggable=true] { cursor: grab; }
.cal-head { border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; background: var(--panel); }
.cal-dh { padding: 8px 10px; font-size: .86rem; border-left: 1px solid var(--line); display: flex; gap: 6px; align-items: center; min-width: 0; }
.cal-dh.today { color: var(--accent); background: var(--accent-soft); }
.cal-ad { border-bottom: 2px solid var(--line); }
.cal-adl { font-size: .7rem; color: var(--muted); padding: 6px 4px; text-align: right; }
.cal-adc { border-left: 1px solid var(--line); padding: 4px; display: grid; gap: 3px; align-content: start; min-height: 34px; cursor: cell; }
.cad { background: color-mix(in srgb, var(--c) 16%, var(--panel)); border-left: 4px solid var(--c); border-radius: 4px; padding: 2px 6px; font-size: .76rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-body { position: relative; }
.cal-gut { position: relative; }
.cal-gut span { position: absolute; right: 6px; transform: translateY(-50%); font-size: .7rem; color: var(--muted); font-family: var(--f-mono); }
.cal-gut span:first-child { transform: none; }
.cal-col { position: relative; border-left: 1px solid var(--line); cursor: cell;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px);
  background-size: 100% var(--hpx, 46px), 100% calc(var(--hpx, 46px) / 2); background-position: 0 0, 0 0; }
.cal-col.today { background-color: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.cal-col.over, .cal-adc.over, .mcell.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.cev { position: absolute; background: color-mix(in srgb, var(--c) 18%, var(--panel)); border-left: 4px solid var(--c); border-radius: 5px; padding: 2px 6px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; font-size: .76rem; line-height: 1.25; box-shadow: 0 1px 2px rgba(0,0,0,.08); z-index: 1; }
.cev:hover { z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.cev[draggable=true] { cursor: grab; }
.cev-t { font-family: var(--f-mono); font-size: .68rem; color: var(--muted); }
.cev-n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cev-s { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 2; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.plan .ein { display: block; border-left: 4px solid var(--pc); background: color-mix(in srgb, var(--pc) 14%, var(--panel)); border-radius: 4px; padding: 3px 6px; font-size: .78rem; margin-bottom: 4px; cursor: pointer; }
/* Kalender scrollt in sich: Kopfzeile und Uhrzeit-Spalte bleiben stehen */
.cal { max-height: calc(100dvh - 210px); min-height: 360px; overflow: auto; overscroll-behavior: contain; }
.cal-row > :first-child { position: sticky; left: 0; z-index: 2; background: var(--panel); border-right: 1px solid var(--line); }
.cal-head > :first-child { z-index: 4; }
.cal-ad { position: sticky; top: 37px; z-index: 3; background: var(--panel); }
.plan td.who, .plan thead th:first-child { position: sticky; left: 0; z-index: 2; background: var(--panel); }
.plan thead th:first-child { background: var(--panel2); z-index: 3; }

/* Ziehen mit Maus und Finger */
[data-pd] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.cev[data-pd], .cev-p[data-pd], .kcard[data-pd], .calma[data-pd], .ein[data-pd], .cad[data-pd] { cursor: grab; }
.pd-on, .pd-on * { cursor: grabbing !important; }
.pd-src { opacity: .35; }
.pd-ghost { position: fixed !important; z-index: 200; pointer-events: none; margin: 0 !important; box-shadow: 0 10px 30px rgba(0,0,0,.28) !important; transform: rotate(1.5deg) scale(1.03); opacity: .95; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; left: 0; top: 0; }
.pd-ghost.cev { background: color-mix(in srgb, var(--c) 22%, var(--panel)); border-left: 4px solid var(--c); }
.pd-ghost .cev-rs, .pd-ghost input { display: none; }
.pd-badge { display: block; font: 600 .74rem var(--f-body); color: var(--accent); white-space: nowrap; }
.pd-badge:empty { display: none; }

/* ---------- Belege */
.pos-tbl input, .pos-tbl select { padding: 5px 7px; }
.pos-tbl td { padding: 5px 6px; }
.pos-tbl .w-txt { min-width: 260px; }
.pos-tbl .w-n { width: 90px; }
.pos-tbl .w-e { width: 90px; }
.totals { display: grid; grid-template-columns: auto auto; gap: 4px 24px; justify-content: end; font-variant-numeric: tabular-nums; }
.totals .big { font-family: var(--f-display); font-size: 1.5rem; font-weight: 700; }
.sheet-wrap { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; overflow-x: auto; }

/* ---------- Chat */
.chat { display: grid; grid-template-columns: 240px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); height: calc(100vh - 190px); min-height: 420px; overflow: hidden; }
.chlist { border-right: 1px solid var(--line); overflow-y: auto; padding: 10px; display: grid; gap: 2px; align-content: start; background: var(--panel2); }
.chbtn { display: flex; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 7px 9px; border-radius: 6px; cursor: pointer; width: 100%; }
.chbtn:hover { background: var(--panel); }
.chbtn.on { background: var(--accent); color: var(--accent-ink); }
.chbtn .h { font-family: var(--f-mono); opacity: .6; }
.chmain { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chhead { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.msg { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 3px 34px 3px 6px; border-radius: 6px; }
.msg:not(.cont) { margin-top: 8px; }
.msg:hover { background: var(--panel2); }
.msg .av { width: 32px; height: 32px; }
.msg .mh { display: flex; gap: 8px; align-items: baseline; }
.msg .mh b { font-weight: 600; }
.msg .mt { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me .mh b { color: var(--accent); }
.msg .mimg { max-width: min(320px, 100%); max-height: 240px; border-radius: 6px; margin-top: 4px; display: block; }
.msg .del { visibility: hidden; position: absolute; right: 4px; top: 2px; }
.msg:hover .del { visibility: visible; }
.dayline { text-align: center; font-size: .75rem; color: var(--muted); margin: 10px 0 4px; }
.chform { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chform textarea { flex: 1; resize: none; max-height: 140px; }

/* ---------- Druck */
#print { display: none; }
.sheet { background: #fff; color: #161616; width: 794px; max-width: 100%; margin: 0 auto; padding: 56px 64px; font: 12.5px/1.5 var(--f-body); box-shadow: 0 2px 14px rgba(0,0,0,.12); min-height: 1060px; display: flex; flex-direction: column; }
.sheet .sh-top { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 40px; }
.sheet .sh-firm { text-align: right; font-size: 11.5px; color: #444; }
.sheet .sh-firm b { font-family: var(--f-display); font-size: 22px; color: #161616; display: block; margin-bottom: 4px; letter-spacing: .02em; }
.sheet .sh-sender { font-size: 9.5px; color: #666; border-bottom: 1px solid #999; display: inline-block; margin-bottom: 6px; }
.sheet h1 { font-size: 26px; margin: 28px 0 4px; color: #161616; }
.sheet .sh-meta { display: grid; grid-template-columns: auto auto; gap: 2px 18px; font-size: 11.5px; justify-content: start; margin-bottom: 22px; color: #333; }
.sheet table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.sheet th { text-align: left; border-bottom: 1.5px solid #161616; padding: 6px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.sheet td { border-bottom: 1px solid #ddd; padding: 6px 4px; vertical-align: top; }
.sheet .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet .sh-sum { margin-left: auto; display: grid; grid-template-columns: auto auto; gap: 3px 28px; font-variant-numeric: tabular-nums; }
.sheet .sh-sum .b { font-weight: 700; font-size: 14px; border-top: 1.5px solid #161616; padding-top: 4px; }
.sheet .sh-foot { margin-top: auto; padding-top: 28px; border-top: 1px solid #ccc; font-size: 9.5px; color: #555; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  #app, #modal, #toast, #auth { display: none !important; }
  #print { display: block; }
  #print .sheet { box-shadow: none; width: 210mm; min-height: 297mm; padding: 18mm 20mm; }
}

/* ---------- Schmale Bildschirme */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bwrap { grid-template-columns: minmax(0, 1fr); }
}
/* ---------- Handy-Navigation (unten) und „Mehr“-Seite */
#mnav { display: none; }
.only-mobile { display: none !important; }
.mehr { display: grid; gap: 2px; padding: 10px 12px; }
.mehr .eyebrow { padding: 4px 6px 6px; }
.mehr-btn { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 12px 6px; border-radius: 8px; font-size: 1rem; text-align: left; cursor: pointer; }
.mehr-btn:hover { background: var(--panel2); }
.mehr-btn svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.mehr-btn span:first-of-type { flex: 1; }

/* ---------- Tablet */
@media (max-width: 1100px) and (min-width: 821px) {
  #app { grid-template-columns: 200px minmax(0, 1fr); }
  #main { padding: 20px 20px 40px; }
  .calwrap { grid-template-columns: 210px minmax(0, 1fr); }
  .kanban { grid-template-columns: repeat(3, minmax(230px, 1fr)); }
}

/* ---------- Handy */
@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #nav { display: none; }
  .only-mobile { display: inline-flex !important; }
  .only-desktop { display: none !important; }
  #mnav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
  .mn-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; color: var(--muted); padding: 6px 2px; border-radius: 8px; font-size: .68rem; cursor: pointer; min-height: 52px; justify-content: center; }
  .mn-btn svg { width: 23px; height: 23px; }
  .mn-btn.on { color: var(--accent); }
  .mn-btn.on svg { stroke-width: 2.3; }
  .mn-badge { position: absolute; top: 3px; left: calc(50% + 6px); background: var(--bad); color: #fff; font-style: normal; font-size: .64rem; font-weight: 700; border-radius: 99px; min-width: 17px; height: 17px; line-height: 17px; padding: 0 4px; text-align: center; }
  #top { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); gap: 10px; }
  .online .lbl { display: none; }
  .online .av:nth-child(n+5) { display: none; }
  #main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom, 0px)); }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .page { gap: 14px; }
  h1 { font-size: 1.65rem; }
  .hello h1 { font-size: 1.9rem; }
  .ph { align-items: flex-start; }
  .ph .acts { width: 100%; }
  .card { padding: 14px; }

  /* Raster */
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .g4 .kpi .v { font-size: 1.6rem; }
  .span2 { grid-column: auto; }
  .fgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
  .fgrid > *:not(.half) { grid-column: 1 / -1; }
  .addrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .addrow input[type=text] { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pcards { grid-template-columns: minmax(0, 1fr); }

  /* Eingaben: 16px, damit das iPhone nicht hineinzoomt; größere Tippflächen */
  input[type=text], input[type=number], input[type=date], input[type=time], input[type=email], input[type=tel], input[type=password], input[type=search], input[type=month], select, textarea { font-size: 16px; padding: 9px 11px; }
  .btn { padding: 9px 14px; }
  .btn.sm { padding: 6px 11px; }
  .ib { width: 40px; height: 40px; }
  .fbtn { padding: 7px 13px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters select { min-width: 150px; }
  .tabs { scrollbar-width: none; }

  /* Formulare als Vollbild-Fenster von unten */
  #modal { padding: 0; place-items: end stretch; }
  .mbox { width: 100%; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px); border-radius: 14px 14px 0 0; }
  .mfoot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; }
  .mfoot .btn.pri { flex: 1; justify-content: center; }

  /* Tabellen werden zu Karten */
  .tbl-wrap { overflow: visible; }
  .card.tbl-wrap:not(:has(.plan)) { padding: 6px; background: transparent; border: 0; }
  .tbl-wrap:has(.plan) { overflow-x: auto; }
  table.tbl:not(.pos-tbl) td { white-space: normal !important; }
  table.tbl:not(.pos-tbl), table.tbl:not(.pos-tbl) tbody { display: block; }
  table.tbl:not(.pos-tbl) thead { display: none; }
  table.tbl:not(.pos-tbl) tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
  table.tbl:not(.pos-tbl) td { display: block; border: 0; padding: 0; min-width: 0; text-align: left !important; overflow-wrap: anywhere; }
  table.tbl:not(.pos-tbl) td[data-l]::before { content: attr(data-l); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  table.tbl:not(.pos-tbl) td:nth-child(2) { grid-column: 1 / -1; order: -1; font-weight: 600; font-size: 1rem; }
  table.tbl:not(.pos-tbl) td:nth-child(2)::before { display: none; }
  table.tbl[data-t]:not(.pos-tbl) td:nth-child(2) { grid-column: auto; order: 0; font-weight: 400; font-size: inherit; }
  table.tbl[data-t]:not(.pos-tbl) td:nth-child(2)::before { display: block; }
  table.tbl[data-t="1"] td:nth-child(1), table.tbl[data-t="3"] td:nth-child(3) { grid-column: 1 / -1; order: -1; font-weight: 600; font-size: 1rem; }
  table.tbl[data-t="1"] td:nth-child(1)::before, table.tbl[data-t="3"] td:nth-child(3)::before { display: none; }
  table.tbl:not(.pos-tbl) td:empty, table.tbl:not(.pos-tbl) td[colspan] { grid-column: 1 / -1; }
  table.tbl:not(.pos-tbl) td.r:last-child:has(.btn) { grid-column: 1 / -1; }
  table.tbl:not(.pos-tbl) tfoot { display: block; }
  .tbl tr.click:hover td { background: none; }

  /* Angebots-/Rechnungspositionen als Karten */
  .pos-tbl thead { display: none; }
  .pos-tbl, .pos-tbl tbody { display: block; }
  .pos-tbl tr { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
  .pos-tbl td { padding: 0 !important; border: 0; min-width: 0 !important; width: auto !important; }
  .pos-tbl td.w-txt { grid-column: 2 / -1; }
  .pos-tbl td:first-child { grid-row: span 2; align-self: start; padding-top: 10px !important; }
  .pos-tbl td[id^="gp"] { grid-column: 2 / 4; font-weight: 600; }
  .pos-tbl td[colspan] { grid-column: 1 / -1; }
  .pos-tbl td.w-n[data-l]::before, .pos-tbl td.w-e[data-l]::before { content: attr(data-l); display: block; font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  .totals { justify-content: stretch; grid-template-columns: 1fr auto; }

  /* Gebäude */
  .bstage { padding: 18px 14px 14px; }
  .floor { min-height: 62px; }
  .trow { grid-template-columns: auto minmax(0, 1fr); }
  .trow > :last-child:empty, .trow > span:last-child:not(.chip) { display: none; }

  /* Aufgaben-Board: Spalten seitlich wischen */
  .kanban { grid-template-columns: repeat(3, 84vw); scroll-snap-type: x mandatory; padding-bottom: 6px; }
  .kcol { scroll-snap-align: start; }

  /* Einsatzplan */
  .fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 41; width: 56px; height: 56px; border-radius: 50%; border: 0;
    background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 1; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer; }
  .caltools { gap: 8px; flex-wrap: nowrap; }
  .caltools .filters { flex: 1; }
  .caltools .acts { flex: none; }
  .caltools .acts { flex-wrap: nowrap; gap: 4px; }
  .caltools .acts .btn { padding: 7px 10px; }
  .caltools .fbtn { padding: 7px 11px; }
  .calwrap { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .calside { position: static; padding: 10px 12px; gap: 8px; }
  .calside-h { gap: 8px; align-items: center; }
  .calside-h b { flex: 1; }
  .calside > .acts, .calside > .small, .calside .calopt { display: none; }
  .calside.open > .acts, .calside.open > .small, .calside.open .calopt { display: flex; }
  .calside.open .calopt.fld { display: grid; }
  .calmas { display: flex; flex-wrap: nowrap; overflow-x: auto; max-height: none; gap: 6px; margin: 0 -12px; padding: 2px 12px 4px; scrollbar-width: none; }
  .calmas::-webkit-scrollbar { display: none; }
  .calma { flex: none; border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; background: var(--panel); }
  .calma .small, .calma .muted { display: none !important; }
  .calma input { display: none; }
  .calma.off { opacity: .45; text-decoration: line-through; }
  .cal { max-height: calc(100dvh - 300px - env(safe-area-inset-bottom, 0px)); }
  .cal-gut span { font-size: .64rem; right: 4px; }
  .cal-adl { font-size: .6rem; }

  /* Chat */
  #main:has(.chat) { padding-bottom: 0; overflow: hidden; }
  #main:has(.chat) .page { gap: 0; }
  .chat { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: calc(100dvh - var(--topbar, 59px) - var(--mnav, 61px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: 240px;
    margin: -14px -12px 0; border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
  .chlist { border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; padding: 8px; scrollbar-width: none; }
  .chbtn { width: auto; white-space: nowrap; padding: 7px 12px; border-radius: 99px; }
  .chhead { padding: 8px 12px; }
  .msgs { padding: 10px; }
  .msg { padding-right: 40px; }
  .chform { padding: 8px; padding-bottom: 8px; }
  .chform .btn.ghost { padding: 9px 10px; }

  /* Belege */
  .sheet-wrap { padding: 8px; }
  .sheet { padding: 28px 22px; min-height: 0; }
  .sheet .sh-top { flex-direction: column; }
  .sheet .sh-firm { text-align: left; }
  .sheet .sh-foot { grid-template-columns: 1fr; }
}

/* Touch-Geräte: Bedienelemente immer sichtbar und größer */
@media (pointer: coarse) {
  .msg .del { visibility: visible; opacity: .5; }
  .cev-rs { height: 16px; }
  .cev-rs.top { top: -6px; }
  .cev-rs.bot { bottom: -6px; }
  .cev-rs::after { opacity: .7; width: 26px; margin-left: -13px; height: 4px; }
  .cev-rs.top::after { top: 6px; }
  .cev-rs.bot::after { bottom: 6px; }
}
