:root {
  --bg: #0e1218;
  --bg2: #151b24;
  --card: #1a2230;
  --card2: #202a3a;
  --text: #e8eef7;
  --muted: #8b98ab;
  --accent: #4cc38a;
  --accent2: #6ea8ff;
  --danger: #ff7a7a;
  --warn: #ffc966;
  --border: #2a3648;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(78,195,138,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(110,168,255,.07), transparent 55%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 22px;
  background: rgba(21,27,36,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-logo { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.brand-sub { color: var(--muted); font-size: 13px; }

.nav { display: flex; gap: 6px; margin-left: auto; }
.nav-link {
  color: var(--muted); text-decoration: none;
  padding: 8px 14px; border-radius: 10px; font-size: 14px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--card2); }
.nav-link.active { color: var(--text); background: var(--card2); }

.btn {
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); padding: 9px 16px; border-radius: 10px;
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #07201a; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); color: #07201a; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- layout ---------- */
.layout {
  flex: 1; display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0; min-height: 0;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
}

.map-wrap { position: relative; min-height: 0; }
#map { width: 100%; height: 100%; min-height: 320px; background: #0b0f15; }

/* ---------- legend ---------- */
.map-legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 10;
  background: rgba(21,27,36,.9); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: var(--muted);
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch.paid    { background: rgba(76,195,138,.75); border: 1.5px solid #4cc38a; }
.swatch.exempt  { background: rgba(140,152,171,.35); border: 1.5px solid #8b98ab; }
.swatch.pending { background: rgba(255,122,122,.20); border: 1.5px solid #ff7a7a; }
.swatch.chat_both { background: rgba(76,195,138,.75); border: 1.5px solid #4cc38a; }
.swatch.chat_tg   { background: rgba(110,168,255,.60); border: 1.5px solid #6ea8ff; }
.swatch.chat_max  { background: rgba(255,201,102,.60); border: 1.5px solid #ffc966; }
.swatch.chat_none { background: rgba(140,152,171,.18); border: 1.5px solid #5a6a80; }

.view-switch { top: 14px; left: 14px; bottom: auto; flex-direction: row; gap: 6px; padding: 6px; }
.btn-switch { border: none; background: transparent; padding: 6px 12px; font-size: 12.5px; color: var(--muted); border-radius: 8px; }
.btn-switch.active { background: var(--card2); color: var(--text); }

/* маркер геолокации «Вы здесь» */
.me-marker {
  width: 18px; height: 18px; border-radius: 50%;
  background: #4ea1ff; border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  animation: me-pulse 1.8s ease-out infinite;
}
@keyframes me-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(78,161,255,.55); }
  70%  { box-shadow: 0 0 0 16px rgba(78,161,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(78,161,255,0); }
}

/* юридические страницы */
.legal-page .legal { max-width: 860px; margin: 28px auto 60px; padding: 0 22px; }
.legal h1 { font-size: 26px; margin: 18px 0 6px; }
.legal h2 { font-size: 18px; margin: 26px 0 8px; }
.legal p { color: #cfd8e3; font-size: 14.5px; line-height: 1.7; margin: 8px 0; }
.legal a { color: var(--accent2); }
.fill { background: rgba(255,201,102,.15); border-bottom: 1px dashed var(--warn);
  padding: 1px 6px; border-radius: 4px; color: var(--warn); }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* cookie/гео-баннер */
.legal-banner {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 200;
  max-width: 880px; width: calc(100% - 32px);
  background: rgba(21,27,36,.96); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 14px 16px;
  display: flex; gap: 14px; align-items: center;
}
.legal-banner-text { font-size: 13px; color: var(--muted); line-height: 1.55; }
.legal-banner-text a { color: var(--accent2); }
.legal-banner .btn { flex-shrink: 0; }
.legal-banner[hidden] { display: none; }

.map-placeholder {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 24px; color: var(--muted); font-size: 13.5px; line-height: 1.6;
  background: repeating-linear-gradient(45deg, #0b0f15, #0b0f15 12px, #0d1219 12px, #0d1219 24px);
}

.map-hint {
  position: absolute; z-index: 11; pointer-events: none;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 13px;
  box-shadow: var(--shadow); transform: translate(-50%, -120%);
  white-space: nowrap;
}

/* ---------- panel ---------- */
.panel {
  background: var(--bg2); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 20px 18px;
  display: flex; flex-direction: column; gap: 18px;
}
@media (max-width: 860px) { .panel { border-left: none; border-top: 1px solid var(--border); } }

.panel-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.panel-section h2 { font-size: 15px; margin-bottom: 10px; letter-spacing: .2px; }
.panel-section > summary { list-style: none; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; cursor: pointer; min-height: 28px; }
.panel-section > summary::-webkit-details-marker { display: none; }
.panel-section > summary > h2 { margin-bottom: 0; }
.panel-section[open] > summary { margin-bottom: 10px; }
.panel-section > summary .chev { color: var(--muted); font-size: 12px; line-height: 1; transition: transform .2s; }
.panel-section[open] > summary .chev { transform: rotate(180deg); }
@media (max-width: 860px) {
  .panel-section:not([open]) { padding-top: 14px; padding-bottom: 14px; }
  .panel-section > summary { min-height: 44px; }
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }

/* карточка участка */
.card-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.card-line:last-child { border-bottom: none; }
.card-line .k { color: var(--muted); }
.card-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.paid    { background: rgba(76,195,138,.15); color: var(--accent); border: 1px solid rgba(76,195,138,.4); }
.badge.pending { background: rgba(255,122,122,.12); color: var(--danger); border: 1px solid rgba(255,122,122,.4); }
.badge.exempt  { background: rgba(140,152,171,.15); color: var(--muted); border: 1px solid rgba(140,152,171,.4); }
.badge.none    { background: rgba(110,168,255,.12); color: var(--accent2); border: 1px solid rgba(110,168,255,.4); }
.badge.chat_both { background: rgba(76,195,138,.15); color: var(--accent); border: 1px solid rgba(76,195,138,.4); }
.badge.chat_tg   { background: rgba(110,168,255,.15); color: var(--accent2); border: 1px solid rgba(110,168,255,.4); }
.badge.chat_max  { background: rgba(255,201,102,.15); color: var(--warn); border: 1px solid rgba(255,201,102,.4); }
.badge.chat_none { background: rgba(140,152,171,.12); color: var(--muted); border: 1px solid rgba(140,152,171,.4); }

/* прогресс сбора */
.progress { height: 10px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), #9be8c4); border-radius: 999px; transition: width .6s ease; }
.sbor-stat { font-size: 13px; color: var(--muted); }

.footer {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 22px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
  background: var(--bg2);
}

/* кнопка «Открыть Яндекс Карты» от ymaps3 висела поверх нашей легенды — прячем её;
   обязательный копирайт «© Яндекс / Условия использования» и логотип остаются */
.ymaps3--controls_bottom.ymaps3--controls_left > .ymaps3--control { display: none; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 12px; font-size: 13.5px;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
#toast.show { opacity: 1; }

/* ---------- мобильная адаптация ---------- */
html { -webkit-text-size-adjust: 100%; }

@media (max-width: 860px) {
  html, body { height: 100%; }
  body { min-height: 100vh; min-height: 100dvh; }

  .topbar { flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 16px; }
  .brand-logo { font-size: 20px; }
  .nav { order: 3; width: 100%; margin-left: 0; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-link { padding: 7px 11px; font-size: 13px; white-space: nowrap; }
  .auth { margin-left: auto; }
  #btn-login { padding: 8px 12px; font-size: 13px; }

  .layout { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
    grid-template-columns: none; grid-template-rows: none; }
  .map-wrap { flex: 1 1 auto; height: auto; min-height: 240px; }
  #map { min-height: 240px; }

  .panel { flex: 0 0 auto; border-left: none; border-top: 1px solid var(--border); padding: 14px 12px; gap: 14px; overflow: visible; }
  .panel-section { padding: 14px; }
  .panel-section:not([open]) { padding: 9px 14px; }
  .panel-section:not([open]) > summary { min-height: 40px; }

  .map-legend { left: 10px; bottom: 30px; padding: 8px 10px; font-size: 12px; gap: 5px; max-height: 34dvh; overflow: auto; }
  .map-legend.view-switch { top: 10px; left: 10px; bottom: auto; right: auto; height: fit-content; padding: 5px; gap: 4px; }
  .btn-switch { padding: 8px 11px; font-size: 12px; }

  .btn { min-height: 44px; padding: 11px 16px; }
  .card-actions .btn { width: 100%; }

  .legal-banner { flex-direction: column; align-items: stretch; gap: 10px; width: calc(100% - 20px);
    padding: 12px 14px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); max-height: 62dvh; overflow-y: auto; }
  .legal-banner .btn { width: 100%; }
  .legal-banner-text { font-size: 12.5px; }

  #toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 24px); }

  .footer { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; gap: 4px; padding: 10px 12px; font-size: 11.5px; }

  .legal-page .legal { margin: 18px auto 40px; padding: 0 14px; }
  .legal h1 { font-size: 22px; }
}

/* телефон в горизонтали: по ширине места хватает — карта слева, панель справа */
@media (orientation: landscape) and (max-height: 560px) {
  .layout { display: grid; grid-template-columns: 1fr min(44vw, 320px); grid-template-rows: 1fr; min-height: 0; }
  .map-wrap { height: auto; min-height: 200px; }
  .panel-section:not([open]) { padding: 9px 14px; }
  .panel-section:not([open]) > summary { min-height: 40px; }
  #map { min-height: 200px; }
  .panel { border-top: none; border-left: 1px solid var(--border); padding: 12px;
    max-height: calc(100dvh - 92px); overflow-y: auto; }
  .nav { width: auto; order: 2; }
  .auth { order: 3; }
  .legal-banner { flex-direction: row; align-items: center; max-height: 46dvh; }
  .legal-banner .btn { width: auto; }
}

/* узкие экраны */
@media (max-width: 380px) {
  .btn-switch { padding: 7px 9px; font-size: 11.5px; }
  .map-legend { font-size: 11.5px; padding: 7px 9px; }
}

/* на тач-устройствах hover-эффекты не залипают */
@media (hover: none) {
  .btn:hover { border-color: var(--border); color: var(--text); }
  .btn-primary:hover { filter: none; }
  .nav-link:hover { color: var(--muted); background: transparent; }
  .btn:active { border-color: var(--accent); }
}

