:root {
    --bg: #f2efe9;
    --card: #fff;
    --text: #2b2b2b;
    --muted: #777;
    --line: #e3ded4;
    --accent: #4a6b57;
    --accent-dark: #3a5646;
    --danger: #b3382c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 8%, #d4ead8 0, transparent 45%),
        radial-gradient(circle at 88% 18%, #a9d2b5 0, transparent 40%),
        radial-gradient(circle at 45% 100%, #8fc3a0 0, transparent 55%),
        linear-gradient(160deg, #e6f3e9, #c3dfcb) fixed;
    min-height: 100vh;
    line-height: 1.5;
}

a { color: var(--accent-dark); }
h1 { font-size: 1.6rem; margin: 1rem 0; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.wrap { max-width: 1840px; margin: 0 auto; padding: 0 1rem 3rem; }

/* Kopfzeile */
.top { background: linear-gradient(135deg, #2f4a3b, #4a6b57); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.brand { display: inline-flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.logo { width: 1.5rem; height: 1.5rem; }
.top nav { display: flex; gap: 0.25rem; flex: 1; }
.top nav a { color: #fff; text-decoration: none; padding: 0.3rem 0.7rem; border-radius: 6px; }
.top nav a:hover, .top nav a.active { background: rgba(255, 255, 255, 0.2); }
.who { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.who a { color: #fff; }
.who .role { background: rgba(255, 255, 255, 0.22); padding: 0.05rem 0.5rem; border-radius: 99px; font-size: 0.78rem; }
.who form { margin: 0; }
button.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* Karten, Formulare */
.card { background: var(--card); border-radius: 12px; padding: 1.25rem; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07); margin: 1rem 0; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.hero { display: block; width: 100%; height: auto; border-radius: 8px; margin-bottom: 0.5rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.92rem; }
label.radio { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: normal; }
input, select, textarea {
    font: inherit; padding: 0.55rem 0.7rem; border: 1px solid #cfc9bd; border-radius: 8px; background: #fff; width: 100%;
}
input[type=radio], input[type=checkbox] { width: auto; }
input[type=file] { padding: 0.4rem; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem; }
legend { font-weight: 600; font-size: 0.92rem; padding: 0 0.3rem; }
fieldset .radio { display: inline-flex; margin-right: 1rem; }

.btn {
    display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: 0.5rem 1rem;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--accent-dark); border-color: #cfc9bd; }
.btn.secondary:hover { background: #f6f3ed; }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #fbeceb; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.actions form { margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-form input { flex: 1 1 180px; width: auto; }

.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.head h1 { margin: 1rem 0; }
.crumb { margin: 1rem 0 0; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.88rem; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.desc { white-space: normal; }

.notice { padding: 0.7rem 1rem; border-radius: 8px; margin: 1rem 0; }
.notice.ok { background: #e4f1e7; color: #1f5130; }
.notice.err { background: #fbe9e7; color: #8a2a20; }

/* Filter */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.chip { text-decoration: none; background: #fff; border: 1px solid #cfc9bd; border-radius: 99px; padding: 0.2rem 0.8rem; font-size: 0.9rem; color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .count { background: var(--danger); color: #fff; border-radius: 99px; padding: 0 0.4rem; font-size: 0.75rem; margin-left: 0.2rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filters input[type=search] { flex: 2 1 160px; width: auto; }
.filters select { flex: 1 1 150px; width: auto; }

/* Liste */
.list { display: flex; flex-direction: column; gap: 0.6rem; }
.list .card { margin: 0; }
.item {
    display: flex; align-items: center; gap: 0.9rem; background: var(--card); border-radius: 12px; padding: 0.6rem;
    text-decoration: none; color: inherit; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
}
.item:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14); }
.item.done { opacity: 0.6; }
.item { border-left: 6px solid #cfc9bd; transition: transform .12s, box-shadow .12s; }
.item:hover { transform: translateY(-1px); }
.item.p3 { border-left-color: #d9534f; }
.item.p2 { border-left-color: #f0ad4e; }
.item.p1 { border-left-color: #6a9bd1; }
.thumb { width: 88px; height: 88px; flex: none; border-radius: 8px; background: #ece8df; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item .body { flex: 1; min-width: 0; padding-left: 0.4rem; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: 0.85rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: flex-end; }

.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.6rem; border-radius: 99px; white-space: nowrap; }
.prio-3 { background: #f8d7d3; color: #8a2a20; }
.prio-2 { background: #fde9c4; color: #7a5200; }
.prio-1 { background: #dfe9f5; color: #2c4a72; }
.st-offen { background: #ececec; color: #444; }
.st-in_arbeit { background: #d9ecf7; color: #1d5878; }
.st-erledigt { background: #dcefdc; color: #1f5130; }
.st-archiv { background: #e8e1f2; color: #4b3a72; }
.role-admin { background: #f8d7d3; color: #8a2a20; }
.role-bewohner { background: #dcefdc; color: #1f5130; }
.role-betrachter { background: #ececec; color: #444; }

/* Fotos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; margin: 1rem 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; }
.photo-del { font-weight: normal; font-size: 0.85rem; }
.photo-del span { display: flex; align-items: center; gap: 0.3rem; }

.area-row .inline-form { margin-bottom: 0.3rem; }

@media (max-width: 560px) {
    .item { flex-wrap: wrap; }
    .item .tags { width: 100%; justify-content: flex-start; }
    .thumb { width: 56px; height: 56px; }
}

/* Banner mit Foto und Kennzahlen */
.banner {
    margin: 1rem 0 1.25rem; padding: 1.6rem 1.4rem 1.2rem; border-radius: 16px; color: #fff;
    background: radial-gradient(circle at 85% 10%, rgba(255,255,255,.22) 0, transparent 40%), linear-gradient(135deg, #2c5a42, #4c8863 55%, #78b08b);
    box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.banner h1 { margin: 0; font-size: 1.9rem; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
.banner p { margin: .2rem 0 1.4rem; opacity: .92; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.stat {
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); border-radius: 12px;
    padding: .6rem .4rem; text-align: center; backdrop-filter: blur(4px);
}
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat span { font-size: .82rem; opacity: .92; }
.stat.hot { background: rgba(217,83,79,.55); }
.stat.good { background: rgba(92,170,110,.5); }
.head h2 { margin: 0; }

/* Karten und Buttons etwas plastischer */
.card { border: 1px solid rgba(0,0,0,.04); }
.btn { box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.chip { box-shadow: 0 1px 2px rgba(0,0,0,.06); }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fa58d; outline-offset: 1px; }
.gallery a { display: block; overflow: hidden; border-radius: 8px; }
.gallery a img { transition: transform .2s; }
.gallery a:hover img { transform: scale(1.05); }

/* Anmeldeseite */
body.auth .card { margin-top: 2rem; }
body.auth .hero { display: none; }

/* Foto-Ansicht */
.lb { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; z-index: 100; }
.lb[hidden] { display: none; }
.lb img { max-width: 94vw; max-height: 90vh; border-radius: 4px; }
.lb button { position: absolute; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 50%; width: 3rem; height: 3rem; font-size: 2rem; line-height: 1; cursor: pointer; }
.lb button:hover { background: rgba(255,255,255,.3); }
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 1rem; color: #ddd; font-size: .9rem; }
body.lb-open { overflow: hidden; }

@media (max-width: 560px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .banner h1 { font-size: 1.5rem; }
}

/* Startseite */
.welcome { max-width: 680px; margin: 2rem auto; text-align: center; }
.welcome h1 { margin: 1rem 0 .6rem; font-size: 1.7rem; }
.welcome p { margin: .6rem 0; }
.welcome .hero { margin-bottom: 0; }
.actions.center { justify-content: center; margin: 1.2rem 0 .4rem; }
.welcome .btn { padding: .65rem 1.8rem; font-size: 1.05rem; }

/* Breite Bildschirme: Listen zweispaltig, Formulare nicht zu breit */
@media (min-width: 1100px) {
    .list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
    form.card.stack:not(.narrow) { max-width: 1100px; }
    .stats { max-width: 1000px; }
}

@media (min-width: 1700px) {
    .list { grid-template-columns: 1fr 1fr 1fr; }
}

/* Hausverwaltung */
.role-hausverwaltung { background: #dfe9f5; color: #2c4a72; }
.st-start { background: #fff3c4; color: #6b5200; }
.hv { margin-top: 1.5rem; padding: 1rem 1.2rem; background: #f3f8fd; border: 1px solid #cfe0f1; border-radius: 10px; }
.hv h2 { margin-top: 0; }
.hv p { margin: .4rem 0; }

/* Kalender */
.cal-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1rem; }
.cal-title { display: flex; align-items: center; gap: .8rem; font-size: 1.15rem; }
.cal-title .btn { padding: .2rem .8rem; font-size: 1.2rem; line-height: 1.2; }
.seg { display: inline-flex; border: 1px solid #cfc9bd; border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: .45rem 1rem; text-decoration: none; font-weight: 600; color: var(--accent-dark); }
.seg a.on { background: var(--accent); color: #fff; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #cfdcd2; border: 1px solid #cfdcd2; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,.07); }
.cal .wd { background: #3f6650; color: #fff; text-align: center; font-weight: 600; padding: .4rem 0; font-size: .9rem; }
.cal .day { background: #fff; min-height: 110px; padding: .3rem .35rem; min-width: 0; }
.cal .day.we { background: #f6faf7; }
.cal .day.other { background: #eef2ee; color: #999; }
.cal .day.today { background: #fff8dc; box-shadow: inset 0 0 0 2px #e0b93c; }
.dn { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; margin-bottom: .2rem; }
.dn a { text-decoration: none; font-weight: 600; }
.dn .add { color: var(--accent); opacity: 0; font-size: 1.1rem; padding: 0 .3rem; }
.day:hover .add, .add:focus { opacity: 1; }
.ev { display: block; background: #dcefe2; color: #1f4a31; border-left: 4px solid var(--accent); border-radius: 4px; padding: .1rem .4rem; margin-bottom: .2rem; font-size: .82rem; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev:hover { background: #c6e4d0; }
.week { grid-template-columns: repeat(7, 1fr); }
.week .day { min-height: 260px; }
.ev.full { white-space: normal; font-size: .88rem; padding: .4rem .5rem; }
.ev.full b { display: block; }
.ev.full span { display: block; color: #3d5f4a; margin-top: .15rem; overflow-wrap: anywhere; }
.none { color: #bbb; margin: .2rem 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.when { font-weight: 600; color: var(--accent-dark); margin: 0 0 .6rem; }

@media (max-width: 800px) {
    .week { grid-template-columns: 1fr; }
    .week .day { min-height: 0; }
    .cal.month .day { min-height: 64px; padding: .15rem; }
    .cal.month .ev { font-size: 0; padding: 0; height: .55rem; margin-bottom: .15rem; }
    .dn .add { opacity: 1; }
    .two { grid-template-columns: 1fr; }
}

/* Arbeitszeiträume der Hausverwaltung im Kalender */
.ev.work { background: #fdeccd; color: #6b4a00; border-left-color: #e0a020; }
.ev.work:hover { background: #fbdfaa; }
.ev.full.work span { color: #7a5a1a; }
.cal-legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); margin: .6rem 0 0; }
.cal-legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; background: #dcefe2; border-left: 3px solid var(--accent); }
.cal-legend i.w { background: #fdeccd; border-left-color: #e0a020; }

.tbl { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.tbl th, .tbl td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .85rem; color: var(--muted); }
