/* ==========================================================================
   Signvio – Design-System „Enterprise Blue“
   Keine externen Fonts/CDNs (DSGVO): Inter liegt lokal unter /assets/fonts.
   Aufbau: 1 Schriften · 2 Tokens · 3 Basis · 4 Layout · 5 Komponenten ·
           6 Öffentliche Seiten · 7 PDF/Editor/Signieren · 8 Hilfsklassen · 9 Responsive
   ========================================================================== */

/* ---------- 1. Schriften ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter-regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/inter-medium.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter-semibold.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter-bold.woff2") format("woff2"); }

/* ---------- 2. Design-Tokens ---------- */
:root {
  /* Marke (Vorgabe) */
  --brand-primary: #2563EB;
  --brand-primary-hover: #1D4ED8;
  --brand-navy: #0F1E3D;
  --brand-accent: #8B5CF6;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --surface-base: #FFFFFF;
  --surface-muted: #F8FAFC;
  --surface-subtle: #F3F4F6;
  --border-default: #E2E8F0;
  --text-primary: #0F1E3D;
  --text-secondary: #64748B;
  --text-secondary-strong: #475569; /* für getönte/graue Flächen */

  /* Abgeleitet – Text auf Weiß mit Kontrast ≥ 4,5:1 (WCAG AA) */
  --success-text: #047857;
  --success-soft: #ECFDF5;
  --warning-text: #B45309;
  --warning-soft: #FFFBEB;
  --danger-text: #B91C1C;
  --danger-soft: #FEF2F2;
  --info-text: #1D4ED8;
  --info-soft: #EFF6FF;
  --primary-soft: #EFF4FF;
  --border-strong: #CBD5E1;
  --navy-hover: #1A2B50;
  --navy-text: #C7D2E5;

  /* Form */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 30, 61, .05);
  --shadow: 0 1px 3px rgba(15, 30, 61, .06), 0 1px 2px rgba(15, 30, 61, .04);
  --shadow-lg: 0 16px 40px rgba(15, 30, 61, .16), 0 2px 8px rgba(15, 30, 61, .06);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .35);

  /* Raster (4/8 px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* Typografie */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  --sidebar-w: 248px;
  --header-h: 64px;
  --control-h: 40px;

  /* Kompatible Aliasnamen (werden in Inline-Styles und JavaScript verwendet) */
  --accent: var(--brand-primary);
  --accent-soft: var(--primary-soft);
  --ok: var(--success-text);
  --bad: var(--danger-text);
  --line: var(--border-default);
  --ink-3: var(--text-secondary);
}

/* ---------- 3. Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 15px/1.5 var(--font);
  color: var(--text-primary);
  background: var(--surface-muted);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.015em; color: var(--text-primary); }
h1 { font-size: 1.625rem; font-weight: 700; }
h2 { font-size: 1.0625rem; font-weight: 650; }
h3 { font-size: .9375rem; font-weight: 650; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .86em; }
img, svg { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }
.skip-link {
  position: absolute; left: var(--s3); top: -60px; z-index: 300; padding: var(--s2) var(--s4); border-radius: var(--radius-sm);
  background: var(--brand-navy); color: #fff; font-weight: 600;
}
.skip-link:focus { top: var(--s3); color: #fff; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- 4. Layout: App-Shell mit Sidebar ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s6);
  padding: var(--s5) var(--s3); background: var(--brand-navy); color: #fff; z-index: 60;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s1) var(--s3); min-height: 40px; }
.sidebar-head a:hover { text-decoration: none; }
.sidebar .sidebar-close { display: none; }
.side-nav { display: flex; flex-direction: column; gap: var(--s1); }
.side-nav a {
  display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3); border-radius: var(--radius-sm);
  color: var(--navy-text); font-weight: 550; font-size: .9375rem;
}
.side-nav a svg { width: 20px; height: 20px; flex: none; }
.side-nav a:hover { background: var(--navy-hover); color: #fff; text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--brand-primary); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .35); }
.side-nav a:focus-visible { box-shadow: 0 0 0 3px rgba(147, 197, 253, .7); }
.sidebar-foot { margin-top: auto; padding: var(--s3); font-size: .78rem; color: var(--navy-text); border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-backdrop { display: none; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: var(--s3);
  height: var(--header-h); padding: 0 var(--s6); background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-default);
}
.app-header .header-logo, .app-header .menu-btn { display: none; }
.header-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: var(--s2); color: var(--text-primary); font-weight: 550; font-size: .9rem; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--brand-primary);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none;
}
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--s8) var(--s6) 64px; }
.container.wide { max-width: none; padding: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head p { margin: var(--s1) 0 0; color: var(--text-secondary); }
.page-head h1 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s5); align-items: start; }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Kompakte Sidebar (Editor): nur Symbole */
.app-shell.compact { grid-template-columns: 72px minmax(0, 1fr); }
.app-shell.compact .sidebar { padding: var(--s5) var(--s2); }
.app-shell.compact .logo-word, .app-shell.compact .side-nav a span, .app-shell.compact .sidebar-foot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.app-shell.compact .side-nav a { justify-content: center; padding: 0; }
.app-shell.compact .sidebar-head { justify-content: center; padding: var(--s1) 0; }

/* ---------- 5. Komponenten ---------- */

/* Logo */
.logo { display: inline-flex; align-items: center; gap: .4em; line-height: 1; }
.logo-word { font-weight: 700; letter-spacing: -.035em; color: var(--brand-navy); }
.logo-sm .logo-word { font-size: 1.15rem; }
.logo-md .logo-word { font-size: 1.5rem; }
.logo-lg .logo-word { font-size: 2.35rem; }
.logo-xl .logo-word { font-size: 3rem; }
.logo-inverse .logo-word { color: #fff; }
.brand-mark-svg { flex: none; overflow: visible; }

/* Karten */
.card { background: var(--surface-base); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: var(--s5) var(--s6); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s6); border-bottom: 1px solid var(--border-default); flex-wrap: wrap; }
.card-head h2, .card-title { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: var(--s2); }
.card-title { margin-bottom: var(--s4); }
.card-head h2 svg, .card-title svg, .card h2 svg { width: 20px; height: 20px; color: var(--brand-primary); flex: none; }
.step-num {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--primary-soft);
  color: var(--brand-primary); font-size: .8rem; font-weight: 700; flex: none;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control-h); padding: 0 var(--s4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: var(--surface-base); color: var(--text-primary);
  font: 600 .9rem/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:hover { background: var(--surface-subtle); text-decoration: none; color: var(--text-primary); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .25); }
.btn-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); color: #fff; }
.btn-danger { color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-soft); border-color: #FECACA; color: var(--danger-text); }
.btn-danger-solid { background: var(--danger-text); border-color: var(--danger-text); color: #fff; }
.btn-danger-solid:hover { background: #991B1B; border-color: #991B1B; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-subtle); }
.btn-sm { min-height: 34px; padding: 0 var(--s3); font-size: .84rem; }
.btn-lg { min-height: 48px; padding: 0 var(--s6); font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-primary); cursor: pointer; font: inherit; font-weight: 550; }
.linkbtn:hover { text-decoration: underline; }

/* Formulare */
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; color: var(--text-primary); }
.input, input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], select, textarea {
  width: 100%; min-height: var(--control-h); padding: 0 var(--s3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: .9375rem; color: var(--text-primary); background: var(--surface-base);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 96px; padding: 10px var(--s3); resize: vertical; line-height: 1.45; }
select { padding-right: 32px; appearance: none; -webkit-appearance: none;
  background: var(--surface-base) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2364748B' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center; }
input::placeholder, textarea::placeholder { color: #8391A7; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-primary); box-shadow: var(--focus-ring); }
input:disabled, select:disabled { background: var(--surface-subtle); color: var(--text-secondary); }
.field { margin-bottom: var(--s4); }
.hint { font-size: .8rem; color: var(--text-secondary); margin-top: 6px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 450; font-size: .9rem; color: var(--text-primary); cursor: pointer; margin: 0; }
.check input { margin-top: 2px; width: 18px; height: 18px; accent-color: var(--brand-primary); flex: none; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-secondary); pointer-events: none; }
.input-icon > input { padding-left: 42px; }
.input-icon > .pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-icon > input.has-toggle { padding-right: 48px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); align-items: end; }

.dropzone {
  display: grid; place-items: center; gap: 6px; text-align: center; padding: var(--s8) var(--s5);
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-muted); cursor: pointer; color: var(--text-secondary);
  transition: border-color .15s, background .15s; margin: 0; font-weight: 450;
}
.dropzone:hover, .dropzone.drag, .dropzone:focus-within { border-color: var(--brand-primary); background: var(--primary-soft); }
.dropzone svg { width: 36px; height: 36px; color: var(--brand-primary); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .file-name { font-weight: 650; color: var(--text-primary); }

/* Meldungen */
.flash { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: var(--s3) var(--s4); border-radius: var(--radius); margin-bottom: var(--s4); border: 1px solid; font-weight: 500; }
.flash svg { width: 18px; height: 18px; flex: none; }
.flash.success { background: var(--success-soft); border-color: #A7F3D0; color: #065F46; }
.flash.error { background: var(--danger-soft); border-color: #FECACA; color: #991B1B; }
.flash.info { background: var(--info-soft); border-color: #BFDBFE; color: #1E40AF; }
.flash.warn { background: var(--warning-soft); border-color: #FDE68A; color: #92400E; }

/* Tabellen (Desktop) – werden mobil zu Karten (siehe 9) */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-secondary); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border-default); background: var(--surface-muted);
}
.table th:first-child { border-top-left-radius: var(--radius-lg); }
.table th:last-child { border-top-right-radius: var(--radius-lg); }
.table td { padding: 14px var(--s4); border-bottom: 1px solid var(--surface-subtle); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #FAFCFF; }
.table .title { font-weight: 650; color: var(--text-primary); }
.table .title:hover { color: var(--brand-primary); }
.doc-cell { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.doc-cell > svg { width: 22px; height: 22px; color: var(--danger-text); flex: none; }
.doc-cell .doc-meta { min-width: 0; }
.row-actions { display: flex; gap: var(--s1); justify-content: flex-end; }

/* Status-Badges: Farbe + Symbol + Text (nie nur Farbe) */
.badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: 99px;
  font-size: .78rem; font-weight: 600; background: var(--surface-subtle); color: #334155; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.s-completed, .badge.s-signed, .badge.s-copied { background: var(--success-soft); color: var(--success-text); border-color: #A7F3D0; }
.badge.s-sent, .badge.s-viewed, .badge.s-sealing { background: var(--info-soft); color: var(--info-text); border-color: #BFDBFE; }
.badge.s-declined, .badge.s-voided { background: var(--danger-soft); color: var(--danger-text); border-color: #FECACA; }
.badge.s-expired { background: var(--warning-soft); color: var(--warning-text); border-color: #FDE68A; }
.badge.s-draft, .badge.s-created { background: var(--surface-subtle); color: #334155; border-color: var(--border-default); }
.badge.s-completed::before, .badge.s-signed::before, .badge.s-copied::before { content: "✓"; width: auto; height: auto; background: none; font-size: .8em; }
.badge.s-declined::before, .badge.s-voided::before { content: "✕"; width: auto; height: auto; background: none; font-size: .75em; }

.progress { height: 6px; background: var(--surface-subtle); border-radius: 99px; overflow: hidden; width: 96px; flex: none; }
.progress > span { display: block; height: 100%; background: var(--color-success); border-radius: 99px; }
.progress-cell { display: flex; align-items: center; gap: var(--s2); }

/* Filter-Chips & Tags */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--border-default); background: var(--surface-base); color: #334155; font-weight: 550; font-size: .86rem;
}
.chip:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text-primary); }
.chip[aria-current="page"], .chip.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.chip .n { font-size: .78rem; font-weight: 500; color: var(--text-secondary-strong); font-variant-numeric: tabular-nums; }
.chip[aria-current="page"] .n, .chip.active .n { color: #fff; }   /* keine Transparenz: Kontrast ≥ 4,5 : 1 */
.chip svg { width: 15px; height: 15px; }
.chip-muted:not(.active) { background: transparent; border-style: dashed; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 8px; margin-left: 4px; border-radius: 6px;
  background: var(--primary-soft); color: #1E3A8A; font-size: .74rem; font-weight: 600; vertical-align: middle;
}
a.tag:hover { text-decoration: none; background: #DBE6FE; color: #1E3A8A; }
.tag-filter { align-items: center; }
.tag-filter .tag { min-height: 28px; margin: 0; font-size: .8rem; }
.tag.active { background: var(--brand-primary); color: #fff; }
.tag .n { font-weight: 500; }
.tag-filter > svg { width: 16px; height: 16px; color: var(--text-secondary); }

.toolbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-secondary); pointer-events: none; }
.search input { padding-left: 38px; width: 300px; max-width: 100%; }

.empty { text-align: center; padding: 56px var(--s5); color: var(--text-secondary); }
.empty svg { width: 48px; height: 48px; color: #B8C4D6; margin-bottom: var(--s3); }
.empty h2 { color: var(--text-primary); }

/* Zeitleiste (Prüfprotokoll) */
.timeline { list-style: none; margin: 0; padding: var(--s1) 0; }
.timeline li { position: relative; padding: 0 0 var(--s4) 24px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 20px; bottom: 0; width: 1px; background: var(--border-default); }
.timeline li:last-child::after { display: none; }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { font-size: .8rem; color: var(--text-secondary); }

.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--s2) var(--s4); font-size: .9rem; margin: 0; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; word-break: break-word; }

/* Empfängerliste (Detailansicht) */
.recipient-list { list-style: none; margin: 0; padding: 0; }
.recipient-list li { display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s6); border-bottom: 1px solid var(--surface-subtle); }
.recipient-list li:last-child { border-bottom: 0; }
.recipient-list li.is-cc { background: #FCFDFF; }
.recipient-list .who { flex: 1; min-width: 0; }
.recipient-list .who b { display: block; }
.recipient-list .who > span { font-size: .86rem; color: var(--text-secondary); word-break: break-all; }
.recipient-list .rec-num { font-size: .66rem; }
.recipient-list > li > svg { width: 20px; height: 20px; color: var(--text-secondary); flex: none; }
.rec-meta { text-align: right; font-size: .82rem; color: var(--text-secondary); }
.rec-fix summary { cursor: pointer; color: var(--brand-primary); list-style: none; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; font-size: .84rem; font-weight: 550; }
.rec-fix summary::-webkit-details-marker { display: none; }
.rec-fix summary svg { width: 14px; height: 14px; }

.rec-num {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  font-size: .75rem; font-weight: 700; flex: none; background: var(--brand-primary);
}
.role-tag { font-weight: 600; font-size: .88rem; line-height: 1.3; }

/* Empfängerzeilen (Neuer Umschlag) */
.rec-head, .rec-row.full { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1.2fr) 152px 76px 40px; gap: var(--s2); align-items: center; }
.rec-row.full { margin-bottom: var(--s2); }
.rec-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); font-weight: 650; margin-bottom: var(--s1); }
.rec-row.with-role { display: grid; grid-template-columns: 26px 140px minmax(0, 1fr) minmax(0, 1fr) 76px; gap: var(--s2); align-items: center; margin-bottom: var(--s2); }

.file-list { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s3); border: 1px solid var(--border-default); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface-base); flex-wrap: wrap; }
.file-list .fl-num { width: 24px; height: 24px; border-radius: 7px; background: var(--primary-soft); color: var(--brand-primary); display: grid; place-items: center; font-size: .75rem; font-weight: 700; flex: none; }
.file-list .fl-name { font-weight: 600; word-break: break-all; }
.file-list .btn { width: 36px; padding: 0; }

.secret-box {
  display: flex; gap: var(--s2); align-items: center; padding: var(--s3) var(--s4); background: var(--brand-navy); color: #E6EBFF;
  border-radius: var(--radius-sm); font-family: var(--mono); font-size: .85rem; word-break: break-all;
}
.sep { border: 0; border-top: 1px solid var(--border-default); margin: var(--s4) 0; }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); font-weight: 650; margin: var(--s5) 0 var(--s2); }

/* Modal */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(15, 30, 61, .55); display: grid; place-items: center; padding: var(--s4); }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface-base); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-head { padding: var(--s5) var(--s6) 0; }
.modal-body { padding: var(--s4) var(--s6); }
.modal-foot { padding: var(--s4) var(--s6); background: var(--surface-muted); border-top: 1px solid var(--border-default); display: flex; gap: var(--s2); justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border-default); margin-bottom: var(--s4); }
.tabs button { all: unset; cursor: pointer; padding: 10px var(--s4); font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--brand-primary); border-color: var(--brand-primary); }
.tabs button:focus-visible { box-shadow: var(--focus-ring); }
.sig-canvas-wrap { position: relative; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: #fff; }
.sig-canvas-wrap::after { content: ""; position: absolute; left: 24px; right: 24px; bottom: 34%; border-bottom: 1px dashed var(--border-strong); pointer-events: none; }
.sig-canvas-wrap canvas { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
.sig-type-preview { font: italic 44px "Segoe Script", "Brush Script MT", "Lucida Handwriting", "Apple Chancery", cursive; height: 120px; display: flex; align-items: center; padding: 0 var(--s4); border: 1px solid var(--border-default); border-radius: var(--radius-sm); margin-top: 10px; overflow: hidden; white-space: nowrap; }
.consent-box { background: var(--surface-base); border: 1px solid #BFDBFE; border-left: 4px solid var(--brand-primary); border-radius: var(--radius-lg); padding: var(--s5); box-shadow: var(--shadow); }

/* ---------- 6. Öffentliche Seiten (Login, Info, Prüfen) ---------- */
.public-wrap { min-height: 100vh; display: flex; flex-direction: column; background:
  radial-gradient(1200px 520px at 110% 110%, rgba(37, 99, 235, .16), transparent 60%),
  radial-gradient(900px 420px at -10% -10%, rgba(139, 92, 246, .08), transparent 60%), var(--surface-muted); }
.public-top { height: var(--header-h); display: flex; align-items: center; padding: 0 var(--s6); }
.public-top a:hover { text-decoration: none; }
.public-main { flex: 1; display: grid; place-items: center; padding: var(--s8) var(--s4); }
.public-inner { width: 100%; display: grid; place-items: center; gap: var(--s4); }
.public-foot { text-align: center; padding: var(--s5) var(--s4); font-size: .8rem; color: var(--text-secondary); }
.auth-card { width: 100%; max-width: 460px; padding: var(--s10) var(--s8); text-align: left; }
.auth-card .auth-logo { display: flex; justify-content: center; margin-bottom: var(--s6); }
.auth-card h1 { text-align: center; font-size: 1.75rem; margin-bottom: var(--s2); }
.auth-card .auth-sub { text-align: center; color: var(--text-secondary); margin-bottom: var(--s6); }
.info-card { width: 100%; max-width: 540px; text-align: center; padding: var(--s8); }
.info-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto var(--s4); font-size: 1.6rem; font-weight: 700; }
.info-icon svg { width: 30px; height: 30px; }
.info-icon.ok { background: var(--success-soft); color: var(--success-text); }
.info-icon.warn { background: var(--warning-soft); color: var(--warning-text); }
.info-icon.wait { background: var(--info-soft); color: var(--info-text); }

/* ---------- 7. PDF-Seiten, Editor, Signieren ---------- */
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 28px var(--s5) 80px; }
.page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(15, 30, 61, .12), 0 8px 24px rgba(15, 30, 61, .08); user-select: none; max-width: 100%; }
.page canvas { display: block; width: 100%; height: 100%; }
.page .overlay { position: absolute; inset: 0; }
.page-label { position: absolute; top: -19px; right: 0; font-size: .72rem; color: var(--text-secondary-strong); }
.loading-pages { padding: 80px var(--s4); text-align: center; color: var(--text-secondary-strong); }
.doc-label { max-width: 100%; font-size: .78rem; font-weight: 700; color: #334155; text-transform: uppercase; letter-spacing: .05em; margin-bottom: -12px; padding-left: 2px; }

/* Editor */
.editor { display: grid; grid-template-columns: 290px minmax(0, 1fr) 280px; height: calc(100vh - var(--header-h)); }
.editor-side { background: var(--surface-base); border-right: 1px solid var(--border-default); overflow-y: auto; padding: var(--s5) var(--s4); }
.editor-side.side-right { border-right: 0; border-left: 1px solid var(--border-default); }
.editor-main { overflow-y: auto; background: #E9EDF4; }
.editor-side h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin: var(--s5) 0 10px; }
.editor-side h3:first-child { margin-top: 0; }
.editor-toolbar { position: sticky; top: 0; z-index: 5; display: flex; gap: var(--s2); align-items: center; padding: 10px var(--s4); background: rgba(233, 237, 244, .94); backdrop-filter: blur(6px); border-bottom: 1px solid #D9DFEA; flex-wrap: wrap; }
.editor-toolbar > * { white-space: nowrap; }
.editor-toolbar .title { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.rec-pick { display: flex; flex-direction: column; gap: 6px; }
.rec-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); cursor: pointer; background: #fff; }
.rec-item.active { border-color: var(--rc); box-shadow: inset 3px 0 0 var(--rc); background: color-mix(in srgb, var(--rc) 7%, #fff); }
.rec-item .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--rc); flex: none; }
.rec-item .meta { flex: 1; min-width: 0; }
.rec-item .meta b { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-item .meta span { display: block; font-size: .76rem; color: var(--text-secondary-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-item .rm { opacity: 0; border: 0; background: none; color: var(--text-secondary); cursor: pointer; font-size: 1.15rem; line-height: 1; width: 28px; height: 28px; border-radius: 6px; }
.rec-item:hover .rm, .rec-item .rm:focus-visible { opacity: 1; }
.rec-item.is-cc { opacity: .8; }
.rec-item.is-cc .dot { background: transparent; border: 2px solid var(--rc); }
.rec-edit { margin-top: var(--s3); padding: var(--s3); background: var(--surface-muted); border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.rec-edit .field { margin-bottom: var(--s2); }
.kind-tag { display: inline-block; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; background: var(--surface-subtle); color: #334155; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.palette.disabled { opacity: .4; pointer-events: none; }
.pal-item { display: flex; align-items: center; gap: 7px; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); background: #fff; cursor: grab; font-size: .84rem; font-weight: 550; transition: border-color .12s, transform .12s; }
.pal-item:hover { border-color: var(--brand-primary); transform: translateY(-1px); }
.pal-item svg { width: 16px; height: 16px; color: var(--brand-primary); flex: none; }
.pal-item.wide { grid-column: span 2; }
.f-box {
  position: absolute; border: 1.5px solid var(--rc); background: color-mix(in srgb, var(--rc) 14%, transparent);
  border-radius: 3px; display: flex; align-items: center; justify-content: flex-start; padding: 0 5px;
  font-size: 11px; font-weight: 600; color: color-mix(in srgb, var(--rc) 80%, #000); overflow: hidden; cursor: move; touch-action: none; white-space: nowrap;
}
.f-box.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--rc); z-index: 3; }
.f-box .handle { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; background: var(--rc); cursor: nwse-resize; border-radius: 2px 0 2px 0; }
.f-box .req { color: var(--danger-text); margin-left: 2px; }
.f-box .who { opacity: .65; font-weight: 500; margin-left: 4px; }
.f-box .cond { margin-right: 3px; font-weight: 800; }
.f-box.f-radio { border-radius: 50%; padding: 0; justify-content: center; }
.f-box.f-radio .handle, .f-box.f-check .handle { width: 7px; height: 7px; }
.props .empty-props { color: var(--text-secondary); font-size: .88rem; padding: 10px 0; }
.editor-tips { padding-left: 18px; margin: 0; font-size: .84rem; color: var(--text-secondary); }

/* Signieren */
.sign-bar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s5); background: #fff; border-bottom: 1px solid var(--border-default); box-shadow: var(--shadow-sm);
}
.sign-bar .doc { flex: 1; min-width: 0; }
.sign-bar .doc b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sign-bar .doc span { font-size: .82rem; color: var(--text-secondary); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sign-secondary, .sign-primary { display: flex; align-items: center; gap: var(--s2); }
.sign-bar .more-toggle { display: none; }
.sign-progress { font-size: .85rem; color: var(--text-secondary-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sign-wrap { background: #E9EDF4; min-height: calc(100vh - 62px); }
.sign-intro { max-width: 860px; margin: var(--s6) auto 0; padding: 0 var(--s5); }
.s-field { position: absolute; border: 2px solid var(--rc); background: color-mix(in srgb, var(--rc) 12%, #fff); border-radius: 4px; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: box-shadow .15s, background .15s; }
.s-field.done { background: rgba(255, 255, 255, .55); border-style: dashed; border-color: color-mix(in srgb, var(--rc) 55%, #fff); }
.s-field.hidden { display: none !important; }
.s-field.pulse { animation: pulse 1.2s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rc) 60%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.s-field:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--rc) 45%, transparent); }
.s-field button.s-sign { all: unset; cursor: pointer; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; color: color-mix(in srgb, var(--rc) 85%, #000); font-weight: 700; font-size: 12px; text-align: center; }
.s-field img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.s-field input[type=text] { all: unset; width: 100%; height: 100%; padding: 0 5px; font: 13px var(--font); color: var(--text-primary); box-sizing: border-box; }
.s-field input[type=checkbox] { width: 70%; height: 70%; margin: 0; accent-color: var(--rc); }
.s-field .static { font-size: 13px; padding: 0 5px; width: 100%; white-space: nowrap; overflow: hidden; }
.s-field .req-dot { position: absolute; top: -7px; right: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--danger-text); color: #fff; font-size: 10px; display: grid; place-items: center; font-weight: 800; }
.s-field.done .req-dot { display: none; }
.s-field select { all: unset; width: 100%; height: 100%; padding: 0 5px; font: 13px var(--font); color: var(--text-primary); box-sizing: border-box; cursor: pointer;
  background: linear-gradient(45deg, transparent 50%, var(--rc) 50%) right 10px center / 5px 5px no-repeat, linear-gradient(135deg, var(--rc) 50%, transparent 50%) right 5px center / 5px 5px no-repeat; }
.s-field.s-radio { border-radius: 50%; }
.s-field input[type=radio] { width: 72%; height: 72%; margin: 0; accent-color: var(--rc); }
.s-field button.s-attach { all: unset; cursor: pointer; width: 100%; height: 100%; display: flex; align-items: center; gap: 4px; padding: 0 6px; box-sizing: border-box; font-size: 12px; font-weight: 600; color: color-mix(in srgb, var(--rc) 85%, #000); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 8. Hilfsklassen ---------- */
.muted { color: var(--text-secondary); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.only-mobile { display: none !important; }
kbd { font-family: var(--mono); font-size: .8em; padding: 1px 5px; border: 1px solid var(--border-default); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-muted); }

/* ---------- 9. Responsive ---------- */
/* Empfängerzeilen: abhängig von der Kartenbreite (auch bei 1024 px mit schmaler Hauptspalte) */
.rec-container { container-type: inline-size; }
@container (max-width: 640px) {
  .rec-head { display: none; }
  .rec-row.full, .rec-row.with-role {
    grid-template-columns: 26px minmax(0, 1fr) 44px 72px; grid-template-areas: "num name name rm" ". mail mail mail" ". kind kind lang";
    padding: var(--s3); border: 1px solid var(--border-default); border-radius: var(--radius); background: var(--surface-muted);
  }
  .rec-row.full > .rec-num { grid-area: num; }
  .rec-row.full > input[type=text] { grid-area: name; }
  .rec-row.full > input[type=email] { grid-area: mail; }
  .rec-row.full > select:nth-of-type(1) { grid-area: kind; }
  .rec-row.full > select:nth-of-type(2) { grid-area: lang; }
  .rec-row.full > .rm { grid-area: rm; width: 44px; justify-self: end; }
  .rec-row.with-role { grid-template-areas: "num role role role" ". name name name" ". mail mail mail" ". lang lang lang"; }
  .rec-row.with-role > .rec-num { grid-area: num; }
  .rec-row.with-role > .role-tag { grid-area: role; }
  .rec-row.with-role > input[type=text] { grid-area: name; }
  .rec-row.with-role > input[type=email] { grid-area: mail; }
  .rec-row.with-role > select { grid-area: lang; }

}

@media (max-width: 1180px) {
  .editor { grid-template-columns: 250px minmax(0, 1fr); }
  .editor-side.side-right { display: none; }
}

/* Kleine Laptops: Tabelle verdichten */
@media (min-width: 1024px) and (max-width: 1279px) {
  .col-optional { display: none; }
  .progress { width: 64px; }
  .table td, .table th { padding-left: 12px; padding-right: 12px; }
}

/* Tablet & Mobil: Off-Canvas-Navigation */
@media (max-width: 1023px) {
  .app-shell, .app-shell.compact { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .app-shell.compact .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); padding: var(--s5) var(--s3);
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); visibility: hidden;
  }
  .app-shell.compact .logo-word, .app-shell.compact .side-nav a span, .app-shell.compact .sidebar-foot { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .app-shell.compact .side-nav a { justify-content: flex-start; padding: 0 var(--s3); }
  .app-shell.compact .sidebar-head { justify-content: space-between; padding: var(--s1) var(--s3); }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 30, 61, .45); }
  .sidebar .sidebar-close { display: inline-flex; color: #fff; }
  .sidebar .sidebar-close:hover { background: var(--navy-hover); color: #fff; }
  .app-header { padding: 0 var(--s4); gap: var(--s2); }
  .app-header .header-logo, .app-header .menu-btn { display: inline-flex; }
  .header-logo:hover { text-decoration: none; }
  .user-chip .user-name { display: none; }
  .editor { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor-side { border-right: 0; border-bottom: 1px solid var(--border-default); }
  .editor-main { min-height: 70vh; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }

  /* Tabellen → Karten */
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { position: relative; padding: var(--s4); border-bottom: 1px solid var(--border-default); }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td { padding: 3px 0; border: 0; text-align: left; }
  .table-cards td[data-label] { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); font-size: .9rem; }
  .table-cards td[data-label]::before { content: attr(data-label); font-size: .78rem; font-weight: 600; color: var(--text-secondary); flex: none; }
  .table-cards td.cell-main { padding-bottom: var(--s2); }
  .table-cards td.cell-main .title::after { content: ""; position: absolute; inset: 0; } /* ganze Karte klickbar */
  .table-cards td.cell-actions { position: relative; z-index: 1; padding-top: var(--s2); }
  .table-cards .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .table-cards tr.clickable:hover td { background: transparent; }


  /* Signierseite: Hauptaktionen unten fixiert, Nebenaktionen im Menü */
  .sign-bar { padding: var(--s2) var(--s3); gap: var(--s2); }
  .sign-bar .more-toggle { display: inline-flex; }
  .sign-secondary { display: none; position: absolute; right: var(--s3); top: calc(100% + 6px); flex-direction: column; align-items: stretch; padding: var(--s2); background: #fff; border: 1px solid var(--border-default); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 210px; }
  .sign-secondary.open { display: flex; }
  .sign-secondary .btn { justify-content: flex-start; min-height: 44px; }
  .sign-primary { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; padding: 10px var(--s3) calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--border-default); box-shadow: 0 -4px 16px rgba(15, 30, 61, .08); }
  .sign-primary .btn { flex: 1; min-height: 48px; }
  .sign-primary .btn-sm { font-size: .95rem; }
  .sign-primary .sign-progress { position: absolute; left: 0; right: 0; top: -26px; text-align: center; font-size: .78rem; }
  .sign-wrap { padding-bottom: 96px; }
}

@media (max-width: 767px) {
  :root { --control-h: 44px; --header-h: 58px; }
  body { font-size: 15px; }
  h1 { font-size: 1.4rem; }
  input, select, textarea { font-size: 16px !important; } /* verhindert Zoom auf iOS */
  .container { padding: var(--s5) var(--s4) 48px; }
  .card-pad { padding: var(--s4); }
  .card-head { padding: var(--s3) var(--s4); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: stretch; }
  .page-head .toolbar, .search, .search input { width: 100%; }
  .btn-sm { min-height: 40px; }
  .btn-icon.btn-sm { width: 40px; }
  .only-mobile { display: initial !important; }
  .hide-mobile { display: none !important; }
  .header-new span { display: none; }
  .header-new { width: var(--control-h); padding: 0; }
  .chips { gap: 6px; }
  .chip { min-height: 40px; padding: 0 12px; }

  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: var(--s2); }
  .recipient-list li { flex-wrap: wrap; padding: var(--s3) var(--s4); }
  .recipient-list .who { flex-basis: calc(100% - 42px); }
  .rec-meta { text-align: left; flex: 1; padding-left: 38px; }

  .auth-card { padding: var(--s8) var(--s5); }
  .info-card { padding: var(--s6) var(--s5); }
  .public-top { padding: 0 var(--s4); }
  .modal-back { padding: 0; place-items: end stretch; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-foot .btn { flex: 1; }
  .modal-foot > .small { flex-basis: 100%; }

  .sign-intro { padding: 0 var(--s3); margin-top: var(--s4); }
  .pages { padding: 24px var(--s2) 40px; }
}

@media (max-width: 400px) {
  .header-logo .logo-word { font-size: 1.05rem; }
  .user-chip .avatar { width: 30px; height: 30px; }
}
