:root {
  --bg: #f5f6f7; --card: #fff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb;
  --accent: #16a34a; --accent-d: #15803d; --accent-soft: #e8f6ed; --danger: #dc2626; --warn-bg: #fff7e6;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1113; --card: #191c1f; --text: #eceef0; --muted: #9aa1a9; --line: #2a2e33;
          --accent-soft: #14301f; --warn-bg: #3a2d10; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 72px; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 24px 0 12px; }
.ic { width: 20px; height: 20px; flex: none; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; }
.brand img { width: 30px; height: 30px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 12px; padding: 0 12px; height: 42px; }
.search input { flex: 1; border: 0; background: none; font: inherit; color: inherit; outline: none; min-width: 0; }
.top-links { display: flex; gap: 4px; }
.top-links a { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; color: var(--muted); font-size: 15px; }
.top-links a:hover { background: var(--bg); color: var(--text); }
.badge { background: var(--danger); color: #fff; border-radius: 9px; font-size: 12px; padding: 0 6px; }

/* кнопки и формы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent-d); }
.btn.ghost { background: var(--bg); color: var(--text); }
.btn.ghost:hover { background: var(--line); }
.btn.danger { background: none; color: var(--danger); }
.btn.wide { width: 100%; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 15px; }
input[type=text], input[type=tel], input[type=number], textarea, select {
  width: 100%; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 140px; resize: vertical; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.error { background: #fde8e8; color: #9b1c1c; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; }
.note { background: var(--accent-soft); padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; }
.warn { background: var(--warn-bg); padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; }
.panel { background: var(--card); border-radius: var(--r); padding: 20px; }

/* категории */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 4px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 15px; white-space: nowrap; }
.cat.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.cat .ic { width: 18px; height: 18px; color: var(--accent); }

/* фильтры */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filters select, .filters input { width: auto; padding: 8px 10px; font-size: 15px; }
.filters input { width: 110px; }

/* сетка карточек */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.card .ph { aspect-ratio: 1; background: var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); position: relative; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.card .b { padding: 10px 12px 12px; }
.card .price { font-weight: 700; font-size: 17px; }
.card .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 6px; }
.card .m { font-size: 13px; color: var(--muted); }
.tag { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.more { display: flex; justify-content: center; margin: 24px 0; }

/* объявление */
.item { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; margin-top: 16px; align-items: start; }
.gallery { background: var(--card); border-radius: var(--r); overflow: hidden; }
.gallery .main { aspect-ratio: 4/3; background: #000; display: flex; align-items: center; justify-content: center; }
.gallery .main img { max-height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 8px; padding: 8px; overflow-x: auto; }
.thumbs button { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; width: 64px; height: 64px; flex: none; cursor: pointer; background: none; }
.thumbs button.on { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.big-price { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.descr { white-space: pre-wrap; overflow-wrap: anywhere; }
.seller { display: flex; align-items: center; gap: 12px; }
.ava { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-d); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.status { display: inline-block; padding: 2px 10px; border-radius: 8px; font-size: 14px; background: var(--bg); }
.status.active { background: var(--accent-soft); color: var(--accent-d); }
.status.rejected, .status.review { background: #fde8e8; color: #9b1c1c; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; padding: 0; }
details summary { cursor: pointer; }

/* редактор фото */
.photos-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-bottom: 8px; }
.photos-edit label { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; display: block; }
.photos-edit img { width: 100%; height: 100%; object-fit: cover; }
.photos-edit input { position: absolute; right: 6px; top: 6px; width: 20px; height: 20px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop input { display: none; }

/* чат */
.chat-list a { display: flex; gap: 12px; padding: 12px; background: var(--card); border-radius: var(--r); margin-bottom: 8px; align-items: center; }
.chat-list img, .chat-list .noimg { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--line); }
.chat-list .c { flex: 1; min-width: 0; }
.chat-list .last { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat { display: flex; flex-direction: column; height: calc(100dvh - 60px - 72px); max-width: 760px; margin: 0 auto; }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.chat-head img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 16px; background: var(--card); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--accent); color: #fff; }
.msg time { display: block; font-size: 11px; opacity: .7; text-align: right; }
.msg-warn { align-self: flex-start; max-width: 80%; font-size: 14px; background: var(--warn-bg); padding: 8px 12px; border-radius: 12px; }
.composer { display: flex; gap: 8px; padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line); }
.composer textarea { min-height: 44px; height: 44px; max-height: 140px; resize: none; }

/* нижнее меню на телефоне */
.tabbar { display: none; }
.foot { margin: 48px 0 24px; color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 16px; }

.narrow { max-width: 640px; margin: 24px auto; }
.tg-btn { background: #2aabee; }
.tg-btn:hover { background: #1e96d1; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }

@media (max-width: 800px) {
  .top-links { display: none; }
  .brand span { display: none; }
  .item { grid-template-columns: 1fr; gap: 16px; }
  .side { position: static; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .b { padding: 8px 10px 10px; }
  .card .price { font-size: 16px; }
  .big-price { font-size: 24px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; font-size: 11px; color: var(--muted); position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a.plus .ic { background: var(--accent); color: #fff; border-radius: 10px; width: 34px; height: 26px; padding: 3px 8px; }
  .tabbar .ic { width: 24px; height: 24px; }
  .tabbar .badge { position: absolute; top: 4px; left: 55%; }
  .gallery { margin: 0 -16px; border-radius: 0; }
  .panel { padding: 16px; }
}
@media (max-width: 800px) { .top-links-btn { display: none; } }
.ic.big { width: 40px; height: 40px; }
.mt6 { margin-top: 6px; } .mt16 { margin-top: 16px; } .mb0 { margin-bottom: 0; }
.row-end { margin-left: auto; display: flex; gap: 8px; }
.seller .ic { width: 15px; height: 15px; vertical-align: -2px; }
.panel .ic { vertical-align: -4px; }
.legal h2 { font-size: 18px; } .legal li { margin-bottom: 8px; }
.panel > h2:first-child { margin-top: 0; }
.hidden { display: none; }
.map-big { height: calc(100dvh - 220px); min-height: 360px; border-radius: var(--r); }
.map-pick { height: 260px; border-radius: 12px; }
.map-small { height: 220px; border-radius: 12px; margin-top: 8px; }
.leaflet-container { font: inherit; z-index: 0; }
.save-search { margin: 0 0 12px; }
.saved-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.msg-photo { max-width: 220px; border-radius: 10px; margin-bottom: 4px; }
.attach { padding: 0 12px; position: relative; }
.attach input { display: none; }
.attach.on { background: var(--accent-soft); color: var(--accent-d); }
.review-box { margin: 0 16px 8px; }
.stars span { padding: 8px 4px; font-size: 14px; }
.danger-text { color: var(--danger); }
input[type=email] { width: 100%; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
input[type=search] { -webkit-appearance: none; }

.fsum { display: none; list-style: none; }
.fsum::-webkit-details-marker { display: none; }
@media (max-width: 800px) {
  .fsum { display: inline-flex; height: 38px; margin-top: 10px; }
  .filters > * { flex: 1 1 45%; }
  .filters input { width: auto; }
}
@media (max-width: 800px) {
  .item { display: flex; flex-direction: column; }
  .item > .col-main { display: contents; }
  .item .gallery { order: 1; }
  .item .side { order: 2; }
  .item .col-main > .panel { order: 3; margin-top: 0; }
}
/* v4: поделиться, перенос с Авито, статистика */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.share-row .btn { height: 38px; padding: 0 12px; font-size: 14px; }
.share-row .grow { flex: 1 1 200px; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.steps { padding-left: 20px; margin: 8px 0 0; } .steps li { margin-bottom: 6px; }
.tbl-wrap { overflow-x: auto; }
.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
.tbl th, .tbl td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; }
.kpi { background: var(--card); border-radius: var(--r); padding: 14px; }
.kpi b { display: block; font-size: 24px; }
