/* Подбор дома — design system: blue = action, green = good/owner, amber = broker, red = risk */
:root {
  --blue: #1652C5; --blue-d: #0F3E99; --ink: #16181D; --ink2: #2D323B; --muted: #5F6775; --line: #E2E5EA;
  --bg: #F6F7F9; --card: #FFFFFF; --grey: #EEF0F3;
  --green: #0E6B43; --green-bg: #E3F4EC; --amber: #7A4300; --amber-bg: #FCEFD9;
  --red: #A3201A; --red-bg: #FDECEA; --blue-bg: #E6EEFB;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 72px; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-d); }
button, input, select, textarea { font: inherit; }
h1 { font-size: 22px; line-height: 1.25; margin: 6px 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
main { max-width: 1280px; margin: 0 auto; padding: 12px 14px 24px; }

/* header */
.top { position: sticky; top: 0; z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; font-size: 17px; }
.search { flex: 1 1 260px; order: 5; }
.search input { width: 100%; height: 44px; padding: 0 14px; border: 1px solid #C9CED6; border-radius: 10px; background: #fff; }
.nav { display: none; gap: 18px; font-weight: 600; }
.nav a { color: var(--ink2); }
.nav a[aria-current] { color: var(--blue); }
.who { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-bg); color: var(--blue-d); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.link { border: 0; background: none; color: var(--blue); padding: 0; cursor: pointer; }
@media (min-width: 860px) { .search { order: 0; } .nav { display: flex; } body { padding-bottom: 0; } .tabbar { display: none !important; } }

/* segmented controls */
.seg { display: inline-flex; background: var(--grey); border-radius: 10px; padding: 3px; gap: 2px; }
.seg > a, .seg > button { border: 0; background: transparent; color: #4A5260; border-radius: 8px; padding: 8px 13px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-height: 38px; }
.seg .on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.12); }
.seg small { color: var(--muted); font-weight: 500; }
.views span { display: none; }
@media (min-width: 700px) { .views span { display: inline; } }

/* buttons, chips, badges */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid #C9CED6; border-radius: 10px; background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); color: #fff; }
.btn.wide { width: 100%; }
.btn.fav.on, .heart.on { color: #B7791F; }
.chip { list-style: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid #C9CED6; border-radius: 999px; background: #fff; font-weight: 600; cursor: pointer; }
.chip::-webkit-details-marker { display: none; }
.b { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.b.new { background: var(--blue); color: #fff; font-weight: 700; }
.b.green { background: var(--green-bg); color: var(--green); }
.b.amber { background: var(--amber-bg); color: var(--amber); }
.b.red { background: var(--red-bg); color: var(--red); }
.b.blue { background: var(--blue-bg); color: var(--blue-d); }
.b.grey { background: var(--grey); color: #4A5260; font-weight: 500; }
.b.mono { background: var(--grey); color: var(--ink); font-family: ui-monospace, monospace; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chipinfo { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 13px; color: var(--ink); }
button.chipinfo { cursor: pointer; }

/* filters + results bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin: 4px 0 10px; }
.more { flex: 1 1 auto; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.grid-form label, .form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { min-height: 42px; padding: 8px 10px; border: 1px solid #C9CED6; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
.grid-form .actions { display: flex; gap: 8px; align-items: end; grid-column: 1 / -1; }
.resultbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 12px; }
.resultbar h1 { flex: 1 1 auto; font-size: 18px; margin: 0; }
.sort select { min-height: 40px; width: auto; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.tile { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.cover { position: relative; display: grid; place-items: center; height: 190px; background: #A9B4C2; overflow: hidden; }
.cover img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .tl { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.cover .count, .gallery .count { position: absolute; right: 10px; bottom: 10px; background: rgba(22,24,29,.72); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.heart { position: absolute; right: 10px; top: 10px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.95); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.heart svg { fill: none; stroke: currentColor; stroke-width: 2; }
.heart.on svg { fill: #B7791F; stroke: #B7791F; }
.info { display: block; padding: 12px 14px 14px; color: var(--ink); }
.price { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.price .muted { font-size: 13px; font-weight: 400; letter-spacing: 0; }
.price a { color: var(--ink); }

/* list */
.list { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.thumb { position: relative; flex: 0 0 104px; min-height: 104px; background: #A9B4C2; }
.thumb .b { position: absolute; left: 6px; top: 6px; font-size: 10px; }
.row .body { flex: 1 1 200px; min-width: 0; padding: 10px 12px; }
.row .title { font-weight: 600; margin: 2px 0; }
.cmp { display: none; margin: 0; padding: 12px 16px; border-left: 1px solid var(--grey); grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px 14px; font-size: 13px; align-content: start; }
.cmp dt { color: var(--muted); } .cmp dd { margin: 0; font-weight: 600; }
.row .acts { display: none; flex-direction: column; gap: 8px; justify-content: center; padding: 10px 14px; }
@media (min-width: 860px) { .thumb { flex-basis: 240px; min-height: 160px; } .cmp { display: grid; flex: 1 1 260px; } .row .acts { display: flex; } }

/* map */
.map { height: 62vh; min-height: 360px; border-radius: var(--r); border: 1px solid var(--line); background: #ECEFF2; }
.map.small { height: 300px; min-height: 240px; }
.mapwrap { margin-bottom: 14px; }
.pin { background: var(--blue); color: #fff; font-weight: 700; font-size: 12px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* home page */
.crumbs { color: var(--muted); margin: 2px 0 10px; }
.gallery { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); grid-auto-rows: 120px; gap: 6px; border-radius: var(--r); overflow: hidden; }
.gallery .ph { display: none; background: #A9B4C2; }
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph.big { display: block; grid-column: 1 / -1; grid-row: span 2; }
@media (min-width: 860px) { .gallery { grid-auto-rows: 200px; } .gallery .ph:nth-child(-n+5) { display: block; } .gallery .ph.big { grid-column: span 2; grid-row: span 2; } }
.cols { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 16px; align-items: flex-start; }
.cols .main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.cols .side { flex: 1 1 280px; }
.sticky { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 10px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.pricebig { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.split { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px 16px; }
.facts span { display: block; font-size: 12px; color: var(--muted); }
.desc { white-space: pre-line; }
.flags { margin: 8px 0 0; padding-left: 18px; color: var(--red); }
.events, .sources, .notes { list-style: none; margin: 0; padding: 0; }
.events li, .sources li { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--grey); align-items: baseline; }
.sources li { grid-template-columns: 1fr auto auto; }
.notes li { padding: 8px 0; border-top: 1px solid var(--grey); }
.note { display: flex; gap: 8px; margin-bottom: 8px; }
.chart { width: 100%; height: auto; background: #FAFBFC; border-radius: 8px; margin-bottom: 6px; }
.applinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.homemap { margin-top: 12px; }
.seller ul { padding-left: 18px; margin: 6px 0 0; }

/* auth */
.auth { max-width: 400px; margin: 8vh auto 0; text-align: center; }
.auth .form { text-align: left; display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.err { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 8px; margin: 0; }
.qr svg { width: 220px; height: 220px; display: block; margin: 0 auto; }
code { background: var(--grey); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* misc */
.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 20px 0; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; justify-content: space-around; background: #fff; border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); min-width: 80px; }
.tabbar a[aria-current] { color: var(--blue); }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 2000; }
