:root {
  color-scheme: light;
  --ink: #15201c;
  --muted: #66736d;
  --line: #dfe8e4;
  --paper: #fbfdfb;
  --green: #16834a;
  --yellow: #c68b00;
  --red: #b63d32;
  --gray: #7d8782;
}

* { box-sizing: border-box; }
html, body, #map { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef3f0;
}

.topbar {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

/* строка поиска */
.searchbox {
  position: relative;
  flex: 1;
  min-width: 0;
  pointer-events: auto;
}
.searchicon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: .6;
  pointer-events: none;
}
#search {
  width: 100%;
  height: 42px;
  padding: 0 34px 0 34px;
  border: 1px solid rgba(25, 35, 30, .14);
  border-radius: 10px;
  background: rgba(251, 253, 251, .97);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .12);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  -webkit-appearance: none;
}
#searchClear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  min-height: 0;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--muted);
}
.suggest {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.sug {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 0;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  line-height: 1.35;
}
.sug:last-child { border-bottom: none; }
.sug:hover { background: #eef3f0; }
.sug.empty { color: var(--muted); text-align: center; }

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.topctl {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

#themeBtn, #locateBtn {
  width: 42px;
  height: 42px;
  min-height: 0;
  pointer-events: auto;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .12);
}
#locateBtn { font-size: 24px; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  max-height: 46vh;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px);
  border-top: 1px solid var(--line);
  background: rgba(251, 253, 251, .97);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, .14);
  overflow: auto;
  transition: transform .22s ease;
}
.sheet.searchhide { transform: translateY(115%); }   /* прячем панель при поиске */

.filters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  align-items: center;
  padding-right: 38px;   /* место под кнопку сворачивания */
}
.fuel { min-height: 32px; padding: 0 4px; font-size: 13px; font-weight: 600; }

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.toggles .toggle { flex: 0 0 auto; min-height: 30px; padding: 0 8px; font-size: 12px; }

#sheetToggle {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  line-height: 1;
  z-index: 1;
}

.sheet.collapsed #list,
.sheet.collapsed .status,
.sheet.collapsed .attribution { display: none; }

.filters button.active {
  border-color: #1a6f4b;
  background: #e3f4ec;
  color: #0d5e3b;
  font-weight: 700;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  white-space: nowrap;
  font-size: 13px;
}

.status {
  padding: 9px 0;
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: grid;
  gap: 7px;
}

.row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bar { width: 10px; height: 34px; border-radius: 4px; background: var(--gray); }
.bar.available { background: var(--green); }
.bar.limited { background: var(--yellow); }
.bar.none { background: var(--red); }
.bar.unknown { background: var(--gray); }
.bar.ambiguous { background: #6f5aa7; }
.row h3 { margin: 0; font-size: 14px; line-height: 18px; }
.favmark { margin-right: 4px; }
.row p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 15px; }
.badge { color: var(--muted); font-size: 12px; white-space: nowrap; }
.attribution { margin-top: 10px; color: var(--muted); font-size: 11px; }

.pin {
  width: 18px;
  height: 18px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28);
}
.pin.available { background: var(--green); }
.pin.limited { background: var(--yellow); }
.pin.none { background: var(--red); }
.pin.unknown { background: var(--gray); }
.pin.ambiguous { background: #6f5aa7; }
.cluster {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid white;
  border-radius: 50%;
  background: #245d8f;
  color: white;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  align-items: end;
  background: rgba(0, 0, 0, .25);
}
.modal.hidden { display: none; }
.modalCard {
  max-height: 65vh;
  overflow: auto;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  border-radius: 12px 12px 0 0;
  background: var(--paper);
}
.close {
  float: right;
  width: 36px;
  height: 36px;
  font-size: 24px;
}
.modal h2 { margin: 0 44px 6px 0; font-size: 20px; }
.modal p { margin: 7px 0; color: var(--muted); }

/* карточка АЗС */
.cardhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 44px 8px 0;
}
.statusbadge {
  padding: 5px 10px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  background: var(--gray);
}
.statusbadge.available { background: var(--green); }
.statusbadge.limited { background: var(--yellow); }
.statusbadge.none { background: var(--red); }
.statusbadge.ambiguous { background: #6f5aa7; }
.cardhead .age { color: var(--muted); font-size: 12px; text-align: right; }
.modal .addr { margin: 0 0 10px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f7f4;
  font-size: 13px;
  font-weight: 600;
}
.chip.hit { border-color: #1a6f4b; background: #dff0e7; color: #0d5e3b; }
.chip.muted { background: #f4f5f5; color: var(--muted); font-weight: 500; }
.modal .meta { margin: 6px 0; color: var(--ink); font-size: 13px; }
.cardbtns { display: flex; gap: 8px; margin: 14px 0 4px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
}
.btn.primary { background: #186f4a; color: #fff; border-color: #186f4a; }
.meta.muted { color: var(--muted); }
.histhead { margin: 14px 0 6px; font-weight: 700; font-size: 14px; }
.hdots { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.hdot { width: 12px; height: 12px; border-radius: 50%; background: var(--gray); }
.hdot.available { background: var(--green); }
.hdot.limited { background: var(--yellow); }
.hdot.none { background: var(--red); }
.hlist { display: grid; gap: 5px; }
.hrow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.hrow:last-child { border-bottom: none; }
.hrow .hdet { color: var(--muted); text-align: right; min-width: 0; }
.cardacts { display: flex; gap: 8px; margin: 12px 0 0; }
.btn.act { min-height: 42px; font-size: 14px; font-weight: 600; }
.btn.act.on { background: #e3f4ec; border-color: #1a6f4b; color: #0d5e3b; }
.disclaimer { margin: 12px 0 0; color: var(--muted); font-size: 11px; }

@media (min-width: 760px) {
  .sheet {
    left: 16px;
    right: auto;
    bottom: 16px;
    width: 390px;
    max-height: 62vh;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}
