:root {
  --bg: #F6F4EE;
  --card: #FFFFFF;
  --ink: #1F2421;
  --muted: #6B6F68;
  --line: #E6E2D8;
  --green: #2F5D3A;
  --green-2: #3E7A4C;
  --green-soft: #E5EFE4;
  --wheat: #C9A24C;
  --wheat-soft: #F6EED9;
  --warn: #B86E14;
  --warn-soft: #FBF0DF;
  --bad: #B5443A;
  --bad-soft: #F8E6E3;
  --blue: #2F6A9E;
  --violet: #6D4C9A;
  --r: 16px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4; min-height: 100vh;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 12px);
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: rgba(246, 244, 238, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 36px; height: 36px; border-radius: 10px; }
.title { font-weight: 800; font-size: 18px; letter-spacing: -.2px; }
.sub { font-size: 12.5px; color: var(--muted); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 18px;
}
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- нижние вкладки ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tabs button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.tabs button span { font-size: 20px; filter: grayscale(1); opacity: .65; }
.tabs button.on { color: var(--green); }
.tabs button.on span { filter: none; opacity: 1; }

main { max-width: 640px; margin: 0 auto; padding: 12px 14px; }

/* ---------- плашки сверху ---------- */
.banner {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 12px;
}
.banner .b-ic { font-size: 26px; }
.banner .b-tx { flex: 1; font-size: 13.5px; }
.banner b { display: block; font-size: 14.5px; margin-bottom: 1px; }
.banner .x { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 4px; }
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 700; background: var(--green); color: #fff;
  white-space: nowrap;
}
.btn.sm { padding: 8px 12px; font-size: 13.5px; }
.btn.ghost { background: var(--green-soft); color: var(--green); }
.btn.line { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.block { width: 100%; }

/* ---------- сортировка ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 13px; font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.count { font-size: 13px; color: var(--muted); margin: 0 2px 10px; }

/* ---------- карточка ---------- */
.card {
  background: var(--card); border-radius: var(--r); overflow: hidden; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(31, 36, 33, .05), 0 6px 18px rgba(31, 36, 33, .05);
  border: 1px solid #EEEAE0;
}
.card.dim { opacity: .62; }
.ph { position: relative; aspect-ratio: 16 / 10; background: linear-gradient(135deg, #DCE6D6, #EDE6D2); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .noimg { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; opacity: .5; }
.badges { position: absolute; z-index: 2; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.bdg {
  font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .93); color: var(--ink);
}
.bdg.new { background: var(--wheat); color: #fff; }
.bdg.drop { background: var(--green); color: #fff; }
.bdg.gone { background: var(--bad); color: #fff; }
.ph .cnt {
  position: absolute; z-index: 2; right: 10px; bottom: 10px; font-size: 12px; font-weight: 700;
  padding: 3px 8px; border-radius: 8px; background: rgba(0, 0, 0, .55); color: #fff;
}
.ph .mk {
  position: absolute; z-index: 2; right: 10px; top: 10px; width: 34px; height: 34px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; font-size: 17px; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.cb { padding: 12px 14px 14px; }
.price-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.price.neg { font-size: 18px; color: var(--muted); }
.was { font-size: 13.5px; color: var(--muted); text-decoration: line-through; }
.meta { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.ttl {
  margin: 4px 0 8px; font-weight: 600; font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.loc { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink); }
.loc .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-2); flex: none; }
.loc.warn .dot { background: var(--warn); }
.loc.reject .dot { background: var(--bad); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; background: var(--green-soft); color: var(--green); }
.tag.grey { background: #F0EEE8; color: var(--muted); }
.alert { margin-top: 10px; padding: 9px 11px; border-radius: 10px; font-size: 13px; }
.alert.warn { background: var(--warn-soft); color: #7A4A0E; }
.alert.bad { background: var(--bad-soft); color: #7E2C24; }
.alert.ok { background: var(--green-soft); color: var(--green); }
.note-prev { margin-top: 9px; font-size: 13px; color: var(--muted); font-style: italic; }
.foot { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty .e-ic { font-size: 40px; margin-bottom: 8px; }
.more {
  display: block; width: 100%; margin: 6px 0 14px; padding: 13px; border-radius: 14px;
  border: 1px dashed #D8D2C2; background: none; color: var(--muted); font-weight: 600;
}
.section-h { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 18px 4px 10px; }
.info-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-size: 13.5px; color: var(--muted); }

/* ---------- карта ---------- */
#map { position: fixed; left: 0; right: 0; top: var(--top-h, 64px); bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 1; }
.pin {
  background: var(--green); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 7px; border-radius: 9px;
  white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); border: 2px solid #fff; transform: translate(-50%, -50%);
  display: inline-block; font-family: Manrope, sans-serif;
}
.pin.warn { background: var(--warn); }
.pin.like { background: var(--wheat); }
.pin.call { background: var(--blue); }
.pin.visit { background: var(--violet); }
.pin.no { background: #9A9A92; }
.map-card {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); z-index: 25;
  max-width: 616px; margin: 0 auto; background: #fff; border-radius: var(--r); display: flex; gap: 12px; padding: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}
.map-card img, .map-card .noimg2 { width: 96px; height: 76px; border-radius: 10px; object-fit: cover; flex: none; background: #E5EAE0; }
.map-card .mc { flex: 1; min-width: 0; }
.map-card .ttl { margin: 2px 0 4px; font-size: 13.5px; }
.map-legend {
  position: fixed; top: calc(var(--top-h, 64px) + 10px); left: 10px; z-index: 20; background: rgba(255,255,255,.95);
  border-radius: 12px; padding: 7px 10px; font-size: 12px; color: var(--muted); box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* ---------- детальная карточка ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto;
  padding-bottom: calc(24px + var(--safe-b)); animation: up .22s ease-out;
}
.sheet.hidden { display: none; }
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-top {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; background: rgba(246,244,238,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: #DDE4D6; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: 100%; max-width: 640px; aspect-ratio: 4 / 3; object-fit: cover; scroll-snap-align: center; }
.gal-wrap { position: relative; max-width: 640px; margin: 0 auto; }
.gal-n { position: absolute; right: 12px; bottom: 12px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; }
.sbody { max-width: 640px; margin: 0 auto; padding: 14px; }
.sbody .price { font-size: 27px; }
.h1 { font-size: 17px; font-weight: 700; margin: 6px 0 4px; }
.box { background: var(--card); border: 1px solid #EEEAE0; border-radius: var(--r); padding: 13px 14px; margin-top: 12px; }
.box h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.status-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.st {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 2px; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
}
.st span { font-size: 19px; }
.st.on { border-color: var(--green); background: var(--green-soft); color: var(--green); }
textarea.note {
  width: 100%; min-height: 72px; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: #FCFBF8; resize: vertical; font-size: 14px;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.kv div:nth-child(even) { font-weight: 600; }
.desc { white-space: pre-line; font-size: 14.5px; }
.hist { font-size: 14px; }
.hist div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.hist div:last-child { border: 0; font-weight: 700; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.actions a { text-decoration: none; text-align: center; }
.reasons { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }

/* ---------- фильтры ---------- */
.fgroup { background: var(--card); border: 1px solid #EEEAE0; border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.fgroup h3 { margin: 0 0 10px; font-size: 15px; }
.fgroup .hint { font-size: 12.5px; color: var(--muted); margin-top: 7px; }
.range2 { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.range2 input, .fgroup input[type=text] {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #FCFBF8; font-size: 15px;
}
.seg { display: flex; background: #F0EEE8; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 9px 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: #fff; color: var(--green); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sw { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; gap: 12px; }
.sw + .sw { border-top: 1px solid #F0EDE5; }
.sw input { display: none; }
.sw .tg { width: 46px; height: 28px; border-radius: 999px; background: #D9D5CA; position: relative; flex: none; transition: .15s; }
.sw .tg::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sw input:checked + .tg { background: var(--green-2); }
.sw input:checked + .tg::after { left: 21px; }
.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.slider-row input { flex: 1; accent-color: var(--green); }
.slider-row b { min-width: 58px; text-align: right; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tgl { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.tgl.on { background: var(--green-soft); border-color: var(--green-2); color: var(--green); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 18px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.gate { max-width: 420px; margin: 60px auto; text-align: center; padding: 0 20px; }
.gate img { width: 88px; height: 88px; border-radius: 22px; }
.skel { height: 260px; border-radius: var(--r); margin-bottom: 14px; background: linear-gradient(90deg, #EDEAE2 25%, #F5F3EE 50%, #EDEAE2 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

.ios-steps { text-align: left; font-size: 14px; margin: 8px 0 0; padding-left: 20px; }
.ios-steps li { margin: 4px 0; }
