:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7683;
  --line: #e3e8ee;
  --brand: #2f6fed;
  --brand-dark: #2257c4;
  --danger: #d3453b;
  --ok-bg: #e7f6ec; --ok-ink: #1c7a44;
  --err-bg: #fdeceb; --err-ink: #b5322a;
  --mark: #fff2a8;
  --silz-red: #e2001a;
  --silz-red-dark: #b40015;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 24px; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 16px; font-weight: 700; font-size: 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-sep { width: 1px; height: 30px; background: var(--line); display: inline-block; }
.brand-name { letter-spacing: .3px; font-size: 21px; }
.fast { color: var(--silz-red); }
.brand-365 { color: var(--silz-red); }

.login-logo { width: 100%; max-width: 280px; height: auto; margin: 0 auto 6px; display: block; }
.login-title { margin: 0; text-align: center; font-size: 26px; }
.login-sub { text-align: center; margin: 0 0 6px; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.who { color: var(--ink); font-weight: 600; }

main { max-width: 900px; margin: 26px auto; padding: 0 20px 60px; }
main.wide { max-width: 1280px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}

.btn {
  background: var(--silz-red); color: #fff; border: 0; border-radius: 9px;
  padding: 9px 16px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--silz-red-dark); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: 9px; padding: 8px 14px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { border-color: #c8d0da; text-decoration: none; }
.btn-danger {
  background: transparent; color: var(--danger); border: 1px solid #f0c7c3;
  border-radius: 9px; padding: 8px 14px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn-danger:hover { background: var(--err-bg); }
.small { padding: 5px 10px; font-size: 13px; }

.searchbar { display: flex; gap: 10px; margin-bottom: 16px; }
.searchbar input {
  flex: 1; padding: 13px 16px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.searchbar input:focus { outline: 2px solid var(--silz-red); border-color: var(--silz-red); }

.uploadbar { display: flex; flex-direction: column; gap: 12px; }
.uploadrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.uploadrow input[type=file] { flex: 1; }

.dropzone {
  position: relative; border: 2px dashed #c4cfe0; border-radius: 12px;
  background: #fbfcfe; padding: 22px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--brand); }
.dropzone.drag { border-color: var(--brand); background: #eef3fe; }
.dz-inner { display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.dz-inner strong { font-size: 16px; }
.small-hint { font-size: 12px; }
.dropzone input[type=file] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.dz-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#fileList { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress-wrap { margin-top: 6px; }
.progress-bar { height: 8px; background: #e7ecf3; border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--silz-red); transition: width .2s; }
#progressText { margin-top: 6px; font-size: 13px; }

.results-h { font-size: 15px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 22px 0 10px; }
.muted { color: var(--muted); }
.empty { padding: 20px 0; }

.doclist, .versionlist { list-style: none; padding: 0; margin: 0; }
.doc, .version { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.doc-main, .version-main { min-width: 0; flex: 1; }

.thumb-link { flex-shrink: 0; display: block; }
.thumb {
  width: 120px; height: 156px; object-fit: cover; object-position: top center;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  display: block; box-shadow: 0 1px 3px rgba(20,30,50,.10);
}
.thumb-link:hover .thumb { border-color: var(--brand); }
.doc-name { font-size: 16px; font-weight: 600; color: var(--ink); }
.doc-name:hover { color: var(--silz-red); }
.doc-meta { font-size: 13px; margin-top: 4px; }
.doc-actions { display: flex; gap: 8px; flex-shrink: 0; }

.badge {
  display: inline-block; background: #eef2fb; color: var(--brand-dark);
  border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; margin-left: 6px;
}
.badge.dl { background: var(--ok-bg); color: var(--ok-ink); }
.current-badge { background: var(--ok-bg); color: var(--ok-ink); }
.vno { font-weight: 700; }
.pill { display: inline-block; background: #f0f3f7; border-radius: 6px;
  padding: 1px 8px; font-size: 12px; margin: 2px 4px 0 0; }

.snippet { margin: 6px 0; color: var(--ink); font-size: 14px; }
mark { background: var(--mark); padding: 0 2px; border-radius: 3px; }

.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.error { background: var(--err-bg); color: var(--err-ink); }
.flash.warn { background: #fff5e0; color: #8a5a00; border: 1px solid #f2d894; }
.ocr-banner { font-weight: 400; line-height: 1.5; }
.ocr-banner code { background: #f6ecd0; padding: 1px 5px; border-radius: 4px; }

.login-wrap { display: flex; justify-content: center; margin-top: 8vh; }
.login { width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; }
.login label, .formgrid label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.login input, .formgrid input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; font-weight: 400;
}
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.formgrid .check { flex-direction: row; align-items: center; gap: 8px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.dochead { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dochead h1 { margin: 8px 0; }
.back { font-weight: 600; }
.version.current { border-color: #bcd0f5; }

/* Zweispaltiges Layout der Dokumentseite: links Details, rechts große Vorschau */
.doc-layout { display: flex; gap: 24px; align-items: flex-start; }
.doc-col-left { flex: 1 1 460px; min-width: 0; }
.doc-col-right { flex: 1 1 420px; min-width: 0; }

.preview-panel {
  position: sticky; top: 84px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: 0 1px 3px rgba(20,30,50,.06);
}
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.preview-frame {
  width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.preview-imgwrap {
  border: 1px solid var(--line); border-radius: 8px; background: #fafbfc;
  max-height: 78vh; overflow: auto; text-align: center;
}
.preview-img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.preview-text {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #fff;
  white-space: pre-wrap; word-wrap: break-word; max-height: 78vh; overflow: auto;
  font: 13px/1.6 "SF Mono", Menlo, Consolas, monospace;
}
.preview-empty { padding: 40px 16px; text-align: center; line-height: 1.6; }
.preview-hint { font-size: 12px; margin-top: 6px; text-align: center; }

/* Info-Formular (Notizen + Felder) auf der Dokumentseite */
.info-card { margin-bottom: 16px; }
.field-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px;
  font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.field-label textarea, .field-label input {
  font-weight: 400; color: var(--ink); font-size: 15px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit;
}
.field-label textarea { resize: vertical; }
.field-label textarea:focus, .field-label input:focus {
  outline: 2px solid var(--silz-red); border-color: var(--silz-red);
}
.fields-table input { width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; font-size: 14px; }
.fields-table .order-cell { white-space: nowrap; width: 1%; }
.fields-table td { vertical-align: middle; }

.formgrid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 14px; }
.check-inline { flex-direction: row; align-items: center; gap: 8px; }
@media (max-width: 600px) { .formgrid2 { grid-template-columns: 1fr; } }

@media (max-width: 820px) {
  .doc-layout { flex-direction: column; }
  .preview-panel { position: static; width: 100%; }
  .preview-frame { height: 60vh; }
}

.textpreview {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; white-space: pre-wrap; word-wrap: break-word; max-height: 70vh; overflow: auto;
  font: 14px/1.6 "SF Mono", Menlo, Consolas, monospace;
}
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }

@media (max-width: 600px) {
  .doc, .version { flex-direction: column; }
  .formgrid { grid-template-columns: 1fr; }
}

/* --- Dialog: Dokument senden ------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 28, 40, .48);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 22px 24px; width: 100%; max-width: 460px;
  box-shadow: 0 18px 50px rgba(20, 28, 40, .28);
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px;
}

/* --- Test-Mail-Zeile in den E-Mail-Einstellungen ----------------------- */
.testmail-row {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
}

/* --- Administrator-Aufklappmenü in der Kopfzeile ----------------------- */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; color: var(--muted);
  font-weight: 500; user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; font-size: 11px; }
.menu > summary:hover { color: var(--ink); }
.menu[open] > summary { color: var(--ink); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 900;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 34px rgba(20, 28, 40, .18);
  padding: 6px; min-width: 172px; display: flex; flex-direction: column;
}
.menu-panel a {
  padding: 9px 12px; border-radius: 7px; color: var(--ink); font-weight: 500;
  white-space: nowrap;
}
.menu-panel a:hover { background: var(--bg); text-decoration: none; }

/* --- Benutzerverwaltung (Karten) --------------------------------------- */
.user-card { display: flex; flex-direction: column; gap: 12px; }
.user-head { display: flex; align-items: center; gap: 10px; }
.user-edit { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.user-edit .field-label { flex: 1; min-width: 160px; margin: 0; }
.user-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  border-top: 1px solid var(--line); padding-top: 12px; }
.user-inline { display: flex; gap: 10px; flex: 1; align-items: flex-end; }

/* --- Sicherheitsschlüssel-Liste ---------------------------------------- */
.keylist { list-style: none; padding: 0; margin: 10px 0; display: flex;
  flex-direction: column; gap: 8px; }
.keyrow { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
