/* Утилитарный стиль: плоская сетка, чёткие границы, ч/б + один акцентный цвет. Без теней, градиентов и анимаций. */
:root {
  --fg: #111;
  --bg: #fff;
  --muted: #666;
  --line: #111;
  --line-soft: #ccc;
  --panel: #f4f4f4;
  --accent: #0050c8;
  --danger: #b00020;
  --ok: #1b6e2d;
  --radius: 0;
}
* { box-sizing: border-box; }
html { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--fg); background: var(--bg); }
body { margin: 0; }
a { color: var(--accent); }
a:hover { text-decoration: none; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1em 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Шапка */
.site-header { border-bottom: 2px solid var(--line); background: var(--bg); }
.site-header .inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.2rem; color: var(--fg); text-decoration: none; border: 2px solid var(--fg); padding: 2px 8px; }
.search-form { display: flex; flex: 1 1 360px; gap: 0; min-width: 240px; }
.search-form input { flex: 1; border-right: 0; }
.nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav a { color: var(--fg); text-decoration: none; border-bottom: 1px solid transparent; }
.nav a:hover, .nav a.active { border-bottom-color: var(--fg); }
.badge-count { display: inline-block; min-width: 1.4em; text-align: center; background: var(--accent); color: #fff; padding: 0 4px; font-size: .8rem; }

/* Формы */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
  border: 1px solid var(--line); background: var(--bg); padding: 6px 8px; border-radius: var(--radius); max-width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 120px; resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: 3px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
.field { margin-bottom: 12px; }
.field .hint { font-size: .85rem; color: var(--muted); }
.field.error input, .field.error select, .field.error textarea { border-color: var(--danger); border-width: 2px; }
.field .err { color: var(--danger); font-size: .85rem; }
.range { display: flex; gap: 6px; align-items: center; }
.range input { width: 100%; min-width: 0; }
button, .btn {
  border: 1px solid var(--line); background: var(--bg); padding: 6px 12px; cursor: pointer; border-radius: var(--radius);
  text-decoration: none; color: var(--fg); display: inline-block;
}
button:hover, .btn:hover { background: var(--panel); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #003c99; }
button.danger { border-color: var(--danger); color: var(--danger); }
button[disabled] { opacity: .5; cursor: not-allowed; }
button.link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
button.search-submit { background: var(--fg); color: var(--bg); }

/* Компоновка главной */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.sidebar { border: 1px solid var(--line); padding: 12px; }
.sidebar h3 { border-bottom: 1px solid var(--line-soft); padding-bottom: 4px; }
.cat-list { list-style: none; margin: 0 0 12px; padding: 0; }
.cat-list li a { display: block; padding: 3px 0; color: var(--fg); text-decoration: none; }
.cat-list li a:hover { text-decoration: underline; }
.cat-list li a.current { font-weight: 700; color: var(--accent); }
.cat-list .count { color: var(--muted); font-size: .85rem; }
.breadcrumbs { font-size: .9rem; margin-bottom: 8px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs span.sep { color: var(--muted); margin: 0 4px; }

/* Карточки */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.card { position: relative; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); }
.card a.card-link { display: block; color: inherit; text-decoration: none; height: 100%; }
.card .thumb { aspect-ratio: 4 / 3; background: var(--panel); border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 8px 10px 10px; }
.card .price { font-weight: 700; font-size: 1.05rem; }
.card .title { margin: 2px 0 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .meta { color: var(--muted); font-size: .85rem; }
.card.promo-1 { outline: 3px solid var(--accent); outline-offset: -3px; }
.card.promo-2 { outline: 3px solid var(--accent); outline-offset: -3px; background: var(--panel); }
.card.promo-3 { outline: 4px solid var(--fg); outline-offset: -4px; background: var(--panel); }
.card .promo-label { position: absolute; left: 0; top: 0; background: var(--fg); color: var(--bg); font-size: .75rem; padding: 1px 6px; }
.card .fav { position: absolute; right: 6px; top: 6px; background: var(--bg); padding: 2px 8px; }
.card .fav.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Пагинация, статусы, таблицы */
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0; }
.pager button.current { background: var(--fg); color: var(--bg); }
.tag { display: inline-block; border: 1px solid var(--line); padding: 0 6px; font-size: .8rem; }
.tag.accent { border-color: var(--accent); color: var(--accent); }
.tag.danger { border-color: var(--danger); color: var(--danger); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
table.kv, table.list { border-collapse: collapse; width: 100%; }
table.kv th, table.kv td, table.list th, table.list td { border: 1px solid var(--line-soft); padding: 6px 10px; text-align: left; vertical-align: top; }
table.kv th { width: 40%; background: var(--panel); font-weight: 600; }
table.list th { background: var(--panel); }
.panel { border: 1px solid var(--line); padding: 12px; background: var(--bg); }
.panel.soft { border-color: var(--line-soft); background: var(--panel); }
.notice { border: 1px solid var(--line); padding: 8px 12px; margin-bottom: 12px; }
.notice.warn { border-color: var(--accent); }
.notice.error { border-color: var(--danger); color: var(--danger); }
.notice.ok { border-color: var(--ok); color: var(--ok); }
#messages { position: fixed; top: 8px; right: 8px; z-index: 50; max-width: 380px; }
#messages .notice { background: var(--bg); margin-bottom: 6px; }

/* Вкладки */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border-bottom: 0; margin-bottom: -1px; border-color: var(--line-soft); }
.tabs button.current { border-color: var(--line); background: var(--fg); color: var(--bg); }

/* Модальное окно */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow: auto; }
.modal { background: var(--bg); border: 2px solid var(--fg); width: 100%; max-width: 420px; padding: 16px; }

/* Карточка объявления */
.listing-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.gallery .main { border: 1px solid var(--line); background: var(--panel); aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; }
.gallery .main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery .thumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.gallery .thumbs button { padding: 0; width: 72px; height: 54px; overflow: hidden; }
.gallery .thumbs button.current { outline: 2px solid var(--accent); }
.gallery .thumbs img { width: 100%; height: 100%; object-fit: cover; }
.price-big { font-size: 1.8rem; font-weight: 700; }
.stars { letter-spacing: 2px; }

/* Фото в форме */
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.photo-item { border: 1px solid var(--line-soft); padding: 4px; font-size: .8rem; }
.photo-item img, .photo-item .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--panel); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.photo-item .actions { display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap; }
.photo-item button { padding: 0 6px; }

/* Чат */
.chat { display: grid; grid-template-columns: 300px 1fr; border: 1px solid var(--line); height: calc(100vh - 150px); min-height: 420px; }
.chat .conv-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat .conv { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); cursor: pointer; display: block; width: 100%; text-align: left; border-width: 0 0 1px; }
.chat .conv.current { background: var(--fg); color: var(--bg); }
.chat .conv .name { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }
.chat .conv .preview { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .8; }
.chat .pane { display: flex; flex-direction: column; min-width: 0; }
.chat .pane-head { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.chat .msgs { flex: 1; overflow-y: auto; padding: 10px 12px; background: var(--panel); }
.msg { max-width: 75%; margin: 0 0 8px; padding: 6px 10px; border: 1px solid var(--line-soft); background: var(--bg); }
.msg.mine { margin-left: auto; border-color: var(--accent); }
.msg .time { font-size: .75rem; color: var(--muted); }
.msg img { max-height: 220px; margin-top: 4px; }
.chat .composer { border-top: 1px solid var(--line); padding: 8px; display: flex; gap: 6px; }
.chat .composer input[type=text] { flex: 1; }
.chat .typing { font-size: .8rem; color: var(--muted); min-height: 1.2em; padding: 0 12px; }

@media (max-width: 800px) {
  .layout, .listing-layout, .chat { grid-template-columns: 1fr; }
  .chat { height: auto; }
  .chat .conv-list { max-height: 200px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat .msgs { min-height: 300px; max-height: 60vh; }
}

.site-footer { margin-top: 3rem; padding: 1.25rem 1rem; border-top: 1px solid rgba(128, 128, 128, .25); font-size: .875rem; }
.site-footer .inner { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.legal { max-width: 860px; }
.legal h2 { margin-top: 2rem; }
.legal ol, .legal ul { padding-inline-start: 1.5rem; }
mark.ph { background: rgba(255, 200, 0, .3); color: inherit; padding: 0 .2em; border-radius: 3px; }

.mobile-actions { display: none; }
@media (max-width: 768px) {
  .mobile-actions {
    display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 2px solid var(--line);
  }
  .mobile-actions button { flex: 1; padding: 12px; font-weight: 600; }
  body.has-mobile-actions { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}