:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e8eef4;
  --muted: #9aabbc;
  --accent: #3d9b6e;
  --border: #2a3542;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

#app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, #15202b 0%, var(--panel) 100%);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand span { color: var(--accent); }

.city-select,
.filters input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font: inherit;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

.filters label {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.filters .field-check input {
  width: auto;
  margin: 0;
}

.meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.lang-btn {
  background: var(--bg);
  color: var(--muted);
  border: 0;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.tg-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.tg-link:hover {
  text-decoration: underline;
}

.lang-btn + .lang-btn {
  border-left: 1px solid var(--border);
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

.map-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: #1c2834;
}

.list-panel {
  position: absolute;
  left: 12px;
  bottom: 52px;
  z-index: 950;
  width: min(400px, calc(100% - 24px));
  max-height: min(55vh, 480px);
  background: rgba(26, 34, 44, 0.97);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-panel[hidden] {
  display: none !important;
}

.list-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.list-panel-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.list-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.list-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}

.list-close:hover {
  color: var(--text);
}

.list-panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

#list-search {
  margin: 8px 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

#list-search::placeholder {
  color: var(--muted);
}

.list-items {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.list-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 10px;
  align-items: start;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #243040;
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: none;
  color: inherit;
  font: inherit;
}

.list-item:hover,
.list-item.active {
  background: rgba(61, 155, 110, 0.12);
}

.list-item-price {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

.list-item-main {
  min-width: 0;
}

.list-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-item-addr {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.list-item--thumb {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.list-item-thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: #243040;
}

.list-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.list-item-body {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 8px;
  align-items: start;
}

.list-item-remove {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.list-item-remove:hover {
  color: #f87171;
}

.fav-count {
  margin-left: 4px;
  font-size: 11px;
  color: var(--accent);
}

.list-toggle-btn.has-count {
  border-color: var(--accent);
}

.popup-thumb {
  margin: -4px -4px 8px;
  border-radius: 8px;
  overflow: hidden;
  max-height: 140px;
  background: #243040;
}

.popup-thumb img {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  display: block;
}

.popup-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  margin: 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.popup-actions {
  margin-top: 8px;
}

.popup-fav-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.popup-fav-btn:hover {
  text-decoration: underline;
}

.favorites-panel {
  right: auto;
  left: 12px;
  bottom: 56px;
  width: min(360px, calc(100vw - 24px));
  max-height: min(52vh, 420px);
}

.list-empty {
  padding: 16px 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.map-bottom-bar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.map-bottom-bar > * {
  pointer-events: auto;
}

.list-toggle-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(26, 34, 44, 0.96);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.list-toggle-btn:hover,
.list-toggle-btn.active {
  border-color: var(--accent);
  background: rgba(61, 155, 110, 0.2);
}

@media (max-width: 768px) {
  .list-panel {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: 48px;
    max-height: min(50vh, 400px);
  }

  .map-bottom-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
}

/* Leaflet 1.9+ ставит флаг в attribution — прячем ссылку на leafletjs на всякий случай */
.leaflet-control-attribution a[href*="leafletjs.com"] {
  display: none !important;
}

.popup h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.leaflet-popup-content .popup {
  min-width: 220px;
  max-width: 280px;
}

.popup p {
  margin: 0.2rem 0;
  font-size: 0.9rem;
  color: #334;
}

.popup a {
  color: #1a7a4c;
  font-weight: 600;
}

.marker-price {
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  white-space: nowrap;
}

.marker-price--manual {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 1px 4px rgba(0,0,0,.35);
}

.feedback-panel {
  position: absolute;
  right: 12px;
  bottom: 52px;
  z-index: 960;
  width: min(360px, calc(100% - 24px));
  max-height: min(60vh, 480px);
  background: rgba(26, 34, 44, 0.98);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.feedback-panel[hidden] {
  display: none !important;
}

.feedback-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.feedback-panel-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}

.feedback-form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.feedback-kind {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.feedback-kind label {
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.feedback-field textarea,
.feedback-field input {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}

.feedback-listing-hint {
  margin: 0;
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
}

.feedback-submit {
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.feedback-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.feedback-status {
  margin: 0;
  font-size: 12px;
}

.feedback-status[data-state="success"] { color: #4ade80; }
.feedback-status[data-state="error"] { color: #f87171; }
.feedback-status[data-state="pending"] { color: var(--muted); }

.feedback-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.feedback-toggle-btn.active {
  border-color: var(--accent);
  background: rgba(61, 155, 110, 0.2);
}

.popup .feedback-link {
  display: inline-block;
  margin-top: 0.35rem;
  color: #f59e0b;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.popup .feedback-link:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .feedback-panel {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: 48px;
  }
}
