:root {
  --bg: #f3f5f9; --card: #fff; --ink: #172033; --muted: #66708a; --line: #e1e5ee; --navy: #17203a;
  --accent: #2f5bea; --accent-dark: #2448c4; --accent-soft: #e8eeff; --teal: #17b897; --teal-soft: #dff7f0;
  --danger: #c0392b; --danger-soft: #fdeceb; --warn: #9a6400; --warn-soft: #fff4d6; --ok: #12784a; --ok-soft: #dcf5e7;
  --shadow: 0 1px 2px rgba(23,32,58,.05), 0 4px 14px rgba(23,32,58,.06); --radius: 12px;
}
* { box-sizing: border-box; }
/* Ausgeblendete Elemente bleiben ausgeblendet, auch Schaltflaechen (deren display sonst gewinnt) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; background: #eef1f6; padding: 1px 5px; border-radius: 4px; word-break: break-all; }

/* Navigation */
nav { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px; padding: 0 20px; height: 56px; background: var(--navy); color: #fff; overflow-x: auto; white-space: nowrap; }
nav { scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { color: #c5cee6; padding: 7px 12px; border-radius: 8px; font-size: 14px; }
nav a:hover { color: #fff; background: rgba(255,255,255,.09); text-decoration: none; }
nav .brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; color: #fff; margin-right: 14px; padding-left: 0; letter-spacing: .01em; }
nav .brand:hover { background: none; }
nav .brand img { width: 28px; height: 28px; border-radius: 7px; }
nav .grow { flex: 1; }
nav .who { color: #aab5d3; font-size: 13px; }
nav form { margin: 0; }
button.link { background: none; border: none; color: #c5cee6; padding: 7px 12px; font-weight: 400; font-size: 14px; box-shadow: none; }
button.link:hover { color: #fff; background: rgba(255,255,255,.09); }

main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 70px; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 30px 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
.headrow { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }

/* Karten, Formulare */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin: 18px 0; box-shadow: var(--shadow); }
.card.narrow { max-width: 430px; margin: 9vh auto 0; padding: 30px; }
.card.subtle { background: transparent; box-shadow: none; border-style: dashed; }
.card.ok { border-color: var(--teal); background: var(--teal-soft); }
.card.review { border-color: var(--accent); border-width: 2px; }
.card h2:first-child { margin-top: 0; }
label { display: block; margin: 14px 0; font-weight: 600; font-size: 13px; color: #36415c; }
label.check { font-weight: 400; font-size: 14px; display: flex; gap: 9px; align-items: flex-start; color: var(--ink); }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid #c9d0de; border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,91,234,.16); }
input[type=checkbox], input[type=radio] { display: inline; width: 16px; height: 16px; margin: 3px 0 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
input[type=file] { padding: 7px; background: #f8f9fc; }
textarea.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; line-height: 1.5; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 17px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(47,91,234,.25); transition: background .15s, border-color .15s; }
button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; }
button.secondary, .btn.secondary { background: #fff; color: var(--accent); border-color: #c9d0de; box-shadow: none; }
button.secondary:hover, .btn.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
button.danger, .btn.danger { color: var(--danger); }
button.danger:hover, .btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.small, .btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; align-items: center; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline input { width: 170px; margin: 0; padding: 5px 8px; }

/* Tabellen */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { background: #f7f8fb; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfe; }
.empty { background: var(--card); border: 1px dashed #c9d0de; border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e9ecf3; color: #414c66; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .75; }
.st-review { background: var(--warn-soft); color: var(--warn); }
.st-changes, .st-declined, .st-rejected, .st-expired { background: var(--danger-soft); color: var(--danger); }
.st-approved, .st-signing { background: var(--accent-soft); color: var(--accent-dark); }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.flash { background: var(--accent-soft); border: 1px solid #b9c9fb; color: #1d3a9c; padding: 11px 15px; border-radius: 10px; margin-bottom: 18px; }
.errors { background: var(--danger-soft); border: 1px solid #f2b8b2; color: var(--danger); padding: 11px 15px; border-radius: 10px; margin: 14px 0; }
.errors ul { margin: 0; padding-left: 18px; }
.note { background: var(--warn-soft); border: 1px solid #efd58a; color: #5f4200; padding: 11px 15px; border-radius: 10px; margin: 14px 0; }

/* Uebersicht */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 20px 0 6px; }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--ink); border-top: 3px solid #c9d0de; }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat b { display: block; font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.s-review { border-top-color: #e2a400; }
.stat.s-signing { border-top-color: var(--accent); }
.stat.s-completed { border-top-color: var(--teal); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.chip { padding: 5px 13px; border-radius: 999px; border: 1px solid #c9d0de; background: #fff; color: #414c66; font-size: 13px; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.tile.alt { border-style: dashed; background: #fafbfe; box-shadow: none; }
.tile .cat { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.search { display: flex; gap: 8px; margin: 14px 0; }
.search input { margin: 0; }

/* Vorgang */
.stepper { list-style: none; display: flex; padding: 0; margin: 18px 0 8px; }
.stepper li { flex: 1; position: relative; text-align: center; font-size: 12.5px; color: var(--muted); padding-top: 34px; }
.stepper li span { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid #c9d0de; color: var(--muted); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; z-index: 1; }
.stepper li::before { content: ""; position: absolute; top: 12px; left: -50%; width: 100%; height: 2px; background: #c9d0de; }
.stepper li:first-child::before { display: none; }
.stepper li.done { color: var(--ink); }
.stepper li.done span { background: var(--teal); border-color: var(--teal); color: #fff; }
.stepper li.done::before, .stepper li.current::before { background: var(--teal); }
.stepper li.current { color: var(--ink); font-weight: 700; }
.stepper li.current span { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px rgba(47,91,234,.15); }
.stepper.bad li.current span { border-color: var(--danger); color: var(--danger); box-shadow: 0 0 0 4px rgba(192,57,43,.13); }
.next { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 13px 16px; margin: 14px 0; box-shadow: var(--shadow); }
.next b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.srow { display: grid; grid-template-columns: 165px 1fr 1fr 1.2fr 185px 34px; gap: 8px; margin-bottom: 8px; }
.srow input, .srow select { margin: 0; }
.srow .rowdel { padding: 0; }
.paper { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 44px 52px; max-width: 820px; box-shadow: var(--shadow); font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.paper h2 { text-align: center; font-size: 20px; margin: 0 0 20px; }
.paper h3 { font-size: 15px; margin: 22px 0 6px; }
.paper p { margin: 7px 0; }
.pdfframe { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.events { list-style: none; padding: 0; margin: 0 0 0 6px; border-left: 2px solid var(--line); }
.events li { position: relative; padding: 5px 0 9px 18px; font-size: 14px; }
.events li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.linkbox { display: inline-block; width: 230px; font-size: 12px; margin: 0 0 5px; padding: 5px 8px; background: #f8f9fc; }
.sigsvg { width: 150px; height: 40px; }
.sigsvg polyline { fill: none; stroke: #0b1f5c; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Anmeldung, oeffentliche Seiten */
.logohead { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.logohead img { width: 46px; height: 46px; }
.logohead h1 { margin: 0; font-size: 28px; }
.tagline { color: var(--muted); margin: 0 0 18px; font-size: 13.5px; }
.card.narrow button { width: 100%; margin-top: 6px; padding: 11px; }
.sublinks { text-align: center; margin-top: 16px; font-size: 13px; }
body.public main { max-width: 900px; }
.pubhead { display: flex; align-items: center; gap: 10px; padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 17px; }
.pubhead img { width: 30px; height: 30px; }
.pubfoot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 34px; }
.pubfoot img { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.verdict { display: flex; gap: 14px; align-items: flex-start; }
.verdict .mark { flex: none; width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; background: var(--teal); }
.verdict.no .mark { background: var(--danger); }

/* Unterschrift */
#sigpad { display: block; width: 100%; max-width: 600px; aspect-ratio: 15 / 4; height: auto; border: 2px dashed #9aa5bd; border-radius: 10px; background: #fbfcfe; touch-action: none; cursor: crosshair; margin-bottom: 8px; }
#sigpad.missing { border-color: var(--danger); border-style: solid; }
.tabs { display: inline-flex; gap: 4px; margin: 6px 0 12px; background: #eef1f6; padding: 4px; border-radius: 10px; }
.tabs label { margin: 0; font-weight: 600; font-size: 13.5px; padding: 6px 16px; border-radius: 7px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.tabs label:has(input:checked) { background: #fff; box-shadow: 0 1px 3px rgba(23,32,58,.15); color: var(--accent-dark); }
.tabs input { position: absolute; opacity: 0; pointer-events: none; }
.typedsig, .sigpreview { font-family: "Times New Roman", Times, serif; font-style: italic; color: #0b1f5c; }
.typedsig { font-size: 20px; }
.sigpreview { font-size: 38px; line-height: 1.2; min-height: 62px; max-width: 600px; padding: 6px 10px 4px; border-bottom: 1.5px solid #8792a8; background: #fbfcfe; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* PDF-Seiten und Felder */
.pdfpages { background: #e6e9f0; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow: auto; }
.pdfpage { position: relative; margin: 0 auto 16px; background: #fff; box-shadow: 0 2px 8px rgba(23,32,58,.2); }
.pdfpage:last-child { margin-bottom: 0; }
.pdfpage canvas { display: block; width: 100%; height: 100%; }
.pdfpages.editing .pdfpage canvas { cursor: copy; }
.ftools { position: sticky; top: 64px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 16px; margin: 14px 0; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.ftools label { margin: 0; font-weight: 400; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; color: var(--ink); }
.ftools select { width: auto; margin: 0; padding: 6px 9px; }
.ftools form { margin: 0 0 0 auto; display: flex; gap: 8px; align-items: center; }
.fld { position: absolute; border: 1.5px solid #2f5bea; background: rgba(47,91,234,.16); color: #14307f; font-size: 11px; line-height: 1.1; padding: 2px 4px; overflow: hidden; cursor: move; user-select: none; touch-action: none; border-radius: 3px; }
.fld.sg1 { border-color: #b4540a; background: rgba(214,120,20,.18); color: #7a3a05; }
.fld.sg2 { border-color: #12703f; background: rgba(18,112,63,.16); color: #0b4a29; }
.fld.sg3 { border-color: #8a2be2; background: rgba(138,43,226,.14); color: #561a8f; }
.fld.sg4 { border-color: #b42318; background: rgba(180,35,24,.14); color: #7d1810; }
.fld.sg5 { border-color: #0e7490; background: rgba(14,116,144,.15); color: #0a4a5c; }
.fld .fdel { position: absolute; top: -1px; right: -1px; width: 16px; height: 16px; padding: 0; line-height: 14px; font-size: 12px; border-radius: 0 3px 0 3px; border: none; background: #172033; color: #fff; box-shadow: none; }
.fld .frs { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; background: currentColor; cursor: nwse-resize; border-radius: 2px 0 2px 0; }
.sfld { position: absolute; border: 1.5px dashed #2f5bea; background: rgba(255,244,179,.78); color: #173c94; font-size: 12px; display: flex; align-items: center; padding: 0 4px; overflow: hidden; border-radius: 3px; }
.sfld input:not([type=checkbox]) { width: 100%; height: 100%; margin: 0; padding: 0 2px; border: none; background: transparent; font-size: 12px; box-shadow: none; }
.sfld input[type=checkbox] { width: 100%; height: 100%; margin: 0; }
.sfld.t-checkbox { padding: 0; }
.sfld.missing { border: 2px solid var(--danger); background: var(--danger-soft); }
.sfld.filled { background: rgba(255,255,255,.88); border-style: solid; }
.sfld svg { width: 100%; height: 100%; }
.sfld polyline { fill: none; stroke: #0b1f5c; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sfld .typedsig { white-space: nowrap; }

/* Wartet auf Unterschrift, gespeicherte Unterschrift, Word-Import */
.next.signnow { display: flex; justify-content: space-between; align-items: center; gap: 14px; border-left-color: var(--teal); }
.savedsig { display: inline-block; background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; vertical-align: middle; }
.importbox { background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.importbox .actions { margin: 8px 0 0; }
.importbox input[type=file] { width: auto; flex: 1; margin: 0; }

/* Zwei-Faktor-Anmeldung */
.qr { width: 210px; height: 210px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; margin: 12px 0; }
.qr svg { width: 100%; height: 100%; display: block; }
.mfakey { font-size: 15px; letter-spacing: .06em; padding: 6px 10px; }
.codes { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.codes code { display: block; text-align: center; font-size: 15px; padding: 8px; letter-spacing: .05em; }
.card.narrow form + form { margin-top: 10px; }

/* Sprachumschalter */
nav .langsw { font-weight: 700; font-size: 12.5px; letter-spacing: .04em; border: 1px solid rgba(255,255,255,.28); padding: 4px 9px; }
.sublinks .langsw { font-weight: 700; }

/* Unterschrift als Bild */
.imgpreview { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.imgpreview img { display: block; max-width: 100%; max-height: 130px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.sigimg { max-width: 160px; max-height: 46px; background: #fff; border-radius: 6px; display: block; margin-top: 4px; }
.sfld img { max-width: 100%; max-height: 100%; margin: 0 auto; display: block; }
details.chg { margin-top: 8px; font-size: 13px; }
details.chg summary { cursor: pointer; color: var(--accent); }
details.chg form { display: grid; gap: 6px; margin-top: 8px; }
details.chg input { margin: 0; padding: 6px 8px; }

/* Assistent fuer neue Anfragen */
.wizard.js .wstep { display: none; }
.wizard.js .wstep.on { display: block; }
.wizard .wsteps { margin: 0 0 22px; }
.wsummary dl { display: grid; grid-template-columns: minmax(160px, 34%) 1fr; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.wsummary dt, .wsummary dd { margin: 0; padding: 9px 13px; border-bottom: 1px solid var(--line); font-size: 14px; }
.wsummary dt { background: #f7f8fb; color: var(--muted); font-size: 13px; }
.wsummary dd { white-space: pre-wrap; word-break: break-word; }
.wsummary dt:nth-last-child(2), .wsummary dd:last-child { border-bottom: none; }

/* Aenderungsvergleich */
details.diff { background: var(--card); border: 1px solid #efd58a; border-left: 4px solid #e2a400; border-radius: 10px; padding: 12px 16px; margin: 14px 0; box-shadow: var(--shadow); }
details.diff summary { cursor: pointer; font-weight: 600; }
details.diff p { margin: 8px 0; font-family: Georgia, "Times New Roman", serif; }
details.diff p.muted { font-family: inherit; }
del { background: #fde3e0; color: #9b2c20; text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
ins { background: #dcf5e7; color: #0f6a40; text-decoration: none; border-radius: 3px; padding: 0 2px; }

/* Branding */
.pubhead img.clogo { width: auto; height: 40px; max-width: 200px; object-fit: contain; }
.logoprev { height: 28px; max-width: 140px; vertical-align: middle; object-fit: contain; margin-left: 6px; }
input.colorpick { width: 70px; height: 40px; padding: 3px; cursor: pointer; }

/* Glocke, Mitteilungen */
nav .bell { position: relative; display: inline-flex; align-items: center; padding: 7px 9px; }
nav .bell.has { color: #fff; }
nav .bell i { position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; font: 700 10.5px/17px "Segoe UI", sans-serif; text-align: center; font-style: normal; }
.notes { list-style: none; padding: 0; margin: 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.notes li { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.notes li:last-child { border-bottom: none; }
.notes li.new { background: var(--accent-soft); font-weight: 600; }

/* Zweispaltige Vorgangsseite */
main:has(.doclayout) { max-width: 1420px; }
.doclayout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 28px; align-items: start; margin-top: 8px; }
.docmain h2:first-child, .docside h2:first-child { margin-top: 14px; }
.docside { position: sticky; top: 70px; max-height: calc(100vh - 84px); overflow-y: auto; padding-right: 4px; }
.scard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.scard .shead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.scard .slinks { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.scard .slinks .linkbox { width: 100%; margin: 0; }
.scard .slinks br { display: none; }
.cmtform { margin: 0 0 14px; }
.cmtform textarea { margin: 0 0 6px; }
.events li.cmt::before { border-color: var(--teal); background: var(--teal); }
.cmttext { background: #f4f6fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 4px; white-space: pre-wrap; }

/* Gefuehrtes Unterschreiben */
.guide { position: sticky; top: 8px; z-index: 6; display: flex; align-items: center; gap: 14px; justify-content: space-between; background: var(--navy); color: #fff; border-radius: 10px; padding: 10px 14px; margin: 12px 0; box-shadow: 0 4px 14px rgba(23,32,58,.25); }
.guide .bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; }
.guide .bar i { display: block; height: 100%; background: var(--teal); transition: width .25s; }
.guide button { background: var(--teal); border-color: var(--teal); box-shadow: none; white-space: nowrap; }
.guide button:hover { background: #129e82; border-color: #129e82; }
.guide.done { background: var(--ok); }
.sfld.focus { box-shadow: 0 0 0 4px rgba(47,91,234,.35); border-style: solid; }

/* Feld-Editor: Auswahl */
.fld.sel { box-shadow: 0 0 0 3px rgba(23,32,58,.45); z-index: 3; }
.fld .fdup { position: absolute; top: -1px; right: 16px; width: 16px; height: 16px; padding: 0; line-height: 14px; font-size: 10px; border-radius: 0 0 0 3px; border: none; background: #46506a; color: #fff; box-shadow: none; }

/* --- Dunkles Design --- */
nav .themebtn { display: inline-flex; align-items: center; padding: 7px 9px; }
nav .themebtn .sun { display: none; }
:root[data-theme=dark] nav .themebtn .sun { display: block; }
:root[data-theme=dark] nav .themebtn .moon { display: none; }
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #0e1320; --card: #19202f; --ink: #e7eaf3; --muted: #9aa4bc; --line: #2b3449; --navy: #0a0f1b;
  --accent: #6c8cff; --accent-dark: #86a0ff; --accent-soft: #1d2a52; --teal: #2fd0ae; --teal-soft: #11342d;
  --danger: #ff8b7e; --danger-soft: #3b1d1b; --warn: #f2c66a; --warn-soft: #3a2f12; --ok: #63d69d; --ok-soft: #143625;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.3);
}
:root[data-theme=dark] nav { border-bottom: 1px solid var(--line); }
:root[data-theme=dark] label { color: #c3cbe0; }
:root[data-theme=dark] input, :root[data-theme=dark] select, :root[data-theme=dark] textarea { background: #111726; border-color: #37415a; color: var(--ink); }
:root[data-theme=dark] input[type=file], :root[data-theme=dark] .linkbox { background: #111726; }
:root[data-theme=dark] button, :root[data-theme=dark] .btn { color: #0c1220; box-shadow: none; }
:root[data-theme=dark] button.secondary, :root[data-theme=dark] .btn.secondary { background: transparent; color: var(--accent); border-color: #3a4560; }
:root[data-theme=dark] button.danger, :root[data-theme=dark] .btn.danger { color: var(--danger); }
:root[data-theme=dark] button.link { color: #c5cee6; }
:root[data-theme=dark] code { background: #111726; }
:root[data-theme=dark] th, :root[data-theme=dark] .wsummary dt { background: #151c2b; }
:root[data-theme=dark] tbody tr:hover td { background: #1e2637; }
:root[data-theme=dark] .badge { background: #2a3348; color: #c9d1e6; }
:root[data-theme=dark] .st-review { background: var(--warn-soft); color: var(--warn); }
:root[data-theme=dark] .st-changes, :root[data-theme=dark] .st-declined, :root[data-theme=dark] .st-rejected, :root[data-theme=dark] .st-expired { background: var(--danger-soft); color: var(--danger); }
:root[data-theme=dark] .st-approved, :root[data-theme=dark] .st-signing { background: var(--accent-soft); color: var(--accent-dark); }
:root[data-theme=dark] .st-completed { background: var(--ok-soft); color: var(--ok); }
:root[data-theme=dark] .flash { border-color: #33488f; color: #c9d6ff; }
:root[data-theme=dark] .errors { border-color: #6e302b; }
:root[data-theme=dark] .note, :root[data-theme=dark] details.diff { border-color: #6a5520; color: #f1dca6; }
:root[data-theme=dark] details.diff { color: var(--ink); }
:root[data-theme=dark] .chip { background: transparent; border-color: #3a4560; color: #c3cbe0; }
:root[data-theme=dark] .chip.on { background: var(--accent); border-color: var(--accent); color: #0c1220; }
:root[data-theme=dark] .tile.alt, :root[data-theme=dark] .cmttext, :root[data-theme=dark] .empty { background: #151c2b; }
:root[data-theme=dark] .stepper li span, :root[data-theme=dark] .events li::before { background: var(--card); }
:root[data-theme=dark] .stepper li span, :root[data-theme=dark] .stepper li::before { border-color: #3a4560; }
:root[data-theme=dark] .stepper li::before { background: #3a4560; }
:root[data-theme=dark] .stepper li.done span { background: var(--teal); border-color: var(--teal); color: #0c1220; }
:root[data-theme=dark] .stepper li.done::before, :root[data-theme=dark] .stepper li.current::before { background: var(--teal); }
:root[data-theme=dark] .tabs { background: #111726; }
:root[data-theme=dark] .tabs label:has(input:checked) { background: #2a3348; color: var(--accent-dark); }
:root[data-theme=dark] .pdfpages { background: #0a0e18; }
:root[data-theme=dark] .ftools { background: var(--card); }
:root[data-theme=dark] .notes li.new { background: var(--accent-soft); }
:root[data-theme=dark] del { background: #4a2320; color: #ffb3aa; }
:root[data-theme=dark] ins { background: #17402b; color: #9be8c0; }
/* Dokumente und Unterschriftsfelder bleiben wie auf Papier: hell mit dunkler Schrift */
:root[data-theme=dark] .paper { background: #fff; color: #172033; border-color: #fff; }
:root[data-theme=dark] #sigpad, :root[data-theme=dark] .sigpreview { background: #fbfcfe; }
:root[data-theme=dark] .sigsvg, :root[data-theme=dark] .scard .typedsig { background: #fbfcfe; border-radius: 6px; padding: 2px 6px; }
:root[data-theme=dark] .sfld input:not([type=checkbox]) { background: transparent; color: #172033; border: none; }

/* Schmale Fenster: Navigation in zwei Zeilen, damit Sprache, Design, Glocke und Abmelden erreichbar bleiben */
@media (max-width: 1150px) {
  nav { flex-wrap: wrap; height: auto; padding: 6px 14px; overflow: visible; white-space: normal; row-gap: 0; }
  nav .grow { flex-basis: 100%; height: 0; }
  nav .brand { margin-right: 6px; }
  nav a, button.link { padding: 6px 9px; }
  .ftools { top: 96px; }
  .docside { top: 100px; max-height: calc(100vh - 112px); }
}
@media (max-width: 1000px) {
  .doclayout { grid-template-columns: 1fr; }
  .docside { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 720px) {
  main { padding: 18px 12px 50px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 24px; }
  .next.signnow { flex-direction: column; align-items: stretch; }
  nav { padding: 0 10px; }
  .srow { grid-template-columns: 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
  .paper { padding: 22px 18px; }
  .stepper li { font-size: 10.5px; }
  .card { padding: 16px; }
  th, td { padding: 8px 9px; }
}
@media print { nav, .actions, .ftools { display: none; } body { background: #fff; } }
