/* Вкладка «Мониторинг» — страница во всю ширину окна (как body.home-projects-wide на главной),
   класс ставит переключатель вкладок в documents.html */
body.docs-market-wide .container { max-width: min(100%, 2400px); }

/* Мониторинг объявлений (Документы → «Мониторинг»). Тулбар/модалки/поля — из wishlist.css (.wl-*). */

.mm-source {
  margin: 0 0 16px;
  border: 1px solid var(--border-color, #33415540);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}
.mm-source > summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 0.88rem;
}
.mm-source > summary::-webkit-details-marker { display: none; }
.mm-source > summary::before { content: "▸"; margin-right: 6px; color: var(--text-muted, #8892a4); }
.mm-source[open] > summary::before { content: "▾"; }
.mm-source-title { font-weight: 600; flex: 1; }
.mm-source-status { font-size: 0.78rem; color: var(--text-muted, #8892a4); }
.mm-source-body { padding: 0 14px 14px; font-size: 0.85rem; }
.mm-steps { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.mm-address-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.mm-address-warn { margin-top: 6px; color: var(--warning-color, #b45309); }
.mm-address-row code {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--hover-bg, #2d5a8e14);
  word-break: break-all;
  font-size: 0.82rem;
}
.mm-events-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted, #8892a4); margin: 10px 0 4px; }
.mm-event { display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; font-size: 0.8rem; padding: 3px 0; border-bottom: 1px solid var(--border-color, #33415522); }
.mm-event-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-event-unmatched span:last-child { color: var(--warning-color, #d97706); }
.mm-event-rejected span:last-child { color: var(--text-muted, #8892a4); }

/* Тулбар: поля в строку на десктопе (глобальные input/select тянутся на 100%) */
.mm-toolbar .wl-search { flex: 1 1 240px; width: auto; }
.mm-toolbar .wl-select { flex: 0 1 auto; width: auto; max-width: 280px; }
@media (max-width: 900px) {
  .mm-toolbar .wl-search,
  .mm-toolbar .wl-select { flex: 1 1 100%; max-width: none; }
}

/* Фильтры */
.mm-searches-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.mm-searches-head h3 { margin: 0; font-size: 0.95rem; }
.mm-searches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.mm-searches-empty {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px dashed var(--border-color, #33415580);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-muted, #8892a4);
}
.mm-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #33415540);
  border-radius: 10px;
  background: var(--card-bg, #fff);
  min-width: 0;
}
.mm-search-off { opacity: 0.6; }
.mm-search-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mm-search-name {
  border: none; background: none; padding: 0; text-align: left; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--text-color, inherit);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.mm-search-name:hover { color: var(--accent-color, #2d5a8e); }
.mm-search-count {
  flex: none;
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-color, #2d5a8e);
  color: #fff;
}
.mm-search-sum { font-size: 0.78rem; color: var(--text-muted, #8892a4); line-height: 1.4; overflow-wrap: anywhere; }
.mm-search-flags { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 0.76rem; color: var(--text-muted, #8892a4); }
.mm-switch { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.mm-link { border: none; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--accent-color, #2d5a8e); margin-left: auto; }
.mm-link:hover { text-decoration: underline; }

/* Таблица объявлений.
   Прокрутка внутри блока в обе стороны: заголовки закреплены сверху, «Оценка» и
   «Объявление» — слева (sticky работает относительно ближайшего скролл-контейнера,
   поэтому блок сам прокручивается и по вертикали). */
.mm-table-wrap {
  overflow: auto;
  max-height: calc(100dvh - 120px);
  overscroll-behavior-x: contain;
  border: 1px solid var(--border-color, #33415540);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}
/* separate, а не collapse: с collapse границы закреплённых ячеек «уезжают» при прокрутке */
.mm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.82rem; min-width: 1320px; }
/* Фон карточки в части тем полупрозрачный (поверх фоновой картинки) — закреплённым ячейкам
   нужна непрозрачная подложка, иначе сквозь них видно прокрученные колонки */
.mm-table { --mm-sticky-base: #ffffff; --mm-sticky-bg: linear-gradient(var(--card-bg, #fff), var(--card-bg, #fff)), var(--mm-sticky-base); }
[data-theme="dark"] .mm-table,
[data-theme="weather"][data-weather-daynight="night"] .mm-table { --mm-sticky-base: #0f172a; }
.mm-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--mm-sticky-bg);
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted, #8892a4);
  border-bottom: 2px solid var(--border-color, #33415540);
  white-space: nowrap;
}
.mm-table tbody td { padding: 7px 8px; border-bottom: 1px solid var(--border-color, #33415522); vertical-align: middle; }
.mm-table th.wl-sortable:hover { color: var(--text-color, inherit); }
.mm-table th.wl-sort-asc, .mm-table th.wl-sort-desc { color: var(--accent-color, #2d5a8e); }

/* Закреплённые слева колонки: непрозрачный фон, иначе под ними просвечивает прокрученное */
.mm-table .mm-col-score,
.mm-table .mm-col-title { position: sticky; background: var(--mm-sticky-bg); z-index: 1; }
.mm-table .mm-col-score { left: 0; width: 64px; min-width: 64px; max-width: 64px; }
.mm-table .mm-col-title { left: 64px; min-width: 200px; max-width: 260px; box-shadow: 6px 0 6px -6px rgba(0, 0, 0, 0.25); }
.mm-table thead th.mm-col-score,
.mm-table thead th.mm-col-title { z-index: 3; }
.mm-table thead th.mm-col-score { padding-left: 6px; padding-right: 2px; letter-spacing: 0; }
/* Подсветка строки — поверх фона закреплённых ячеек тоже */
.mm-table tbody tr:hover td { background-image: linear-gradient(var(--hover-bg, #2d5a8e0d), var(--hover-bg, #2d5a8e0d)); }
.mm-table tbody tr:hover td.mm-col-score,
.mm-table tbody tr:hover td.mm-col-title {
  background: linear-gradient(var(--hover-bg, #2d5a8e0d), var(--hover-bg, #2d5a8e0d)), var(--mm-sticky-bg);
}

.mm-th-short { display: none; }
.mm-col-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mm-col-date { width: 84px; white-space: nowrap; color: var(--text-muted, #8892a4); }
.mm-col-actions { width: 84px; text-align: right; white-space: nowrap; }
.mm-col-addr { min-width: 120px; max-width: 190px; }
.mm-col-seller { min-width: 120px; max-width: 180px; }
.mm-seller-name { font-weight: 600; overflow-wrap: anywhere; }
.mm-seller-name a { color: inherit; text-decoration: underline dotted; }
.mm-col-seller .mm-badge { margin-top: 3px; }
.mm-muted { color: var(--text-muted, #8892a4); }

.mm-title {
  border: none; background: none; padding: 0; text-align: left; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--text-color, inherit); line-height: 1.3;
}
.mm-title:hover { color: var(--accent-color, #2d5a8e); }
.mm-sub { margin-top: 2px; font-size: 0.75rem; color: var(--text-muted, #8892a4); }
.mm-sub a { color: var(--accent-color, #2d5a8e); }
.mm-unknown { color: var(--warning-color, #d97706); }

.mm-score {
  display: inline-block;
  min-width: 34px;
  padding: 3px 6px;
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mm-score-hi { background: #16a34a22; color: #16a34a; }
.mm-score-mid { background: #d9770622; color: #d97706; }
.mm-score-lo { background: #64748b22; color: var(--text-muted, #8892a4); }
.mm-score-none { color: var(--text-muted, #8892a4); }

.mm-drop {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #16a34a22;
  color: #16a34a;
}

.mm-icon-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--border-color, #33415540);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #8892a4);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}
.mm-icon-btn:hover { color: var(--text-color, inherit); border-color: var(--accent-color, #2d5a8e); }
a.mm-icon-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; vertical-align: top; }

/* Проверка сделки: прогресс чек-листа в строке и кнопка в карточке */
.mm-deal-chip { margin-top: 4px; font-size: 0.8rem; }
.mm-deal-chip a { color: var(--accent-color, #2d5a8e); text-decoration: none; }
.mm-deal-flag { color: #d64545; font-weight: 600; }
.mm-deal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.mm-deal-actions a.btn { text-decoration: none; }

/* Детали строки: продавец, оборудование, дубли по адресу */
.mm-seller a { color: inherit; text-decoration: underline dotted; }
.mm-badge {
  display: inline-block; padding: 0 6px; border-radius: 5px;
  font-size: 0.7rem; background: var(--hover-bg, #2d5a8e14); color: var(--text-color, inherit);
}
.mm-badge-company { background: #7c3aed1f; color: #7c3aed; }
.mm-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.mm-chip {
  padding: 0 6px; border-radius: 5px; font-size: 0.7rem; line-height: 1.5;
  border: 1px solid var(--border-color, #33415540); color: var(--text-muted, #8892a4);
}
.mm-chip-ct { border-color: #16a34a; color: #16a34a; font-weight: 700; }
.mm-twin { color: var(--warning-color, #d97706); }
.mm-views { color: var(--text-muted, #8892a4); font-size: 0.75rem; }
.mm-spark { display: block; margin: 2px 0 0 auto; }
.mm-spark polyline { stroke: var(--text-muted, #8892a4); }
.mm-spark-down polyline { stroke: #16a34a; }
.mm-spark-up polyline { stroke: #dc2626; }
.mm-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 4px; }

/* «Новое» — ещё не открывали карточку */
.mm-new-badge {
  display: inline-block; margin-right: 5px; padding: 0 5px; border-radius: 4px;
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  background: #2563eb; color: #fff; vertical-align: 1px;
}
.mm-newbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.mm-newbar[hidden] { display: none; }

/* Кнопка «на карте» у адреса */
.mm-map-btn {
  padding: 0 4px; margin-left: 2px;
  border: 1px solid var(--border-color, #33415540); border-radius: 5px;
  background: transparent; cursor: pointer; font-size: 0.78rem; line-height: 1.5;
  color: var(--text-color, inherit); vertical-align: 1px;
}
.mm-map-btn:hover { border-color: var(--accent-color, #2d5a8e); }

/* Пояснение «оценки нет, пока нет фильтров» */
.mm-score-hint {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  margin: 0 0 10px; padding: 10px 12px;
  border: 1px dashed var(--accent-color, #2d5a8e); border-radius: 10px;
  font-size: 0.85rem; line-height: 1.4;
}
.mm-score-hint[hidden] { display: none; }

/* Карта */
.mm-map-wrap { margin-bottom: 12px; }
.mm-map {
  height: min(70vh, 620px);
  border: 1px solid var(--border-color, #33415540);
  border-radius: 10px;
  overflow: hidden;
  background: var(--hover-bg, #2d5a8e0d);
}
.mm-map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 0.76rem; color: var(--text-muted, #8892a4); align-items: center; }
.mm-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.mm-dot-hi { background: #16a34a; }
.mm-dot-mid { background: #d97706; }
.mm-dot-lo { background: #64748b; }
.mm-dot-none { background: #94a3b8; }
.mm-map-note { flex-basis: 100%; }

/* Модалки */
.mm-listing-card { max-width: 640px; }
.mm-check { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; cursor: pointer; }
.mm-hint { margin: 0; font-size: 0.78rem; color: var(--text-muted, #8892a4); line-height: 1.4; }
.mm-push-right { margin-left: auto; }
.mm-listing-summary:empty { display: none; }
.mm-listing-summary { margin-bottom: 14px; font-size: 0.83rem; display: flex; flex-direction: column; gap: 8px; }
.mm-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.mm-kpis > div {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--hover-bg, #2d5a8e10);
  display: flex; flex-direction: column; gap: 2px;
}
.mm-kpis span { font-size: 0.72rem; color: var(--text-muted, #8892a4); }
.mm-kpis b { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.mm-matches { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.mm-prices { color: var(--text-muted, #8892a4); }
.mm-open-link { color: var(--accent-color, #2d5a8e); font-weight: 600; }

/* Телефон: та же таблица с горизонтальной прокруткой — закреплены заголовки,
   «Оценка» и «Объявление»; колонки уже и шрифт мельче */
@media (max-width: 760px) {
  .mm-table-wrap { max-height: calc(100dvh - 150px); }
  .mm-table { font-size: 0.76rem; min-width: 1160px; }
  .mm-table thead th { padding: 6px 6px; font-size: 0.64rem; }
  .mm-table tbody td { padding: 6px 6px; }
  .mm-table .mm-col-score { width: 40px; min-width: 40px; max-width: 40px; }
  .mm-table .mm-col-title { left: 40px; min-width: 132px; max-width: 132px; }
  .mm-table .mm-col-title .mm-title { font-size: 0.78rem; }
  .mm-score { min-width: 26px; padding: 2px 3px; font-size: 0.74rem; }
  .mm-th-full { display: none; }
  .mm-th-short { display: inline; }
  .mm-col-addr, .mm-col-seller { min-width: 110px; }
  .mm-kpis b { font-size: 0.85rem; }
}

/* ---- Закладка «В LIFE UP» и отслеживание изменений ---- */
.mm-clip {
  margin: 4px 0 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border-color, #33415560);
  border-radius: 10px;
}
.mm-clip-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.mm-bookmarklet {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--color-primary, #2f6fdf);
  color: #fff !important;
  font-weight: 600;
  text-decoration: none;
  cursor: grab;
}
.mm-clip-list { margin: 8px 0 6px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; line-height: 1.45; }
.mm-clip-help > summary { cursor: pointer; color: var(--text-muted, #8892a4); font-size: 0.82rem; }
.mm-clip-help p { margin: 6px 0; }

.mm-state {
  display: inline-block;
  margin: 0 4px 2px 0;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: 1px;
}
.mm-state-closed { background: #b4231822; color: #d92d20; }
.mm-state-missing { background: #b5470922; color: #dc6803; }
.mm-state-changed { background: #6941c622; color: #9e77ed; font-weight: 600; }
.mm-row-closed .mm-title { text-decoration: line-through; opacity: 0.7; }
.mm-partial { color: #dc6803; }
.mm-checked { color: var(--text-muted, #8892a4); }
.mm-checked-old { color: #dc6803; }

.mm-state-line { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; font-size: 0.85rem; font-weight: 400; display: block; }
.mm-state-line.mm-state-partial { background: #b5470914; color: inherit; }
.mm-history { margin: 8px 0; }
.mm-history > summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.mm-history ul { margin: 6px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.mm-history li > span:first-child { color: var(--text-muted, #8892a4); margin-right: 4px; }
.mm-history-good { color: #12b76a; }
.mm-history-bad { color: #f04438; }
.mm-linkish { border: 0; background: none; padding: 0; color: var(--color-link, #2f6fdf); cursor: pointer; font: inherit; text-decoration: underline; }
.mm-diff { margin-top: 4px; padding: 6px 8px; border-radius: 6px; background: var(--hover-bg, #2d5a8e14); color: var(--text-color, inherit); white-space: pre-wrap; max-height: 280px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.mm-diff[hidden] { display: none; }
