/* ── Base ─────────────────────────────────────────────────────── */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2329;
  --text-soft: #6b7280;
  --border: #e3e6ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --wa: #25d366;
  --wa-dark: #1da851;
  --tg: #229ed9;
  --tg-dark: #1a8cc0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  /* Запрет горизонтального скролла — контент адаптируется, а не уезжает. */
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f0f2f5; }

.btn-ghost { background: transparent; color: var(--text-soft); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(0,0,0,0.05); }

.btn-danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.08); }

/* Итог последнего парсинга — три строки: статус / счётчики / дата. */
.last-parse {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 13px;
  color: var(--text-soft);
  max-width: 420px;
  text-align: right;
  white-space: normal;
}
.lp-status { font-weight: 700; color: var(--text); }
.lp-counts { font-weight: 600; color: var(--primary); }
.lp-date { font-size: 12px; color: var(--text-soft); }

.btn-block { width: 100%; }

.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); }
.btn-tg { background: var(--tg); color: #fff; }
.btn-tg:hover { background: var(--tg-dark); }

/* ── Login view ───────────────────────────────────────────────── */
.conn-state {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  padding: 10px 16px;
  font-size: 14px;
  text-align: center;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #eef2ff 0%, #f4f5f7 60%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.login-title { margin: 0 0 4px; font-size: 22px; }
.login-subtitle { margin: 0 0 24px; color: var(--text-soft); font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  line-height: 1.6;
}
.field textarea {
  min-height: 160px;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 14px;
}

/* ── Password visibility toggle (login form) ─────────────────── */
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap .pw-input {
  padding-right: 44px; /* место под кнопку-глазок */
}
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.pw-toggle:hover { color: var(--primary); background: rgba(37, 99, 235, .08); }
.pw-toggle:focus-visible {
  outline: none;
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* ── Edit form: Main Service section ─────────────────────────── */
.form-section-title {
  margin: 18px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}
.form-section-note {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-soft);
}
.ms-auto-hint {
  margin: -4px 0 8px;
  font-size: 12.5px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 6px 10px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .check {
  align-self: center;
  margin-bottom: 16px;
}
.form-collapse {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.form-collapse summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  user-select: none;
}
.form-collapse summary:hover { color: var(--primary); }
.form-collapse .form-grid { margin-top: 12px; }
.form-collapse .field { margin-bottom: 10px; }
.form-collapse input,
.form-collapse textarea {
  background: #f3f5f7;
  color: var(--text-soft);
  cursor: not-allowed;
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ── App header ───────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px 6px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
  transition: transform 0.28s ease;
  will-change: transform;
}
.app-header.app-header--hidden {
  transform: translateY(-100%);
}
.header-inner {
  max-width: none;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Строка 1: заголовок слева, пользователь/выйти справа */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  white-space: nowrap;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.user-box { display: flex; align-items: center; gap: 6px; }
.user-name { font-size: 13px; font-weight: 600; }
.role-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #fff; background: var(--primary);
  padding: 1px 7px; border-radius: 999px;
}

/* Кнопки чуть крупнее и удобнее для чтения */
.btn-sm { padding: 5px 12px; font-size: 12.5px; gap: 4px; min-height: 30px; }

/* Строка 2: статус парсинга + контролы */
.parse-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* Статус — компактная плашка по ширине текста, прижата вправо
   (margin-left:auto). Без flex-grow/фиксированного минимума, чтобы
   серая полоска не растягивалась на всю строку. */
.parse-progress {
  margin-left: auto;
  flex: 0 1 auto;
  max-width: 100%;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  white-space: normal;
  word-break: break-word;
}
/* Пока нет текста (между стартом и первым тиком поллинга) — не рисуем пустую рамку */
.parse-progress:empty { display: none; }

/* Метка автопарсинга по расписанию (docs/cron.md): компактная плашка слева
   от прогресса. Зелёная — включён, серая — выключен/недоступен. */
.scheduler-status {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.3;
  border-radius: 8px;
  padding: 4px 9px;
  white-space: normal;
  word-break: break-word;
  color: var(--text-soft);
  background: var(--bg);
  border: 1px solid var(--border);
}
.scheduler-status.on {
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.4);
  background: rgba(22, 163, 74, 0.08);
}
.scheduler-status.off {
  color: var(--text-soft);
}
.scheduler-status.cooldown {
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.4);
  background: rgba(217, 119, 6, 0.08);
}
.scheduler-status:empty { display: none; }

/* Карточка настройки автопарсинга (вкладка «Парсинг», docs/cron.md §8) */
.scheduler-card { margin-bottom: 12px; }
.scheduler-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.scheduler-card-head h3 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text); }
.sched-detail { font-size: 12.5px; color: var(--text-soft); }
.scheduler-card-body {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.sched-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-soft); }
.sched-field input {
  width: 110px;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.sched-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.sched-hint { font-size: 12.5px; color: var(--text-soft); }
.sched-hint.ok { color: #15803d; }
.sched-hint.err { color: #b91c1c; }


/* Лимит / «Всё» для парсинга */
.parse-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}
.parse-opt-label { color: var(--text-soft); }
#parse-limit {
  width: 116px;
  min-height: 30px;
  padding: 3px 8px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
/* Плейсхолдер «по умолч.» — чуть мельче, чтобы помещался */
#parse-limit::placeholder { font-size: 11.5px; color: var(--text-soft); }
#parse-limit:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
#parse-all { accent-color: var(--primary); margin: 0; width: 15px; height: 15px; }
.parse-all { cursor: pointer; user-select: none; }
/* ── Tabs ── */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin-top: 2px;
  border-top: 1px solid var(--border);
}
.tab {
  padding: 2px 8px; background: transparent; border: none;
  border-bottom: 2px solid transparent; font-size: 12px; font-weight: 600;
  color: var(--text-soft); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-color: var(--primary); }

/* ── Filters ── */
.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto 1fr 0.9fr 0.9fr auto;
  gap: 6px;
  align-items: end;
  padding: 6px 0 3px;
}
.filters .field { margin-bottom: 0; }
.filters .field span { font-size: 10px; margin-bottom: 2px; }
.filters .field input, .filters .field select { padding: 4px 8px; font-size: 12px; min-height: 28px; }
.filter-q input { width: 100%; min-width: 260px; }
.filter-phone input { width: 100%; min-width: 150px; }
.filter-min input, .filter-max input { width: 100%; min-width: 110px; }
.filter-contact select { width: 100%; }
.filter-sort select { width: 100%; }
.filter-photo { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; font-size: 11px; color: var(--text-soft); }
.filters .check input { accent-color: var(--primary); }
.filters .btn { padding: 4px 8px; font-size: 11px; height: 28px; }

/* ── Calendar / Stats toolbar ── */
.listings-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.listings-toolbar .btn { padding: 4px 10px; font-size: 12px; }
.cal-selected { font-size: 12px; font-weight: 600; color: var(--text); }

/* Calendar panel */
.cal-panel {
  padding: 8px 0;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head .btn { padding: 2px 8px; font-size: 12px; }
.cal-month { font-size: 14px; font-weight: 700; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin: 4px 0 2px;
}
.cal-weekdays span { text-align: center; font-size: 10px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { min-height: 52px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); cursor: pointer; }
.cal-cell.cal-empty { border: none; background: transparent; cursor: default; }
.cal-cell:not(.cal-has):not(.cal-empty) { cursor: default; opacity: .55; }
.cal-day { font-size: 12px; font-weight: 700; }
.cal-today .cal-day { color: var(--primary); }
.cal-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
.cal-count { font-size: 10px; font-weight: 600; color: var(--primary); line-height: 1.15; }

/* Stats panel */
.stats-panel { padding: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 6px; justify-content: center; }
.chip { background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }

.filters {
  max-width: none;
  margin: 10px auto 0;
  padding-bottom: 10px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto auto;
  gap: 12px;
  align-items: end;
}
.filters .field { margin-bottom: 0; }
.filter-address input { min-width: 200px; }
.filter-q input { width: 100%; min-width: 320px; }
.filter-phone input { width: 100%; min-width: 170px; }
.filter-min input, .filter-max input { width: 100%; min-width: 150px; }
.filter-min, .filter-max { min-width: 150px; }
.filter-phone { min-width: 190px; }

/* ── Calendar (posts by date) ─────────────────────────────────── */
.listings-toolbar {
  max-width: none;
  margin: 8px auto 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cal-selected { font-size: 13px; font-weight: 600; color: var(--text); }
.cal-panel {
  max-width: none;
  margin: 8px auto 0;
  padding: 0 12px;
}
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.cal-month { font-size: 16px; font-weight: 700; flex: 1; text-align: center; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 6px 0 4px;
}
.cal-weekdays span { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-cell {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  cursor: pointer;
}
.cal-cell.cal-empty { border: none; background: transparent; cursor: default; }
.cal-cell:not(.cal-has):not(.cal-empty) { cursor: default; opacity: .55; }
.cal-cell:hover:not(.cal-empty):not(.cal-has-not) { border-color: var(--primary); }
.cal-day { font-size: 13px; font-weight: 700; }
.cal-today .cal-day { color: var(--primary); }
.cal-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
.cal-count { font-size: 11px; font-weight: 600; color: var(--primary); line-height: 1.15; }

/* ── Stats panel (below calendar) ───────────────────────────────── */
.stats-panel {
  max-width: none;
  margin: 8px auto 0;
  padding: 0 12px;
}

/* ── Cards grid ───────────────────────────────────────────────── */
.cards {
  max-width: none;
  margin: 16px auto;
  padding: 0 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  position: relative;  /* для абсолютного чекбокса выбора (batch-select) */
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.card-img-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #e9edf2;
  overflow: hidden;
}
.card-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-body { padding: 16px; display: flex; flex-direction: column; flex: 1; }

/* Бейдж «поля заполнены ИИ» (main_service_json.ai_fields) — см. aiBadge() в app.js */
.ai-badge {
  display: inline-block;
  align-self: flex-start;
  margin: 0 0 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  background: var(--accent, #6851d6);
  color: #fff;
}

.card-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.card-price .none { font-size: 15px; color: var(--text-soft); font-weight: 500; }

.card-address {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: #374151;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
}
.card-address .pin { flex: none; }

.card-desc {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.card-contacts {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.card-contacts .btn { width: 100%; }

.card-meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-updated {
  color: #b45309;
  font-weight: 600;
  background: #fef3c7;
  padding: 1px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.meta-verified {
  color: #15803d;
  font-weight: 600;
  background: #dcfce7;
  padding: 1px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-phone {
  margin: 2px 0 12px;
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Pagination / empty ───────────────────────────────────────── */
.pagination {
  max-width: none;
  margin: 0 auto 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.page-btn:hover:not(:disabled) { background: #f0f2f5; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.empty {
  max-width: none;
  margin: 48px auto;
  padding: 0 12px;
  text-align: center;
  color: var(--text-soft);
  font-size: 15px;
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-width: 90vw;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 820px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-address { grid-column: 1 / -1; }
  .filters .btn { grid-column: span 1; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
}

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
  max-width: none; margin: 8px auto 0; padding: 0 12px;
  display: flex; gap: 4px; flex-wrap: wrap;
  justify-content: center;
}
.tab {
  padding: 6px 12px; background: transparent; border: none;
  border-bottom: 2px solid transparent; font-size: 14px; font-weight: 600;
  color: var(--text-soft); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-color: var(--primary); }

.tab-panel { max-width: none; margin: 20px auto; padding: 0 12px; }

/* ── Filters: adapt for new fields ────────────────────────────── */
.filters {
  grid-template-columns: 2fr 1.2fr 1.2fr 1fr 1fr auto auto auto;
}
.filter-photo { display: flex; align-items: center; gap: 6px; padding-bottom: 10px; font-size: 13px; color: var(--text-soft); user-select: none; }
.filters .check input { accent-color: var(--primary); }

/* ── Badges ───────────────────────────────────────────────────── */
.card-badges { display: flex; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.badge-new { background: #e5e7eb; color: #374151; }
.badge-changed { background: #fde68a; color: #92400e; }
.badge-waiting { background: #fef3c7; color: #b45309; }
.badge-type-shared { background: #e0f2fe; color: #0369a1; }
.badge-type-whole { background: #fef9c3; color: #a16207; }
.badge-type-unknown { background: #f3f4f6; color: #6b7280; }
.badge-verified { background: #dcfce7; color: #15803d; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-sent { background: #ede9fe; color: #6d28d9; }
.badge-failed { background: #fee2e2; color: #b91c1c; }
.badge-sync { font-size: 10px; }

/* ── Inline contact links ─────────────────────────────────────── */
.contact-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.contact-link:hover { text-decoration: underline; }

/* ── Moderation buttons on card ───────────────────────────────── */
.card-mod { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.card-mod .btn { font-size: 13px; padding: 6px 10px; }
.btn-verify { background: var(--surface); color: #15803d; border-color: #86efac; }
.btn-verify:hover { background: #dcfce7; }
.btn-waiting { background: var(--surface); color: #b45309; border-color: #fde68a; }
.btn-waiting:hover { background: #fef3c7; }
.btn-reject { background: var(--surface); color: #b91c1c; border-color: #fecaca; }
.btn-reject:hover { background: #fee2e2; }

/* ── Detail modal ─────────────────────────────────────────────── */
.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.modal-panel {
  position: relative; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 480px;
  max-height: 90vh; overflow: auto; padding: 24px; z-index: 1;
}
.modal-wide { max-width: 760px; }
.modal-close {
  position: absolute; top: 10px; right: 12px; background: transparent;
  border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--text-soft);
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.detail-price { font-size: 24px; font-weight: 700; margin: 8px 0 4px; }
.detail-line { margin: 4px 0; color: var(--text); }
.detail-desc { margin-top: 12px; white-space: pre-line; color: var(--text); line-height: 1.55; }
.detail-meta { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-soft); font-size: 13px; display: grid; gap: 2px; }

.gallery { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.gallery-item { flex: none; width: 220px; aspect-ratio: 16/9; background: #e9edf2; border-radius: 8px; overflow: hidden; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

/* ── Inline gallery (в модалке деталей) ─────────────────────── */
.ph-viewer { margin: 12px 0 4px; }
.ph-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  background: #0b1220; border-radius: 10px; overflow: hidden; min-height: 320px; max-height: 62vh;
}
.ph-main {
  display: block; width: 100%; height: 100%; max-height: 62vh;
  object-fit: contain; cursor: zoom-in; user-select: none;
}
.ph-nav, .ph-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .92); color: #0b1220;
  font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); z-index: 2;
}
.ph-prev { left: 12px; }
.ph-next { right: 12px; }
.ph-nav:hover, .ph-arrow:hover { background: #fff; }
.ph-counter { text-align: center; color: var(--text-soft); font-size: 12px; margin-top: 6px; }
.ph-thumbs {
  display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px;
}
.ph-thumb, .pl-thumb {
  flex: none; width: 64px; height: 48px; object-fit: cover; border-radius: 6px;
  cursor: pointer; border: 2px solid transparent; opacity: .75; transition: opacity .15s, border-color .15s;
}
.ph-thumb:hover, .pl-thumb:hover { opacity: 1; }
.ph-thumb.on, .pl-thumb.on { border-color: var(--primary); opacity: 1; }

/* ── Fullscreen lightbox ────────────────────────────────────── */
.photo-lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(5, 8, 15, .94);
  display: flex; align-items: center; justify-content: center;
}
.photo-lightbox.hidden { display: none; }
.pl-main {
  max-width: calc(100vw - 140px); max-height: calc(100vh - 180px);
  object-fit: contain; user-select: none; border-radius: 4px;
}
.pl-close {
  position: absolute; top: 14px; right: 18px; background: transparent; border: none;
  font-size: 40px; line-height: 1; color: #fff; cursor: pointer; opacity: .8; z-index: 3;
}
.pl-close:hover { opacity: 1; }
.ph-arrow { background: rgba(255,255,255,.92); color: #0b1220; width: 52px; height: 52px; font-size: 32px; }
.pl-bottom {
  position: absolute; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 0 20px; z-index: 3;
}
.pl-counter { color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.pl-thumbs {
  display: flex; gap: 8px; overflow-x: auto; max-width: 100%;
  padding: 6px 4px; border-radius: 8px;
}
.pl-thumb { width: 88px; height: 62px; background: #222; }

/* ── Admin panels ─────────────────────────────────────────────── */
.panel-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-toolbar h2 { margin: 0; font-size: 18px; flex: 1; }
.data-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table th { background: #f8fafc; color: var(--text-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.data-table tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; }
.btn-small { font-size: 12px; padding: 5px 9px; }

.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); user-select: none; }
.check input { accent-color: var(--primary); }

/* ── Clean 2-column grid & Chip Cards for Amenities/Terms ─────── */
.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}
.field-group-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-group-box .group-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease-in-out;
}
.chip-check input {
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
}
.chip-check:hover {
  border-color: var(--primary);
  background: #f8fafc;
}
.chip-check:has(input:checked) {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #15803d;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(34, 197, 94, 0.15);
}

@media (max-width: 640px) {
  .form-grid-2col {
    grid-template-columns: 1fr;
  }
}

.audit-list { display: grid; gap: 10px; }
.audit-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.audit-row.row-failed { border-color: #fca5a5; background: #fef2f2; }
.audit-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 13.5px; }
.audit-time { color: var(--text-soft); }
.audit-user { font-weight: 600; }
.audit-action { font-family: ui-monospace, monospace; background: #f1f5f9; padding: 1px 7px; border-radius: 6px; }
.audit-entity { color: var(--text-soft); }
.audit-ip { color: var(--text-soft); }
.audit-payload { margin-top: 8px; font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }

/* ── Responsive filters ───────────────────────────────────────── */
@media (max-width: 1000px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-q { grid-column: 1 / -1; }
  .filter-phone { grid-column: 1 / -1; }
}

/* ── Batch moderation: select checkbox on cards ──────────────── */
.card-select-wrap {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.card-select {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Batch moderation: action bar ────────────────────────────── */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px auto 0;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.batch-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-soft);
  user-select: none;
  cursor: pointer;
}
.batch-check input { accent-color: var(--primary); margin: 0; }
.batch-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.batch-count:hover { background: #e0e7ff; }
.batch-count:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Batch moderation: report modal ──────────────────────────── */
.br-summary {
  margin: 8px 0 14px;
  padding: 10px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
}
.br-summary-fail {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.br-hint {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
}
.br-title {
  margin: 14px 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-soft);
}
.br-list {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.br-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13.5px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 8px;
  word-break: break-word;
}
.br-row-fail { background: #fef2f2; color: #b91c1c; }
.br-id { font-weight: 700; color: var(--text); flex: none; }

/* ── Batch moderation: selected-list split-view workstation ── */
.modal-split {
  max-width: 1240px;
  width: 95vw;
  height: 88vh;
  max-height: 88vh;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sel-split-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.sel-pane-left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding-right: 16px;
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.sel-pane-left h2 {
  margin: 0 0 10px;
  font-size: 18px;
}
.sel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex: none;
}
.sel-search {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
}
.sel-search:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.sel-count { font-size: 12px; color: var(--text-soft); white-space: nowrap; flex: none; }

.sel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}
.sel-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  flex: none;
}
.sel-row:hover {
  background: var(--surface);
  border-color: var(--primary);
}
.sel-row.active {
  background: #f0fdf4;
  border-color: #22c55e;
  box-shadow: 0 0 0 1px #22c55e;
}
.sel-check {
  margin-top: 4px;
  accent-color: var(--primary);
  flex: none;
}
.sel-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
}
.sel-actions .btn {
  padding: 4px 8px;
  font-size: 11.5px;
  white-space: nowrap;
}
.sel-body { flex: 1; min-width: 0; }
.sel-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13.5px;
}
.sel-id { font-weight: 700; color: var(--text); flex: none; }
.sel-addr {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.sel-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.sel-price { font-weight: 700; color: var(--primary); font-size: 12.5px; }
.sel-desc {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sel-left-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex: none;
}

/* ── Правая панель сплита ── */
.sel-pane-right {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.sel-detail-empty {
  margin: auto;
  text-align: center;
  color: var(--text-soft);
  max-width: 320px;
  padding: 20px;
}
.sel-detail-empty .empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
  opacity: 0.6;
}
.sel-detail-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.sel-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 10px;
  flex: none;
  gap: 8px;
}
.sel-detail-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sel-detail-title-box h3 {
  margin: 0;
  font-size: 17px;
}
.sel-detail-tabs {
  display: flex;
  gap: 6px;
}
.sel-detail-tabs .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.sel-edit-content, .sel-view-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
}
.sel-edit-content form {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.sel-right-actions {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex: none;
}

@media (max-width: 860px) {
  .modal-split {
    height: 92vh;
    max-height: 92vh;
  }
  .sel-split-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1.2fr;
    height: 100%;
  }
  .sel-pane-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
  }
}

/* ── Channel Management (tab-parse) ─────────────────────────── */
.channels-card {
  margin-bottom: 20px;
}
.channels-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.channels-card-head h3 {
  margin: 0;
  font-size: 16px;
}
.channels-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-soft);
}
.channel-add-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.channel-input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.channel-input:focus-visible {
  outline: 2px solid var(--primary);
}
.channels-table th, .channels-table td {
  padding: 10px 14px;
  text-align: left;
}
.channel-actions {
  display: flex;
  gap: 6px;
}
