:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --top: #f97316;
  --zajimave: #22c55e;
  --proverit: #eab308;
  --nezajimave: #9ca3af;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --border: #2a2e37;
    --text: #f1f2f4;
    --text-muted: #9aa0ab;
    --accent-light: #1e3a5f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.app-header .logo {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.app-header .logo span { color: var(--accent); }

.select-input, .text-input {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.chip:hover { border-color: var(--accent); color: var(--text); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-bar .count-label {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Main grid ---- */
.main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  overflow: hidden;
  min-height: 0;
}

@media (max-width: 860px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.9rem;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0.3rem 0 0.7rem;
}

/* ---- Opportunity card ---- */
.opp-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.opp-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.opp-card-top {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.opp-score {
  font-size: 1.15rem;
  font-weight: 800;
}

.opp-score-max { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

.opp-title { font-weight: 700; font-size: 0.92rem; margin: 0.1rem 0 0.5rem; }

.opp-return {
  display: flex;
  gap: 1.2rem;
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
}

.opp-return .label { display: block; font-size: 0.68rem; }
.opp-return-num { font-size: 1.05rem; }

.opp-sub { font-size: 0.78rem; color: var(--text-muted); }
.opp-sub .dot { margin: 0 0.25rem; }

.opp-meta {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
}

.opp-meta b { display: block; font-size: 0.88rem; }
.opp-meta .label { color: var(--text-muted); }

.discount-positive { color: var(--zajimave); }
.discount-negative { color: var(--danger); }

.opp-explain {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.45rem 0 0;
  line-height: 1.35;
}

.opp-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
}

.tag-drop { color: var(--zajimave); border-color: var(--zajimave); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.badge-top { background: color-mix(in srgb, var(--top) 18%, transparent); color: var(--top); }
.badge-zajimave { background: color-mix(in srgb, var(--zajimave) 18%, transparent); color: var(--zajimave); }
.badge-proverit { background: color-mix(in srgb, var(--proverit) 22%, transparent); color: #92720a; }
.badge-nezajimave { background: color-mix(in srgb, var(--nezajimave) 18%, transparent); color: var(--text-muted); }

/* ---- Map ---- */
.map-wrap { position: relative; height: 100%; }
#map { width: 100%; height: 100%; background: #dfe3e8; }

.map-control {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.6rem 0.7rem;
  font-size: 0.78rem;
}

.layer-switcher {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 165px;
}

.layer-switcher .opt {
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}

.layer-switcher .opt.active { background: var(--accent-light); color: var(--accent); }

.map-legend {
  position: absolute;
  bottom: 14px;
  left: 12px;
  z-index: 500;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0.25rem; }

.leaflet-popup-content { font-size: 0.85rem; min-width: 190px; }
.popup-score { font-weight: 800; font-size: 1.1rem; }
.popup-title { font-weight: 700; margin: 0.2rem 0; }
.popup-link { display: inline-block; margin-top: 0.4rem; color: var(--accent); font-weight: 700; font-size: 0.8rem; }

/* ---- Mobile tabs ---- */
.mobile-tabs {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .mobile-tabs { display: flex; }
  .sidebar, .map-wrap { display: none; }
  .main-grid.show-list .sidebar { display: block; }
  .main-grid.show-map .map-wrap { display: block; }
}

.mobile-tabs button {
  flex: 1;
  padding: 0.8rem;
  background: none;
  border: none;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.mobile-tabs button.active { color: var(--accent); border-top: 2px solid var(--accent); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.85rem;
}

/* ---- Property detail page ---- */
.muted { color: var(--text-muted); }

.detail-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.back-link {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.back-link:hover { color: var(--accent); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1rem;
}

.detail-score { display: flex; align-items: baseline; gap: 0.35rem; margin-bottom: 0.4rem; }
.detail-score-emoji { font-size: 1.3rem; }
.detail-score-num { font-size: 1.8rem; font-weight: 800; }
.detail-score-max { font-size: 0.85rem; color: var(--text-muted); font-weight: 700; margin-right: 0.4rem; }

.detail-header-main h1 { font-size: 1.15rem; margin: 0.1rem 0 0.3rem; }
.detail-price-row { font-size: 0.85rem; }

.detail-return-hero {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.detail-return-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-return-num { font-size: 1.5rem; font-weight: 800; }
.detail-return-num.is-good { color: var(--zajimave); }
.detail-return-num.is-bad { color: var(--danger); }

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.panel h3 { font-size: 0.85rem; margin: 0 0 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.panel h4 { font-size: 0.8rem; margin: 0 0 0.4rem; }

.panel-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .panel-pair { grid-template-columns: 1fr; } }

.reason-list, .risk-list { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; line-height: 1.9; }
.reason-list li { color: var(--text); }
.risks-block { margin-top: 0.8rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
.risk-list li { color: #92720a; }

.compare-row { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; font-size: 0.82rem; }
.compare-label { color: var(--text-muted); }
.compare-track { background: var(--bg); border-radius: 6px; height: 10px; overflow: hidden; }
.compare-bar { height: 100%; border-radius: 6px; }
.bar-ask { background: var(--accent); }
.bar-market { background: var(--nezajimave); }
.bar-score { background: var(--accent); }
.compare-value { font-weight: 700; white-space: nowrap; font-size: 0.8rem; }

.confidence-line { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.6rem; }
.low-confidence { color: var(--danger); }

.score-row { display: grid; grid-template-columns: 110px 1fr 50px; align-items: center; gap: 0.6rem; margin-bottom: 0.45rem; font-size: 0.8rem; }
.score-row-label { color: var(--text-muted); }
.score-row-value { text-align: right; font-weight: 700; }

.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem; }
.fact-grid .label { display: block; font-size: 0.7rem; color: var(--text-muted); }
.fact-grid b { font-size: 0.88rem; }

.small-note { font-size: 0.75rem; margin-top: 0.5rem; }

.mock-banner {
  background: color-mix(in srgb, var(--proverit) 15%, transparent);
  border: 1px solid var(--proverit);
  color: #7a5d06;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
}

.source-link {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
}

.photo-gallery {
  margin-bottom: 0.9rem;
  border-radius: var(--radius);
  overflow: hidden;
}

.photo-gallery img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
}

.photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.photo-empty-icon { font-size: 1.8rem; }

/* ---- Ziva tecka pro tichou automatiku (viz dashboard.js autoCycle) ---- */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--zajimave);
  margin-right: 0.35rem;
  animation: live-dot-pulse 1.4s ease-in-out infinite;
}

@keyframes live-dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--zajimave) 55%, transparent); }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px color-mix(in srgb, var(--zajimave) 0%, transparent); }
}

/* ---- Sber e-mailu na nove TOP prilezitosti (jen verejny web) ---- */
.lead-box {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  margin-top: 0.9rem;
}

.lead-title {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.lead-sub {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.lead-row { display: flex; gap: 0.4rem; }

.lead-input { flex: 1; min-width: 0; }

.lead-btn {
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.lead-btn:hover { filter: brightness(1.08); }
.lead-btn:disabled { opacity: 0.6; cursor: default; }

.lead-msg { margin: 0.5rem 0 0; font-size: 0.8rem; font-weight: 600; }
.lead-msg.is-good { color: var(--zajimave); }
.lead-msg.is-bad { color: var(--danger); }

.lead-note {
  margin: 0.5rem 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}
