:root {
    --primary: #00a7b7;
    --primary-dark: #008a99;
    --primary-soft: #e0f7f9;
    --success: #059669;
    --warn: #d97706;
    --error: #dc2626;
    --text: #1f2937;
    --muted: #64748b;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }

/* Login */
#login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); padding: 20px; }
.login-card { background: var(--card); border-radius: 12px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.15); max-width: 380px; width: 100%; }
.brand { text-align: center; margin-bottom: 24px; }
.logo { width: 64px; height: 64px; border-radius: 16px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.brand h1 { margin: 0 0 4px; font-size: 22px; color: var(--primary-dark); }
.brand .subtitle { margin: 0; color: var(--muted); font-size: 13px; }
#login-step1 label,
#login-step2 label,
#login-step-pw label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 13px; color: var(--text); }
#login-step1 input,
#login-step2 input,
#login-step-pw input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
#login-step1 input:focus,
#login-step2 input:focus,
#login-step-pw input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,167,183,.15); }
#login-step1 button,
#login-step2 button,
#login-step-pw button { width: 100%; margin-top: 14px; }
.hint { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.hint a { color: var(--primary-dark); text-decoration: none; }
.hint a:hover { text-decoration: underline; }
#code { letter-spacing: .3em; font-size: 20px !important; text-align: center; font-weight: 600; }
#email-echo { color: var(--primary-dark); font-weight: 600; }

/* Buttons */
button { background: var(--primary); color: #fff; border: 0; padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .12s; }
button:hover { background: var(--primary-dark); }
button.secondary { background: #fff; color: var(--primary-dark); border: 1.5px solid var(--primary); }
button.secondary:hover { background: var(--primary-soft); }
button.link-btn { background: none; color: #fff; padding: 4px 8px; font-weight: 500; }
button.link-btn:hover { background: rgba(255,255,255,.15); }
section button.link-btn { color: var(--primary-dark); }
section button.link-btn:hover { background: var(--primary-soft); }
button:disabled { opacity: .6; cursor: not-allowed; }

/* Header */
.app-header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-left h1 { margin: 0; font-size: 18px; }
.logo-small { background: rgba(255,255,255,.2); width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
#me-name { opacity: .9; }

main { max-width: 880px; margin: 0 auto; padding: 20px; }

/* Audit-Liste */
.audit-card { background: var(--card); border-radius: 10px; padding: 14px 18px; margin-bottom: 10px; border: 1px solid var(--border); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.audit-card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.06); border-color: var(--primary); }
.audit-card .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.audit-card .audit-actions-inline { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.audit-card .audit-actions-inline .nachsenden-btn { color: var(--primary-dark); background: var(--primary-soft); font-weight: 600; padding: 4px 10px; border-radius: 5px; font-size: 12px; }
.audit-card .audit-actions-inline .nachsenden-btn:hover { background: var(--primary); color: #fff; }
.audit-card .audit-actions-inline .nachsenden-btn:disabled { background: #f1f5f9; color: var(--muted); cursor: progress; }
.audit-card .title { font-weight: 600; font-size: 15px; }
.audit-card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge { padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.badge.offen { background: #fef3c7; color: #92400e; }
.badge.in_arbeit { background: #dbeafe; color: #1e40af; }
.badge.abgeschlossen { background: #d1fae5; color: #065f46; }

/* Audit-Formular */
.audit-meta { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px; }
.audit-meta .row { display: flex; justify-content: space-between; padding: 3px 0; }
.audit-meta b { color: var(--primary-dark); }
.audit-progress { background: var(--primary-soft); border-radius: 8px; padding: 8px 14px; margin-bottom: 14px; font-size: 13px; }
.audit-progress .bar { height: 6px; background: #fff; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.audit-progress .bar > div { height: 100%; background: var(--primary); transition: width .2s; }

.kapitel { background: var(--card); border-radius: 10px; padding: 14px 18px; margin-bottom: 14px; border: 1px solid var(--border); }
.kapitel h3 { margin: 0 0 12px; color: var(--primary-dark); font-size: 16px; }
.frage { padding: 12px 0; border-top: 1px solid var(--border); }
.kapitel .frage:first-of-type { border-top: 0; }
.frage .nr { color: var(--muted); font-weight: 600; margin-right: 4px; }
.frage .text { font-weight: 600; }
.frage .hilfe { font-size: 12px; color: var(--muted); margin-top: 4px; font-style: italic; }
.frage .pflicht { color: var(--error); font-weight: 700; }

.jn-row { display: flex; gap: 10px; margin-top: 10px; }
.jn-btn { flex: 1; padding: 10px; border: 1.5px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-weight: 600; cursor: pointer; font-size: 14px; }
.jn-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.jn-btn.active.ja { background: var(--success); color: #fff; border-color: var(--success); }
.jn-btn.active.nein { background: var(--error); color: #fff; border-color: var(--error); }

.bedingt { background: #fef9e7; border-left: 3px solid var(--warn); padding: 10px 14px; margin-top: 10px; border-radius: 0 6px 6px 0; display: none; }
.bedingt.show { display: block; }
.bedingt label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.bedingt textarea, .bedingt input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }
.bedingt textarea { min-height: 70px; resize: vertical; padding-right: 44px; }
.bedingt .row { display: flex; gap: 10px; margin-top: 8px; }
.bedingt .row > div { flex: 1; }

.textarea-wrap { position: relative; }
.mic-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mic-btn:hover { background: var(--primary); color: #fff; }
.mic-btn.recording {
    background: var(--error);
    color: #fff;
    animation: pulse 1.2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); }
    50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

.input-text { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; margin-top: 8px; font-family: inherit; }
textarea.input-text { min-height: 60px; resize: vertical; }

.sterne-row { display: flex; gap: 6px; margin-top: 10px; }
.stern { font-size: 30px; cursor: pointer; color: var(--border); transition: color .1s; user-select: none; }
.stern.active { color: var(--warn); }
.stern:hover, .stern:hover ~ .stern { color: var(--border); }
.sterne-row:hover .stern { color: var(--warn); }
.sterne-row:hover .stern:hover ~ .stern { color: var(--border); }

.foto-row { margin-top: 10px; }
.foto-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.foto-thumbs .thumb { position: relative; width: 80px; height: 80px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.foto-thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; }
.foto-thumbs .thumb .del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; width: 22px; height: 22px; border-radius: 50%; padding: 0; font-size: 14px; line-height: 1; }
.foto-upload-btn { display: inline-block; padding: 6px 12px; background: var(--primary-soft); color: var(--primary-dark); border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.foto-upload-btn input { display: none; }
.foto-status { display: inline-block; margin-left: 10px; font-size: 12px; vertical-align: middle; }
.foto-status.info { color: var(--primary-dark); }
.foto-status.ok { color: var(--success); font-weight: 600; }
.foto-status.err { color: var(--error); font-weight: 600; }

.audit-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.audit-actions button { padding: 12px 22px; }

.msg { margin-top: 12px; padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.msg.ok { background: #d1fae5; color: #065f46; }
.msg.err { background: #fee2e2; color: #991b1b; }
.msg.info { background: var(--primary-soft); color: var(--primary-dark); }

.loading { text-align: center; color: var(--muted); padding: 32px; }

@media (max-width: 600px) {
    main { padding: 12px; }
    .audit-actions button { width: 100%; }
}
