* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #1d2733; }

#app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; }

#sidebar {
  overflow-y: auto;
  background: #f7f9fc;
  border-right: 1px solid #d8dee8;
  padding: 16px;
}

#sidebar header h1 { margin: 0; font-size: 1.5rem; }
#sidebar header p { margin: 4px 0 16px; }
.muted { color: #6b7785; }
.small { font-size: 0.8rem; }

.panel {
  background: white;
  border: 1px solid #e1e7ef;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5a6877;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel.collapsible h2.collapse-toggle { cursor: pointer; user-select: none; }
.panel.collapsible h2.collapse-toggle .caret { font-size: 0.9rem; color: #94a3b8; }
.panel.collapsible[data-open="false"] .collapse-body { display: none; }
.panel.collapsible[data-open="false"] h2 { margin-bottom: 0; }

.panel label {
  display: block;
  font-size: 0.9rem;
  padding: 3px 0;
  cursor: pointer;
  user-select: none;
}
.panel select, .panel input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cdd5e0;
  border-radius: 6px;
  font-size: 0.95rem;
  background: white;
}
.panel input[type="range"] { width: 100%; }
.panel button {
  display: inline-block;
  margin: 3px 4px 3px 0;
  padding: 6px 10px;
  background: #2563eb;
  color: white;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
}
.panel button:hover { background: #1d4ed8; }
.panel button.primary {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  font-weight: 600;
}

.row { margin: 6px 0; }

/* Search */
.search-panel { position: relative; }
.search-box { position: relative; }
.search-box input {
  width: 100%;
  padding: 9px 36px 9px 12px;
  border: 1px solid #cdd5e0;
  border-radius: 6px;
  font-size: 0.95rem;
  background: white;
}
.search-box input:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }
.icon-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent !important;
  color: #6b7785 !important;
  font-size: 1.3rem;
  cursor: pointer;
  display: none;
  margin: 0 !important;
  padding: 0 !important;
}
.icon-btn.visible { display: block; }
.icon-btn:hover { background: #eef2f7 !important; }

.search-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 0.8rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #eef2f7;
  border-radius: 12px;
  font-size: 0.78rem;
  cursor: pointer;
  margin: 2px 2px;
}
.chip input { margin: 0; }
.chip:has(input:checked) { background: #dbeafe; color: #1e40af; }

.cat-chips { display: flex; flex-wrap: wrap; margin: 6px 0; }
.cat-chips.small-chips .chip { font-size: 0.72rem; padding: 2px 6px; }

.suggest {
  margin-top: 8px;
  background: white;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  position: absolute;
  left: 12px; right: 12px;
  z-index: 30;
}
.suggest.hidden { display: none; }
.suggest .item {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  cursor: pointer;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: start;
}
.suggest .item:last-child { border-bottom: 0; }
.suggest .item:hover, .suggest .item.active { background: #eaf2ff; }
.suggest .icon {
  width: 24px;
  height: 24px;
  background: #2563eb;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
}
.suggest .icon.t-residential { background: #f59e0b; }
.suggest .icon.t-shop { background: #10b981; }
.suggest .icon.t-admin { background: #2563eb; }
.suggest .icon.t-transportation { background: #6366f1; }
.suggest .icon.t-venue { background: #ef4444; }
.suggest .icon.t-country { background: #1d4ed8; }
.suggest .name { font-weight: 600; font-size: 0.92rem; }
.suggest .name mark { background: #fef08a; padding: 0 2px; border-radius: 2px; }
.suggest .addr { color: #6b7785; font-size: 0.8rem; line-height: 1.3; }
.suggest .meta { color: #94a3b8; font-size: 0.72rem; margin-top: 2px; }
.suggest .empty { padding: 12px; color: #6b7785; font-size: 0.85rem; text-align: center; }

/* Result lists (nearby + offers) */
.result-list {
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px dashed #e1e7ef;
}
.result-list .item {
  padding: 7px 4px;
  border-bottom: 1px solid #f0f3f8;
  cursor: pointer;
}
.result-list .item:hover { background: #eaf2ff; }
.result-list .item:last-child { border-bottom: 0; }
.result-list .ttl { font-size: 0.88rem; font-weight: 600; }
.result-list .sub { color: #6b7785; font-size: 0.78rem; margin-top: 2px; line-height: 1.35; }
.result-list .badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 0.7rem;
  margin-right: 4px;
  background: #dbeafe;
  color: #1e40af;
}
.result-list .badge.green { background: #dcfce7; color: #166534; }
.result-list .badge.amber { background: #fef3c7; color: #854d0e; }
.result-list .empty { color: #94a3b8; padding: 10px; text-align: center; font-size: 0.85rem; }
.result-list .item .dist { float: right; color: #94a3b8; font-size: 0.72rem; }

/* Map + toolbar */
#map-container { position: relative; }
#map { position: absolute; inset: 0; }
#map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
}
.map-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  color: #1d2733;
}
.map-tool:hover { background: #eaf2ff; }
.map-tool.active { background: #2563eb; color: white; border-color: #1d4ed8; }
.map-tool .ico { font-size: 1rem; }
.hint {
  background: rgba(0,0,0,0.78);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
}
.hint.hidden { display: none; }

#map.cursor-streetview { cursor: crosshair; }

/* Popups */
.maplibregl-popup-content {
  font-size: 0.85rem;
  max-width: 320px;
  padding: 12px 14px;
}
.maplibregl-popup-content h3 { margin: 0 0 6px; font-size: 0.95rem; }
.maplibregl-popup-content table { border-collapse: collapse; width: 100%; }
.maplibregl-popup-content td { padding: 2px 6px 2px 0; vertical-align: top; }
.maplibregl-popup-content td:first-child { color: #6b7785; white-space: nowrap; }
.popup-loading { color: #6b7785; font-style: italic; }
.popup-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.popup-actions a, .popup-actions button {
  background: #2563eb; color: white;
  border: 0; padding: 4px 8px; border-radius: 4px;
  text-decoration: none; font-size: 0.78rem; cursor: pointer;
}
.popup-actions a.secondary, .popup-actions button.secondary { background: #6b7785; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65);
}
.modal-card {
  position: relative;
  width: min(92vw, 1100px);
  height: min(85vh, 720px);
  background: #0f172a;
  color: white;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-head .icon-btn { color: white !important; position: static; transform: none; }
.modal-head .icon-btn:hover { background: rgba(255,255,255,0.12) !important; }
.modal-head .muted { color: #94a3b8; margin-left: 8px; }
.modal-foot {
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: flex-end;
}
.modal-empty { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px; color: #94a3b8; }
.modal-empty.hidden { display: none; }
#sv-pano { flex: 1; background: #000; }
.link { color: #93c5fd; text-decoration: none; font-size: 0.85rem; }
.link:hover { text-decoration: underline; }
.link.hidden { display: none; }

@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #sidebar { max-height: 50vh; }
}
