/* ---- Display-Schrift (geometrischer Sans), lokal eingebettet ---- */
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../vendor/fonts/poppins-500.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../vendor/fonts/poppins-600.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../vendor/fonts/poppins-700.woff2") format("woff2");
}

:root {
  --brand: #000000;          /* Primärfarbe: Schwarz (druckt sauber in S/W) */
  --brand-dark: #2a2a2a;
  --brand-light: #ededed;
  --ok: #111111;             /* aktive Auswahl monochrom */
  --ok-light: #e7e7e7;
  --danger: #c0392b;
  --bg: #f4f4f4;             /* helles Grau wie auf der Website */
  --card: #ffffff;
  --text: #111111;
  --muted: #767676;
  --border: #e3e3e3;
  --radius: 16px;
  --pill: 999px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --header-h: 60px;
  --footer-h: 72px;
  --font-display: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  width: 100%;
  overflow-x: hidden;       /* Seite scrollt nie seitlich */
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  padding-right: 16px;
  border-bottom: 1px solid var(--border);
}
.app-header h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  background: #f0f0f0;
  border: none;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--pill);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cfcfcf;
  flex: 0 0 auto;
}
.status-dot.online { background: #111; }

/* ---------- View ---------- */
.view {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: calc(100vh - var(--header-h));
}

/* ---------- Karten / Liste ---------- */
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 18px 4px 8px;
  font-weight: 700;
}
.lead { color: var(--muted); margin: 4px 4px 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  overflow: hidden;
}
.proto-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.06s ease;
}
.proto-card:active { transform: scale(0.99); }
.proto-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex: 0 0 auto;
}
.proto-info { flex: 1; min-width: 0; }
.proto-name {
  font-family: var(--font-display);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proto-sub { font-size: 0.82rem; color: var(--muted); }
.proto-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  padding: 6px 8px;
  cursor: pointer;
}
.proto-go {
  color: #bdbdbd;
  font-size: 1.7rem;
  line-height: 1;
  padding: 0 4px;
  flex: 0 0 auto;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--pill);
  padding: 15px 20px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-display);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: var(--brand-light); color: var(--text); }
.btn-outline { background: #fff; color: var(--text); border: 1.5px solid #111; }
.btn-success { background: var(--brand); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-sm { padding: 9px 14px; font-size: 0.9rem; width: auto; }

.app-version {
  text-align: center;
  color: #b7bccb;
  font-size: 0.75rem;
  margin: 18px 0 4px;
}

/* ---------- Anmeldung ---------- */
.auth-wrap { min-height: 62vh; display: flex; align-items: flex-start; justify-content: center; padding-top: 22px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.auth-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-bottom: 12px; }
.auth-hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }
.auth-note { background: var(--brand-light); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 0.88rem; margin: 0 0 12px; }
.auth-lbl { display: block; margin: 12px 0 6px; }
.auth-input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 12px; font-size: 16px; font-family: inherit; background: #fff; color: var(--text);
}
.auth-input:focus { outline: none; border-color: var(--brand); }
.auth-msg { min-height: 18px; font-size: 0.85rem; margin-top: 8px; color: var(--muted); }
.auth-msg.err { color: var(--danger); }
.auth-alt { margin-top: 14px; font-size: 0.9rem; color: var(--muted); text-align: center; }
.auth-alt a { color: var(--text); font-weight: 600; }

/* ---------- Kopfleiste (angemeldet) ---------- */
.userbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.userchip { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.userbar-actions { display: flex; gap: 8px; }
.ubtn {
  background: #f0f0f0; border: none; border-radius: var(--pill);
  padding: 8px 14px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--text);
}
.ubtn:active { background: #e2e2e2; }

/* ---------- Nutzerverwaltung ---------- */
.pending-head { font-family: var(--font-display); font-weight: 700; margin: 6px 2px 8px; }
.hint-line { color: var(--muted); font-size: 0.9rem; margin: 0 2px 8px; }
.user-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 8px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.user-name { font-weight: 600; }
.user-sub { font-size: 0.8rem; color: var(--muted); }
.user-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-sel { font-size: 0.85rem; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-family: inherit; }

.ok-tag { font-size: 0.72rem; font-weight: 700; color: var(--ok); background: var(--ok-light); padding: 2px 8px; border-radius: 999px; }
.ck-line { display: flex; align-items: flex-start; gap: 8px; font-size: 0.9rem; color: var(--text); cursor: pointer; }
.ck-line input { margin-top: 2px; width: 18px; height: 18px; flex: 0 0 auto; }
.warn-tag { font-size: 0.72rem; font-weight: 700; color: var(--danger); background: #f6e4e2; padding: 2px 8px; border-radius: 999px; }

/* ---------- KI-Chat ---------- */
.chat-fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 90;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--brand); color: #fff; border: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.chat-fab svg { width: 26px; height: 26px; }

.chat-panel {
  position: fixed;
  z-index: 95;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 90px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  display: flex; flex-direction: column;
  overflow: hidden;
}
@media (max-width: 480px) {
  .chat-panel { right: 8px; left: 8px; width: auto; bottom: 8px; height: calc(100vh - 80px); max-height: none; }
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-weight: 700;
}
.chat-close { background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.ai { align-self: flex-start; background: #f0f1f5; color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-img { align-self: flex-end; max-width: 60%; border-radius: 12px; }
.chat-imgprev { padding: 8px 14px 0; position: relative; }
.chat-imgprev img { max-height: 70px; border-radius: 8px; }
.chat-img-x { position: absolute; top: 4px; left: 60px; background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }
.chat-input {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 10px; border-top: 1px solid var(--border);
}
.chat-input textarea {
  flex: 1; min-width: 0; resize: none;
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: 16px; font-family: inherit;
  max-height: 120px; background: #fff; color: var(--text);
}
.chat-input textarea:focus { outline: none; border-color: var(--brand); }
.chat-icon-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px;
  border: none; background: var(--brand-light); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.chat-icon-btn.send { background: var(--brand); color: #fff; }
.chat-icon-btn svg { width: 20px; height: 20px; }
.chat-sources {
  align-self: flex-start;
  max-width: 92%;
  margin-top: -4px;
  font-size: 0.78rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.src-label { color: var(--muted); font-weight: 600; }
.src-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.src-chip:not(.nolink):active { background: #dcdcdc; }
.src-chip.nolink { color: var(--muted); background: #f2f2f2; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}
.empty .big { color: #cdcdcd; margin-bottom: 10px; }
.empty .big .ic { width: 56px; height: 56px; margin: 0 auto; }

/* ---------- Wizard ---------- */
.wizard-progress {
  position: sticky;
  top: calc(var(--header-h) + env(safe-area-inset-top));
  z-index: 20;
  background: var(--bg);
  padding: 12px 2px 8px;
  margin: -16px -16px 12px;
  padding-left: 16px;
  padding-right: 16px;
}
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}
.step-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 6px 2px 16px; }

/* ---------- Felder ---------- */
.field {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.field-label {
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}
.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.field textarea { resize: vertical; min-height: 90px; }

.input-with-cam { display: flex; gap: 8px; align-items: flex-start; }
.input-with-cam textarea, .input-with-cam input { flex: 1; }
.cam-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--brand-light);
  color: var(--text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-btn:active { background: #dcdcdc; }
.ic { width: 22px; height: 22px; display: block; }
.proto-icon .ic { width: 24px; height: 24px; }
.cam-grid .ic { width: 18px; height: 18px; }

/* Checkbox */
.check-field {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.check-box {
  width: 30px;
  height: 30px;
  border: 2px solid var(--border);
  border-radius: 8px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  transition: all 0.12s ease;
}
.check-field.checked .check-box {
  background: var(--ok);
  border-color: var(--ok);
}
.check-field .field-label { margin: 0; font-weight: 500; }
.check-field.checked { /* visuelles Feedback */ }

.ocr-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 8px;
}
.ocr-toggle select {
  font-size: 0.78rem;
  padding: 3px 6px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
}

/* Unterschrift */
.sig-wrap { margin-bottom: 14px; }
.sig-canvas {
  width: 100%;
  height: 170px;
  background: #fff;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  touch-action: none;
  display: block;
}
.sig-actions { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ---------- Wizard-Footer ---------- */
.wizard-footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  margin: 16px -16px 0;
  display: flex;
  gap: 10px;
}
.wizard-footer .btn { flex: 1; }

/* ---------- Overlay / Toast ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 15, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay-box {
  background: #fff;
  border-radius: 16px;
  padding: 26px 34px;
  text-align: center;
  max-width: 80%;
}
.overlay-box p { margin: 14px 0 0; color: var(--text); }
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--brand-light);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 110;
  background: #2b2f45;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  max-width: 88%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- Checkliste ---------- */
.checklist-field .cl-label { font-weight: 600; margin-bottom: 8px; }
.cl-status { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.cl-tog {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.cl-tog.on {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.cam-sm { width: 44px; height: 42px; font-size: 1.2rem; }

/* ---------- Raster / Grid ---------- */
.grid-field { padding: 12px; }
.grid-caption { font-family: var(--font-display); font-weight: 700; color: var(--text); margin-bottom: 8px; }
/* Breite Tabellen: eigener wischbarer Bereich, Rest der Seite bleibt fix */
.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.g-table { border-collapse: collapse; }
/* schmal: füllt die Breite, kein Seitwärts-Scrollen */
.g-table.fit { table-layout: fixed; width: 100%; }
/* breit: eigener wischbarer Bereich mit lesbaren Mindestbreiten */
.g-table.wide { width: auto; min-width: 100%; }
.g-table td {
  border: 1px solid var(--border);
  padding: 7px 7px;
  font-size: 0.9rem;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.g-table.wide td { min-width: 58px; }
.g-table.wide td.g-l { min-width: 84px; }
.g-table td.g-l { background: #f7f8fc; color: var(--text); font-weight: 600; }
.g-in {
  width: 100%;
  min-width: 0;
  border: none;
  border-bottom: 1.5px solid #d6d6d6;
  padding: 8px 4px;
  font-size: 16px;            /* >=16px: verhindert iOS-Zoom beim Tippen */
  font-family: inherit;
  background: #fafafa;
  color: var(--text);
}
.g-table.wide .g-in { min-width: 70px; }
.g-in:focus { outline: none; border-bottom-color: #111; background: #fff; }
.g-cam { display: flex; gap: 6px; align-items: center; }
.g-cam .g-in { flex: 1; min-width: 0; }
.cam-grid { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 9px; }
.g-date { width: 100%; }
.g-lead { font-weight: 600; display: block; margin-bottom: 3px; }
.g-opt {
  display: inline-block;
  margin: 2px 5px 2px 0;
  padding: 4px 9px;
  border-radius: var(--pill);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
}
.g-opt.on { background: #111; color: #fff; border-color: #111; font-weight: 600; }
/* Optionen als Chips in einem Formularfeld */
.opt-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
/* Unter-Überschrift innerhalb eines Rasters (Rückfall) */
.gsub { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin: 14px 2px 8px; }
/* Einheit-Auswahl (DFP) */
.unit-select {
  width: 100%;
  font-size: 16px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.unit-select:focus { outline: none; border-color: var(--brand); }

/* Errechnete (schreibgeschützte) Ergebniszellen */
.g-out {
  font-weight: 700;
  padding: 8px 5px;
  font-size: 0.92rem;
  color: #111;
  background: #efefef;
  border-radius: 6px;
  text-align: center;
  min-height: 22px;
  min-width: 80px;
}
.g-out.tol-bad { text-decoration: underline; text-decoration-thickness: 2px; }
.dfp-unit {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 2px 0 12px;
}
.dfp-unit select {
  font-size: 16px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: inherit;
}

/* ---------- Summary / Review ---------- */
.summary-group { margin-bottom: 16px; }
.summary-group h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 2px;
  font-size: 0.92rem;
}
.summary-row .k { color: var(--muted); flex: 1; }
.summary-row .v { font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }
.summary-row .v.empty-v { color: #b7bccb; font-weight: 400; font-style: italic; }
