:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #0a0d12;          /* qfloow near-black */
  --muted: #5b6472;
  --line: #e6e9ef;
  --brand: #004aad;        /* qfloow blue */
  --brand-dark: #003a87;
  --brand-tint: #eaf1fb;
  --brand-ink: #ffffff;
  --navy: #0a0d12;
  --ok: #16a34a;
  --ok-bg: #e7f6ec;
  --warn: #b7791f;
  --warn-bg: #fdf3e0;
  --wait-bg: #eef1f6;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(10,13,18,.06), 0 1px 2px rgba(10,13,18,.04);
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Sora", "Manrope", -apple-system, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: var(--font-body);
  background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased;
  /* Kein Doppeltipp-/Pinch-Zoom; nur die Hauptseite scrollt. */
  touch-action: pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }
a { color: var(--brand); }
h1, h2, legend, .brand-text { font-family: var(--font-head); }

.topbar { background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.logo-bafa { height: 40px; width: auto; }
.brand-text { font-weight: 700; font-size: 1rem; color: var(--navy); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: .92rem; font-weight: 600; }
.topbar nav a:hover { color: var(--brand-dark); }
.powered { display: inline-flex; align-items: center; gap: 6px; color: #94a3b8; font-size: .72rem; }
.logo-qfloow { height: 16px; }
.demo-badge { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d9a8;
  border-radius: 999px; font-size: .66rem; font-weight: 700; padding: 2px 8px; margin-left: 8px;
  text-transform: uppercase; letter-spacing: .04em; vertical-align: middle; }
.foot { text-align: center; color: #94a3b8; font-size: .78rem; padding: 24px; }

.wrap { max-width: 900px; margin: 30px auto; padding: 0 20px; }
.wrap.wide { max-width: 1200px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; margin-bottom: 22px; }
.card.official { border-top: 4px solid var(--brand); }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; color: var(--navy); }
.lead { color: var(--muted); margin: 0 0 22px; }

/* Pipeline */
.pipeline { list-style: none; padding: 0; margin: 0; }
.pipeline li { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; position: relative; }
.pipeline li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 34px; bottom: -12px; width: 2px; background: var(--line); }
.dot { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; border: 2px solid var(--line); background: #fff; color: var(--muted); z-index: 1; }
.step-done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-current .dot { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(0,74,173,.18); }
.step-label { font-weight: 600; }
.step-current .step-label { color: var(--brand-dark); }
.step-upcoming .step-label { color: var(--muted); font-weight: 500; }

.callout { border-radius: 12px; padding: 16px 18px; margin: 18px 0; border: 1px solid var(--line); }
.callout.action { background: var(--brand-tint); border-color: #cfe0f7; }
.callout.info { background: var(--wait-bg); }
.callout.done { background: var(--ok-bg); border-color: #bfe6ce; }
.callout.warn { background: var(--warn-bg); border-color: #f0d9a8; color: #7a4f10; }
.callout h3 { margin: 0 0 6px; font-size: 1rem; }
.callout p { margin: 0 0 6px; }
.callout p:last-child { margin: 0; }
/* Dauerhafter Vollständigkeits-Hinweis über der Upload-Liste. */
.hinweis-box { background: var(--warn-bg); border: 1px solid #f0d9a8; color: #7a4f10;
  border-radius: 10px; padding: 12px 14px; margin: 4px 0 14px; font-size: .86rem;
  line-height: 1.5; }

.btn { display: inline-block; border: none; cursor: pointer; text-decoration: none; background: var(--brand);
  color: var(--brand-ink); padding: 11px 18px; border-radius: 10px; font-weight: 700; font-size: .95rem; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #eef1f6; color: var(--ink); }
.btn.navy { background: var(--navy); }
.btn.bafa { background: #0f766e; }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn.block { display: block; width: 100%; text-align: center; }

label { display: block; font-weight: 600; font-size: .86rem; margin: 14px 0 5px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: .95rem; font-family: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0,74,173,.28); border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 18px 18px; margin: 0 0 18px; }
legend { font-weight: 700; color: var(--navy); padding: 0 8px; font-size: .95rem; }
.errors { background: #fdecea; border: 1px solid #f5c6c0; color: var(--danger); border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }
.hint { color: var(--muted); font-size: .82rem; margin: 4px 0 0; }

/* Signature pad */
.sigwrap { border: 2px dashed #cbd5e1; border-radius: 12px; background: #fbfcfe; padding: 8px; }
#sigpad { width: 100%; height: 170px; touch-action: none; border-radius: 8px; background: #fff; display: block; }
.sigbar { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* Doc list */
.doclist { list-style: none; padding: 0; margin: 0; }
.doclist li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.doclist li:last-child { border-bottom: none; }
.doclist .name { font-weight: 600; }
/* Unterschriften-Liste immer sauber gestapelt: Titel oben, Aktionen darunter
   (verhindert das schiefe "nebeneinander" bei kurzen Titeln wie De-minimis). */
.doclist.signlist li { flex-direction: column; align-items: stretch;
  justify-content: flex-start; flex-wrap: nowrap; gap: 10px; }
.doclist.signlist .doc-actions { width: 100%; }
.doc-actions { display: flex; align-items: center; gap: 8px; }
/* Akte: Titel + Status links, Öffnen/Vorlage rechts; auf Mobile gestapelt. */
.akten-links { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { background: #eef1f6; color: var(--ink); }
.upload-inline { display: flex; align-items: center; gap: 8px; }
.upload-inline input[type=file] { width: auto; padding: 6px; font-size: .82rem; }
.badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.open { background: var(--warn-bg); color: var(--warn); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbff; }
.pill { font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.system { background: var(--wait-bg); color: var(--muted); }
.pill.berater { background: var(--brand-tint); color: var(--brand-dark); }
.pill.kunde { background: var(--warn-bg); color: var(--warn); }
.pill.bafa { background: #e6f6f4; color: #0f766e; }
.pill.ende { background: var(--ok-bg); color: var(--ok); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.timeline .ts { color: var(--muted); font-size: .78rem; }

.vorgang-card { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; flex-wrap: wrap; }
.vorgang-card.act { border-color: #cfe0f7; background: var(--brand-tint); }
.progressbar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; width: 220px; max-width: 100%; }
.progressbar > span { display: block; height: 100%; background: var(--brand); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.linkbox { background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.sig-preview { height: 46px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }

@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---- Nur der Download-Button ist grün und pulsiert (Feld bleibt normal) ---- */
.btn.pulse-download { background: var(--ok); color: #fff; animation: pulse-green 1.6s infinite; }
.btn.pulse-download:hover { background: #128040; }
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}
.doc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filebtn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: #eef1f6; color: var(--ink); padding: 8px 14px; border-radius: 10px;
  font-weight: 600; font-size: .85rem; margin: 0; }
.filebtn:hover { background: #e2e7ef; }
.filebtn.cam { background: var(--brand-tint); color: var(--brand-dark); }
.filebtn input[type=file] { display: none; }
.foot-logo { height: 20px; display: block; margin: 0 auto 8px; opacity: .8; }

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .brand-text { font-size: .82rem; }
  .logo-bafa { height: 30px; }
  .topbar nav { gap: 12px; font-size: .85rem; flex-wrap: wrap; }
  .powered-desktop { display: none; }
  .powered-mobile { display: inline-flex !important; margin-top: 3px; font-size: .66rem; }
  .powered-mobile .logo-qfloow { height: 13px; }
  .wrap { margin: 16px auto; padding: 0 14px; }
  .card { padding: 18px; border-radius: 12px; }
  h1 { font-size: 1.3rem; }
  .doc-actions { width: 100%; }
  .doc-actions .btn, .doc-actions .filebtn, .doc-actions form { width: 100%; }
  .filebtn { justify-content: center; }
  .doclist li { flex-direction: column; align-items: stretch; }
  .akten-links { width: 100%; }
  .akten-links .btn { flex: 1; text-align: center; }
  .vorgang-card { flex-direction: column; align-items: flex-start; }
  .progressbar { width: 100%; }
  /* Tabellen brechen um statt horizontal zu scrollen (kein Inner-Scroll). */
  table { table-layout: fixed; width: 100%; font-size: .8rem; }
  th, td { white-space: normal; word-break: break-word; overflow-wrap: anywhere;
    padding: 8px 8px; }
  .btn { padding: 12px 18px; }  /* größere Touch-Ziele */
  .linkbox, .mono { word-break: break-all; overflow-wrap: anywhere; }
}

/* ---- Erfassungsbogen-Sektionen (wie BAFA-Original) ---- */
h2.sec { color: var(--brand); font-size: 1.15rem; margin: 26px 0 2px;
  padding-bottom: 8px; border-bottom: 2px solid var(--brand); }
.sec-sub { font-style: italic; color: var(--muted); font-size: .86rem; margin: 0 0 8px; }
.opt { font-weight: 400; color: var(--muted); font-size: .8rem; }
.vollmacht-box { background: #eef3fb; border: 1px solid #cfe0f7; border-radius: 12px;
  padding: 16px 18px; margin: 22px 0 18px; }
.vollmacht-box h3 { color: var(--brand); margin: 0 0 8px; font-size: 1rem; }
.vollmacht-box p { margin: 0; font-size: .88rem; color: var(--ink); line-height: 1.6; }

/* ---- Zentrierter BAFA-Kopf + rote Pflicht-Sternchen (wie Original) ---- */
.form-card { padding-top: 34px; }
.bafa-head { text-align: center; margin-bottom: 10px; padding-bottom: 6px; }
.bafa-hero { height: 96px; width: auto; display: block; margin: 0 auto 18px; }
.bafa-head h1 { text-align: center; font-size: 1.7rem; }
.bafa-head .lead { max-width: 620px; margin: 8px auto 0; }
.req { color: #d81f2a; font-weight: 800; }
@media (max-width: 720px) { .bafa-hero { height: 74px; } .bafa-head h1 { font-size: 1.35rem; } }

/* ---- Grüner Hinweis (z. B. WZ-Code) ---- */
.hint-green { background: #e7f6ec; border: 1px solid #bfe6ce; color: #15803d;
  border-radius: 10px; padding: 10px 14px; font-size: .86rem; margin: 8px 0 0; line-height: 1.5; }
/* Stammdaten-Tabelle im Admin */
.stammdaten { width: 100%; border-collapse: collapse; }
.stammdaten td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: .88rem; vertical-align: top; }
.stammdaten td.k { color: var(--muted); width: 42%; font-weight: 600; }

/* Brand-Block: Titel + (mobil) powered-by gestapelt */
.brand-block { display: flex; flex-direction: column; gap: 1px; }
.powered-mobile { display: none; }   /* Desktop: aus (steht rechts im nav) */
