/* ==========================================================================
   Formular-Renderer (App, öffentliche Formulare, Vorschau, Bearbeitung)
   ========================================================================== */
.sform { --gap: 16px; container-type: inline-size; display: flex; flex-direction: column; gap: var(--gap); }
.sform-page-head { margin-bottom: 2px; }
.sform-page-head h2 { font-size: 19px; margin: 0 0 4px; }
.sform-page-head p { color: var(--muted); margin: 0; white-space: pre-wrap; }
.sform-fields { display: flex; flex-wrap: wrap; gap: var(--gap); }
.sf { width: 100%; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sf.half { width: calc(50% - var(--gap) / 2); }
@container (max-width: 520px) { .sf.half { width: 100%; } }
.sf-label { font-weight: 600; font-size: 14px; color: var(--text); display: flex; gap: 4px; align-items: baseline; }
.sf-label .req { color: var(--danger); }
.sf-help { color: var(--muted); font-size: 12.5px; margin-top: -2px; white-space: pre-wrap; }
.sf-error { color: var(--danger); font-size: 12.5px; font-weight: 550; }
.sf.invalid input, .sf.invalid textarea, .sf.invalid select, .sf.invalid .choice-group, .sf.invalid .sf-box { border-color: var(--danger) !important; }
.sf input, .sf select, .sf textarea { height: 44px; font-size: 16px; border-radius: 9px; }
.sf textarea { height: auto; min-height: 96px; padding-top: 10px; }
.sf .unit-wrap { display: flex; align-items: stretch; }
.sf .unit-wrap input { border-radius: 9px 0 0 9px; }
.sf .unit-wrap .unit { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--muted); }
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-group.vertical { flex-direction: column; }
.choice { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 15px; user-select: none; -webkit-tap-highlight-color: transparent; transition: border-color .1s, background .1s; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .mark { width: 20px; height: 20px; border: 2px solid var(--border-strong); border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.choice.multi .mark { border-radius: 6px; }
.choice.selected { border-color: var(--choice-color, var(--brand)); background: color-mix(in srgb, var(--choice-color, var(--brand)) 9%, var(--surface)); }
.choice.selected .mark { border-color: var(--choice-color, var(--brand)); background: var(--choice-color, var(--brand)); }
.choice.selected .mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.choice.multi.selected .mark::after { width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; border-radius: 0; background: none; transform: rotate(-45deg) translate(1px, -1px); }
.choice-group.vertical .choice { width: 100%; }
.choice.readonly { cursor: default; }
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 360px; }
.yesno .choice { justify-content: center; font-weight: 600; }
.yesno .choice .mark { display: none; }
.check-item { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.check-item .choice-group .choice { flex: 1 1 0; justify-content: center; min-width: 70px; font-weight: 600; }
.check-item .choice .mark { display: none; }
.check-item.failed { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 4%, var(--surface)); }
.rating { display: flex; gap: 4px; }
.rating button { border: 0; background: none; padding: 2px; cursor: pointer; color: var(--border-strong); -webkit-tap-highlight-color: transparent; }
.rating button .icon { width: 34px; height: 34px; stroke-width: 1.5; }
.rating button.on { color: #f5a524; }
.rating button.on .icon { fill: #f5a524; }
.slider-wrap { display: flex; align-items: center; gap: 14px; }
.slider-wrap output { min-width: 64px; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.sf-box { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 12px; background: var(--surface); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.media-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.media-tile .rm { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 60%); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.media-tile .rm .icon { width: 14px; height: 14px; }
.media-tile.file { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; text-align: center; font-size: 11px; color: var(--muted); }
.media-tile.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.media-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.media-actions .btn { height: 42px; }
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 14px; }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig-preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sig-preview img { max-height: 90px; max-width: 260px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.sig-pad-wrap { position: relative; background: #fff; border: 1.5px solid var(--border-strong); border-radius: 12px; touch-action: none; overflow: hidden; }
.sig-pad-wrap canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; }
.sig-pad-wrap .baseline { position: absolute; left: 24px; right: 24px; bottom: 46px; border-top: 1.5px dashed #c8ced8; pointer-events: none; }
.sig-pad-wrap .hint { position: absolute; left: 24px; bottom: 22px; font-size: 12px; color: #9aa1ad; pointer-events: none; }
.sig-modal .modal-body { padding: 14px; }
@media (max-width: 640px) and (orientation: landscape) { .sig-pad-wrap canvas { height: 58vh; } }
.loc-box { display: flex; flex-direction: column; gap: 8px; }
.loc-box .coords { font-family: var(--mono); font-size: 13.5px; }
.barcode-video { width: 100%; max-height: 60vh; background: #000; border-radius: 10px; }
.cust-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--border-strong); border-radius: 12px; background: var(--surface); }
.cust-card .info { flex: 1; min-width: 0; }
.cust-card .name { font-weight: 650; font-size: 15px; }
.cust-card .addr { color: var(--muted); font-size: 13.5px; }
.cust-picker-list { display: flex; flex-direction: column; max-height: 55vh; overflow-y: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; }
.cust-picker-list button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: inherit; }
.cust-picker-list button:last-child { border-bottom: 0; }
.cust-picker-list button:hover, .cust-picker-list button:focus { background: var(--brand-softer); outline: none; }
.cust-picker-list .n { font-weight: 600; }
.cust-picker-list .a { color: var(--muted); font-size: 12.5px; }
.formula-out { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 650; font-variant-numeric: tabular-nums; font-size: 16px; }
.formula-out.err { color: var(--danger); font-weight: 500; font-size: 13px; }
.sf-heading { font-size: 17px; font-weight: 700; margin: 8px 0 -4px; color: var(--text); }
.sf-info { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--info-soft); font-size: 14px; white-space: pre-wrap; }
.sf-info .icon { color: var(--info); margin-top: 1px; }
.sf-info.warning { background: var(--warning-soft); } .sf-info.warning .icon { color: var(--warning); }
.sf-info.success { background: var(--success-soft); } .sf-info.success .icon { color: var(--success); }
.sf-info.danger { background: var(--danger-soft); } .sf-info.danger .icon { color: var(--danger); }
.sf-info strong { display: block; margin-bottom: 2px; }
.sf-divider { border-top: 1px solid var(--border); margin: 6px 0; }
.sf-image img { border-radius: 10px; max-height: 360px; }
.repeat-list { display: flex; flex-direction: column; gap: 10px; }
.repeat-row { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.repeat-row-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13.5px; }
.repeat-row-head .summary { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.repeat-row-body { padding: 14px; }
.repeat-row.collapsed .repeat-row-body { display: none; }
.repeat-add { border: 1.5px dashed var(--border-strong); background: transparent; height: 46px; border-radius: 12px; color: var(--brand-text); font: 600 14px var(--font); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.repeat-add:hover { background: var(--brand-softer); border-color: var(--brand); }
.sform-progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.sform-progress span { display: block; height: 100%; background: var(--brand); transition: width .25s; }
.sform-nav { display: flex; gap: 10px; }
.sform-nav .btn { flex: 1; height: 48px; font-size: 15px; border-radius: 11px; }
.sform-summary-errors { padding: 12px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; }
.sform-summary-errors ul { margin: 6px 0 0; padding-left: 18px; }
.sform-summary-errors a { color: inherit; text-decoration: underline; cursor: pointer; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.sform.readonly .choice { cursor: default; }
.sform.compact { --gap: 12px; }
.sform.compact .sf input, .sform.compact .sf select { height: 38px; font-size: 14px; }
.sform.compact .choice { min-height: 36px; padding: 6px 12px; font-size: 14px; }
