:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --gray: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #111827;
  background: #f9fafb;
  color-scheme: light;
}

body {
  display: flex;
  flex-direction: column;
  /* iOS Safari: 100% считается по «большому» вьюпорту и низ уезжает
     под панель браузера; dvh — реально видимая высота */
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 1001;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  margin: 0; /* логотип — h1 */
}

.logo span { color: var(--green); }

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

.support-chip {
  border-color: var(--green);
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: none;
}

.support-btn {
  display: inline-block;
  text-decoration: none;
}

.disclaimer {
  padding: 6px 14px;
  background: var(--green-bg);
  color: #374151;
  font-size: 12px;
  line-height: 1.35;
  border-bottom: 1px solid var(--border);
  z-index: 1001;
}

.about-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  color: var(--green-dark);
  text-decoration: underline;
  cursor: pointer;
}

#about p { font-size: 14px; line-height: 1.5; }
#about h3 { margin: 14px 0 4px; font-size: 15px; }
#about a { color: var(--green-dark); }

.content {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative; /* якорь для переключателя карта/список */
}

#map {
  flex: 1;
  min-height: 0;
  z-index: 1;
}

/* Список парковок */
#list-panel {
  width: 360px;
  flex-shrink: 0;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 12px 14px;
}

.list-title {
  margin: 2px 0 10px;
  font-size: 16px;
}

.list-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  background: #fff;
}

.list-item:hover { border-color: var(--green); }

.list-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-item-head .muted { margin: 0 0 0 auto; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-good { background: var(--green); }
.dot-bad { background: var(--red); }
.dot-neutral { background: #9ca3af; }

.list-item-desc {
  font-size: 14px;
  margin: 6px 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-item-meta {
  font-size: 13px;
  color: var(--gray);
}

/* Переключатель карта/список (только мобильные) —
   позиционируется от начала карты, а не от фиксированной высоты,
   поэтому не пересекается с плашкой любого размера */
.view-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  background: #fff;
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
  gap: 4px;
}

.toggle-btn {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}

.toggle-btn.active {
  background: var(--green);
  color: #fff;
}

@media (max-width: 899px) {
  #list-panel { display: none; }
  .view-toggle { display: flex; }

  body.view-list #list-panel {
    display: block;
    width: 100%;
    border-right: none;
    padding-top: 66px; /* под переключателем */
  }


  body.view-list #map,
  body.view-list .fab,
  body.view-list .locate-fab { display: none; }
}

/* Маркеры */
.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  border: 2px solid #fff;
  box-shadow: var(--shadow);
}

.pin > span { transform: rotate(45deg); }
.pin-good { background: var(--green); }
.pin-bad { background: var(--red); }
.pin-neutral { background: #4b5563; }

.locate-fab {
  position: absolute; /* внутри .content — не зависит от вьюпорта браузера */
  right: 14px;
  bottom: 96px;
  z-index: 1002;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 16px;
  background: #fff;
  color: #374151;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.locate-fab:active { color: var(--green); }

.fab {
  position: absolute; /* внутри .content — не зависит от вьюпорта браузера */
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 1002;
  background: linear-gradient(180deg, #1fb457, var(--green));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.4);
  cursor: pointer;
}

.fab:active {
  background: var(--green-dark);
  transform: translateX(-50%) scale(0.97);
}

.hint {
  position: absolute; /* внутри .content, под переключателем */
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
  max-width: calc(100% - 28px);
}

.hint-cancel {
  background: none;
  border: none;
  color: #86efac;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

/* Нижняя шторка */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1003;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 78vh;
  overflow-y: auto;
}

.sheet-grip {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: #d1d5db;
  margin: 4px auto 10px;
}

.sheet h2 { margin: 0 0 6px; font-size: 20px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.muted { color: var(--gray); font-size: 13px; margin: 2px 0 10px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--gray); margin-bottom: 4px; }

textarea, select, input[type="text"], input[type="password"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
  font-family: inherit;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn-primary:active { background: var(--green-dark); }
.btn-small { padding: 7px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Карточка точки */
.status-line {
  background: var(--green-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.vote-row { display: flex; gap: 10px; margin: 10px 0; }

.vote-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.vote-btn.active-up { background: var(--green); border-color: var(--green); color: #fff; }
.vote-btn.active-down { background: var(--red); border-color: var(--red); color: #fff; }

.section { margin: 14px 0; }
.section h3 { margin: 0 0 8px; font-size: 15px; }

.photos-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

.photos-strip img {
  height: 90px;
  border-radius: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Просмотрщик фото */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1010;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}

.lb-btn {
  position: absolute;
  z-index: 1;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-close {
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  font-size: 30px;
  line-height: 1;
  padding-bottom: 4px;
}

.lb-prev { left: 10px; }
.lb-next { right: 10px; }

.lb-counter {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 4px 12px;
}

.comment {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  font-size: 14px;
}

.comment .muted { margin: 2px 0 0; }

.history-list { font-size: 13px; color: var(--gray); margin: 6px 0 0; padding-left: 0; list-style: none; }
.history-list li { padding: 2px 0; }

details summary { cursor: pointer; font-size: 14px; color: var(--gray); }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1005;
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: calc(100% - 28px);
  text-align: center;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

/* На широких экранах шторки не растягиваются на всю ширину */
@media (min-width: 900px) {
  .sheet {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 440px;
    border-radius: 20px;
    max-height: calc(100vh - 160px);
  }
}

/* Админка */
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 16px; width: 100%; }
.admin-wrap h1 { font-size: 22px; }
.admin-wrap h1 span { color: var(--green); }

.tabs { display: flex; gap: 8px; margin: 14px 0; }

.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.tab.active { background: var(--green); border-color: var(--green); color: #fff; }

.item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}

.item-card img { max-height: 140px; border-radius: 10px; display: block; margin: 8px 0; }
.item-card .row { margin-top: 8px; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

.login-box { max-width: 360px; margin: 10vh auto; }
