:root{
  --bg:#f6f8fb;
  --card:#ffffff;
  --text:#13233a;
  --muted:#667085;
  --line:#e6eaf0;
  --accent:#1f6feb;
  --danger:#d92d20;
  --ok:#067647;
}

*{
  box-sizing:border-box;
}

.no-margin{
  margin:0;
}

[hidden]{
  display:none !important;
}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Helvetica Neue", Helvetica;
  background:var(--bg);
  color:var(--text);
}

.wrap{
  max-width: 1060px;
  margin: 18px auto 48px auto;
  padding: 0 16px;
}

.grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(16,24,40,0.06);
  padding: 16px 16px;
}

h1{
  font-size: 20px;
  margin: 0 0 10px 0;
}

h2{
  font-size: 16px;
  margin: 0 0 10px 0;
}

.muted{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.section-title{
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:flex-start;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.section-title-text{
  flex:1;
  min-width:0;
}

.header-logo{
  display:none;
  max-width: 200px;
  max-height: 70px;
  width:auto;
  height:auto;
  object-fit:contain;
}

.header-logo.is-visible{
  display:block;
}

.badge{
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background:#fbfcfe;
}

.row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 680px){
  .row{ grid-template-columns: 1fr; }
}

label{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.required-star{
  color: var(--danger);
  font-weight: 700;
  margin-left: 4px;
}

input, select, textarea{
  width:100%;
  box-sizing:border-box;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus{
  border-color: rgba(31,111,235,0.45);
  box-shadow: 0 0 0 4px rgba(31,111,235,0.12);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"]{
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(217,45,32,0.14);
}

.field-error{
  margin-top:6px;
  color:#991b1b;
  font-size:13px;
  font-weight:700;
  line-height:1.35;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible{
  outline: 3px solid rgba(31,111,235,0.55);
  outline-offset: 3px;
}

button:disabled{
  cursor:not-allowed;
  opacity:0.55;
}

textarea{
  min-height: 92px;
  resize: vertical;
}

.multiselect-hinweis{
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px 0;
}

.multiselect-gruppe{
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.multiselect-option{
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  line-height: 1.2;
}

.multiselect-option:focus-within{
  border-color: rgba(31,111,235,0.45);
  box-shadow: 0 0 0 4px rgba(31,111,235,0.12);
}

.multiselect-option input[type="checkbox"]{
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.multiselect-option span{
  color: var(--text);
}

hr.divider{
  border:0;
  border-top:1px solid var(--line);
  margin:14px 0;
}

/* Checkboxen - getrennt */
.check{
  display:flex;
  gap:10px;
  align-items:flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:#fbfcfe;
  margin-top: 10px;
}

.check.required{
  border-color: rgba(217,45,32,0.25);
  background: rgba(217,45,32,0.03);
}

.check.required .check-badge{
  background: var(--danger);
  color: #fff;
}

.check.optional{
  border-color: rgba(3,152,85,0.2);
  background: rgba(3,152,85,0.03);
}

.check.optional .check-badge{
  background: var(--ok);
  color: #fff;
}

.check input[type="checkbox"]{
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}

.check-content{
  flex: 1;
}

.check-header{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.check strong{
  display:block;
  margin-bottom: 2px;
}

.check-badge{
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
}

.hint{
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
  font-style: italic;
}

.small{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.pill{
  display:inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-right: 6px;
  margin-bottom: 4px;
  color: var(--muted);
  background:#fff;
}

.actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button{
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

.btn-primary{
  background: var(--accent);
  color:#fff;
}

.btn-primary:hover{
  background: #1859c4;
}

.btn-send{
  flex:1 1 290px;
  min-height:48px;
}

.btn-ghost{
  background:#fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-ghost:hover{
  background: #f8f9fa;
}

.status{
  margin-top: 10px;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:#fff;
}

.status:focus{
  outline: 3px solid rgba(31,111,235,0.55);
  outline-offset: 3px;
}

.status.ok{ border-color: rgba(3,152,85,0.25); background: rgba(3,152,85,0.06); color: #065f46; }
.status.bad{ border-color: rgba(217,45,32,0.25); background: rgba(217,45,32,0.06); color: #991b1b; }

.page-footer{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  display: none;
}

.page-footer.is-visible{
  display:block;
}

.page-footer a{
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.page-footer a:hover,
.page-footer a:focus{
  text-decoration: underline;
}

/* Signatur-Bereich */
.signature-section{
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: 14px;
  padding: 16px;
  margin-top: 14px;
}

.signature-heading{
  color: #166534;
  font-size:16px;
  font-weight:700;
  padding:0 4px;
}

.signature-help{
  margin-bottom:12px;
}

.signature-canvas-wrap{
  background: #fff;
  border: 2px dashed #86efac;
  border-radius: 12px;
  padding: 8px;
  margin: 12px 0;
}

#signatureCanvas{
  width: 100%;
  height: 150px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.signature-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn-small{
  width:auto;
  padding:7px 10px;
  font-size:12px;
}

.signature-alternative{
  border-top:1px solid rgba(22,101,52,0.2);
  margin-top:14px;
  padding-top:14px;
}

.signature-alternative label{
  color:#166534;
  font-weight:700;
}

.signature-alternative .small{
  margin-top:6px;
}

.privacy-note{
  margin-top:14px;
  padding:12px 14px;
  border:1px solid #f2c94c;
  border-radius:12px;
  background:#fffbea;
  color:#5f4b00;
  font-size:13px;
  line-height:1.45;
}

.btn-clear{
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.btn-clear:hover{
  background: #fee2e2;
}

/* Desktop Handoff */
.desktop-handoff{
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 2px solid #93c5fd;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  margin-top: 14px;
}

.desktop-handoff h2{
  color: #1e40af;
  margin-bottom: 8px;
}

.qr-placeholder{
  width: 180px;
  height: 180px;
  margin: 16px auto;
  background: #fff;
  border: 2px solid #93c5fd;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.handoff-code{
  font-family: ui-monospace, monospace;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 4px;
  color: #1e40af;
  background: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  border: 2px dashed #93c5fd;
  margin: 12px 0;
  display: inline-block;
}

.handoff-link{
  display: block;
  margin-top: 12px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 700;
}

.handoff-link:hover{
  background: #1859c4;
}

.sms-input-row{
  display: flex;
  gap: 10px;
  margin-top: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.sms-input-row input{
  max-width: 200px;
}

/* Handoff Option Box */
.handoff-option{
  background: #eff6ff;
  border: 2px dashed #93c5fd;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  margin-bottom: 14px;
}

.btn-handoff{
  display: inline-block;
  background: #1f6feb;
  color: #fff;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
}

.btn-handoff:hover{
  background: #1859c4;
}

.handoff-tip{
  margin-top: 10px;
  font-size: 12px;
  color: #475569;
  font-style: italic;
}

/* Signature Status */
.signature-status{
  font-size: 13px;
  font-weight: 600;
  margin-left: auto;
}

.signature-status.missing{
  color: #92400e;
}

.signature-status.signed{
  color: #166534;
}

.health-data-rule{
  margin-top:12px;
  padding:10px 12px;
  border:1px solid #f2c94c;
  border-radius:10px;
  background:#fffbea;
  color:#5f4b00;
  font-size:13px;
  line-height:1.45;
}

.signature-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
}

/* Hide handoff option on mobile */
@media (max-width: 767px), (hover: none), (pointer: coarse){
  .handoff-option{
    display: none;
  }
}

/* Mobile Device Detection Override */
body.is-mobile-device .handoff-option{
  display: none !important;
}

/* Download Button */
.btn-download{
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, #1f6feb 0%, #1859c4 100%);
  color: #fff;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(31, 111, 235, 0.3);
  transition: all 0.2s ease;
}

.btn-download:hover{
  background: linear-gradient(135deg, #1859c4 0%, #1347a3 100%);
  box-shadow: 0 6px 16px rgba(31, 111, 235, 0.4);
  transform: translateY(-1px);
}

/* QR Modal */
.modal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  padding: 16px;
}

.modal.hidden{
  display: none;
}

.modal-content{
  background: #fff;
  border-radius: 16px;
  width: min(520px, 100%);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.3);
  border: 1px solid var(--line);
}

.modal-content:focus{
  outline:none;
}

.modal-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-title{
  margin:0;
  font-size:16px;
}

.modal-body{
  padding: 18px;
}

.modal-close{
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

.modal-close:hover{
  background:#eef2f7;
  border-radius:8px;
}

.modal-instructions{
  margin-bottom:8px;
}

.modal-steps{
  padding-left:18px;
  margin:8px 0;
}

.qr-security-notice{
  margin-top:10px;
}

.qr-code-container{
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f8fafc;
  margin: 12px 0;
  overflow:auto;
}

.qr-code-container canvas,
.qr-code-container img,
.qr-code-container svg{
  display:block;
  max-width:100%;
  height:auto;
}

.qr-url-row{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.qr-url-row input{
  flex: 1;
  min-width: 0;
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    scroll-behavior:auto !important;
    transition:none !important;
    animation:none !important;
  }
}
