:root {
  --bg-deep: #0b1219;
  --panel: #141f2e;
  --panel-border: #223144;
  --text-primary: #eef2f6;
  --text-muted: #8b98a8;
  --accent: #2dd4bf;
  --accent-dim: #1a3d38;
  --danger: #e6636b;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-deep);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--bg-deep);
}

/* Leaflet controls — сдвигаем ниже топбара, приглушаем стиль под тёмную тему */
.leaflet-control-zoom {
  margin-top: 76px !important;
}
.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text-primary) !important;
  border-color: var(--panel-border) !important;
}
.leaflet-container {
  font-family: var(--font-body);
}

.hidden { display: none !important; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(to bottom, rgba(11,18,25,0.92), rgba(11,18,25,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.city-select, .locale-select {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  border-radius: 10px;
  padding: 8px 10px;
  max-width: 160px;
}
.locale-select { max-width: 70px; }

.balance-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 8px 16px;
}
.balance-label {
  font-size: 12px;
  color: var(--text-muted);
}
.balance-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--accent);
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-ghost {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
}
.btn-ghost:hover { border-color: var(--accent); }

.btn-accent {
  background: var(--accent);
  color: #06231f;
}
.btn-accent:hover { opacity: 0.9; }
.btn-accent:disabled {
  background: var(--panel-border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---------------- Legend ---------------- */
.legend {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 500;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  min-width: 168px;
}
.legend-title {
  color: var(--text-muted);
  margin-bottom: 2px;
  font-size: 11px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------------- House panel (bottom sheet) ---------------- */
.house-panel {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 600;
  width: min(380px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 20px 20px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

.panel-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.panel-close:hover { color: var(--text-primary); }

.house-zone-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.house-zone-tag::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--zone-color, var(--accent));
}

.house-address {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 14px;
  padding-right: 20px;
}

.house-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}
.stat-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
}

.house-owner-line {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.house-action-btn { width: 100%; padding: 12px; font-size: 15px; }

.locked-note {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.4;
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5,9,13,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  position: relative;
  width: min(340px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 22px 20px 20px;
}
.modal-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}
.modal-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.modal-tab.active {
  background: var(--panel-border);
  color: var(--text-primary);
}
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-form input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
}
.modal-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-form input::placeholder { color: var(--text-muted); }
.form-error {
  font-size: 12.5px;
  color: var(--danger);
  min-height: 16px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: absolute;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  z-index: 1200;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
}

/* ---------------- Map markers ---------------- */
.house-marker {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35);
}
.house-marker.owned {
  border-style: dashed;
  opacity: 0.55;
}

@media (max-width: 480px) {
  .brand { font-size: 16px; }
  .legend { min-width: 140px; padding: 10px 12px; }
}
