/* Wohnungssuche Gießen – dunkles Abendblau, ruhige Flächen, die Ampel ist die einzige kräftige Farbe. */
:root {
  --bg: #141a24;
  --surface: #1c2431;
  --raised: #263041;
  --line: #334056;
  --text: #e8ecf2;
  --muted: #9aa7ba;
  --accent: #7cc4ff;
  --accent-ink: #0c1b2a;
  --gruen: #4cc38a;
  --gelb: #f0b84a;
  --rot: #ef6b6b;
  --radius: 10px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); overflow-x: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; }
h1 { font-size: 1.35rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6em; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.boot { padding: 48px var(--gutter); color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Bedienelemente ---------- */
button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: #4a5b78; }
button:disabled { opacity: .55; cursor: default; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.ghost { background: transparent; }
button.danger { color: var(--rot); }
button.on { background: #2f4563; border-color: var(--accent); color: #fff; }
button.tiny { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: #151c27; color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }
label { display: block; font-size: .85rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
label .small { display: block; margin-top: 3px; overflow-wrap: anywhere; }
label.row { display: flex; color: var(--text); font-size: .95rem; }
label.row > input, label.row > select { width: auto; max-width: 130px; margin-top: 0; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; min-height: 38px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.field-grid.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ---------- Kopf ---------- */
.top { position: sticky; top: 0; z-index: 20; background: rgba(20, 26, 36, .96); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1320px; margin: 0 auto; padding: 10px var(--gutter); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 30px; height: 30px; }
.updated { color: var(--muted); font-size: .88rem; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { padding: 9px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
main { max-width: 1320px; margin: 0 auto; padding: 18px var(--gutter) 64px; }
.progress { color: var(--muted); font-size: .88rem; min-height: 1.3em; }

/* ---------- Kennzahlen ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat b { display: block; font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.gruen b { color: var(--gruen); } .stat.gelb b { color: var(--gelb); }

/* ---------- Filter ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.panel > h2, .panel > h3 { margin-bottom: 10px; }
.panel h3:not(:first-child) { margin-top: 18px; }
.panel form > .row, form.panel > .row { margin-top: 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
details.more > summary { cursor: pointer; color: var(--accent); padding: 6px 0; list-style-position: inside; }
details.more[open] > summary { margin-bottom: 10px; }
.portal-links { display: flex; flex-wrap: wrap; gap: 8px; }
.count-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 12px; }
.count-line select { width: auto; }

/* ---------- Wohnungskarten ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { display: grid; grid-template-columns: 62px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.inactive { opacity: .62; }
.band { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 0; color: #10161f; font-variant-numeric: tabular-nums; }
.band b { font-size: 1.6rem; line-height: 1; font-weight: 750; }
.band small { font-size: .7rem; opacity: .8; }
.band.gruen { background: var(--gruen); } .band.gelb { background: var(--gelb); } .band.rot { background: var(--rot); } .band.none { background: var(--raised); color: var(--muted); }
.card-body { padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.card-title { font-size: 1rem; font-weight: 650; overflow-wrap: anywhere; cursor: pointer; background: none; border: 0; padding: 0; min-height: 0; text-align: left; white-space: normal; color: var(--text); justify-content: flex-start; }
.card-title:hover { color: var(--accent); }
.where { color: var(--muted); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--raised); border-radius: 999px; padding: 2px 10px; font-size: .85rem; white-space: nowrap; }
.chip.new { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.chip.warn { background: #4a3320; color: #ffd9a8; white-space: normal; }
.chip.status { background: #2f4563; }
.chip.gruen { color: var(--gruen); } .chip.gelb { color: var(--gelb); } .chip.rot { color: var(--rot); }
.prices { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 2px 18px; font-variant-numeric: tabular-nums; }
.prices div b { font-size: 1.05rem; }
.prices div span { display: block; color: var(--muted); font-size: .78rem; }
.meta { color: var(--muted); font-size: .84rem; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Detail / Dialog ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(8, 11, 16, .72); display: flex; justify-content: flex-end; }
.sheet { width: min(760px, 100%); height: 100%; overflow-y: auto; background: var(--bg); border-left: 1px solid var(--line); padding: 0 0 48px; overscroll-behavior: contain; }
.sheet.center { margin: auto; height: auto; max-height: 92vh; border: 1px solid var(--line); border-radius: 12px; width: min(620px, calc(100% - 24px)); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; align-items: flex-start; padding: 12px var(--gutter); background: var(--bg); border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; overflow-wrap: anywhere; }
.sheet-body { padding: 14px var(--gutter); display: flex; flex-direction: column; gap: 16px; }
.section > h3 { margin-bottom: 8px; }
.scoreline { display: flex; align-items: center; gap: 12px; }
.badge { display: inline-flex; align-items: baseline; gap: 4px; padding: 6px 12px; border-radius: 8px; color: #10161f; font-weight: 750; font-variant-numeric: tabular-nums; }
.badge.gruen { background: var(--gruen); } .badge.gelb { background: var(--gelb); } .badge.rot { background: var(--rot); }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.gallery img { height: 220px; max-width: 86%; border-radius: 8px; scroll-snap-align: start; object-fit: cover; background: var(--raised); }
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.proscons ul { margin: 0; padding: 0; list-style: none; }
.proscons li { padding: 2px 0 2px 22px; position: relative; }
.proscons li::before { position: absolute; left: 0; font-weight: 700; }
.pro li::before { content: "+"; color: var(--gruen); } .con li::before { content: "–"; color: var(--rot); }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.bar-row .t { color: var(--muted); font-size: .85rem; grid-column: 1 / -1; }
.bar { grid-column: 1 / -1; height: 6px; background: var(--raised); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; color: #d5dbe6; }
.map { width: 100%; height: 240px; border: 0; border-radius: 8px; background: var(--raised); }
.note { background: #1b2a3c; border: 1px solid #2f4563; border-radius: 8px; padding: 10px 12px; font-size: .92rem; }
.note.warn { background: #33261a; border-color: #5c4326; }
.note.error { background: #3a1f22; border-color: #6d3237; }

/* ---------- Tabellen (auf dem Handy als Stapel) ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: .85rem; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #263041; vertical-align: top; overflow-wrap: anywhere; }
td.ok { color: var(--gruen); } td.fail { color: var(--rot); }
td.r, th.r { text-align: right; }
@media (max-width: 720px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.stack td { display: grid; grid-template-columns: 42% 1fr; gap: 8px; border: 0; padding: 2px 0; text-align: left; }
  table.stack td::before { content: attr(data-l); color: var(--muted); font-size: .85rem; }
}

/* ---------- Admin ---------- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.source { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 6px; }
.source:first-of-type { border-top: 0; }
.source-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--gruen); } .dot.err { background: var(--rot); } .dot.off { background: #56627a; }
.tag { font-size: .78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: #151c27; padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 var(--gutter); }
.login h1 { margin-bottom: 6px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); }
#toast div { background: #0d1219; border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; margin-top: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, .45); }
#toast div.error { border-color: var(--rot); }

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .card { grid-template-columns: 54px 1fr; }
  .proscons { grid-template-columns: 1fr; }
  .gallery img { height: 180px; }
  .top-inner .updated { flex-basis: 100%; order: 3; }
}

/* ---------- Suchprofile, Straßen, Umkreis ---------- */
.profile-pick { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; }
.profile-pick select { width: auto; max-width: 220px; margin-top: 0; color: var(--text); font-weight: 600; }
.chip.place { background: #1f3a4d; color: #bfe3ff; white-space: normal; }
.near { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.near .grow, .area-row .grow { flex: 1 1 220px; min-width: 0; }
.near label:not(.grow) { flex: 0 0 120px; }
#near-state { margin-top: 8px; }
#near-state .row { margin-top: 8px; }
.area-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.area-row:first-child { border-top: 0; }
.area-row select { width: auto; }
.source-head .tag + .tag { margin-left: 0; }
@media (max-width: 560px) {
  .profile-pick { flex-basis: 100%; order: 2; }
  .profile-pick select { flex: 1; max-width: none; }
  .near label:not(.grow) { flex: 1 1 110px; }
}
#near-state button { white-space: normal; text-align: left; }
