/* Objektportal Mühlbauer – AP&S Service Dresden
   Farben hier anpassen, falls das AP&S-CD andere Werte vorgibt. */
:root {
  --brand: #00457c;
  --brand-2: #0068b4;
  --brand-soft: #e6eff8;
  --ink: #1b2430;
  --ink-2: #5a6675;
  --line: #dde3ea;
  --bg: #f4f6f9;
  --card: #fff;
  --red: #d33b32;   --red-soft: #fdecea;
  --yellow: #e0a100; --yellow-soft: #fff6da;
  --green: #2e9a52; --green-soft: #e6f5ec;
  --grey: #8a94a1;  --grey-soft: #eef0f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --tabbar-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.45; }
a { color: var(--brand-2); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile & Navigation */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 58px; background: var(--brand); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; white-space: nowrap; }
.brand-logo { height: 30px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-text { font-size: 16px; }
.brand-text b { letter-spacing: .5px; }
.mainnav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.mainnav a { color: #d7e6f5; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.mainnav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.mainnav a.on { background: rgba(255,255,255,.18); color: #fff; }
.usermenu { margin-left: auto; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: #fff; color: var(--brand); font-weight: 700; font-size: 14px;
}
.tabbar { display: none; }
.badge-n {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}

@media (max-width: 760px) {
  .mainnav { display: none; }
  .topbar { padding: 0 14px; height: 52px; }
  .brand-text span { display: none; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--ink-2); font-size: 11px; font-weight: 500; position: relative;
  }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a.on { color: var(--brand); }
  .tabbar .badge-n { position: absolute; top: 6px; left: 52%; margin: 0; }
  .app { padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
}

/* ---------- Grundlayout */
.app { max-width: 1100px; margin: 0 auto; padding: 22px 20px 40px; }
.loading { padding: 60px; text-align: center; color: var(--ink-2); }
.pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead .sub { color: var(--ink-2); font-size: 14px; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); margin-bottom: 10px; font-size: 14px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.stats { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) {
  .grid.two { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .app { padding: 16px 12px; }
}
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.empty { padding: 28px 10px; text-align: center; color: var(--ink-2); }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.pre { white-space: pre-wrap; }

/* ---------- Kennzahlen */
.stat { display: block; color: var(--ink); padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--ink-2); font-size: 13px; }
.stat.red .n { color: var(--red); } .stat.yellow .n { color: var(--yellow); }
.stat.green .n { color: var(--green); } .stat.blue .n { color: var(--brand-2); }

/* ---------- Buttons & Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: #c3ccd6; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: var(--brand); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand-2); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .fgrid { grid-template-columns: 1fr; } }
.err { color: var(--red); font-size: 14px; margin: 6px 0 10px; }
.hint { font-size: 13px; color: var(--ink-2); margin: -6px 0 12px; }

/* ---------- Status & Ampel */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px;
  font-weight: 600; white-space: nowrap;
}
.pill.offen { background: var(--red-soft); color: var(--red); }
.pill.in_bearbeitung { background: var(--yellow-soft); color: #9a6c00; }
.pill.erledigt { background: var(--green-soft); color: var(--green); }
.pill.cat { background: var(--brand-soft); color: var(--brand); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot.rot { background: var(--red); } .dot.gelb { background: var(--yellow); }
.dot.gruen { background: var(--green); } .dot.grau { background: var(--grey); }
.amp { display: inline-flex; gap: 5px; padding: 5px 7px; background: #263241; border-radius: 99px; }
.amp i { width: 11px; height: 11px; border-radius: 50%; background: #4b5563; }
.amp.rot i:nth-child(1) { background: var(--red); box-shadow: 0 0 6px var(--red); }
.amp.gelb i:nth-child(2) { background: #f5b800; box-shadow: 0 0 6px #f5b800; }
.amp.gruen i:nth-child(3) { background: #3cc56b; box-shadow: 0 0 6px #3cc56b; }

/* ---------- Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.item { display: flex; gap: 12px; padding: 12px 4px; color: var(--ink); align-items: center; }
a.item:hover { background: #fafbfc; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--ink-2); font-size: 13px; }
.thumb { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--grey-soft); flex: none; }
.thumb.ph { display: grid; place-items: center; color: var(--grey); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; font: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Tabellen */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2);
  padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #fafbfc; }
@media (max-width: 760px) { .hide-m { display: none; } }

/* ---------- Mangel-Detail */
.gallery { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.gallery img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--grey-soft); }
.gallery a.pdf { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 8px;
  background: var(--grey-soft); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; border: 2px solid var(--brand-2); }
.timeline li.st::after { background: var(--brand-2); }
.timeline .who { font-size: 13px; color: var(--ink-2); }
.timeline .bubble { background: var(--bg); border-radius: 10px; padding: 8px 11px; margin-top: 4px; }
.statusbar { display: flex; gap: 6px; flex-wrap: wrap; }
.statusbar .chip.offen.on { background: var(--red); border-color: var(--red); }
.statusbar .chip.in_bearbeitung.on { background: var(--yellow); border-color: var(--yellow); }
.statusbar .chip.erledigt.on { background: var(--green); border-color: var(--green); }

/* ---------- Foto-Auswahl */
.picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.picker .pv { position: relative; width: 78px; height: 78px; }
.picker .pv img, .picker .pv .pdf { width: 78px; height: 78px; object-fit: cover; border-radius: 8px; }
.picker .pv .pdf { display: grid; place-items: center; background: var(--grey-soft); font-size: 11px; font-weight: 700;
  text-align: center; padding: 4px; overflow: hidden; }
.picker .pv button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; cursor: pointer; font-size: 13px; line-height: 22px; padding: 0; }
.picker .add { width: 78px; height: 78px; border: 2px dashed var(--line); border-radius: 8px; display: grid;
  place-items: center; color: var(--ink-2); cursor: pointer; font-size: 12px; text-align: center; background: #fff; }
.picker .add svg { width: 26px; height: 26px; }

/* ---------- Kalender */
.calhead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.calhead h2 { margin: 0; min-width: 170px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.cal .wd { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 6px; text-align: center;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafbfc; }
.cal .d { min-height: 92px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  cursor: pointer; background: #fff; overflow: hidden; }
.cal .d.out { background: #fafbfc; color: #aab3bf; }
.cal .d.today .num { background: var(--brand-2); color: #fff; }
.cal .d.sel { outline: 2px solid var(--brand-2); outline-offset: -2px; }
.cal .num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 600; }
.cal .ev { font-size: 11px; padding: 1px 5px; border-radius: 4px; margin-top: 2px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; background: var(--brand-soft); color: var(--brand); }
.ev.c-reinigung { background: #e3f4f4; color: #0b7a78; }
.ev.c-handwerker { background: #f3ebfb; color: #6d3fa5; }
.ev.c-begehung { background: #fff1e0; color: #a45a00; }
.ev.c-ablesung { background: #eaf1e1; color: #4b7022; }
.ev.c-wartung { background: var(--red-soft); color: var(--red); }
.ev.c-wartung.gruen, .ev.c-wartung.grau { background: var(--green-soft); color: var(--green); }
.ev.c-wartung.gelb { background: var(--yellow-soft); color: #9a6c00; }
.cal .more { font-size: 11px; color: var(--ink-2); margin-top: 2px; }
@media (max-width: 760px) {
  .cal .d { min-height: 54px; padding: 2px; }
  .cal .ev { display: none; }
  .cal .more { display: none; }
  .cal .dots { display: flex; gap: 2px; justify-content: center; margin-top: 2px; flex-wrap: wrap; }
  .cal .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-2); }
  .cal .dots i.c-reinigung { background: #0b9a96; } .cal .dots i.c-wartung { background: var(--red); }
}
@media (min-width: 761px) { .cal .dots { display: none; } }
.agenda .item { align-items: flex-start; }
.agenda .date { width: 54px; text-align: center; flex: none; }
.agenda .date b { display: block; font-size: 20px; line-height: 1.1; }
.agenda .date span { font-size: 12px; color: var(--ink-2); text-transform: uppercase; }
.agenda .ev { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; font-weight: 600; }

/* ---------- Login */
.auth { max-width: 400px; margin: 7vh auto 0; }
.auth .logo { text-align: center; margin-bottom: 18px; }
.auth .logo .mark { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 16px;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.auth .logo img { max-height: 60px; max-width: 220px; }
.auth h1 { text-align: center; margin: 10px 0 4px; }
.auth p.lead { text-align: center; color: var(--ink-2); margin: 0 0 20px; }
.auth .card { padding: 22px; }
.auth .foot { text-align: center; margin-top: 14px; font-size: 14px; }

/* ---------- Dialog & Toast */
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(15,23,35,.45); }
.dlg .dh { display: flex; align-items: center; padding: 16px 18px 6px; }
.dlg .dh h2 { margin: 0; flex: 1; }
.dlg .db { padding: 10px 18px; }
.dlg .df { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 18px 18px; flex-wrap: wrap; }
.dlg .df .left { margin-right: auto; }
.dlg.img { width: auto; max-width: 96vw; background: transparent; box-shadow: none; }
.dlg.img img { max-width: 94vw; max-height: 88vh; border-radius: 10px; display: block; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 50; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
@media (min-width: 761px) { .toast { bottom: 28px; } }
.toast.bad { background: var(--red); }
.copybox { display: flex; gap: 6px; }
.copybox input { font-size: 13px; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 15;
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--brand-2); color: #fff; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,80,160,.4); display: none; place-items: center; }
.fab svg { width: 28px; height: 28px; }
@media (max-width: 760px) { .fab { display: grid; } .hide-m-btn { display: none !important; } }
.btn svg { width: 18px; height: 18px; flex: none; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
.thumb.ph svg { width: 22px; height: 22px; }

/* ---------- Gebäude-Kopfbild & Login-Foto */
.hero { background: var(--brand); color: #fff; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px;
  box-shadow: var(--shadow); position: relative; }
.hero .txt { padding: 18px 20px 0; position: relative; z-index: 1; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.hero h1 { font-size: 24px; }
.hero .sub { color: #c9dcef; font-size: 14px; }
.hero .actions { margin-left: auto; }
.hero .btn.primary { background: #fff; color: var(--brand); border-color: #fff; }
.hero img { display: block; width: 100%; height: auto; margin-top: -26px; }
@media (max-width: 760px) { .hero img { margin-top: 6px; } .hero h1 { font-size: 20px; } }
body.authbg { background: linear-gradient(rgba(0,45,85,.72), rgba(0,45,85,.82)), url(/hero.jpg) center/cover fixed; }
body.authbg .auth h1, body.authbg .auth p.lead, body.authbg .auth > .foot a { color: #fff; }
body.authbg .auth p.lead { color: #d5e4f3; }
body.authbg .auth .logo img { background: #fff; border-radius: 10px; padding: 6px 10px; }
body.authbg .auth .logo .mark { background: #fff; color: var(--brand); }
.auth .addr { text-align: center; color: #c9dcef; font-size: 13px; margin-top: 18px; }
@media (min-width: 761px) { .hero img { width: auto; max-width: 100%; max-height: 250px; margin: -14px auto 0; } }
@media (max-width: 760px) { body.authbg { background-attachment: scroll; } }

/* ---------- Feiertage & gestrichene Termine */
.cal .d.we { background: #fbfcfd; }
.cal .d.hol { background: #fff5f4; }
.cal .d.hol .num { color: var(--red); }
.cal .holname { display: block; font-size: 10.5px; color: var(--red); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.c-feiertag { background: var(--red-soft); color: var(--red); }
.ev.skip { background: var(--grey-soft) !important; color: var(--grey) !important; text-decoration: line-through; }
.item.skipped .t { text-decoration: line-through; color: var(--grey); }
.skipnote { color: #9a6c00; }
.legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg.hol { background: #fbdcd9; } .lg.skip { background: var(--grey-soft); border: 1px solid #cfd5dc; }
.skiplist li { padding: 6px 0; font-size: 14px; }
@media (max-width: 760px) { .cal .holname { font-size: 8.5px; } .cal .d.hol .num { font-weight: 800; } }

/* ---------- Videos & Upload-Fortschritt */
.picker .pv video { width: 78px; height: 78px; object-fit: cover; border-radius: 8px; background: #000; display: block; }
.play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px;
  text-shadow: 0 1px 6px rgba(0,0,0,.6); pointer-events: none; }
.picker .pv .up { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 6px; background: rgba(255,255,255,.8); border-radius: 3px; overflow: hidden; }
.picker .pv .up i { display: block; height: 100%; width: 0; background: var(--brand-2); transition: width .2s; }
.picker .pv .up.err-up { height: auto; background: var(--red); color: #fff; font-size: 11px; text-align: center; padding: 1px; }
.picker .pv.bad img, .picker .pv.bad video { opacity: .4; }
.vthumb { position: relative; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; cursor: pointer; background: #000; }
.vthumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.dlg.img video { max-width: 94vw; max-height: 80vh; border-radius: 10px; display: block; background: #000; }
.areagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; }
.areagrid h3 { font-size: 13px; color: var(--brand); margin: 0 0 4px; }
.areagrid ul { margin: 0; padding-left: 18px; font-size: 14px; }
