:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #23201c;
  --muted: #7a7268;
  --line: #e6e0d6;
  --accent: #b5532f;
  --accent-soft: #f6e4dc;
  --ok: #2f7d4f;
  --ok-soft: #e3f1e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35,32,28,.06), 0 4px 16px rgba(35,32,28,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin-bottom: .75rem; }
.loading { padding: 4rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1rem 4rem; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(246,243,238,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1180px; margin: 0 auto; padding: .7rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); display: flex; align-items: center; gap: .4rem; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a { padding: .35rem .7rem; border-radius: 999px; color: var(--ink); font-size: .92rem; }
.nav a:hover { background: var(--line); text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
.role-pill { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--line); color: var(--muted); }

/* Buttons & Formulare */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: .45rem .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .btn:hover { border-color: #cfc6b8; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #9e4626; border-color: #9e4626; }
.btn-danger { color: #b42318; }
.btn-sm { padding: .2rem .55rem; font-size: .85rem; border-radius: 8px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .9rem; }
.checkbox { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink); font-size: .9rem; margin: 0; }
.checkbox input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }

/* Karten */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 1rem; flex-wrap: wrap; }

/* Statistik */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1.2rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

/* Filter */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { max-width: 260px; }
.filters select { width: auto; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .25rem .75rem; font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Exposé-Kacheln */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--ink); display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s; }
.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 2px 4px rgba(35,32,28,.08), 0 10px 28px rgba(35,32,28,.1); }
.card.dim { opacity: .62; }
.card .img { aspect-ratio: 16/10; background: #ece6dc center/cover no-repeat; position: relative; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.card .img .badge { position: absolute; top: .6rem; left: .6rem; }
.card .img .counts { position: absolute; bottom: .5rem; right: .5rem; background: rgba(0,0,0,.55); color: #fff; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; }
.card .body { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.card .title { font-weight: 650; font-size: 1.05rem; }
.card .addr { color: var(--muted); font-size: .88rem; }
.card .price { font-weight: 650; font-size: 1.05rem; }
.card .facts { display: flex; gap: .8rem; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.progress { display: flex; align-items: center; gap: .5rem; margin-top: auto; padding-top: .5rem; }
.progress .icons { display: flex; gap: 2px; flex-wrap: wrap; }
.progress .icons span { font-size: .9rem; filter: grayscale(1); opacity: .25; }
.progress .icons span.done { filter: none; opacity: 1; }
.progress .n { font-size: .8rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.badge { display: inline-block; color: #fff; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; }
.stars { color: #e0a526; letter-spacing: 1px; }
.stars .off { color: #d9d2c5; }
.stars button { border: 0; background: none; padding: 0 1px; font-size: 1.25rem; color: inherit; cursor: pointer; }

/* Detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.detail .col { display: flex; flex-direction: column; gap: 1.2rem; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem 1rem; }
.facts-grid div span { display: block; font-size: .8rem; color: var(--muted); }
.facts-grid div b { font-weight: 600; }
.intern { background: #fff8e6; border: 1px dashed #e7c66b; border-radius: 10px; padding: .6rem .8rem; }
.intern-tag { font-size: .75rem; color: #8a6d12; }
.prewrap { white-space: pre-wrap; }

.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.checklist li { display: flex; align-items: flex-start; gap: .6rem; padding: .45rem .6rem; border-radius: 10px; border: 1px solid var(--line); }
.checklist li.done { background: var(--ok-soft); border-color: #bfdfcb; }
.checklist .box { width: 1.4rem; height: 1.4rem; border-radius: 6px; border: 2px solid #cfc6b8; display: flex; align-items: center; justify-content: center; flex: none; background: #fff; padding: 0; font-size: .9rem; color: #fff; }
.checklist li.done .box { background: var(--ok); border-color: var(--ok); }
.checklist .lbl { flex: 1; }
.checklist .meta { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.checklist .box { margin-top: .05rem; }
.checklist input[type=date] { width: auto; padding: 0 .3rem; font-size: .8rem; border-radius: 6px; background: transparent; border-color: transparent; color: var(--muted); }
.checklist input[type=date]:hover { border-color: var(--line); background: #fff; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.media-item { position: relative; border-radius: 10px; overflow: hidden; background: #ece6dc; aspect-ratio: 4/3; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.media-item video { cursor: default; background: #000; object-fit: contain; }
.media-item .tools { position: absolute; top: .3rem; right: .3rem; display: none; gap: .25rem; }
.media-item:hover .tools, .media-item:focus-within .tools { display: flex; }
.media-item .tools button { background: rgba(255,255,255,.92); }
.media-item .cover-tag { position: absolute; bottom: .3rem; left: .3rem; background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; padding: .05rem .4rem; border-radius: 6px; }

.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.doc-list li { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; }
.doc-list li a.name { flex: 1; word-break: break-word; }

.dropzone { border: 2px dashed #d5ccbe; border-radius: 12px; padding: 1rem; text-align: center; color: var(--muted); cursor: pointer; margin-top: .8rem; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ico { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; flex: none; font-size: .85rem; }
.timeline .txt { flex: 1; min-width: 0; }
.timeline .meta { font-size: .8rem; color: var(--muted); }
.timeline .notiz .ico { background: var(--accent-soft); }
.day-head { font-weight: 650; margin: 1.2rem 0 .3rem; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }

table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; }

/* Login */
.login { max-width: 360px; margin: 12vh auto; }
.login h1 { text-align: center; margin-bottom: .3rem; }
.login p { text-align: center; margin-top: 0; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(15,13,11,.92); z-index: 100; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 88vh; object-fit: contain; border-radius: 6px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; font-size: 1.6rem; width: 3rem; height: 3rem; border-radius: 50%; justify-content: center; }
.lightbox .prev { left: 1rem; } .lightbox .next { right: 1rem; } .lightbox .close { top: 1rem; right: 1rem; }
.lightbox .cap { position: absolute; bottom: 1rem; color: #ddd; font-size: .85rem; }

.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 10px; z-index: 200; box-shadow: var(--shadow); }
.toast.err { background: #b42318; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
