*, *::before, *::after { box-sizing: border-box; }

/* ── Topbar (Zurück + Formular-Titel) ── */
.auftrag-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: #D92B1A;
    color: #fff;
}
.auftrag-topbar__back {
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
    transition: opacity 0.15s;
}
.auftrag-topbar__back:hover { opacity: 1; text-decoration: underline; }
.auftrag-topbar__title {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.85;
}

.btn-test-data {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding: 8px 16px;
    background: #fef3c7;
    color: #92400e;
    border: 1.5px dashed #f59e0b;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-test-data:hover { background: #fde68a; }

.btn-form-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 7px 14px;
    background: #fff7ed;
    color: #9a3412;
    border: 1.5px solid #fb923c;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-form-reset:hover { background: #ffedd5; border-color: #ea580c; }

body {
    margin: 0;
    background: #f3f4f6;
    color: #111827;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}


/* ── Page Container ── */
.auftrag-form-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 5rem;
}

.auftrag-form-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 1.75rem;
}

/* ── Progress Indicator ── */
.form-progress-indicator {
    display: flex;
    gap: 4px;
    margin-bottom: 2rem;
}

.progress-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: #e5e7eb;
    border-radius: 6px;
    transition: background 0.2s;
}

.progress-step-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-step-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: #6b7280;
    text-align: center;
    line-height: 1.2;
}

.progress-step.active { background: #1d4ed8; }
.progress-step.active .progress-step-number { background: rgba(255,255,255,0.25); color: #fff; }
.progress-step.active .progress-step-label  { color: #fff; }

.progress-step.completed { background: #16a34a; }
.progress-step.completed .progress-step-number { background: rgba(255,255,255,0.25); color: #fff; }
.progress-step.completed .progress-step-label  { color: #fff; }

/* ── Form Card ── */
.form-step {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 1.75rem;
}

/* ── Step Header ── */
.step-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

/* ── Sections ── */
.form-section {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0 1.125rem 1.125rem;
    margin-bottom: 1.25rem;
    background: #fafafa;
}

.form-section-legend {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #111827;
    margin: 0 -1.125rem 0.875rem;
    padding: 0.875rem 1.125rem 0.5rem;
    border-bottom: 1px solid #e9eaec;
}

/* ── Fields ── */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.form-row:last-child { margin-bottom: 0; }

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}

.form-field--narrow { flex: 0 0 80px; min-width: 80px; }
.form-field--hausnr { flex: 0 0 4.5rem; min-width: 4.5rem; max-width: 5.5rem; }
.form-field--grow   { flex: 2; }

.form-field label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
}

.form-field input:not([type="checkbox"]):not([type="radio"]),
.form-field textarea,
.form-field select {
    padding: 0.5rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: #fff;
    color: #111827;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
}

.form-field input:not([type="checkbox"]):not([type="radio"]):focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.form-field input:not([type="checkbox"]):not([type="radio"]).field-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* ── Radio & Checkbox ── */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    padding-top: 0.25rem;
}

.checkbox-group--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: #374151;
    user-select: none;
}

.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    accent-color: #1d4ed8;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.radio-label--large  { font-size: 0.9375rem; }
.radio-label--warning { color: #b91c1c; }

/* ── Checklist table ── */
.checklist-table {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.checklist-header {
    display: grid;
    grid-template-columns: 1fr 60px 60px;
    background: #374151;
    color: #fff;
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.checklist-row {
    display: grid;
    grid-template-columns: 1fr 60px 60px;
    padding: 7px 10px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.8125rem;
    align-items: center;
}

.checklist-row:nth-child(even) { background: #f9fafb; }

.checklist-row label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
}

/* ── Field Validation Errors ── */
.field-error-message {
    display: block;
    font-size: 0.75rem;
    color: #dc2626;
    margin-top: 3px;
    font-weight: 500;
}

input.field-error,
textarea.field-error,
select.field-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.radio-group.field-error,
.form-section.field-error {
    border-color: #dc2626;
}

/* ── AGB ── */
.agb-hinweis-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0 0 0.875rem;
    line-height: 1.55;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.75rem;
}

/* ── Step Navigation ── */
.step-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e5e7eb;
}

.btn-previous, .btn-next, .btn-submit {
    padding: 0.625rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.btn-previous { background: #f3f4f6; color: #374151; }
.btn-previous:hover { background: #e5e7eb; }

.btn-next, .btn-submit { background: #1d4ed8; color: #fff; margin-left: auto; }
.btn-next:hover, .btn-submit:hover { background: #1e40af; }
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Success message ── */
.form-success-message {
    text-align: center;
    padding: 3rem 2rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    margin-top: 2rem;
}

.form-success-message h2 { color: #16a34a; margin: 0 0 0.5rem; }

.success-icon {
    font-size: 2.5rem;
    color: #16a34a;
    background: #dcfce7;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

/* ── PDF Actions Block ── */
.pdf-actions-block {
    margin-top: 1.75rem;
    padding: 1.25rem 1.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-align: left;
}

.pdf-actions-block h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 0.25rem;
}

.pdf-expiry-note {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0 0 1rem;
}

.pdf-btn-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1.25rem;
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-pdf--download { background: #1d4ed8; color: #fff; }
.btn-pdf--download:hover { background: #1e40af; }
.btn-pdf--view     { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-pdf--view:hover { background: #e2e8f0; }

.pdf-email-row { display: flex; flex-direction: column; gap: 0.4rem; }
.pdf-email-row label { font-size: 0.8125rem; font-weight: 600; color: #374151; }

.pdf-email-input-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pdf-email-input-group input[type="email"] {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 0.875rem;
    font-family: inherit;
}

.pdf-email-input-group button {
    padding: 0.5rem 1.25rem;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.pdf-email-input-group button:hover { background: #15803d; }
.pdf-email-input-group button:disabled { opacity: 0.55; cursor: not-allowed; }

.pdf-action-message { font-size: 0.8125rem; font-weight: 500; min-height: 1.2em; }

/* ── Öffentliches Endkunden-Formular ── */
.auftrag-form-container--public {
    --kf-primary: #2563eb;
    --kf-primary-dark: #1d4ed8;
    --kf-primary-soft: #eff6ff;
    --kf-slate: #1e293b;
    --kf-success: #059669;
    max-width: 720px;
    padding-top: 1rem;
}

.kundenformular-hero {
    background: linear-gradient(145deg, #1e293b 0%, #334155 100%);
    color: #fff;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
    border-left: 3px solid var(--kf-primary);
}

.kundenformular-hero__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
}

.kundenformular-hero__brand {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
    color: #93c5fd;
}

.kundenformular-hero__sep {
    margin: 0 0.35rem;
    font-weight: 400;
    color: #64748b;
}

.kundenformular-hero__intro {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #cbd5e1;
}

.form-progress-compact {
    margin-bottom: 1.5rem;
    padding: 1rem 1.125rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.form-progress-compact__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.625rem;
}

.form-progress-text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--kf-primary-dark);
}

.form-progress-label {
    font-size: 0.8125rem;
    color: #64748b;
    text-align: right;
}

.form-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.form-progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--kf-primary) 0%, #3b82f6 100%);
    border-radius: 999px;
    transition: width 0.35s ease;
}

.form-progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 0.75rem;
}

.form-progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.auftrag-form-container--public .form-progress-dots {
    gap: 6px;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

.form-progress-dot.is-active {
    background: var(--kf-primary);
    transform: scale(1.15);
}

.form-progress-dot.is-done {
    background: var(--kf-success);
}

.auftrag-form-container--public .form-step {
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 1.5rem 1.25rem;
    border: 1px solid #e5e7eb;
}

.auftrag-form-container--public .step-header {
    margin-bottom: 1.25rem;
}

.auftrag-form-container--public .step-header h2 {
    margin: 0;
    padding-bottom: 0;
    border-bottom: none;
    font-size: 1.25rem;
    color: var(--kf-slate);
}

.step-subtitle {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0.35rem 0 0;
    font-weight: 400;
    line-height: 1.45;
}

.auftrag-form-container--public .form-section {
    background: #fff;
    border-color: #e5e7eb;
}

.auftrag-form-container--public .form-section-legend {
    color: var(--kf-slate);
}

.auftrag-form-container--public .radio-group {
    flex-direction: column;
    gap: 0.625rem;
    padding-top: 0;
}

.auftrag-form-container--public .radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: #374151;
}

.auftrag-form-container--public .radio-option:hover {
    border-color: #93c5fd;
    background: var(--kf-primary-soft);
}

.auftrag-form-container--public .radio-option:has(input:checked) {
    border-color: var(--kf-primary);
    background: var(--kf-primary-soft);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.auftrag-form-container--public .radio-option input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--kf-primary);
}

.radio-group--stacked .radio-option { margin-bottom: 0; }

.auftrag-form-container--public .checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.auftrag-form-container--public .checkbox-option:hover {
    border-color: #93c5fd;
    background: var(--kf-primary-soft);
}
.auftrag-form-container--public .checkbox-option:has(input:checked) {
    border-color: var(--kf-primary);
    background: var(--kf-primary-soft);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}
.auftrag-form-container--public .checkbox-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--kf-primary);
    cursor: pointer;
}
.checkbox-option__check { display: none; }
.checkbox-group.field-error { border: 1.5px solid #dc2626; border-radius: 10px; padding: 0.5rem; }
.form-section-hint { font-size: 0.8125rem; color: #6b7280; margin: -0.25rem 0 0.5rem; }

.legal-text-box {
    max-height: 240px;
    overflow-y: auto;
    font-size: 0.8125rem;
    line-height: 1.65;
    color: #374151;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.125rem;
}

.legal-text-box p { margin: 0 0 0.75rem; }
.legal-text-box p:last-child { margin-bottom: 0; }

/* Zustimmungs-Box */
.consent-box {
    margin-bottom: 1.25rem;
    padding: 1rem 1.125rem;
    background: var(--kf-primary-soft);
    border: 2px solid #bfdbfe;
    border-radius: 12px;
    transition: border-color 0.2s, background 0.2s;
}

.consent-box.is-error {
    background: #fef2f2;
    border-color: #f87171;
}

.consent-box__label {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    cursor: pointer;
    margin: 0;
}

.consent-box__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.consent-box__check {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    margin-top: 2px;
    border: 2px solid #94a3b8;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}

.consent-box__input:checked + .consent-box__check {
    background: var(--kf-primary);
    border-color: var(--kf-primary);
}

.consent-box__input:checked + .consent-box__check::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.consent-box__input:focus-visible + .consent-box__check {
    outline: 2px solid var(--kf-primary);
    outline-offset: 2px;
}

.consent-box__content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.consent-box__title {
    font-size: 0.9375rem;
    color: var(--kf-slate);
}

.consent-box__text {
    font-size: 0.875rem;
    line-height: 1.55;
    color: #475569;
    font-weight: 400;
}

.consent-box__meta {
    margin: 0.625rem 0 0 2.125rem;
    font-size: 0.75rem;
    color: #64748b;
}

.consent-box.is-error .field-error-message {
    margin: 0.5rem 0 0 2.125rem;
}

.form-section--signature { background: #fff; }

.conditional-block[hidden] { display: none !important; }

.auftrag-form-container--public .btn-next,
.auftrag-form-container--public .btn-submit {
    background: var(--kf-primary);
}

.auftrag-form-container--public .btn-next:hover,
.auftrag-form-container--public .btn-submit:hover {
    background: var(--kf-primary-dark);
}

.auftrag-form-container--public .form-field input:focus,
.auftrag-form-container--public .form-field textarea:focus {
    border-color: var(--kf-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-success-hint { color: #4b5563; font-size: 0.875rem; margin-top: 0.5rem; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .auftrag-form-container { padding: 1.25rem 0.75rem 3rem; }
    .kundenformular-hero { padding: 0.625rem 0.875rem; }
    .kundenformular-hero__title { font-size: 1rem; }
    .auftrag-form-container:not(.auftrag-form-container--public) .form-progress-indicator { flex-wrap: wrap; }
    .auftrag-form-container:not(.auftrag-form-container--public) .progress-step { flex: 0 0 calc(33.33% - 3px); }
    .form-row { flex-direction: column; }
    .form-field--narrow,
    .form-field--hausnr { flex: 1; min-width: 0; max-width: none; }
    .checklist-header, .checklist-row { grid-template-columns: 1fr 48px 48px; }
    .form-step { padding: 1.25rem; }
}
