:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --border: #e3e1da;
  --text: #1c1b18;
  --muted: #6f6b63;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #e3f1ef;
  --good: #15803d;
  --mid: #b45309;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --warn-soft: #fff4e0;
  --info-soft: #eaf2fb;
  --score-top: #15803d;
  --score-good: #0f766e;
  --score-mid: #b45309;
  --score-low: #78716c;
  --score-none: #a8a29e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1d1d1a;
    --surface-2: #262622;
    --border: #34332e;
    --text: #ecebe6;
    --muted: #a19d93;
    --accent: #2dd4bf;
    --accent-text: #0b1f1d;
    --accent-soft: #123331;
    --good: #4ade80;
    --mid: #fbbf24;
    --bad: #f87171;
    --bad-soft: #3a1c1c;
    --warn-soft: #3a2c12;
    --info-soft: #182636;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: .8rem 0 .3rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--mid); }
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }

.container { max-width: 1240px; margin: 0 auto; padding: 20px 16px 80px; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .01em; white-space: nowrap; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 8px; box-shadow: 0 0 0 3px var(--accent-soft); }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

/* Knöpfe und Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { padding: 5px 10px; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn.is-on { border-color: var(--accent); }

input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label small, label .check { font-weight: 400; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
.radio-row, .checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }
.input-unit { display: flex; align-items: center; gap: 6px; }
.input-unit span { color: var(--muted); font-weight: 400; min-width: 2.2em; }
.switch { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; }
.switch input { width: 18px; height: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 10px; }
.stack-lg > * + * { margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h1, .section-head h2 { margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.code { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; margin: 0; }
.prewrap { white-space: pre-wrap; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--accent-soft); }
.flash-error { background: var(--bad-soft); color: var(--bad); }
.flash-info { background: var(--info-soft); }

.show-sm { display: none; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: .8rem; background: var(--surface-2); white-space: nowrap; }
.pill-busy { background: var(--warn-soft); color: var(--mid); }

/* Aufklappbare Bereiche */
.fold { padding: 0; }
.fold > summary {
  display: grid; grid-template-columns: 9px minmax(0, auto) minmax(0, 1fr); align-items: center; gap: 2px 12px;
  padding: 14px 16px; cursor: pointer; list-style: none;
}
.fold-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
  content: ""; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
.fold[open] > summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.fold[open] > summary { border-bottom: 1px solid var(--border); }
@media (hover: hover) { .fold > summary:hover .fold-title { color: var(--accent); } }
.fold-title { font-weight: 700; font-size: 1.05rem; }
.fold-info { color: var(--muted); font-size: .88rem; text-align: right; }
.fold-body { padding: 14px 16px 16px; }
.fold-tools { justify-content: flex-end; }
.pill-on { background: var(--accent-soft); color: var(--accent); }
.pill-off { background: var(--surface-2); color: var(--muted); }

/* Login */
.login { max-width: 380px; margin: 10vh auto 0; }
.login h1 { text-align: center; }

/* Übersicht */
.status-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-wide { font-size: .9rem; }
.stat form { margin: 6px 0 0; }
.stat-action { padding: 3px 8px; font-size: .78rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 12px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: .8rem; text-align: center; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.filters label { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; color: var(--muted); }
.filters select { width: auto; padding: 5px 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.listing { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.listing.is-excluded, .listing.is-gone { opacity: .7; }
.listing-media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.slides { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Pfeile immer leicht sichtbar: Hover wird nicht von jedem Gerät/Browser gemeldet */
.slide-nav {
  position: absolute; top: 50%; z-index: 2; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0 0 3px;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer;
  opacity: .75; transition: opacity .15s, background-color .15s;
}
.slide-prev { left: 8px; }
.slide-next { right: 8px; }
.listing-media:hover .slide-nav, .slide-nav:focus-visible { opacity: 1; }
.slide-nav:hover { background: rgba(0, 0, 0, .7); }
.slide-count { position: absolute; z-index: 2; left: 8px; bottom: 8px; padding: 1px 8px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .75rem; pointer-events: none; }
@media (max-width: 640px) and (hover: none) { .slide-nav { display: none; } }  /* Handy: wischen */
.noimg { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); text-decoration: none; }
.listing-media.no-image { aspect-ratio: auto; height: 62px; }
.listing-media.no-image .noimg { justify-content: flex-start; padding-left: 14px; font-size: .85rem; }
.listing-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.listing-body h3 { margin: 0; font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.listing-body h3 a { color: var(--text); text-decoration: none; }
.listing-body h3 a:hover { color: var(--accent); }
.meta { color: var(--muted); font-size: .88rem; margin: 0; }
.facts { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; margin: 2px 0 0; padding: 6px 0; border-block: 1px solid var(--border); }
.facts div { min-width: 0; padding: 0 8px; }
.facts div:first-child { padding-left: 0; }
.facts div + div { border-left: 1px solid var(--border); }
.facts dt { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts dd { margin: 0; font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auction { color: var(--mid); font-size: .85rem; margin: 0; font-weight: 600; }
.summary { font-size: .9rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.summary.error { color: var(--bad); }
.listing-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.listing-actions form { margin: 0; }
.view-hint { margin: -4px 0 14px; max-width: 70ch; }

.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .72rem; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag-zvg { background: var(--warn-soft); color: var(--mid); }
.tag-kleinanzeigen { background: var(--accent-soft); color: var(--accent); }
.tag-immowelt { background: var(--info-soft); color: var(--text); }
.tag-ohne_makler { background: var(--accent-soft); color: var(--good); }
.tag-status { background: var(--info-soft); color: var(--text); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-good { background: var(--accent-soft); color: var(--good); }

.score { position: absolute; z-index: 2; top: 10px; right: 10px; width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); pointer-events: none; }
.score-top { background: var(--score-top); }
.score-good { background: var(--score-good); }
.score-mid { background: var(--score-mid); }
.score-low { background: var(--score-low); }
.score-none { background: var(--score-none); }
.score-big { position: static; width: 56px; height: 56px; font-size: 1.5rem; flex: none; }
.empty { text-align: center; padding: 40px 16px; }

/* Detailseite */
.breadcrumb { margin: 0 0 8px; }
.breadcrumb a { text-decoration: none; }
.detail-head { margin-bottom: 16px; }
.detail-head h1 { margin: 6px 0 4px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.gallery { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.gallery-main { width: 100%; max-height: 460px; object-fit: contain; background: #000; display: block; }
.gallery-thumbs { display: flex; gap: 6px; padding: 6px; overflow-x: auto; }
.gallery-thumbs img { height: 64px; border-radius: 6px; cursor: pointer; }
.eval-head { display: flex; align-items: center; gap: 12px; }
.eval-head h2 { margin: 0; }
.eval-head p { margin: 0; }
.push { margin-left: auto; }
.lead { font-size: 1.02rem; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }
ul { margin: 0; padding-left: 1.2em; }
li { margin: 2px 0; }
.list-good li::marker { color: var(--good); }
.list-bad li::marker { color: var(--bad); }
.list-warn li::marker { color: var(--mid); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.status-buttons form { margin: 0; }
.docs li { margin: 4px 0; }

/* Protokoll */
.run summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.run-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.run-kind { font-weight: 600; }
.run pre { margin-top: 10px; max-height: 420px; overflow: auto; }
.run-error { border-color: var(--bad); }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .status-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-wide { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .container { padding: 14px 12px 80px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -8px; }
  .topbar-actions { margin-left: auto; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  /* iOS vergrößert die Seite beim Antippen von Feldern mit Schrift unter 16 px */
  input[type=text], input[type=password], input[type=number], input[type=time], select, textarea { font-size: 16px; }
  .btn-small { padding: 7px 12px; }
  .status-row { gap: 8px; }
  .stat { padding: 10px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .78rem; }
  .stat-wide { font-size: .82rem; }
  .stat-action { white-space: normal; }
  .filters { gap: 8px; }
  .filters label { flex: 1 1 28%; flex-direction: column; align-items: stretch; gap: 2px; font-size: .8rem; }
  .filters select { width: 100%; }
  .fold > summary { grid-template-columns: 9px minmax(0, 1fr); }
  .fold-info { grid-column: 2; text-align: left; }
  .gallery-main { max-height: 300px; }
  .sticky-actions .btn { flex: 1 1 auto; }
  .card { padding: 14px; }
  .fold { padding: 0; }
}

/* Profile */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-actions { justify-content: flex-end; }
.table form { margin: 0; }
.invite-box { border-color: var(--accent); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.btn.danger { color: var(--bad); }
