/* Einsatzdoku Baufachberater – Gestaltung (schlicht, THW-Blau nur für Aktives) */
:root {
  --blue: #0033cc;
  --blue-d: #00218a;
  --blue-l: #e8edfb;
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #667085;
  --line: #d6dbe4;
  --ok: #1e7b3c;
  --ok-l: #e5f4ea;
  --warn: #9a5b00;
  --err: #b3261e;
  --err-l: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 1rem; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
  background: var(--blue); color: #fff;
}
.top-home { color: #fff; text-decoration: none; display: flex; align-items: center; gap: .5rem; min-width: 0; margin-right: auto; }
.top-title { font-size: 1.05rem; white-space: nowrap; }
.save-state { font-size: .82rem; opacity: .9; white-space: nowrap; }
.save-state.err { background: #fff; color: var(--err); padding: .1rem .5rem; border-radius: 99px; opacity: 1; font-weight: 600; }
.icon-btn {
  background: transparent; border: 0; color: inherit; font-size: 1.35rem; line-height: 1;
  padding: .35rem .5rem; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .15); }
.menu {
  position: fixed; right: .75rem; top: calc(3.2rem + env(safe-area-inset-top)); z-index: 30;
  background: var(--card); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  min-width: 220px; padding: .4rem; display: flex; flex-direction: column;
}
.menu-user { padding: .6rem .75rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.menu button { text-align: left; background: none; border: 0; padding: .6rem .75rem; border-radius: 8px; cursor: pointer; width: 100%; }
.menu button:hover { background: var(--bg); }
.menu-ver { padding: .4rem .75rem 0; }

/* ---------- Grundbausteine ---------- */
.app { max-width: 980px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
h1 { font-size: 1.35rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--card); padding: .55rem .95rem;
  border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--text); min-height: 44px;
}
.btn:hover { border-color: #b5bdcc; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.danger { color: var(--err); border-color: #efc3bf; }
.btn.primary.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.primary.danger:hover { background: #8f1d17; }
.btn.small { min-height: 34px; padding: .3rem .65rem; font-size: .9rem; }
.btn.big { min-height: 52px; font-size: 1.05rem; width: 100%; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.msg { padding: .6rem .8rem; border-radius: 8px; }
.msg.err { background: var(--err-l); color: var(--err); }

/* ---------- einfache Seiten (Anmeldung) ---------- */
body.simple { display: flex; justify-content: center; padding: 1rem; }
.simple-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; width: 100%; max-width: 440px; margin-top: 6vh; }
.brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.brand-bar { background: var(--blue); color: #fff; font-weight: 700; padding: .5rem .75rem; font-size: .92rem; border: 1px solid #000; flex: 1; min-width: 0; }
.brand-logo { width: 36%; max-width: 145px; height: auto; flex-shrink: 0; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .92rem; }

/* ---------- Eingabefelder ---------- */
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input:not([type]), textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem;
  background: #fff; min-height: 44px; font-size: 16px; /* 16px verhindert Zoom auf dem iPhone */
}
input:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input[type=datetime-local], input[type=date] { -webkit-appearance: none; appearance: none; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }

/* ---------- Übersicht ---------- */
.list-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.list-head h1 { margin: 0; flex: 1; }
.e-item {
  display: flex; gap: 1rem; align-items: center; padding: .9rem 1rem;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .6rem;
  text-decoration: none; color: inherit;
}
.e-item:hover { outline: 2px solid var(--blue-l); }
.e-link { display: flex; gap: 1rem; align-items: center; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.icon-del {
  flex-shrink: 0; border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer;
  width: 44px; height: 44px; font-size: 1.1rem; opacity: .55;
}
.icon-del:hover { opacity: 1; border-color: #efc3bf; background: var(--err-l); }

/* Sperren */
.sperre {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--bg); border-radius: 8px; padding: .5rem .75rem; margin-bottom: 1rem;
  font-size: .9rem; color: var(--muted);
}
.sperre.an { background: #fff4e5; color: var(--warn); font-weight: 600; }
.blatt .sperre { margin: 1rem 0 0; }
.blatt.zu .sperre { display: none; }
input:disabled, textarea:disabled { background: #f6f7f9; color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; border-style: dashed; }
.seg button:disabled { cursor: default; opacity: .75; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Begehung: + als eigener Knopf, Zeiten einzeln korrigierbar */
.step.beg .s-icon.s-add {
  border: 0; cursor: pointer; width: 2.6rem; height: 2.6rem; font-size: 1.5rem; line-height: 1;
  background: var(--blue); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.step.beg .s-icon.s-add:active { transform: scale(.94); }
.beg-zeiten { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.beg-zeit {
  border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .1rem .55rem;
  font-size: .82rem; cursor: pointer; font-variant-numeric: tabular-nums; min-height: 28px;
}
.e-date { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--blue); min-width: 5.6rem; }
.e-main { min-width: 0; }
.e-title { font-weight: 600; }
.e-sub { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }

/* ---------- Einsatz ---------- */
.e-head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .75rem; }
.e-head h1 { margin: 0; font-size: 1.25rem; }
.back { text-decoration: none; font-size: .92rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: .6rem; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: .4rem .85rem;
  white-space: nowrap; cursor: pointer; min-height: 38px; max-width: 16rem; overflow: hidden; text-overflow: ellipsis;
}
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.add { color: var(--blue); border-style: dashed; }
.tabs {
  position: sticky; top: calc(2.9rem + env(safe-area-inset-top)); z-index: 10;
  display: flex; gap: .25rem; background: var(--bg); padding: .35rem 0; margin-bottom: .75rem;
  overflow-x: auto; scrollbar-width: none; align-items: center;
}
.tabs::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; padding: .5rem .8rem; border-radius: 8px; cursor: pointer;
  white-space: nowrap; color: var(--muted); font-weight: 600; min-height: 40px;
}
.tab.active { background: var(--card); color: var(--blue); box-shadow: var(--shadow); }
.tabs .btn { margin-left: auto; flex-shrink: 0; }

/* Formular */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.1rem; }
.f { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f > label, .f-label { font-weight: 600; font-size: .9rem; display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.badge { font-weight: 500; font-size: .72rem; color: var(--blue); background: var(--blue-l); border-radius: 99px; padding: .05rem .5rem; }
.hint { color: var(--muted); font-size: .8rem; }
.zeit { display: flex; gap: .4rem; }
.zeit input { flex: 1; min-width: 0; }
.zeit .btn { flex-shrink: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; width: max-content; }
.seg button { border: 0; background: #fff; padding: .5rem 1.4rem; cursor: pointer; min-height: 44px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--blue); color: #fff; }
.seg button.on.nein { background: var(--err); }
.sep { grid-column: 1 / -1; border: 0; border-top: 1px solid var(--line); margin: .2rem 0; }
.sec-title { grid-column: 1 / -1; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-top: .3rem; }

/* Einlegeblätter */
.blatt-head { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.blatt-head h2 { margin: 0; flex: 1; }
.blatt-head .chev { transition: transform .15s; color: var(--muted); }
.blatt.zu .chev { transform: rotate(-90deg); }
.blatt .form { margin-top: 1rem; }
.blatt.zu .form, .blatt.zu .blatt-foot { display: none; }
.blatt-foot { margin-top: 1rem; display: flex; justify-content: flex-end; }

/* Zeiten (Einsatzmodus) */
.steps { display: flex; flex-direction: column; gap: .5rem; }
.step {
  display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .85rem 1rem; min-height: 62px; cursor: pointer; box-shadow: var(--shadow);
}
.step .s-icon {
  width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
  background: var(--bg); color: var(--muted);
}
.step .s-text { flex: 1; min-width: 0; }
.step .s-label { font-weight: 600; font-size: 1.02rem; }
.step .s-sub { color: var(--muted); font-size: .84rem; }
.step .s-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.step.done { background: #fafbfd; }
.step.done .s-icon { background: var(--ok-l); color: var(--ok); }
.step.next { border: 2px solid var(--blue); background: var(--blue-l); }
.step.next .s-icon { background: var(--blue); color: #fff; }
.step.next .s-label { color: var(--blue-d); }
.step:active { transform: scale(.99); }
.quick { margin-top: 1rem; }
.quick textarea { min-height: 84px; }
.quick .row { margin-top: .5rem; }

/* Protokoll */
.prot { width: 100%; border-collapse: collapse; font-size: .9rem; }
.prot td { padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prot .p-ts { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.prot .p-alt { color: var(--muted); text-decoration: line-through; }
.prot .p-what { font-weight: 600; }
.prot .p-ctx { color: var(--muted); font-weight: 400; }

/* Gefahrenbereich */
.danger-zone { margin-top: 1.5rem; display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }

/* Hinweis unten */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 50;
  background: #1c2230; color: #fff; border-radius: 10px; padding: .7rem 1rem; display: flex; gap: 1rem; align-items: center;
  max-width: calc(100% - 2rem); box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.toast button { background: none; border: 0; color: #9db4ff; font-weight: 700; cursor: pointer; padding: .2rem .3rem; }

/* Dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100% - 2rem)); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dlg { padding: 1.2rem; display: flex; flex-direction: column; gap: .9rem; }
.dlg h2 { margin: 0; }
.dlg-btns { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Handy ---------- */
@media (max-width: 700px) {
  .app { padding: .75rem .75rem 6rem; }
  .form { grid-template-columns: 1fr; }
  .card { padding: .85rem; }
  .e-date { min-width: 4.9rem; font-size: .95rem; }
  .tabs .btn { padding: .3rem .6rem; }
  .top-title { font-size: 1rem; }
  dialog { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; }
  .dlg { padding-bottom: calc(1.2rem + env(safe-area-inset-bottom)); }
  .dlg-btns .btn { flex: 1; }
  .toast { width: calc(100% - 1.5rem); justify-content: space-between; }
}

/* ---------- Fotos (M2) ---------- */
select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem;
  background: #fff; min-height: 44px; font-size: 16px;
}
select:disabled { background: #f6f7f9; border-style: dashed; color: var(--text); opacity: 1; }
.up { font-weight: 600; }
.ta-tools { display: flex; justify-content: flex-end; margin-top: .35rem; }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card.foto { padding: 0; overflow: hidden; margin: 0; display: flex; flex-direction: column; }
.foto-bild { border: 0; padding: 0; background: #e3e7ee; cursor: zoom-in; display: block; aspect-ratio: 4 / 3; width: 100%; }
.foto-bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-body { padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.foto-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.chk { display: flex; align-items: center; gap: .4rem; font-size: .9rem; min-height: 32px; cursor: pointer; }
.chk input { width: 20px; height: 20px; }
.chk.aus { color: var(--muted); }
.foto-akt { display: flex; gap: .4rem; align-items: center; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; max-height: 60vh; overflow: auto; }
.pick-item { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .3rem; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: .25rem; }
.pick-item:hover { border-color: var(--blue); }
.pick-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; display: block; }
.pick-item span { font-weight: 600; font-size: .85rem; display: flex; flex-direction: column; }
.pick-item small { font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.gross { width: min(1100px, calc(100% - 2rem)); }
.foto-gross img { width: 100%; max-height: 72vh; object-fit: contain; display: block; background: #111; border-radius: 6px; }
.blatt-fotobox { margin-top: 1rem; display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.blatt.zu .blatt-fotobox { display: none; }
.blatt-fotos { display: flex; flex-wrap: wrap; gap: .4rem; }
.mini { border: 2px solid var(--line); border-radius: 8px; padding: 0; background: #fff; cursor: zoom-in; overflow: hidden; width: 84px; display: flex; flex-direction: column; }
.mini.im { border-color: var(--blue); }
.mini img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.mini span { font-size: .72rem; padding: .1rem .3rem; text-align: center; }
.foto-row { margin-top: .75rem; }
.quick .blatt-fotos { margin-top: .5rem; }
@media (max-width: 700px) {
  .fotos { grid-template-columns: 1fr; }
  .up { font-size: .75rem; }
}

/* Hinweis auf nahende Löschung (Aufbewahrungsfrist) */
.e-frist { color: #9a5b00; font-weight: 600; }
