/* ============================================================
   Personalfragebogen — online form
   Clean, grouped, responsive form + 1:1 PDF replica styles
   ============================================================ */

:root {
  --ink: #0f0f0f;
  --ink-soft: #3a3a3a;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --line-strong: #c9c9c9;
  --bg: #f4f5f7;
  --card: #ffffff;
  --accent: #fb824b;
  --accent-dark: #e26a34;
  --accent-soft: #fff1e9;
  --blue: #6699cc;
  --ok: #2e7d5b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 15, 15, .04), 0 8px 30px rgba(15, 15, 15, .06);
  --field-h: 44px;
  --maxw: 940px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--ink);
  color: #fff;
}
.topbar .brand { display: flex; align-items: baseline; gap: 10px; }
.topbar .brand b { font-size: 16px; letter-spacing: .2px; }
.topbar .brand span { font-size: 12px; color: #b9b9b9; }
.topbar .accent-dot { color: var(--accent); }

/* ---------- Layout ---------- */
main { padding: clamp(18px, 4vw, 40px) clamp(14px, 4vw, 40px) 80px; }

.wrap { max-width: var(--maxw); margin: 0 auto; }

.intro { max-width: var(--maxw); margin: 0 auto 22px; }
.intro h1 { font-size: clamp(22px, 4vw, 30px); margin: 6px 0 8px; letter-spacing: -.3px; }
.intro p { margin: 0; color: var(--muted); max-width: 62ch; }
.intro .legend-note {
  margin-top: 14px; font-size: 13px; color: var(--ink-soft);
  display: flex; flex-wrap: wrap; gap: 8px 18px;
}
.intro .legend-note b { color: var(--accent-dark); }

/* ---------- Progress / section nav (auto on desktop) ---------- */
.section-index {
  position: sticky; top: 64px;
  display: none;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
  margin: 0 auto 20px;
  max-width: var(--maxw);
}
.card > .card-head { margin: 0 0 4px; }
.card h2 {
  font-size: clamp(17px, 2.4vw, 20px);
  margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.card h2 .num {
  flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.card .card-sub { margin: 4px 0 18px; color: var(--muted); font-size: 13.5px; }
.card h3 {
  font-size: 15px; margin: 24px 0 12px;
  color: var(--ink-soft); letter-spacing: .2px;
  padding-top: 16px; border-top: 1px dashed var(--line);
}
.card h3:first-of-type { }

.employer-flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--blue);
  background: #eef4fb; border-radius: 999px; padding: 3px 10px;
  margin-left: auto;
}

/* ---------- Grid system (responsive by default) ---------- */
.grid { display: grid; gap: 14px 16px; }
/* vertical rhythm between stacked field groups inside a card
   (previously provided incidentally by reserved label height) */
.card > .grid,
.card > fieldset.choice,
.card > label.field,
.card > .weekdays,
.card > textarea { margin-top: 16px; }
.grid.two   { grid-template-columns: repeat(2, 1fr); }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four  { grid-template-columns: repeat(4, 1fr); }
.grid.auto  { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-all { grid-column: 1 / -1; }

/* ---------- Fields ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); min-width: 0; }
/* Labels are top-aligned. Row-by-row height matching is done in JS
   (PF.alignRows): only rows that actually contain a two-line label get the
   single-line labels raised to that height — other rows hug their input. */
label.field > .lbl {
  font-weight: 500; line-height: 1.22;
  display: flex; align-items: flex-start; flex-wrap: wrap;
  gap: 0 4px;
}
label.field .req { color: var(--accent-dark); }

input[type="text"], input:not([type]), input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], input[type="password"], select, textarea {
  width: 100%;
  min-width: 0;
  height: var(--field-h);
  padding: 0 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(251, 130, 75, .18);
}
input::placeholder { color: #b3b3b3; }

/* ---------- Choice groups (radio / checkbox as pills) ---------- */
fieldset.choice {
  border: 0; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
fieldset.choice > legend {
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  padding: 0; margin-bottom: 6px; /* == label.field gap, so options align with inputs */
  line-height: 1.22;
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: 0 4px;
}
/* choice group with no visible legend text keeps no reserved gap */
fieldset.choice > legend:empty { margin-bottom: 0; }
fieldset.choice > legend .sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.options.stack { flex-direction: column; }

.opt {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--ink-soft);
  cursor: pointer;
  background: #fff;
  transition: border-color .12s, background .12s;
  min-height: 44px;
  user-select: none;
}
.options.stack .opt { width: 100%; }
.opt { min-width: 0; }
.opt .txt { min-width: 0; overflow-wrap: anywhere; }
.opt:hover { border-color: var(--accent); }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt .box {
  flex: 0 0 auto;
  width: 18px; height: 18px; border-radius: 5px;
  border: 2px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .12s, background .12s;
}
.opt input[type="radio"] + .box { border-radius: 50%; }
.opt .box::after {
  content: ""; width: 8px; height: 8px; border-radius: 3px;
  background: var(--accent); transform: scale(0); transition: transform .12s;
}
.opt input[type="radio"] + .box::after { border-radius: 50%; }
.opt input:checked + .box { border-color: var(--accent); }
.opt input:checked + .box::after { transform: scale(1); }
.opt input:checked ~ .txt { color: var(--ink); font-weight: 500; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt:focus-within { box-shadow: 0 0 0 3px rgba(251, 130, 75, .18); }
.opt .txt { min-width: 0; }

/* inline amount attached to a choice (e.g. Grad, Entgelt) */
.inline-amount { display: flex; align-items: center; gap: 8px; }
.inline-amount label.field { flex: 1; }

/* week days row */
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.weekdays label.field { text-align: center; }
.weekdays input { text-align: center; padding: 0 4px; }

/* children rows */
.child-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 150px;
  gap: 12px; align-items: end;
}
.child-row .idx {
  height: var(--field-h); display: flex; align-items: center;
  font-weight: 700; color: var(--muted);
}

/* ---------- Signature ---------- */
.sig {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fcfcfc;
  padding: 12px;
  margin-top: 6px;
}
.sig-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sig-head b { font-size: 13px; }
.sig canvas {
  display: block; width: 100%; height: 160px;
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  touch-action: none; cursor: crosshair;
}
.sig-hint { margin: 6px 2px 0; font-size: 12px; color: var(--muted); }
.btn-ghost {
  border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink-soft); font: inherit; font-size: 13px;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-dark); }

.declaration {
  background: #fafafa; border-left: 3px solid var(--accent);
  padding: 14px 16px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-soft); margin: 0 0 20px;
}

/* ---------- Submit / actions bar ---------- */
.actionbar {
  position: sticky; bottom: 0; z-index: 15;
  max-width: var(--maxw); margin: 26px auto 0;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.btn {
  font: inherit; font-weight: 600; font-size: 15px;
  border: 0; border-radius: 10px; cursor: pointer;
  padding: 13px 22px; min-height: 48px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.btn.secondary:hover { border-color: var(--accent); }
.btn.danger { background: #fff; color: #c0392b; border: 1px solid #e2b3ac; }
.btn.danger:hover { background: #fdf1ef; border-color: #c0392b; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.status { margin: 0; font-size: 13.5px; color: var(--muted); }
.status.ok { color: var(--ok); font-weight: 600; }
.status.err { color: #c0392b; font-weight: 600; }

/* ---------- Responsive breakpoints ---------- */
@media (max-width: 860px) {
  .grid.four { grid-template-columns: repeat(2, 1fr); }
  .grid.three { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  :root { --field-h: 46px; }
  .grid.two, .grid.three, .grid.four, .grid.auto { grid-template-columns: 1fr; }
  .col-span-2, .col-span-all { grid-column: auto; }
  .weekdays { grid-template-columns: repeat(4, 1fr); }
  .child-row { grid-template-columns: 1fr; gap: 8px; }
  .child-row .idx { height: auto; margin-top: 4px; }
  .actionbar { flex-direction: column; align-items: stretch; }
  .actionbar .btn { width: 100%; }
  .topbar .brand span { display: none; }
}

/* ============================================================
   PDF REPLICA (1:1 of the original Personalfragebogen)
   Rendered off-screen, captured by html2pdf.
   ============================================================ */
#pdfRoot { position: fixed; left: -10000px; top: 0; }
.pdf-page {
  width: 794px;              /* ~A4 @96dpi */
  min-height: 1050px;
  max-height: 1123px;
  padding: 30px 42px;
  background: #fff;
  color: #000;
  font-family: "Arial", "Helvetica", sans-serif;
  font-size: 11px;
  line-height: 1.22;
  box-sizing: border-box;
  overflow: hidden;
  page-break-after: always;
  break-after: page;
}
.pdf-page:last-child { page-break-after: auto; break-after: auto; }
.pdf-title { text-align: center; font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.pdf-subtitle { text-align: center; font-size: 10.5px; font-weight: 700; border-top:1px solid #000; border-bottom:1px solid #000; padding:3px 0; margin: 0 0 3px; }
.pdf-hint { text-align: right; font-size: 8.5px; margin: 0 0 8px; }
.pdf-h { font-size: 14px; font-weight: 400; margin: 9px 0 3px; }
.pdf-note { font-size: 10px; margin: 6px 0 3px; }
table.pdf-t { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.pdf-t td {
  border: 1px solid #000;
  vertical-align: top;
  padding: 2px 5px;
  height: 22px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
table.pdf-t td .k { font-size: 9px; color: #000; display: block; line-height: 1.15; }
table.pdf-t td .v { font-size: 11px; font-weight: 700; display: block; min-height: 12px; margin-top: 1px; line-height: 1.15; }
.pdf-check { font-family: "DejaVu Sans", Arial, sans-serif; }
.pdf-vlist { margin: 4px 0; }
.pdf-vrow { display: flex; align-items: center; border: 1px solid #000; padding: 3px 7px; margin-top: -1px; font-size: 10.5px; justify-content: space-between; }
.pdf-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.pdf-cols-head { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; font-size: 9.5px; margin-top: 6px; }
.pdf-sign-line { border-top: 1px solid #000; margin-top: 40px; padding-top: 3px; font-size: 10px; }
.pdf-sign-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 26px; }
.pdf-sign-imgs img { max-height: 70px; max-width: 100%; display: block; }
.pdf-footer { margin-top: 20px; font-size: 9px; display: flex; justify-content: space-between; }
.pdf-kinder-row { display: grid; grid-template-columns: 20px 1fr 1fr 130px; gap: 16px; margin: 12px 0; }
.pdf-kinder-row .ln { border-bottom: 1px solid #000; min-height: 16px; font-weight: 700; padding: 0 2px 2px; }
.pdf-kinder-row .cap { font-size: 9px; }

/* ============================================================
   ADMIN PANEL + LOGIN
   ============================================================ */
.logout-btn {
  font: inherit; font-size: 13px; font-weight: 500;
  color: #fff; background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.30);
  border-radius: 8px; padding: 8px 16px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.logout-btn:hover { background: rgba(255,255,255,.20); border-color: rgba(255,255,255,.55); }

.login-view {
  min-height: calc(100vh - 120px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 40px 20px;
}
.login-card {
  position: relative;
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(15,15,15,.04), 0 18px 50px rgba(15,15,15,.10);
  padding: 40px 34px 34px;
  text-align: center;
  overflow: hidden;
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
}
.login-badge {
  width: 60px; height: 60px; margin: 6px auto 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 16px;
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.2px; }
.login-card p { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.login-field { text-align: left; margin-bottom: 6px; }
.login-field input { height: 50px; font-size: 16px; letter-spacing: .06em; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 38px; height: 38px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: color .12s, background .12s;
}
.pw-toggle:hover { color: var(--accent-dark); background: var(--accent-soft); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-submit { width: 100%; height: 50px; margin-top: 16px; font-size: 15.5px; }
.login-card .status.err { min-height: 18px; margin: 10px 0 0; text-align: left; }
.login-card .status.err:empty { margin: 0; min-height: 0; }
.login-foot { color: var(--muted); font-size: 12px; margin: 0; }

.admin-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; max-width: 1240px; margin: 0 auto; align-items: start; }
.list-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; position: sticky; top: 84px; }
.list-card h2 { font-size: 15px; margin: 4px 6px 12px; }
.sub-item { width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: border-color .12s; }
.sub-item:hover { border-color: var(--accent); }
.sub-item.active { border-color: var(--accent); background: var(--accent-soft); }
.sub-item b { font-size: 14px; }
.sub-item .meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.badge.new { background: #eef4fb; color: var(--blue); }
.badge.in_progress { background: #fff4e6; color: var(--accent-dark); }
.badge.completed { background: #e7f5ee; color: var(--ok); }
.badge.flagged { background: #fdecea; color: #c0392b; }

/* list tabs: open requests vs. entries marked for deletion */
.list-tabs { display: flex; gap: 6px; margin: 0 0 12px; }
.list-tab {
  flex: 1; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 10px; cursor: pointer; transition: border-color .12s, color .12s;
}
.list-tab:hover { border-color: var(--accent); }
.list-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.flag-note {
  margin: 0 0 14px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: #fdecea; border: 1px solid #f3c9c3; color: #8f2c1f;
  font-size: 13px; font-weight: 500;
}
.action-spacer { flex: 1 1 auto; }
.empty { color: var(--muted); font-size: 13px; padding: 16px 6px; }

.detail-empty { background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 60px 24px; text-align: center; color: var(--muted); }
.summary-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(18px,3vw,26px); margin-bottom: 20px; }
.summary-card h2 { font-size: 17px; margin: 0 0 4px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 10px 18px; margin-top: 14px; }
.summary-grid .kv { font-size: 13px; min-width: 0; }
.summary-grid .kv .k { color: var(--muted); font-size: 11.5px; display: block; }
.summary-grid .kv .v { font-weight: 600; word-break: break-word; }
.summary-sig img { max-height: 60px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 4px; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .list-card { position: static; }
}
