/* i2fm Inspect — B2B design system (Red #DC2626, Slate #0F172A, Light Gray #F8FAFC) */
:root {
  --red: #DC2626;
  --red-dark: #B91C1C;
  --slate: #0F172A;
  --slate-2: #1E293B;
  --slate-3: #334155;
  --gray-bg: #F8FAFC;
  --gray-line: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --white: #FFFFFF;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
  --touch: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--gray-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }
.topbar {
  background: var(--slate);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--red); display: inline-block; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; align-items: center; }
.topbar nav a {
  color: #CBD5E1; font-size: 14px; font-weight: 600;
  padding: 10px 14px; border-radius: 8px; min-height: var(--touch);
  display: inline-flex; align-items: center;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.topbar nav a.active { background: rgba(220,38,38,.18); color: #fff; }
.user-chip { color: #94A3B8; font-size: 13px; margin-left: 8px; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--gray-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 18px; margin-bottom: 4px; letter-spacing: -.01em; }
.card .sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 20px;
  border-radius: 10px; border: none; font-weight: 700; font-size: 15px;
  transition: background .2s, transform .15s, box-shadow .2s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); box-shadow: 0 6px 18px rgba(220,38,38,.3); text-decoration: none; color: #fff; }
.btn-dark { background: var(--slate); color: #fff; }
.btn-dark:hover { background: var(--slate-2); color: #fff; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--slate); border: 1px solid var(--gray-line); }
.btn-ghost:hover { background: var(--gray-bg); text-decoration: none; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.btn-danger-ghost { background: transparent; color: var(--red); border: 1px solid #FECACA; }
.btn-danger-ghost:hover { background: #FEF2F2; }
.btn-block { width: 100%; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(220,38,38,.4); outline-offset: 2px;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--slate-2); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; min-height: 44px;
  border: 1.5px solid var(--gray-line); border-radius: 10px;
  padding: 10px 14px; font-size: 16px; background: #fff;
  transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--red); outline: none; }
.textarea { min-height: 90px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 12px; min-height: var(--touch); }
.checkbox-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--red); }

/* File input — touch friendly + mobile camera trigger */
.file-drop {
  border: 2px dashed var(--gray-line); border-radius: 10px;
  padding: 16px; text-align: center; cursor: pointer; background: var(--gray-bg);
  transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag { border-color: var(--red); background: #FEF2F2; }
.file-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop .fd-icon { font-size: 26px; display: block; margin-bottom: 4px; }
.file-drop .fd-label { font-size: 14px; font-weight: 600; color: var(--slate-2); }
.file-drop .fd-sub { font-size: 12.5px; color: var(--muted); }
.file-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--gray-line); }

/* ---------- Login ---------- */
.login-body { background: var(--slate); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; color: var(--slate); margin-bottom: 4px; }
.login-logo .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--red); }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-error { background: #FEF2F2; color: var(--red); border: 1px solid #FECACA; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; display: none; }
.login-card .btn { margin-top: 6px; }

/* ---------- Builder ---------- */
.builder-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.builder-field {
  background: var(--gray-bg); border: 1px solid var(--gray-line); border-radius: 10px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.bf-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bf-top .bf-label { flex: 1; min-width: 140px; }
.bf-actions { display: flex; gap: 6px; }
/* Drag & Drop Griff */
.bf-grip {
  cursor: grab; color: var(--slate-3); font-size: 18px; letter-spacing: -2px;
  padding: 4px 6px; border-radius: 6px; user-select: none; line-height: 1;
  touch-action: none;
}
.bf-grip:hover { color: var(--slate); background: var(--slate-2); }
.bf-grip:active { cursor: grabbing; }
.builder-field.dragging { opacity: .45; border-style: dashed; }
.builder-field.drop-before { border-top: 3px solid var(--red); border-radius: 4px; }
.builder-field.drop-after { border-bottom: 3px solid var(--red); border-radius: 4px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--gray-line);
  background: #fff; font-size: 16px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--slate-3);
}
.icon-btn:hover { background: var(--gray-bg); }
.icon-btn.danger:hover { background: #FEF2F2; color: var(--red); border-color: #FECACA; }
.type-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--red); background: #FEF2F2; padding: 4px 8px; border-radius: 6px; }
.builder-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.add-type { flex: 1; min-width: 110px; }

/* ---------- Dashboard tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--gray-line); }
.table td { padding: 12px; border-bottom: 1px solid var(--gray-line); vertical-align: middle; }
.table tr:hover td { background: var(--gray-bg); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.badge { display: inline-block; background: #FEF2F2; color: var(--red); font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge-green { background: #F0FDF4; color: #15803D; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty-state .es-icon { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- Form runner ---------- */
.form-heading {
  font-size: 17px; font-weight: 800; letter-spacing: -.01em; color: var(--slate);
  border-left: 4px solid var(--red); padding: 2px 0 2px 12px; margin: 26px 0 14px;
}
.form-heading:first-child { margin-top: 0; }
.runner-head { margin-bottom: 20px; }
.runner-head h1 { font-size: 22px; letter-spacing: -.01em; }
.runner-head .meta { color: var(--muted); font-size: 13.5px; }
.submit-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--gray-line); padding: 12px 16px; margin: 0 -16px; display: flex; gap: 10px; align-items: center; box-shadow: 0 -6px 20px rgba(15,23,42,.06); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--gray-line); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--slate); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  z-index: 100; display: none; max-width: 92vw; text-align: center;
}
.toast.show { display: block; animation: toastIn .25s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Responsive ---------- */
/* ---------- PDF preview (builder) — pixelgetreue HTML-Nachbildung des echten PDFs ---------- */
.pdf-preview {
  background: var(--slate-2); border-radius: 10px; padding: 18px;
  overflow-x: auto;
}
.pp-sheet {
  background: #fff; max-width: 680px; margin: 0 auto; border-radius: 3px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  font-size: 12px; line-height: 1.5; overflow: hidden;
}
/* Kopfband: vollbreit, wie im PDF (rect 0,0,page.width,84) */
.pp-header { background: #0F172A; color: #fff; padding: 14px 32px; flex-shrink: 0; }
.pp-title { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.pp-subtitle { color: #94A3B8; font-size: 8px; margin-top: 2px; }
.pp-accent { width: 84px; height: 2px; background: #DC2626; margin-top: 7px; }
.pp-body { padding: 16px 32px 18px; flex: 1; display: flex; flex-direction: column; }
.pp-docname { font-weight: 800; font-size: 10.5px; color: #0F172A; }
.pp-meta { color: #6B7280; font-size: 7.5px; margin: 4px 0 10px; }
/* Tabellenkopf: dunkles Band, "Feld" links / "Wert" bei x=210 */
.pp-tablehead {
  display: flex; background: #0F172A; color: #fff;
  font-weight: 700; font-size: 8px; padding: 7px 10px;
}
.pp-tablehead .pp-c1 { width: 20%; }
.pp-tablehead .pp-c2 { flex: 1; }
/* Datenzeilen: einheitlich #F8FAFC, KEINE Rahmen (wie im PDF), 28pt hoch */
.pp-row {
  display: flex; gap: 12px; background: #F8FAFC; padding: 8px 10px;
}
.pp-label { font-weight: 700; color: #0F172A; font-size: 8px; width: 20%; }
.pp-value { color: #334155; font-size: 8px; flex: 1; word-break: break-word; text-align: left; }
/* Überschrift: roter Balken 4×20 links + fett */
.pp-heading {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 2px;
  font-weight: 800; font-size: 8.5px; color: #0F172A;
}
.pp-heading .pp-bar { width: 4px; height: 15px; background: #DC2626; flex-shrink: 0; }
/* Foto-Abschnitt: wie im PDF ("Angehängte Fotos", Bild 240×160, Beschriftung) */
.pp-photos-title { font-weight: 700; font-size: 9.5px; color: #0F172A; margin-top: 12px; }
.pp-photo-box {
  border: 1px dashed #CBD5E1; height: 60px; margin-top: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #94A3B8; font-size: 8px;
}
.pp-photo-caption { color: #6B7280; font-size: 6.5px; margin-top: 3px; }
.pp-footer { margin-top: auto; text-align: center; color: #9CA3AF; font-size: 7px; padding-top: 12px; }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 6px; padding: 10px 12px; }
  .topbar .spacer { display: none; }
  .topbar nav { flex: 1 1 100%; flex-wrap: wrap; justify-content: space-between; gap: 2px; margin-top: 2px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.08); }
  .topbar nav a span.txt { display: inline; }
  .topbar nav a { padding: 7px 6px; font-size: 12px; min-height: 34px; white-space: nowrap; }
  .user-chip { display: none; }
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
  .card { padding: 16px; }
}
@media (min-width: 641px) {
  .mobile-only { display: none !important; }
}

/* ---- FM Stichproben: Status-Bewertung ---- */
.status-toggle { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:6px; }
.st-btn { flex:1 1 auto; min-width:0; padding:10px 10px; border:1.5px solid #CBD5E1; border-radius:10px; background:#fff; cursor:pointer; font-size:14px; font-weight:700; color:#334155; display:flex; flex-direction:column; align-items:center; gap:2px; transition:all .15s ease; }
.st-btn .st-sub { font-size:10.5px; font-weight:500; color:#94A3B8; }
.st-btn.active { color:#fff; border-color:transparent; }
.st-btn.active .st-sub { color:rgba(255,255,255,.75); }
.st-btn[data-s="i.O."].active { background:#16A34A; }
.st-btn[data-s="m.i.O."].active { background:#F59E0B; }
.st-btn[data-s="n.i.O."].active { background:#DC2626; }
.st-btn[data-s="N/A"].active { background:#94A3B8; }
.mangel-box { margin-top:10px; padding:14px; border:1.5px solid #FECACA; border-left:4px solid #DC2626; border-radius:10px; background:#FFF7F7; }
#scoreBar { margin-bottom:16px; padding:14px 16px; border-radius:10px; color:#fff; font-size:16px; text-align:center; box-shadow:0 2px 8px rgba(0,0,0,.12); }
.sig-wrap { display:flex; gap:10px; align-items:flex-start; flex-wrap:wrap; }
.sig-canvas { border:1.5px dashed #94A3B8; border-radius:8px; background:#fff; touch-action:none; width:100%; max-width:420px; height:150px; cursor:crosshair; }
