* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; background: #111827; color: #e5e7eb; }

/* Login */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: #111827;
}
.login-box {
  background: #1f2937; padding: 2rem; border-radius: 12px;
  border: 1px solid #374151; text-align: center; width: 320px;
  max-width: 90vw;
}
.login-box h1 { font-size: 1.4rem; margin-bottom: 1.5rem; }
.login-box input {
  width: 100%; padding: 10px 12px; background: #374151;
  border: 1px solid #4b5563; border-radius: 6px; color: #e5e7eb;
  font-size: 0.9rem; margin-bottom: 0.8rem;
}
.login-box button {
  width: 100%; padding: 10px; background: #10b981; color: #fff;
  border: none; border-radius: 6px; font-size: 0.9rem; cursor: pointer;
}
.login-box button:hover { background: #059669; }
.error { color: #ef4444; font-size: 0.8rem; margin-top: 0.5rem; }

/* ===== App layout ===== */
#app-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: relative; overflow: hidden; }

/* Mobile bar — hidden on desktop */
#mobile-bar { display: none; }

/* Filter close button — hidden on desktop */
#filter-close { display: none; }

/* ===== Desktop filter bar (inline) ===== */
#filter-bar {
  background: #1f2937; padding: 8px 16px; display: flex; gap: 10px;
  align-items: center; flex-wrap: wrap; border-bottom: 1px solid #374151;
  flex-shrink: 0;
}
.filter-group { display: flex; gap: 6px; align-items: center; }
.filter-group label { font-size: 0.7rem; color: #9ca3af; white-space: nowrap; }
.filter-group input, .filter-group select {
  background: #374151; border: 1px solid #4b5563; color: #e5e7eb;
  padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; width: 70px;
}
.filter-group select { width: auto; }
.filter-group input[type="date"] { width: 115px; }
.range-inputs { display: flex; gap: 6px; align-items: center; }
.separator { color: #6b7280; font-size: 0.7rem; }
.divider { width: 1px; height: 20px; background: #374151; }
.filter-right { margin-left: auto; }

/* Mobile-only elements hidden on desktop */
.mobile-only { display: none; }
.toggle-label { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 0.7rem; color: #9ca3af; white-space: nowrap; }
.toggle-label input[type="checkbox"] { accent-color: #10b981; width: auto; }

/* Map */
#map { flex: 1; min-height: 0; }

/* ===== Footer ===== */
#footer {
  background: #1f2937; padding: 6px 12px; display: flex;
  justify-content: space-between; align-items: center;
  border-top: 1px solid #374151; flex-shrink: 0;
}
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stats span { font-size: 0.7rem; color: #9ca3af; white-space: nowrap; }
.stats strong { color: #e5e7eb; }
.scraper-controls { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.indicator { width: 8px; height: 8px; border-radius: 50%; }
.indicator.active { background: #10b981; animation: pulse 2s infinite; }
.indicator.inactive { background: #6b7280; }
#scraper-status { font-size: 0.7rem; white-space: nowrap; }
#scraper-btn {
  background: #374151; border: 1px solid #4b5563; color: #e5e7eb;
  padding: 3px 10px; border-radius: 4px; font-size: 0.7rem; cursor: pointer;
}

/* ===== Popup ===== */
.listing-popup { font-size: 0.75rem; line-height: 1.4; max-width: 260px; }
.listing-popup img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; margin-bottom: 6px; }
.listing-popup .price { font-weight: bold; font-size: 0.85rem; }
.listing-popup .deviation { font-weight: bold; }
.listing-popup .deviation.positive { color: #c0392b; }
.listing-popup .deviation.negative { color: #27ae60; }
.listing-popup .sold-date { color: #9ca3af; font-size: 0.72rem; margin: 2px 0; }
.listing-popup .details { color: #666; margin: 4px 0; }
.listing-popup a { color: #6366f1; text-decoration: none; }
.listing-popup a:hover { text-decoration: underline; }

/* ===== Loading bar ===== */
#loading-bar {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(31, 41, 55, 0.9);
  padding: 6px 16px;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: #9ca3af;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
#loading-bar strong { color: #10b981; }
.loading-spinner {
  width: 14px; height: 14px;
  border: 2px solid #374151;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Heatmap glow / flash ===== */
.glow-marker { filter: blur(8px); }
.flash-burst {
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,0.9) 0%, rgba(16,185,129,0) 70%);
  animation: flashShrink 1.5s ease-out forwards;
  pointer-events: none;
}
@keyframes flashShrink {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.1); opacity: 0; }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }


/* ============================================================
   MOBILE  (< 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- Mobile top bar with filter button + quick toggles --- */
  #mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1f2937;
    padding: 6px 12px;
    border-bottom: 1px solid #374151;
    flex-shrink: 0;
    z-index: 1001;
  }
  #filter-toggle {
    display: flex; align-items: center; gap: 6px;
    background: #374151; border: 1px solid #4b5563; color: #e5e7eb;
    padding: 6px 12px; border-radius: 6px; font-size: 0.8rem;
    cursor: pointer;
  }
  #filter-toggle svg { opacity: 0.7; }
  .mobile-toggles {
    display: flex; gap: 12px; align-items: center;
  }
  .mobile-toggles .toggle-label { font-size: 0.75rem; }

  /* --- Hide desktop-only elements, show mobile-only --- */
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }

  /* --- Filter bar: full-width overlay panel --- */
  #filter-bar {
    display: none;           /* hidden by default */
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 1002;
    background: #1f2937;
    border-bottom: 2px solid #10b981;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    padding: 16px;
    flex-direction: column;
    align-items: stretch;    /* override desktop center → full width rows */
    gap: 0;
  }
  #filter-bar.open {
    display: flex;
  }

  /* Hide desktop dividers on mobile */
  #filter-bar .divider { display: none; }

  /* Each filter-group: simple flexbox row */
  #filter-bar .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #1a2332;
  }
  #filter-bar .filter-group:last-of-type {
    border-bottom: none;
  }

  /* Label: fixed width, left-aligned, right-padded */
  #filter-bar .filter-group > label {
    width: 85px;
    min-width: 85px;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: left;
  }

  /* Range-inputs wrapper: inline flex */
  #filter-bar .filter-group .range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  /* Shared input/select sizing on mobile */
  #filter-bar .filter-group input,
  #filter-bar .filter-group select {
    font-size: 0.85rem;
    padding: 8px 10px;
    border-radius: 6px;
  }
  #filter-bar .filter-group input[type="number"] { width: 80px; }
  #filter-bar .filter-group input[type="date"] { width: 140px; }
  #filter-bar .filter-group select { width: auto; min-width: 80px; max-width: 160px; }

  /* Separator inside range-inputs */
  #filter-bar .filter-group .range-inputs .separator {
    font-size: 0.85rem;
    color: #6b7280;
  }

  /* "Fertig" close button */
  #filter-close {
    display: block;
    margin-top: 8px;
    padding: 10px;
    background: #10b981;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
  }
  #filter-close:active { background: #059669; }

  /* --- Footer: compact row --- */
  #footer {
    padding: 5px 10px;
    gap: 4px;
  }
  .stats { gap: 8px; }
  .stats span { font-size: 0.6rem; }
  .scraper-controls { gap: 4px; }
  #scraper-status { font-size: 0.6rem; }
  #scraper-btn { font-size: 0.6rem; padding: 2px 8px; }

  /* Popup */
  .listing-popup { max-width: 240px; }
  .listing-popup img { height: 80px; }
}
