:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --success: #16A34A;
    --danger: #DC2626;
    --bg: #F1F5F9;
    --surface: #FFFFFF;
    --border: #E2E8F0;
    --text: #0F172A;
    --text-muted: #64748B;
    --r: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,.08);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    /* content-visibility: auto activates paint containment for perf */
}

/* ── Header ── */
header {
    background: var(--primary);
    color: #fff;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon { font-size: 1.75rem; flex-shrink: 0; }

header h1 { font-size: 1.0625rem; font-weight: 700; line-height: 1.25; }
header p  { font-size: .8125rem; opacity: .85; }

.offline-badge {
    margin-left: auto;
    background: rgba(0,0,0,.35);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: .75rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ── Layout ── */
main { padding: 20px 0 40px; }

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    box-shadow: var(--shadow);
    /* hint browser this is an independent layer */
    contain: layout style;
}

.card h2 { font-size: 1.0625rem; font-weight: 700; margin-bottom: 4px; }

.card-success { text-align: center; padding: 40px 20px; }
.success-icon { font-size: 2.5rem; margin-bottom: 12px; }
.card-success h2 { font-size: 1.25rem; margin-bottom: 8px; }
.card-success p  { color: var(--text-muted); margin-bottom: 20px; }

/* ── Form ── */
.subtitle {
    color: var(--text-muted);
    font-size: .8125rem;
    margin-bottom: 18px;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
}

.row-2 .field { margin-bottom: 0; }

label { font-size: .875rem; font-weight: 600; }

.req  { color: var(--danger); }
.optional { color: var(--text-muted); font-weight: 400; font-size: .8125rem; }
.hint { font-size: .8125rem; color: var(--text-muted); }

input[type=text],
input[type=email],
input[type=tel],
input[type=password],
input[type=file],
select,
textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font: inherit;
    font-size: .9375rem;
    color: var(--text);
    background: #fff;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .12s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

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

input[type=file] { padding: 9px 12px; cursor: pointer; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border: none;
    border-radius: 7px;
    font: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, opacity .12s;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-ghost { background: none; color: var(--text-muted); border: 1.5px solid transparent; }
.btn-ghost:hover { border-color: var(--border); }

.btn-full { width: 100%; margin-top: 8px; }
.btn-sm   { padding: 7px 14px; font-size: .8125rem; }

/* ── Alert ── */
.alert {
    padding: 10px 14px;
    border-radius: 7px;
    font-size: .875rem;
    margin-bottom: 12px;
}
.alert-error { background: #FEF2F2; border: 1.5px solid #FECACA; color: #991B1B; }

/* ── Reports list ── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.loading { color: var(--text-muted); font-size: .875rem; padding: 12px 0; text-align: center; }

.report-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.report-item:last-child { border-bottom: none; }

.report-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.report-cat   { font-weight: 600; font-size: .9375rem; }
.report-date  { color: var(--text-muted); font-size: .8125rem; margin-left: auto; }
.report-loc   { color: var(--text-muted); font-size: .8125rem; margin-bottom: 4px; }
.report-desc  { font-size: .9375rem; line-height: 1.5; color: var(--text); }

.badge {
    padding: 2px 9px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-offen        { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.badge-in_bearbeitung { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.badge-erledigt     { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

.empty { text-align: center; color: var(--text-muted); padding: 28px 0; font-size: .9375rem; }

/* ── Login-Screen ── */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 36px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.login-card h1 { font-size: 1.375rem; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: .875rem; margin-bottom: 24px; }
.login-card .field { text-align: left; }

/* ── Share-Karte ── */
.share-card { background: linear-gradient(135deg, var(--primary) 0%, #1D4ED8 100%); color: white; }
.share-card h2 { color: white; margin-bottom: 16px; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.share-item { text-align: center; }
.share-label { font-size: .75rem; opacity: .8; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.share-value { font-size: 1.5rem; font-weight: 700; }
.share-denom { font-size: .75rem; opacity: .75; margin-top: 2px; }

/* ── Logout-Button im Header ── */
.btn-logout {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    color: white;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Passwort-Karte ── */
.pw-card { padding: 16px 20px; }
.pw-header { display: flex; justify-content: space-between; align-items: center; }
.pw-title { font-size: .875rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.btn-pw-toggle {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    padding: 6px 12px; font-size: .8125rem; cursor: pointer; color: var(--text-muted);
    transition: background .12s;
}
.btn-pw-toggle:hover { background: var(--bg); }
#pw-section-body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.pw-msg { padding: 8px 12px; border-radius: 6px; font-size: .875rem; margin: 8px 0; }
.pw-msg--ok    { background: #F0FDF4; border: 1px solid #BBF7D0; color: #166534; }
.pw-msg--error { background: #FEF2F2; border: 1.5px solid #FECACA; color: #991B1B; }

/* ── Statusfilter ── */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 12px;
}
.filter-btn {
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: 20px; padding: 5px 12px;
    font-size: .8125rem; font-weight: 500; cursor: pointer;
    color: var(--text-muted); transition: all .12s;
    touch-action: manipulation;
}
.filter-btn.active {
    background: var(--primary); border-color: var(--primary);
    color: #fff; font-weight: 600;
}
.filter-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }
.filter-cnt {
    display: inline-block; background: rgba(0,0,0,.1);
    border-radius: 10px; padding: 0 6px;
    font-size: .75rem; margin-left: 2px;
}
.filter-btn.active .filter-cnt { background: rgba(255,255,255,.25); }

/* ── Eigene-Meldungen-Toggle ── */
.mine-toggle {
    display: flex; align-items: center; gap: 8px;
    font-size: .875rem; color: var(--text-muted);
    cursor: pointer; margin-bottom: 14px;
    user-select: none;
}
.mine-toggle input[type=checkbox] {
    width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
    flex-shrink: 0;
}

/* ── Eigene Meldung ── */
.report-item--own {
    background: #EFF6FF;
    border-radius: 6px;
    padding-left: 10px; padding-right: 10px;
    margin-left: -10px; margin-right: -10px;
}
.badge-own {
    background: #DBEAFE; color: #1D4ED8;
    border: 1px solid #BFDBFE;
    padding: 2px 9px; border-radius: 12px;
    font-size: .75rem; font-weight: 700;
}

/* ── Verwalter-Rückmeldung ── */
.report-feedback {
    margin-top: 8px; padding: 8px 12px;
    background: #F0FDF4; border-left: 3px solid var(--success);
    border-radius: 0 6px 6px 0;
    font-size: .875rem;
}
.feedback-label { font-weight: 600; color: #166534; margin-right: 6px; }
.feedback-text  { color: #15803D; }

/* ── Offline-Hinweis in Liste ── */
.offline-hint { color: var(--text-muted); }

/* ── Responsive tweaks ── */
@media (max-width: 480px) {
    .card { padding: 16px; }
    header { padding: 14px 16px; }
    .share-grid { gap: 8px; }
    .share-value { font-size: 1.25rem; }
    .filter-bar { gap: 4px; }
    .filter-btn { padding: 5px 9px; font-size: .75rem; }
}
