* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #0d0d0d;
  color: #e8e8e8;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #161616;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}
#topbar h1 { font-size: 18px; margin: 0; }
#topbar-actions { display: flex; align-items: center; gap: 14px; }
#scan-info { color: #777; font-size: 12px; }
#archive-toggle-wrap { font-size: 12px; color: #999; display: flex; align-items: center; gap: 4px; }

#manual-add-form { display: flex; gap: 6px; }
#manual-add-url {
  background: #111; color: #e8e8e8; border: 1px solid #2a2a2a; border-radius: 8px;
  padding: 7px 10px; font-size: 12px; width: 220px;
}
#manual-add-url:focus { border-color: #2563eb; outline: none; }

button {
  background: #1f1f1f;
  color: #e8e8e8;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { border-color: #555; }

#logout-btn {
  background: #1f1f1f; color: #999; border: 1px solid #333; border-radius: 8px;
  padding: 7px 11px; text-decoration: none; line-height: 1; display: inline-flex;
}
#logout-btn:hover { border-color: #c0392b; color: #ff6b6b; }
button.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
button.primary:hover { background: #1d4ed8; }

#board {
  display: flex;
  gap: 16px;
  padding: 20px;
  align-items: stretch;
  overflow-x: auto;
  flex: 1;
  min-height: 0;
}

.column {
  background: #131313;
  border: 1px solid #232323;
  border-radius: 12px;
  padding: 12px;
  flex: 1 0 270px;
  min-width: 270px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.column.drag-over { border-color: #2563eb; background: #131c2e; }
.column h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #999;
  margin: 4px 6px 12px;
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}
.count { color: #555; font-weight: 400; }

#new-sort-select {
  width: 100%; margin: -6px 0 10px; background: #161616; color: #999;
  border: 1px solid #2a2a2a; border-radius: 6px; padding: 5px 8px; font-size: 11px;
  flex-shrink: 0;
}

.cards {
  display: flex; flex-direction: column; gap: 10px; min-height: 40px;
  overflow-y: auto; flex: 1; padding-right: 4px;
}
.cards::-webkit-scrollbar { width: 8px; }
.cards::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }
.cards::-webkit-scrollbar-track { background: transparent; }

.card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
}
.card.dragging { opacity: .4; }
.card { touch-action: pan-y; }
.card.cheap { border-color: #2e7d32; box-shadow: 0 0 0 1px #2e7d3255; }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title {
  color: #e8e8e8;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.3;
}
.card-title:hover { color: #6ea8fe; }
.archive-btn, .delete-btn { padding: 2px 6px; font-size: 12px; flex-shrink: 0; }
.delete-btn:hover { border-color: #c0392b; color: #ff6b6b; }

.card-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.card-addr { color: #888; font-size: 12px; }
.card-source {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px; flex-shrink: 0;
  background: #17263f; color: #7aa7e8; border: 1px solid #23395c;
}
.card-source[data-source="kleinanzeigen"] { background: #1c2a16; color: #9ccc65; border-color: #2f4a22; }
/* Direktanbieter (Wohnungsunternehmen/Hausverwaltungen) einheitlich rot - Einzelfarben unten. */
.card-source.direct { background: #2e1a1b; color: #e57373; border-color: #4a2527; }
.card-source[data-source="dawonia"] { background: #10282b; color: #4dd0e1; border-color: #1c4247; }
.card-source[data-source="hvn"] { background: #2a2413; color: #ffd54f; border-color: #4a3f1f; }
.card-source[data-source="lpe"] { background: #241a2e; color: #ba68c8; border-color: #3d2a4a; }
.card-source[data-source="graf"],
.card-source[data-source="schlaugk"],
.card-source[data-source="iliev"],
.card-source[data-source="auctiora"] { background: #222; color: #bdbdbd; border-color: #3a3a3a; }
.card-cross { font-size: 11px; color: #ffb74d; }

.card-stats {
  display: flex; gap: 10px; margin-top: 8px; font-size: 12px; color: #ccc; flex-wrap: wrap;
}
.stat-psqm {
  margin-top: 4px; font-size: 13px; font-weight: 700; color: #51cf66;
}
.card.cheap .stat-psqm { color: #69db7c; }

.history-toggle { font-size: 11px; color: #666; margin-top: 8px; cursor: pointer; }
.history-toggle:hover { color: #999; }
.history-list { margin: 6px 0 0; padding-left: 16px; font-size: 11px; color: #999; }

.rating { margin-top: 10px; font-size: 16px; color: #444; }
.rating span { cursor: pointer; }
.rating span.filled { color: #ffd43b; }

.check-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #ccc; margin-top: 8px; }

.notes {
  width: 100%; margin-top: 8px; background: #111; color: #e8e8e8;
  border: 1px solid #2a2a2a; border-radius: 6px; padding: 6px 8px;
  font-size: 12px; font-family: inherit; min-height: 50px; resize: vertical;
}

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.overlay[hidden] { display: none; }
.modal {
  background: #161616; border: 1px solid #2a2a2a; border-radius: 12px;
  padding: 20px 24px; width: 340px; display: flex; flex-direction: column; gap: 12px;
  max-height: 88vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 4px; font-size: 16px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #999; }
.modal label.checkbox-row { flex-direction: row; align-items: center; gap: 8px; }
.modal input[type="number"],
.modal input[type="text"] {
  background: #111; color: #e8e8e8; border: 1px solid #2a2a2a; border-radius: 6px; padding: 7px 9px; font-size: 13px;
}
.modal label small { color: #666; font-size: 11px; line-height: 1.4; }
.modal fieldset { border: 1px solid #333; border-radius: 8px; padding: 8px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.modal legend { font-size: 12px; color: #999; padding: 0 4px; }
#set-sources { display: flex; flex-direction: column; gap: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.login-body { align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: #161616; border: 1px solid #2a2a2a; border-radius: 14px;
  padding: 36px 32px; width: 300px; display: flex; flex-direction: column; gap: 14px;
  margin: auto;
}
.login-icon { font-size: 32px; text-align: center; }
.login-card h1 { font-size: 17px; text-align: center; margin: 0 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #999; }
.login-card input {
  background: #111; color: #e8e8e8; border: 1px solid #2a2a2a; border-radius: 8px;
  padding: 9px 11px; font-size: 14px;
}
.login-card input:focus { border-color: #2563eb; outline: none; }
.login-card button { padding: 10px; font-size: 14px; margin-top: 4px; }
.login-error {
  background: #2a1414; border: 1px solid #5c2323; color: #ff8080;
  border-radius: 8px; padding: 8px 10px; font-size: 12px; text-align: center;
}

/* ── Mobile Tab Navigation ──────────────────────────────────────────────────── */
#tab-bar { display: none; }

@media (max-width: 700px) {
  body { overflow: auto; }

  #topbar { padding: 10px 12px; flex-wrap: wrap; gap: 6px; }
  #topbar h1 { font-size: 15px; }
  #topbar-actions { gap: 8px; }
  #manual-add-form { display: none; }
  #scan-info { display: none; }
  #archive-toggle-wrap { display: none; }

  #board {
    flex-direction: column;
    overflow: hidden;
    padding: 0 0 64px;
    gap: 0;
  }

  .column {
    display: none;
    min-width: unset;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    background: transparent;
    height: calc(100dvh - 110px);
    padding: 10px 12px;
  }
  .column.mobile-active { display: flex; }

  #tab-bar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #161616;
    border-top: 1px solid #2a2a2a;
    z-index: 50;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0);
    scrollbar-width: none;
  }
  #tab-bar::-webkit-scrollbar { display: none; }

  .tab-btn {
    flex: 1 0 auto;
    min-width: 56px;
    padding: 10px 10px 12px;
    font-size: 11px;
    text-align: center;
    color: #666;
    cursor: pointer;
    border: none;
    border-top: 2px solid transparent;
    background: none;
    border-radius: 0;
    white-space: nowrap;
  }
  .tab-btn.active { color: #6ea8fe; border-top-color: #2563eb; }
}

/* Suchprofil-/Stadt-Auswahl und Profile in den Einstellungen */
#city-select { background: #222; color: #ddd; border: 1px solid #444; border-radius: 6px; padding: 4px 6px; }
.profile-row { border-top: 1px solid #333; padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }

/* Vermietung (IS24-Exposé) */
.card-extra { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; margin-top: 4px; }
.rent-badge { padding: 1px 6px; border-radius: 8px; font-weight: 600; }
.rent-badge.empty { background: #2b8a3e; color: #fff; }
.rent-badge.rented { background: #c92a2a; color: #fff; }
.rent-badge.unknown { background: #495057; color: #dee2e6; }
.card-facts { color: #adb5bd; }
