/*
 * FlyStart Sign – Gestaltung wie Houston und Mission Control (Vorbild sevdesk, siehe Design.md der Plattform):
 * weiße Fläche, feine Linien statt Schatten, ein dunkler Hauptknopf je Ansicht, Akzent Grün für Text.
 * Inter für alles Bedienbare und Text, Bricolage Grotesque in normaler Stärke für Überschriften.
 * Keine externen Ressourcen: Schriften liegen in assets/fonts (ausgeliefert unter /fonts/).
 */

/* Inter (variabel, 100–900) */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Bricolage Grotesque (variabel mit optischer Größe) */
@font-face {
  font-family: 'Bricolage Grotesque Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('/fonts/bricolage-grotesque-latin-ext-opsz-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage Grotesque Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url('/fonts/bricolage-grotesque-latin-opsz-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
}

/* Rollen wie in shared/src/styles/app.css der Plattform (helle Darstellung) */
:root {
  --font: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque Variable', 'Inter Variable', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sig-font: 'Snell Roundhand', 'Segoe Script', 'Apple Chancery', 'Brush Script MT', 'Lucida Handwriting', 'URW Chancery L', 'Z003', cursive;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  --brand-night: #0e3a2c;
  --brand-start: #19b86a;
  --brand-mint: #6ee7a8;

  --bg: #ffffff;
  --surface: #ffffff;
  --sunken: #f5f5f1;
  --text: #0d1b16;
  --muted: #59645e;
  --faint: #67716b;
  --border: #e6e8e4;
  --border-soft: #eef0ec;
  --border-strong: #d2d7d3;
  --hover: #f1f3ef;
  --hover-2: #f8f9f6;
  --accent: #19b86a;
  --accent-soft: #e8f6ee;
  --accent-text: #0a7a45;
  --accent-strong: #075c34;
  --ring: #d4f0e0;
  --focus: #0a7a45;
  --seg: #f0f1ed;
  --seg-on: #ffffff;
  --btn-bg: #0e3a2c;
  --btn-bg-hover: #155040;
  --btn-text: #ffffff;
  --side-bg: #f7f8f5;
  --side-muted: #4f5a54;
  --side-hover: #eceee9;
  --side-active-bg: #e3f3ea;
  --th-bg: #f7f8f6;

  --danger: #b4321f;
  --danger-border: #f1cfc8;
  --danger-bg: #fdecea;
  --warn-dot: #e5a01e;
  --warn-bg: #fdf1cf;
  --warn-border: #f3e0a8;
  --warn-text: #5a3a0a;
  --warn-strong: #7a5200;
  --info-bg: #ecebfb;
  --info-text: #3d3a8c;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

button, input, textarea, select { font-family: inherit; color: inherit; }

img, svg { display: block; max-width: 100%; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--ring); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--sunken);
  border-radius: var(--r-sm);
  padding: 1px 5px;
}
code.wrap { word-break: break-all; }

h1, h2, h3 { color: var(--text); margin: 0; }
h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 32;
  text-wrap: balance;
}
h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.015em;
  font-variation-settings: 'opsz' 24;
}
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 24;
}
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.45; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--btn-bg); color: var(--btn-text); padding: 9px 14px; border-radius: var(--r-md); font-weight: 500; }
.skip:focus { top: 12px; }
.skip:hover { color: var(--btn-text); }

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Gerüst ---------- */

.topbar { position: relative; z-index: 2; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar__inner {
  max-width: 1200px;
  min-height: 60px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
}
.topbar--dark { background: var(--side-bg); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { height: 28px; width: auto; }
.brand__tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
}

.adminnav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.adminnav a, .adminnav button {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--side-muted);
  font: 500 13.5px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.adminnav a:hover, .adminnav button:hover { background: var(--side-hover); color: var(--text); text-decoration: none; }
.adminnav a.is-current { background: var(--side-active-bg); color: var(--text); font-weight: 600; }
.adminnav__logout { margin: 0 0 0 6px; }

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.wrap--wide { max-width: 1200px; }
.wrap--narrow { max-width: 640px; }
.is-admin .wrap { padding-top: 36px; gap: 24px; }
@media (min-width: 1000px) {
  .wrap--wide { padding-left: 48px; padding-right: 48px; }
}

.footer { position: relative; z-index: 1; padding: 28px 16px 36px; border-top: 1px solid var(--border-soft); color: var(--faint); font-size: 12.5px; }
.footer__inner { max-width: 880px; margin: 0 auto; text-align: center; display: grid; gap: 6px; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }
.footer__links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

/* Die frühere Flugbahn im Hintergrund entfällt: Fläche bleibt weiß wie in Houston und Mission Control. */
.flugbahn { display: none; }

/* ---------- Bausteine ---------- */

.hero { display: grid; gap: 10px; padding: 4px 0 0; }
.hero--center { text-align: center; justify-items: center; padding-top: 10vh; gap: 14px; }
.hero--center .lead { max-width: 34em; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.eyebrow .icon { color: var(--accent-text); }
.eyebrow a { color: var(--muted); }
.eyebrow a:hover { color: var(--text); }
.lead { font-size: 15px; line-height: 1.55; color: var(--muted); max-width: 42em; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  background: var(--seg);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chip .icon { width: 14px; height: 14px; }

.note {
  margin: 4px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--sunken);
  white-space: pre-line;
  font-size: 14px;
}
.note__label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 2px; white-space: normal; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--center { text-align: center; display: grid; justify-items: center; gap: 12px; }
.card__title { padding: 18px 22px 12px; }
.stack { display: grid; gap: 16px; }
.stack > * { min-width: 0; }
.stack > h2 { margin-bottom: -4px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions--center { justify-content: center; }
.actions--end { justify-content: flex-end; }

.grid2 { display: grid; gap: 20px; }
@media (min-width: 760px) {
  .grid2 { grid-template-columns: 1fr 1fr; align-items: end; }
  .grid2--top { align-items: start; }
}

/* Knöpfe: weiß mit feinem Rahmen, genau ein dunkler Hauptknopf je Ansicht */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: 500 13.5px/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s, opacity .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--hover-2); color: var(--text); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { border-color: var(--btn-bg); background: var(--btn-bg); color: var(--btn-text); }
.btn--primary:hover { border-color: var(--btn-bg-hover); background: var(--btn-bg-hover); color: var(--btn-text); }
.btn--accent { border-color: var(--accent); background: var(--accent); color: var(--brand-night); }
.btn--ghost { background: var(--surface); color: var(--text); }
.btn--warn { border-color: var(--warn-border); background: var(--surface); color: var(--warn-strong); }
.btn--warn:hover { background: var(--warn-bg); color: var(--warn-strong); }
.btn--danger { border-color: var(--danger-border); background: var(--surface); color: var(--danger); }
.btn--danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn--lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn--sm .icon { width: 15px; height: 15px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .45; cursor: default; }
.btn[disabled]:hover { background: var(--surface); }
.btn--primary[disabled]:hover { background: var(--btn-bg); }
.btn.is-busy { opacity: .7; cursor: progress; }
/* Auf Touch-Geräten etwas größere Tippflächen für die Hauptaktion */
@media (pointer: coarse) {
  .btn--lg { height: 44px; }
}

.linkbutton {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: 500 13.5px/1.4 var(--font);
  cursor: pointer;
}
.linkbutton:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.iconbutton {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.iconbutton:hover { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.inline-form { display: inline; margin: 0; }

/* Formulare */
.field { display: grid; gap: 6px; min-width: 0; }
label, .field > label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.field small { font-size: 12.5px; color: var(--faint); line-height: 1.45; }
.input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: 400 14px/1.4 var(--font);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: var(--faint); opacity: .85; }
.input:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text)); }
.input:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.input[readonly], .input:disabled { background: var(--sunken); color: var(--muted); }
textarea.input { height: auto; min-height: 84px; padding: 9px 11px; line-height: 1.55; resize: vertical; }
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  /* Pfeil aus zwei Verläufen (CSP erlaubt keine data:-Bilder) */
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input--mono { font-family: var(--mono); font-size: 12.5px; }
.input--code {
  height: 52px;
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: .32em;
  text-align: center;
  max-width: 240px;
  padding-left: calc(11px + .32em);
}
.input--file { height: auto; padding: 7px; font-size: 13px; }
/* iOS vergrößert die Ansicht bei Feldern unter 16 px – auf dem Handy daher 16 px */
@media (max-width: 640px) {
  .input { font-size: 16px; }
  .input--mono { font-size: 14px; }
  .input--code { font-size: 26px; }
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  transition: border-color .12s, background-color .12s;
}
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent-text); flex-shrink: 0; cursor: pointer; }
.check:hover { background: var(--hover-2); }
.check:has(input:checked) { border-color: var(--accent-text); background: var(--accent-soft); }
.check:focus-within { box-shadow: 0 0 0 3px var(--ring); }
.check--boxed { align-self: end; }

.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--hover-2);
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  transition: border-color .12s, background-color .12s;
}
.dropzone input[type='file'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent-text); background: var(--accent-soft); }
.dropzone:focus-within { box-shadow: 0 0 0 3px var(--ring); border-color: var(--accent-text); }
.dropzone.has-file { border-style: solid; border-color: var(--accent-text); background: var(--accent-soft); }
.dropzone__icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface); color: var(--accent-text); border: 1px solid var(--border); }
.dropzone__icon .icon { width: 20px; height: 20px; }
.dropzone__text strong { color: var(--accent-text); font-weight: 600; }

/* Hinweise */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.alert .icon { margin-top: 2px; }
.alert--ok { background: var(--accent-soft); color: var(--accent-strong); border-color: #cfead9; }
.alert--error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.alert[hidden] { display: none; }
.devnote {
  font-size: 13px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  color: var(--warn-text);
}
.legal { font-size: 12.5px; line-height: 1.5; color: var(--faint); }

/* Schritte: schlichte Fortschrittsleiste mit Linie oben */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.steps:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, 1fr); }
.steps__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 0;
  border-top: 2px solid var(--border);
  color: var(--faint);
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
}
.steps__num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--seg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.steps__num .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.steps__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps__item.is-current { border-top-color: var(--btn-bg); color: var(--text); font-weight: 600; }
.steps__item.is-current .steps__num { background: var(--btn-bg); color: var(--btn-text); }
.steps__item.is-done { border-top-color: var(--accent-text); color: var(--muted); }
.steps__item.is-done .steps__num { background: var(--accent-soft); color: var(--accent-text); }
@media (max-width: 620px) {
  .steps, .steps:has(> :nth-child(2):last-child) { display: flex; }
  .steps__item { flex: 0 0 44px; }
  .steps__item.is-current { flex: 1 1 auto; }
  .steps__item:not(.is-current) .steps__label { display: none; }
}

/* PDF-Anzeige */
.viewer { display: grid; }
.viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.viewer__meta { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--accent-text); }
.viewer__meta > span { display: grid; min-width: 0; color: var(--text); }
.viewer__meta strong { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__meta small { color: var(--faint); font-size: 12.5px; }
.viewer__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.viewer__frame { display: block; width: 100%; height: min(78vh, 980px); border: 0; background: var(--sunken); }
.viewer__fallback { display: grid; justify-items: center; gap: 12px; padding: 32px 20px; text-align: center; background: var(--sunken); }
.viewer__fallback[hidden], .viewer__frame[hidden] { display: none; }
.viewer__doc { width: 52px; height: 64px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); color: var(--accent-text); }
.viewer__doc .icon { width: 26px; height: 26px; }
.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  list-style: none;
}
.disclosure > summary:hover { background: var(--hover-2); }
.disclosure > summary .icon { color: var(--accent-text); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after { content: '+'; margin-left: auto; font-size: 18px; line-height: 1; color: var(--faint); }
.disclosure[open] > summary { border-bottom: 1px solid var(--border); }
.disclosure[open] > summary::after { content: '–'; }

/* Code */
.code-form { display: grid; gap: 8px; }
.code-form__row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.code-form__row .btn--lg { height: 52px; padding: 0 22px; }

/* Unterschrift */
.sign-form__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.segmented {
  display: inline-flex;
  justify-self: start;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--seg);
  max-width: 100%;
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button .icon { width: 15px; height: 15px; }
.segmented button[aria-selected='true'] { background: var(--seg-on); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

.sigpad {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 2;
  min-height: 190px;
  max-height: 420px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.sigpad[hidden] { display: none; }
.sigpad.has-ink { border-style: solid; }
.sigpad__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.sigpad__line {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 24%;
  border-bottom: 1px solid var(--border-strong);
  pointer-events: none;
}
.sigpad__line span { position: absolute; left: -2px; bottom: 2px; color: var(--faint); font-size: 18px; line-height: 1; }
.sigpad__hint {
  position: absolute;
  inset: 0 0 24% 0;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 14px;
  pointer-events: none;
  padding: 0 16px;
  text-align: center;
}
.sigpad.has-ink .sigpad__hint { display: none; }
.sigpad__clear { position: absolute; top: 10px; right: 10px; }

.typed { display: grid; gap: 8px; }
.typed[hidden] { display: none; }
.typed__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 16px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-family: var(--sig-font);
  font-style: italic;
  font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.4rem);
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
}

/* Erfolg / Info */
.success { padding-top: 36px; padding-bottom: 32px; }
.success__badge {
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.success__badge .icon { width: 24px; height: 24px; stroke-width: 2.4; }
.info { padding-top: 32px; padding-bottom: 28px; margin-top: 6vh; }
.info__icon { width: 48px; height: 48px; border-radius: var(--r-lg); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.info__icon .icon { width: 24px; height: 24px; }
.info--warn .info__icon { background: var(--warn-bg); color: var(--warn-strong); }
.info--error .info__icon { background: var(--danger-bg); color: var(--danger); }
.info h1, .success h1 { font-size: 26px; }

.facts { display: grid; gap: 0; margin: 8px 0 0; text-align: left; width: 100%; max-width: 480px; }
.facts > div { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border-soft); }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.facts--left { max-width: none; margin-top: 0; }
.facts code.wrap { background: none; padding: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.verdict { display: flex; gap: 16px; align-items: flex-start; }
.verdict__icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0; }
.verdict__icon .icon { width: 20px; height: 20px; }
.verdict--ok { border-color: #cfead9; }
.verdict--ok .verdict__icon { background: var(--accent-soft); color: var(--accent-text); }
.verdict--warn { border-color: var(--warn-border); }
.verdict--warn .verdict__icon { background: var(--warn-bg); color: var(--warn-strong); }
.verdict--error { border-color: var(--danger-border); }
.verdict--error .verdict__icon { background: var(--danger-bg); color: var(--danger); }
@media (max-width: 520px) { .verdict { flex-direction: column; } }
.hash { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); }
.hash code { word-break: break-all; background: none; padding: 0; color: var(--text); }
.hash strong { font-weight: 500; color: var(--text); }

/* ---------- Admin ---------- */
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; }
.pagehead > div:first-child { display: grid; gap: 6px; min-width: 0; }
.pagehead h1 { overflow-wrap: anywhere; }
.pagehead .chips { margin-top: 4px; }
.pagehead__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.login { margin-top: 8vh; }
.login form { width: 100%; text-align: left; }
.login__mark { width: 44px; height: 44px; }

/* Kennzeichen wie in Houston: 22 px, Radius 6 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--seg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.badge--offen { background: var(--warn-bg); color: var(--warn-strong); box-shadow: inset 0 0 0 1px var(--warn-border); }
.badge--teilweise { background: #fde6c4; color: var(--warn-text); }
.badge--abgeschlossen { background: var(--accent-soft); color: var(--accent-text); }
.badge--abgeschlossen::before, .badge--p-unterschrieben::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.badge--abgelaufen { background: var(--seg); color: var(--muted); }
.badge--zurueckgezogen { background: var(--seg); color: var(--faint); text-decoration: line-through; }
.badge--owner { height: 20px; padding: 0 6px; background: var(--btn-bg); color: var(--btn-text); font-size: 11.5px; }
.badge--p-unterschrieben { background: var(--accent-soft); color: var(--accent-text); }
.badge--p-bestaetigt, .badge--p-geoeffnet { background: var(--warn-bg); color: var(--warn-strong); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  height: 40px;
  padding: 0 12px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  background: var(--th-bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { height: 52px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tr:last-child td { border-bottom: 0; }
.table td small { display: block; margin-top: 2px; font-size: 12.5px; }
.table--list tbody tr:hover td { background: var(--hover-2); }
.rowlink { color: var(--text); text-decoration: none; }
.rowlink strong { font-weight: 500; }
.rowlink:hover { color: var(--accent-text); text-decoration: none; }
.progress {
  appearance: none;
  -webkit-appearance: none;
  width: 56px;
  height: 6px;
  border: 0;
  border-radius: 99px;
  background: var(--seg);
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}
.progress::-webkit-progress-bar { background: var(--seg); border-radius: 99px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.table--events td { height: 44px; font-size: 13.5px; }
@media (min-width: 761px) { .table--events td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; } }
.table--events .ev--unterschrieben td, .table--events .ev--abgeschlossen td { background: #f6fbf8; }
.table--events .ev--mail_fehler td, .table--events .ev--code_gesperrt td { background: #fdf6f4; }

@media (max-width: 760px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
  .table tr:last-child { border-bottom: 0; }
  /* Bezeichnung links, Inhalt fließt rechts daneben */
  .table td, .table td:first-child, .table td:last-child { position: relative; height: auto; border: 0; padding: 3px 0 3px 120px; min-height: 26px; }
  .table td::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 110px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
  .table--list tbody tr:hover td { background: none; }
}

.signer { display: grid; gap: 14px; }
.signer__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.signer__head h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.timeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.timeline > div { padding: 9px 12px; border-radius: var(--r-md); background: var(--hover-2); border: 1px solid var(--border-soft); }
.timeline dt { font-size: 12.5px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.timeline dt::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.timeline dd { margin: 3px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.timeline .is-done { background: var(--surface); border-color: var(--border); }
.timeline .is-done dt::before { background: var(--accent); }
@media (max-width: 760px) { .timeline { grid-template-columns: 1fr 1fr; } }
.signer__sig { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.signer__sig img { max-height: 72px; width: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px 12px; }
.linkbox { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.linkbox .input { flex: 1 1 280px; height: 32px; }

.signer-list { display: grid; gap: 10px; }
.signer-row {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr 150px 38px;
  gap: 12px;
  align-items: end;
  background: var(--hover-2);
  min-width: 0;
}
.signer-row .field > label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .signer-row { grid-template-columns: 1fr 38px; }
  .signer-row .field { grid-column: 1 / -1; }
  .signer-row .field--order { grid-column: 1; }
}
.num {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  font: 600 12.5px/1 var(--font);
  margin-right: 6px;
  vertical-align: 3px;
}
.inline-fields { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields .field { flex: 1 1 200px; }
.empty { padding: 56px 24px; }

@media (max-width: 520px) {
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1 1 0; justify-content: center; padding: 0 8px; }
  .btn--lg { width: 100%; }
  .code-form__row .btn { width: 100%; }
  .input--code { max-width: none; }
  .hero { padding-top: 0; }
}

@media (max-width: 640px) {
  .wrap { padding: 20px 16px 28px; }
  .is-admin .wrap { padding-top: 24px; }
  .topbar__inner { padding: 10px 16px; }
  .adminnav { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
  .adminnav a, .adminnav button { flex: none; }
  .card { padding: 18px 16px; }
  .card--flush { padding: 0; }
  h1 { font-size: 26px; }
  .info h1, .success h1 { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .topbar, .footer, .flugbahn, .actions { display: none !important; }
  body { background: #fff; }
}

/* Datenschutzhinweis vor der Zustimmung */
.privacy-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--sunken);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.privacy-note .icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; color: var(--accent-text); }
.privacy-note strong { color: var(--text); font-weight: 600; }

/* Vertretungsbefugnis beim Unterschreiben */
.authority {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--hover-2);
  min-width: 0;
}
/* Legende als erste Zeile im Kasten statt auf dem Rahmen */
.authority legend { float: left; width: 100%; padding: 0; margin: 0; font-size: 14px; font-weight: 400; color: var(--text); }
.authority legend strong { font-weight: 600; }
.authority .check { background: var(--surface); }

/* Längere Texte (Datenschutzhinweise) */
.prose { font-size: 14px; line-height: 1.6; }
.prose h2 { font-size: 17px; margin: 16px 0 0; }
.prose h2:first-child { margin-top: 0; }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.prose p { margin: 0; }
.prose strong { font-weight: 600; }

/* Admin: Suche, Aufbewahrung, Export */
.searchbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.searchbar .input { flex: 1 1 260px; }
.retention { display: grid; gap: 10px; }
.retention__due { font-weight: 600; color: var(--text); }
.retention__hold { display: flex; gap: 8px; align-items: flex-start; color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--r-md); padding: 9px 12px; font-size: 13px; }
.retention__hold .icon { margin-top: 2px; }

/* ---------- Entwurf ---------- */
.badge--entwurf { background: var(--info-bg); color: var(--info-text); }
.draftbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 13.5px;
}
.draftbar .muted { color: var(--warn-text); opacity: .85; }

/* ---------- Unterschreiben: Hinweis auf platzierte Felder ---------- */
.placed-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.placed-note .icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; color: var(--accent-text); }

/* ---------- Unterschrift als Bild hochladen ---------- */
.sigupload { display: grid; gap: 10px; justify-items: start; }
.sigupload[hidden] { display: none; }
.sigupload__drop {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 190px;
  padding: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--hover-2);
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
}
.sigupload__drop input[type='file'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.sigupload__drop:hover, .sigupload__drop.is-over { border-color: var(--accent-text); background: var(--accent-soft); }
.sigupload__drop:focus-within { box-shadow: 0 0 0 3px var(--ring); border-color: var(--accent-text); }
.sigupload__drop.has-image { border-style: solid; border-color: var(--border); background: var(--surface); }
.sigupload__text { display: grid; gap: 4px; max-width: 34ch; }
.sigupload__text[hidden] { display: none; }
.sigupload__text strong { color: var(--accent-text); font-weight: 600; }
.sigupload__canvas { display: block; max-width: 100%; max-height: 170px; width: auto; height: auto; }
.sigupload__canvas[hidden] { display: none; }
/* Hinterlegte Unterschrift (Gegenzeichnung in Houston) */
.sigsaved { display: grid; gap: 8px; justify-items: center; padding: 20px; min-height: 190px; align-content: center; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.sigsaved[hidden] { display: none; }
.sigsaved__img { display: block; max-width: 100%; max-height: 150px; width: auto; height: auto; }
@media (max-width: 440px) {
  .segmented button { padding: 0 6px; font-size: 12.5px; gap: 4px; }
  .segmented button .icon { display: none; }
}

/* ---------- Feld-Editor ---------- */
.fe {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  --current: var(--accent-text);
}
.fe__side { position: sticky; top: 16px; display: grid; gap: 12px; }
.fe__panel { display: grid; gap: 12px; padding: 18px; }
.fe__h { margin: 2px 0 0; font: 600 13px/1.3 var(--font); letter-spacing: 0; color: var(--text); }
.fe__signers { display: grid; gap: 6px; }
.fe-signer {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font: 500 13.5px var(--font);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.fe-signer:hover { border-color: var(--c); }
.fe-signer[aria-checked='true'] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: color-mix(in srgb, var(--c) 6%, #fff); }
.fe-signer:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fe-signer__dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: var(--c); }
.fe-signer__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-signer__count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-sm); background: var(--seg); color: var(--muted); font-size: 12px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.fe__palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fe-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px dashed var(--current);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--current) 6%, #fff);
  font: 500 13.5px var(--font);
  color: var(--text);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.fe-tool:hover { background: color-mix(in srgb, var(--current) 12%, #fff); }
.fe-tool:active { cursor: grabbing; }
.fe-tool:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fe-tool--unterschrift { grid-column: 1 / -1; }
.fe-tool__grip { color: var(--faint); font-size: 14px; line-height: 1; }
.fe__status { margin: 0; color: var(--muted); }
.fe__status.is-warn { color: var(--warn-strong); }
/* PDF auf grauer Fläche wie in Houston */
.fe__pages { display: grid; gap: 20px; min-width: 0; padding: 20px; border-radius: var(--r-lg); background: var(--sunken); }
.fe__loading { padding: 60px 0; text-align: center; }
.fe-page { display: grid; gap: 6px; }
.fe-page__label { margin: 0; font-size: 12.5px; color: var(--muted); }
.fe-page__sheet {
  position: relative;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.fe-page__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fe-page__overlay { position: absolute; inset: 0; }
.fe-field, .fe-ghost {
  position: absolute;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 6px;
  border: 1.5px solid var(--c);
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 14%, rgba(255, 255, 255, .7));
  color: color-mix(in srgb, var(--c) 80%, #000);
  font: 600 clamp(9px, 1.2vw, 12px)/1.1 var(--font);
  cursor: move;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.fe-field--unterschrift { align-items: flex-end; padding-bottom: 4px; border-bottom-width: 2.5px; }
.fe-field:focus { outline: none; }
.fe-field.is-selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); z-index: 2; }
.fe-field.is-dragging { opacity: .85; z-index: 3; }
.fe-field__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.fe-field__del {
  position: absolute;
  top: -10px;
  right: -10px;
  display: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font: 700 15px/22px var(--font);
  cursor: pointer;
}
.fe-field.is-selected .fe-field__del, .fe-field:hover .fe-field__del { display: block; }
.fe-field__resize {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 3px;
  background: var(--c);
  cursor: nwse-resize;
}
.fe-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; opacity: .9; }
.fe-ghost.is-off { opacity: .45; }
@media (max-width: 860px) {
  .fe { grid-template-columns: 1fr; }
  .fe__side { position: static; }
  .fe__pages { padding: 12px; }
}
@media (hover: none) {
  .fe-field__del { display: block; }
}
.fe__panel .btn { white-space: normal; text-align: center; line-height: 1.2; }
.fe__secondary { display: grid; gap: 6px; }
.fe__back { justify-self: center; font-size: 13px; }

/* ---------- Eingebettet (Houston, Mission Control) ---------- */
.is-embed { background: transparent; min-height: 0; }
.is-embed .wrap { flex: none; max-width: none; padding-top: 4px; padding-bottom: 8px; }
.is-embed .fe__side { top: 8px; }
