@font-face {
  font-family: "Open Sans"; font-weight: 400; font-display: swap;
  src: url("../fonts/OpenSans-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Open Sans"; font-weight: 700; font-display: swap;
  src: url("../fonts/OpenSans-Bold.ttf") format("truetype");
}

:root {
  --brand: #8b0d17;       /* pro familia Dunkelrot */
  --accent: #e94900;      /* pro familia Orange */
  --accent-dark: #c83f00;
  --ink: #222326;
  --muted: #6b6d72;
  --line: #e7e5e3;
  --bg: #f5f4f2;
  --card: #ffffff;
  --ok-bg: #e6f4ec; --ok-fg: #15603f;
  --warn-bg: #fbecd2; --warn-fg: #8a5b15;
  --err-bg: #fae3e3; --err-fg: #8a1f1f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5;
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ---- Header ---- */
header {
  background: var(--card); padding: .55rem 1.4rem;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; }
.brand .logo { height: 36px; width: auto; display: block; }
.brand-sub { color: var(--brand); font-weight: 600; font-size: 1rem; }
header nav { display: flex; align-items: center; flex: 1; margin-left: 1.6rem; gap: .2rem;
  justify-content: flex-end; }
header nav a {
  color: var(--ink); text-decoration: none; padding: .35rem .2rem; margin-left: .8rem;
  font-size: .95rem; border-bottom: 2px solid transparent;
}
header nav a:hover { color: var(--accent); }
header nav a.active { color: var(--brand); border-bottom-color: var(--accent); font-weight: 600; }
header nav .user {
  margin-left: 1rem; color: var(--muted); font-size: .9rem;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
header nav a.logout { display: inline-flex; align-items: center; margin-left: .8rem; color: var(--brand); }
header nav a.logout:hover { color: var(--accent); }
header nav a.logout svg { display: block; }

/* ---- Layout ---- */
main { width: 100%; max-width: 1000px; margin: 1.6rem auto; padding: 0 1rem; flex: 1; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.7rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.2rem; }
.card.narrow { max-width: 380px; margin: 3.5rem auto; }

h1 { margin: 0 0 1.1rem; font-size: 1.35rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
h2 {
  font-size: 1.1rem; margin: 0 0 .8rem; padding-left: .6rem;
  border-left: 3px solid var(--accent);
}

/* ---- Forms ---- */
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1.1rem; padding: .9rem 1.1rem; }
legend { font-weight: 600; padding: 0 .4rem; color: var(--brand); }
label { display: block; margin: .65rem 0; font-size: .92rem; }
label.inline { display: block; font-weight: normal; margin: .35rem 0; }
label.inline input { margin-right: .45rem; }
.fieldlabel { font-weight: 600; margin: .6rem 0 .2rem; font-size: .92rem; }
/* Zwischenueberschrift, wenn ein Formular mehrere Dokumente erfasst. */
.section-head { font-size: 1rem; color: var(--brand); margin: 1.4rem 0 .2rem;
  padding-top: .8rem; border-top: 1px solid var(--line); }
.section-head:first-of-type { border-top: none; padding-top: 0; margin-top: .2rem; }
/* Lange Ankreuzlisten (16 Gruende, 15 Hilfen) zweispaltig, damit die Erfassung
   ohne Scrollen ueberblickbar bleibt. */
.opt-cols { columns: 2; column-gap: 1.6rem; margin-bottom: .5rem; }
.opt-cols label.inline { break-inside: avoid; }
@media (max-width: 700px) { .opt-cols { columns: 1; } }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=file], textarea {
  width: 100%; padding: .55rem .6rem; border: 1px solid #c7c5c3; border-radius: 6px;
  font-size: 1rem; background: #fff; transition: border-color .12s, box-shadow .12s;
}
textarea { font-family: inherit; line-height: 1.45; resize: vertical; }
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,73,0,.15);
}
label.inline input[type=checkbox], label.inline input[type=radio] { width: auto; }
small { color: var(--muted); font-weight: normal; }
/* Hilfetext, der einem Feld folgt, gehoert unter das Feld – nicht daneben.
   Ausnahme: in Checkbox-Zeilen (.inline) bleibt er in derselben Zeile. */
input + small, textarea + small, select + small { display: block; margin-top: .25rem; }
label.inline input + small { display: inline; margin-top: 0; }

/* ---- Buttons ---- */
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: .6rem 1.15rem; font-size: 1rem; cursor: pointer; font-weight: 600;
  transition: background .12s;
}
button:hover { background: var(--accent-dark); }
button.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
button.secondary:hover { background: var(--brand); color: #fff; }
button.danger { background: var(--err-fg); }
button.danger:hover { background: #6e1717; }
a { color: var(--brand); }
a:hover { color: var(--accent); }

/* ---- Flash ---- */
.flash { padding: .65rem .9rem .65rem .85rem; border-radius: 6px; margin-bottom: 1rem;
  border-left: 4px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok-fg); border-left-color: var(--ok-fg); }
.flash.error { background: var(--err-bg); color: var(--err-fg); border-left-color: var(--err-fg); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); border-bottom: 2px solid var(--line);
}
tbody tr:nth-child(even) { background: #faf9f8; }
tbody tr:hover { background: #fdf2ec; }
table.kv th { width: 220px; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .88rem; }
table.kv tr:hover { background: transparent; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: #f3eee9; color: var(--brand); padding: .12rem .4rem; border-radius: 4px;
  font-weight: 600; letter-spacing: .04em; }

/* ---- Resend inline form ---- */
.resend { display: flex; gap: .3rem; }
.resend input { font-size: .82rem; padding: .32rem; flex: 1; min-width: 150px; }
.resend button { padding: .32rem .7rem; font-size: .82rem; white-space: nowrap; }
/* lange Inhalte: IDs/Daten nicht umbrechen, Mails duerfen brechen */
td code { white-space: nowrap; }
td .resend input { width: 100%; }

/* ---- Badges ---- */
.badge { font-size: .78rem; padding: .14rem .55rem; border-radius: 20px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---- Feature lists ---- */
ul.feat { margin: .3rem 0 1rem; padding-left: 1.5rem; }
ul.feat li { margin: .25rem 0; }
ul.feat.done li::marker { content: "✓ "; color: var(--ok-fg); }
ul.feat.todo li::marker { content: "○ "; color: var(--muted); }
.hint { color: var(--muted); font-size: .88rem; }

/* ---- Login ---- */
.login-card { text-align: center; }
.login-card .login-logo { height: 54px; width: auto; margin: .2rem auto 1rem; }
.login-card h1 { border: 0; padding: 0; }
.login-card form { text-align: left; }

.docid-box { background:#f3eee9; border:1px solid var(--line); border-left:4px solid var(--accent);
  border-radius:6px; padding:.55rem .8rem; margin:0 0 1rem; }
.docid-box code { font-size:1.05rem; }

/* ---- Home: Formular-Buttons ---- */
.form-grid { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .6rem; }
.form-btn {
  display: flex; flex-direction: column; justify-content: center; gap: .3rem;
  min-width: 240px; flex: 1 1 240px; padding: 1.1rem 1.2rem; text-decoration: none;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 8px; box-shadow: var(--shadow);
  transition: border-color .12s, transform .08s, box-shadow .12s;
}
.form-btn:hover { color: var(--ink); border-left-color: var(--brand);
  transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 10px 24px rgba(0,0,0,.06); }
.form-btn .ft { font-weight: 600; font-size: 1.02rem; color: var(--brand); }
.form-btn .fs { font-size: .85rem; color: var(--muted); }

/* ---- Ablaufdiagramm (Statusseite) ---- */
.flow { display: flex; flex-direction: column; align-items: center; }
.flow .step {
  width: 100%; max-width: 560px; display: flex; gap: .7rem; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: .6rem .9rem; box-shadow: var(--shadow);
}
.flow .step .num {
  flex: 0 0 auto; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: .82rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: .1rem;
}
.flow .step .t { font-weight: 600; color: var(--brand); }
.flow .step .s { font-size: .85rem; color: var(--muted); }
.flow .conn { color: var(--accent); font-size: 1rem; line-height: 1; padding: .25rem 0; }
.flow .channels { display: flex; gap: .6rem; margin-top: .45rem; flex-wrap: wrap; }
.flow .ch { flex: 1; min-width: 210px; border: 1px solid var(--line); border-radius: 6px;
  padding: .45rem .6rem; font-size: .85rem; background: #fbfafa; }
.flow .ch .ct { font-weight: 600; }
.flow .ch.mail { border-left: 3px solid var(--accent); }
.flow .ch.sms { border-left: 3px solid var(--warn-fg); }
.flow-note { max-width: 560px; margin: .8rem auto 0; font-size: .85rem; color: var(--muted); text-align: center; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-head h2 { margin-bottom: 0; }
.flow.clickable, .qa.clickable { cursor: zoom-in; }

/* ---- Offene Fragen ---- */
.qa { display: flex; flex-direction: column; gap: .7rem; }
.qa .q {
  display: flex; gap: .8rem; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: .8rem 1rem; box-shadow: var(--shadow);
}
.qa .q .num {
  flex: 0 0 auto; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; margin-top: .1rem;
}
.qa .q .t { font-weight: 600; color: var(--ink); }
.qa .q .s { font-size: .88rem; color: var(--muted); margin-top: .25rem; }
.qa .q.open { border-left-style: dashed; border-left-color: var(--brand); background: #faf7f7; }
.qa .q.open .num { background: var(--accent); }
.qa h2 { margin: 1.2rem 0 .2rem; }

/* ---- Modal / Popup ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1000;
  display: none; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; overflow: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  position: relative; background: var(--bg); border-radius: 12px; padding: 1.6rem 1.6rem 1.2rem;
  max-width: 680px; width: 100%; box-shadow: 0 12px 48px rgba(0,0,0,.35);
}
.modal h2 { margin-top: 0; }
.modal-close {
  position: absolute; top: .5rem; right: .6rem; background: transparent; color: var(--ink);
  border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; padding: .1rem .5rem;
}
.modal-close:hover { color: var(--accent); }
.modal .flow .step { max-width: 600px; }

/* ---- Signatur-Vorschau ---- */
.signature-preview {
  max-width: 320px; max-height: 110px; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px; background:
    repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 16px 16px;  /* Schachbrett zeigt Transparenz */
}

/* ---- Erfolgsseite (case_done) ---- */
.pw-box {
  display: flex; align-items: center; gap: .8rem;
  background: #f3eee9; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 6px; padding: .7rem 1rem; margin: .5rem 0 1.4rem;
}
.pw-box code { font-size: 1.1rem; flex: 1; word-break: break-all; }

.meta-table { border-collapse: collapse; margin: .5rem 0 1.2rem; }
.meta-table th { text-align: left; color: var(--muted); font-weight: 600;
  padding: .2rem 1.2rem .2rem 0; white-space: nowrap; }
.meta-table td code { font-size: 1rem; }

/* ---- Sprachauswahl (Infopaket-Detail) ---- */
.lang-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 .9rem; }
.lang-tab {
  display: inline-block; padding: .3rem .85rem; border-radius: 20px; text-decoration: none;
  background: #fff; color: var(--ink); border: 1px solid var(--line); font-size: .88rem;
}
.lang-tab:hover { border-color: var(--accent); color: var(--ink); }
.lang-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.lang-add { display: flex; align-items: flex-end; gap: .6rem; margin-bottom: 1.1rem; }
.lang-add label.inline { margin: 0; }
.lang-add button { align-self: flex-end; }

/* ---- Vertikale Tabs (Konfigurationsbereich) ---- */
.tabs-layout { display: flex; align-items: flex-start; gap: 1.2rem; }
.tabs-nav {
  flex: 0 0 190px; display: flex; flex-direction: column; gap: .2rem;
  position: sticky; top: 1rem;
}
.tabs-nav a {
  display: block; padding: .55rem .8rem; border-radius: 8px; text-decoration: none;
  color: var(--ink); font-size: .92rem; border-left: 3px solid transparent;
}
.tabs-nav a:hover { background: #fdf2ec; color: var(--ink); }
.tabs-nav a.active {
  background: var(--card); color: var(--brand); font-weight: 600;
  border-left-color: var(--accent); box-shadow: var(--shadow);
}
.tabs-content { flex: 1 1 auto; min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
@media (max-width: 640px) {
  .tabs-layout { flex-direction: column; }
  .tabs-nav { flex-direction: row; flex-wrap: wrap; position: static; width: 100%; }
  .tabs-nav a { flex: 1 1 auto; text-align: center; }
}

/* ---- Footer ---- */
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.4rem 1rem 1.8rem; }
