/* ============================================================
   4EBIT Fileshare · App-Styles (übernommen aus eSign) auf Basis des 4EBIT Design Systems
   Komponenten (Button, Card, Callout, Kicker, Badge, Input,
   Checkbox) als CSS-Klassen nach den React-Vorlagen in ds/.
   ============================================================ */

/* Ginora Sans zeichnet alle Ziffern auf Kleinbuchstabenhöhe (Mediävalziffern). Das Design System setzt Zahlen
   deshalb in IBM Plex Mono, die wir nicht von Google laden. Für Daten, Codes und „4EBIT“ im Text nehmen wir die
   Ziffern aus der Systemschrift, die Buchstaben bleiben Ginora Sans. */
@font-face { font-family: "App Ziffern"; font-weight: 300 500; unicode-range: U+0030-0039;
  src: local("Helvetica Neue"), local("HelveticaNeue"), local("Arial"), local("Liberation Sans"), local("DejaVu Sans"); }
@font-face { font-family: "App Ziffern"; font-weight: 600 800; unicode-range: U+0030-0039;
  src: local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"), local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("DejaVu Sans Bold"); }
:root {
  --font-display: "App Ziffern", "Ginora Sans", "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-sans: "App Ziffern", "Ginora Sans", "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--surface-tint); }
body { background: var(--surface-tint); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--text-brand); text-decoration: none; font-weight: var(--fw-semibold); }
a:hover { text-decoration: underline; }
p { margin: 0 0 var(--space-3); }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; word-break: break-all; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- Layout ------------------------------------------------ */
.topbar {
  background: var(--surface-card); border-bottom: 1px solid var(--border-default);
}
.topbar-inner {
  max-width: var(--container-max); margin: 0 auto; padding: 0 var(--gutter);
  height: 68px; display: flex; align-items: center; gap: var(--space-5);
}
.brand { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none !important; }
.brand img { height: 30px; width: auto; display: block; }
.brand-product {
  font-family: var(--font-brand-ext); font-weight: 300; font-size: var(--text-h4);
  letter-spacing: var(--tracking-wide); color: var(--text-strong);
  padding-left: var(--space-3); border-left: 1px solid var(--border-strong);
}
.nav { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }
.nav a, .nav button.linklike {
  white-space: nowrap; color: var(--text-secondary); font-weight: var(--fw-semibold); font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
}
.nav a:hover, .nav button.linklike:hover { background: var(--surface-subtle); color: var(--text-strong); text-decoration: none; }
.nav a.active { color: var(--text-strong); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
.nav form { margin: 0; }
button.linklike { background: none; border: 0; cursor: pointer; font-family: var(--font-sans); }

.page { flex: 1; width: 100%; max-width: var(--container-max); margin: 0 auto; padding: var(--space-7) var(--gutter) var(--space-9); }
.page-narrow { max-width: var(--container-narrow); }
.page-head { margin-bottom: var(--space-6); }
.page-head h1 { font-size: var(--text-h1); line-height: var(--lh-h1); font-weight: var(--fw-bold); margin: var(--space-2) 0 var(--space-3); }
.lead { font-size: var(--text-body-lg); line-height: var(--lh-body-lg); color: var(--text-secondary); max-width: 62ch; }
h2 { font-size: var(--text-h3); line-height: var(--lh-h3); font-weight: var(--fw-bold); margin: 0 0 var(--space-3); }
h3 { font-size: var(--text-h4); line-height: var(--lh-h4); font-weight: var(--fw-semibold); margin: 0 0 var(--space-2); }
.muted { color: var(--text-muted); font-size: var(--text-sm); }
.stack > * + * { margin-top: var(--space-5); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-5); }
.footer { text-align: center; color: var(--text-muted); font-size: var(--text-xs); padding: var(--space-5); }

/* ---- Section kicker ---------------------------------------- */
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: var(--text-sm); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--tracking-overline); color: var(--text-muted);
}
.kicker .num { color: var(--brand); font-weight: var(--fw-bold); }
.kicker .num::after { content: ""; display: inline-block; width: 20px; height: 2px; background: var(--brand); margin-left: 10px; vertical-align: middle; }

/* ---- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: var(--text-body); font-weight: var(--fw-semibold);
  line-height: 1; letter-spacing: 0.01em; white-space: nowrap; cursor: pointer; text-decoration: none !important;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); box-shadow: var(--shadow-brand); }
.btn-secondary { background: var(--surface-card); color: var(--text-strong); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-subtle); border-color: var(--ink-800); }
.btn-ghost { background: transparent; color: var(--text-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-subtle); }
.btn-sm { height: 34px; padding: 0 14px; font-size: var(--text-sm); }
.btn-lg { height: 50px; padding: 0 24px; font-size: var(--text-body-lg); }
.btn-block { display: flex; width: 100%; }

/* ---- Cards & callouts -------------------------------------- */
.card {
  background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); padding: var(--space-6);
}
.card-sm { padding: var(--space-5); }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.callout {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--space-4) var(--space-5); padding-left: calc(var(--space-5) - var(--accent-bar));
  background: var(--surface-subtle); border-left: var(--accent-bar) solid var(--brand);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.callout-title { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--text-h4); color: var(--text-strong); letter-spacing: var(--tracking-tight); }
.callout > p:last-child { margin-bottom: 0; }
.callout-info { border-left-color: var(--info); }
.callout-warning { border-left-color: var(--warning); }
.callout-ink { border-left-color: var(--ink-800); }

/* ---- Meldungen --------------------------------------------- */
.alert {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4);
  font-size: var(--text-body); border: 1px solid;
}
.alert-error { background: var(--danger-bg); border-color: var(--red-200); color: var(--red-700); }
.alert-success { background: var(--success-bg); border-color: #B9E3C8; color: #1C7A43; }
.alert-info { background: var(--info-bg); border-color: #BCD0F6; color: #1F4FB0; }
.alert-warning { background: var(--warning-bg); border-color: #F2D6A0; color: #9A6608; }

/* ---- Badges ------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 3px 10px;
  font-size: var(--text-sm); font-weight: var(--fw-semibold); line-height: 1; letter-spacing: 0.01em;
  border-radius: var(--radius-pill); white-space: nowrap; color: var(--slate-600); background: var(--gray-75);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-plain::before { display: none; }
.badge-brand { color: var(--red-700); background: var(--brand-tint); }
.badge-success { color: #1C7A43; background: var(--success-bg); }
.badge-warning { color: #9A6608; background: var(--warning-bg); }
.badge-info { color: #1F4FB0; background: var(--info-bg); }

/* ---- Formulare --------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field > label, .label { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }
.field .helptext, .hint { font-size: var(--text-sm); color: var(--text-muted); }
.field .helptext ul { margin: 4px 0 0; padding-left: 18px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], textarea, select {
  width: 100%; min-height: 42px; padding: 9px 12px; font-family: var(--font-sans); font-size: var(--text-body);
  color: var(--text-strong); background: var(--surface-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
textarea { line-height: var(--lh-body); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }
input[type=file] { padding: 8px; background: var(--surface-subtle); color: var(--text-secondary); cursor: pointer; }
input[type=file]::file-selector-button {
  margin-right: var(--space-3); height: 32px; padding: 0 14px; cursor: pointer;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong);
  background: var(--surface-card); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input[type=file]::file-selector-button:hover { border-color: var(--ink-800); }
input.code-input { font-family: var(--font-mono); font-size: var(--text-h3); letter-spacing: 0.3em; max-width: 220px; text-align: center; }
ul.errorlist { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: var(--text-sm); font-weight: var(--fw-semibold); }
ul.errorlist.nonfield { background: var(--danger-bg); border: 1px solid var(--red-200); color: var(--red-700); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--text-body); color: var(--text-strong); }
.check input { appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface-card); display: grid; place-items: center; cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); }
.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--white); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* Auswahlkarten (Radio) */
.choices { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); }
.choices-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body {
  display: block; height: 100%; padding: var(--space-4) var(--space-5); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); background: var(--surface-card); transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.choice-body:hover { border-color: var(--ink-800); }
.choice input:checked + .choice-body { border-color: var(--brand); background: var(--brand-wash); box-shadow: 0 0 0 1px var(--brand); }
.choice input:focus-visible + .choice-body { box-shadow: 0 0 0 3px var(--focus-ring); }
.choice-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-weight: var(--fw-bold); font-size: var(--text-h4); color: var(--text-strong); margin-bottom: 4px; }
.choice-text { display: block; color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--lh-sm); }
.choice.is-disabled { cursor: not-allowed; }
.choice.is-disabled .choice-body { background: var(--surface-subtle); border-style: dashed; color: var(--text-muted); }
.choice.is-disabled .choice-title { color: var(--text-muted); }

/* ---- Fortschritt (Stepper) --------------------------------- */
.stepper { display: flex; gap: var(--space-2); list-style: none; margin: 0 0 var(--space-6); padding: 0; counter-reset: step; }
.stepper li {
  flex: 1; counter-increment: step; display: flex; align-items: center; gap: 10px;
  padding-top: var(--space-3); border-top: 3px solid var(--border-default);
  font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-muted);
}
.stepper li::before {
  content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: var(--text-xs); font-weight: var(--fw-bold); background: var(--surface-subtle); color: var(--text-muted); border: 1px solid var(--border-strong);
}
.stepper li.is-done { border-top-color: var(--ink-800); color: var(--text-secondary); }
.stepper li.is-done::before { content: "✓"; background: var(--ink-800); border-color: var(--ink-800); color: var(--white); }
.stepper li.is-current { border-top-color: var(--brand); color: var(--text-strong); }
.stepper li.is-current::before { background: var(--brand); border-color: var(--brand); color: var(--white); }

/* Nummerierte Erklär-Liste */
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; margin-bottom: var(--space-4); }
.steps li::before {
  content: counter(s, decimal-leading-zero); position: absolute; left: 0; top: 0;
  font-weight: var(--fw-bold); color: var(--brand); font-size: var(--text-body);
}
.steps li strong { display: block; color: var(--text-strong); }
.steps li.is-done::before { content: "✓"; color: var(--success); }
.steps li.is-done strong { color: var(--text-secondary); }

/* ---- Tabellen ---------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-body); }
.table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-overline); color: var(--text-muted); font-weight: var(--fw-semibold); padding: 0 var(--space-3) var(--space-2); border-bottom: 1px solid var(--border-default); }
.table td { padding: var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; padding: var(--space-8) var(--space-5); color: var(--text-secondary); }

details.disclosure { border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-card); }
details.disclosure > summary { cursor: pointer; padding: var(--space-4) var(--space-5); font-weight: var(--fw-semibold); color: var(--text-strong); }
details.disclosure > .disclosure-body { padding: 0 var(--space-5) var(--space-5); }
details.help { margin: var(--space-2) 0 var(--space-5); }
details.help > summary { cursor: pointer; color: var(--text-brand); font-weight: var(--fw-semibold); font-size: var(--text-sm); }
details.help > div { margin-top: var(--space-3); }

/* ---- Anmeldeseiten: dunkler Hero + Formular ---------------- */
.auth { flex: 1; display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 100vh; }
.auth-hero {
  background: var(--ink-800) url("ds/images/hero-dark.4fe807ea6fa3.jpg") center / cover no-repeat;
  color: var(--white); padding: var(--space-9) var(--space-9) var(--space-7);
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-7);
}
.auth-hero img { height: 40px; width: auto; align-self: flex-start; }
.auth-hero .eyebrow { font-size: var(--text-sm); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-overline); text-transform: uppercase; color: var(--brand-bright); margin-bottom: var(--space-4); }
.auth-hero h1 { color: var(--white); font-size: var(--text-h1); line-height: var(--lh-h1); font-weight: var(--fw-bold); max-width: 15ch; }
.auth-hero p { color: var(--text-inverse-muted); font-size: var(--text-body-lg); line-height: var(--lh-body-lg); max-width: 44ch; margin-top: var(--space-4); }
.auth-hero .steps li { color: var(--text-inverse-muted); }
.auth-hero .steps li strong { color: var(--white); }
.auth-hero .steps li::before { color: var(--brand-bright); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: var(--space-7) var(--space-5); background: var(--surface-card); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: var(--text-h2); line-height: var(--lh-h2); margin-bottom: var(--space-2); }
.auth-form .sub { color: var(--text-muted); margin-bottom: var(--space-6); }
.auth-alt { margin-top: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--text-muted); }

/* ---- Signierseite: PDF-Vorschau mit Stempel ---------------- */
#pages { display: flex; flex-direction: column; gap: var(--space-4); background: var(--gray-75); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4); }
.page-canvas { position: relative; margin: 0 auto; background: var(--white); box-shadow: var(--shadow-md); }
.page-canvas canvas { display: block; width: 100%; height: 100%; }
.stamp {
  position: absolute; border: 2px dashed var(--brand); border-radius: var(--radius-sm); cursor: grab; touch-action: none;
  user-select: none; font-size: 12px; padding: 4px 8px; line-height: 1.3; overflow: hidden;
  background: rgba(255, 241, 241, 0.92); color: var(--red-700); box-shadow: var(--shadow-sm);
}
.stamp strong { color: var(--brand); }
.stamp.dragging { cursor: grabbing; opacity: 0.85; box-shadow: var(--shadow-lg); }

/* ---- Responsiv --------------------------------------------- */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: var(--space-6) var(--space-5); min-height: auto; }
  .auth-hero .hero-extra { display: none; }
  .page-head h1 { font-size: var(--text-h2); }
}
@media (max-width: 640px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding-top: var(--space-3); padding-bottom: var(--space-3); gap: var(--space-2); }
  .brand-product { display: none; }
  .nav { margin-left: 0; width: 100%; overflow-x: auto; }
  .stepper li { font-size: 0; gap: 0; }
  .stepper li::before { font-size: var(--text-xs); }
  .card { padding: var(--space-5); }
  .page { padding-top: var(--space-5); }
}

/* QR-Code der Authenticator-Einrichtung */
.qr { width: 220px; max-width: 100%; margin: var(--space-3) 0; padding: var(--space-3); background: var(--white); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.qr svg { display: block; width: 100%; height: auto; }

/* Reiter (z. B. Aktiv / Archiv) */
.tabs { display: inline-flex; gap: var(--space-1); padding: 3px; background: var(--surface-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.tabs a { padding: 6px 14px; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--text-secondary); text-decoration: none !important; }
.tabs a:hover { color: var(--text-strong); }
.tabs a.active { background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-xs); }

/* ---- Dateien: Liste, Dropzone, Fortschritt ------------------ */
input[type=date] { padding: 10px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md); font: inherit; background: var(--surface-card); color: var(--text-strong); }
.filelist, .uploads { list-style: none; margin: 0; padding: 0; }
.filelist li { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); }
.filelist li:last-child { border-bottom: 0; }
.filelist-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.filelist-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; text-align: right; }
.filelist-side details.help { margin: 0; max-width: 260px; text-align: left; }
.sha { font-size: 11px; overflow-wrap: anywhere; }
.dropzone { margin-top: var(--space-4); padding: var(--space-6) var(--space-5); border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); text-align: center; background: var(--surface-subtle); transition: border-color .15s, background .15s; }
.dropzone p { margin: 0 0 var(--space-2); }
.dropzone p:last-child { margin: 0; font-size: var(--text-sm); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-wash); }
.dropzone .linklike { color: var(--text-brand); font-weight: var(--fw-semibold); font-size: inherit; padding: 0; }
.uploads li { padding: var(--space-3) 0; }
.upload-head { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); margin-bottom: 6px; overflow-wrap: anywhere; }
.progress { height: 6px; border-radius: 3px; background: var(--gray-150); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.uploads li.is-error .progress span { background: var(--warning); }
.uploads li.is-error .muted { color: var(--danger); }
.prewrap { white-space: pre-wrap; }
@media (max-width: 640px) { .filelist li { flex-direction: column; } .filelist-side { align-items: flex-start; text-align: left; } }

/* ---- Hilfsklassen (!important wie vorher die style-Attribute; statt style-Attributen, damit die CSP ohne 'unsafe-inline' auskommt) ---- */
.ta-r { text-align: right !important; }
.m-0 { margin: 0 !important; }
.mt-1 { margin-top: 6px !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-n2 { margin-top: -8px !important; }
.mb-5 { margin-bottom: var(--space-5) !important; }
.between { justify-content: space-between !important; }
.items-end { align-items: flex-end !important; }
.items-start { align-items: start !important; }
.w-auto { width: auto !important; }
